You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.9 KiB
106 lines
2.9 KiB
15 years ago
|
/*
|
||
|
* This file is part of ScalixAdmin.
|
||
|
*
|
||
|
* Copyright (C) 2007 Trolltech ASA. All rights reserved.
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqlineedit.h>
|
||
|
#include <tqtoolbutton.h>
|
||
15 years ago
|
|
||
|
#include <klocale.h>
|
||
|
|
||
|
#include "jobs.h"
|
||
|
#include "ldapdialog.h"
|
||
|
|
||
|
#include "delegatedialog.h"
|
||
|
|
||
13 years ago
|
DelegateDialog::DelegateDialog( TQWidget *parent )
|
||
|
: KDialogBase( parent, "", true, "", Ok | Cancel, Ok, true )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget *page = new TQWidget( this );
|
||
13 years ago
|
TQGridLayout *layout = new TQGridLayout( page, 5, 3, 11, 6 );
|
||
15 years ago
|
|
||
14 years ago
|
TQLabel *label = new TQLabel( i18n( "User:" ), page );
|
||
13 years ago
|
layout->addWidget( label, 0, 0 );
|
||
15 years ago
|
|
||
14 years ago
|
mEmail = new TQLineEdit( page );
|
||
13 years ago
|
layout->addWidget( mEmail, 0, 1 );
|
||
15 years ago
|
|
||
14 years ago
|
TQToolButton *emailSelector = new TQToolButton( page );
|
||
15 years ago
|
emailSelector->setUsesTextLabel( true );
|
||
|
emailSelector->setTextLabel( i18n( "..." ) );
|
||
13 years ago
|
layout->addWidget( emailSelector, 0, 2 );
|
||
15 years ago
|
|
||
14 years ago
|
TQValueList<Scalix::DelegateTypes> types;
|
||
15 years ago
|
types << Scalix::SendOnBehalfOf;
|
||
|
types << Scalix::SeePrivate;
|
||
|
types << Scalix::GetMeetings;
|
||
|
types << Scalix::InsteadOfMe;
|
||
|
|
||
|
int row = 1;
|
||
|
for ( uint i = 0; i < types.count(); ++i ) {
|
||
14 years ago
|
TQCheckBox *box = new TQCheckBox( Scalix::Delegate::rightsAsString( types[ i ] ), page );
|
||
13 years ago
|
layout->addMultiCellWidget( box, row, row, 1, 2 );
|
||
15 years ago
|
|
||
|
mRights.insert( types[ i ], box );
|
||
|
row++;
|
||
|
}
|
||
|
|
||
14 years ago
|
connect( emailSelector, TQT_SIGNAL( clicked() ), TQT_SLOT( selectEmail() ) );
|
||
15 years ago
|
|
||
|
setMainWidget( page );
|
||
|
}
|
||
|
|
||
|
void DelegateDialog::setDelegate( const Scalix::Delegate &delegate )
|
||
|
{
|
||
|
mEmail->setText( delegate.email() );
|
||
|
|
||
14 years ago
|
TQMap<int, TQCheckBox*>::Iterator it;
|
||
15 years ago
|
for ( it = mRights.begin(); it != mRights.end(); ++it )
|
||
|
it.data()->setChecked( delegate.rights() & it.key() );
|
||
|
}
|
||
|
|
||
|
Scalix::Delegate DelegateDialog::delegate() const
|
||
|
{
|
||
|
int rights = 0;
|
||
|
|
||
14 years ago
|
TQMap<int, TQCheckBox*>::ConstIterator it;
|
||
15 years ago
|
for ( it = mRights.begin(); it != mRights.end(); ++it )
|
||
|
if ( it.data()->isChecked() )
|
||
|
rights |= it.key();
|
||
|
|
||
|
return Scalix::Delegate( mEmail->text(), rights );
|
||
|
}
|
||
|
|
||
|
void DelegateDialog::selectEmail()
|
||
|
{
|
||
|
LdapDialog dlg( this );
|
||
|
if ( !dlg.exec() )
|
||
|
return;
|
||
|
|
||
14 years ago
|
const TQString email = dlg.selectedUser();
|
||
15 years ago
|
if ( email.isEmpty() )
|
||
|
return;
|
||
|
|
||
|
mEmail->setText( email );
|
||
|
}
|
||
|
|
||
|
#include "delegatedialog.moc"
|