diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kresources/scalix/scalixadmin/delegatedialog.cpp | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/scalix/scalixadmin/delegatedialog.cpp')
-rw-r--r-- | kresources/scalix/scalixadmin/delegatedialog.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/kresources/scalix/scalixadmin/delegatedialog.cpp b/kresources/scalix/scalixadmin/delegatedialog.cpp new file mode 100644 index 000000000..3dc0412a4 --- /dev/null +++ b/kresources/scalix/scalixadmin/delegatedialog.cpp @@ -0,0 +1,105 @@ +/* + * 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. + */ + +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qtoolbutton.h> + +#include <klocale.h> + +#include "jobs.h" +#include "ldapdialog.h" + +#include "delegatedialog.h" + +DelegateDialog::DelegateDialog( QWidget *parent ) + : KDialogBase( parent, "", true, "", Ok | Cancel, Ok, true ) +{ + QWidget *page = new QWidget( this ); + QGridLayout *layout = new QGridLayout( page, 5, 3, 11, 6 ); + + QLabel *label = new QLabel( i18n( "User:" ), page ); + layout->addWidget( label, 0, 0 ); + + mEmail = new QLineEdit( page ); + layout->addWidget( mEmail, 0, 1 ); + + QToolButton *emailSelector = new QToolButton( page ); + emailSelector->setUsesTextLabel( true ); + emailSelector->setTextLabel( i18n( "..." ) ); + layout->addWidget( emailSelector, 0, 2 ); + + QValueList<Scalix::DelegateTypes> types; + types << Scalix::SendOnBehalfOf; + types << Scalix::SeePrivate; + types << Scalix::GetMeetings; + types << Scalix::InsteadOfMe; + + int row = 1; + for ( uint i = 0; i < types.count(); ++i ) { + QCheckBox *box = new QCheckBox( Scalix::Delegate::rightsAsString( types[ i ] ), page ); + layout->addMultiCellWidget( box, row, row, 1, 2 ); + + mRights.insert( types[ i ], box ); + row++; + } + + connect( emailSelector, SIGNAL( clicked() ), SLOT( selectEmail() ) ); + + setMainWidget( page ); +} + +void DelegateDialog::setDelegate( const Scalix::Delegate &delegate ) +{ + mEmail->setText( delegate.email() ); + + QMap<int, QCheckBox*>::Iterator it; + for ( it = mRights.begin(); it != mRights.end(); ++it ) + it.data()->setChecked( delegate.rights() & it.key() ); +} + +Scalix::Delegate DelegateDialog::delegate() const +{ + int rights = 0; + + QMap<int, QCheckBox*>::ConstIterator it; + 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; + + const QString email = dlg.selectedUser(); + if ( email.isEmpty() ) + return; + + mEmail->setText( email ); +} + +#include "delegatedialog.moc" |