28 #include <QtCore/QPair>
29 #include <QApplication>
31 #include <QCloseEvent>
33 #include <QGridLayout>
35 #include <QHeaderView>
37 #include <QPushButton>
39 #include <QVBoxLayout>
40 #include <QSortFilterProxyModel>
44 #include <akonadi/collection.h>
45 #include <akonadi/itemcreatejob.h>
46 #include <kcombobox.h>
48 #include <kconfiggroup.h>
49 #include <kcmultidialog.h>
50 #include <kdialogbuttonbox.h>
51 #include <kldap/ldapobject.h>
52 #include <kldap/ldapserver.h>
53 #include <klineedit.h>
55 #include <kmessagebox.h>
57 #include <KPIMUtils/ProgressIndicatorLabel>
59 using namespace KLDAP;
61 static QString
asUtf8(
const QByteArray &val )
63 if ( val.isEmpty() ) {
67 const char *data = val.data();
70 if ( data[ val.size() - 1 ] ==
'\0' ) {
71 return QString::fromUtf8( data, val.size() - 1 );
73 return QString::fromUtf8( data, val.size() );
77 static QString
join(
const KLDAP::LdapAttrValue &lst,
const QString &sep )
81 KLDAP::LdapAttrValue::ConstIterator end(lst.constEnd());
82 for ( KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin(); it != end; ++it ) {
96 static QMap<QString, QString> keys;
98 if ( keys.isEmpty() ) {
99 keys[ i18nc(
"@item LDAP search key",
"Title" ) ] = QLatin1String(
"title");
100 keys[ i18n(
"Full Name" ) ] = QLatin1String(
"cn");
101 keys[ i18nc(
"@item LDAP search key",
"Email" ) ] = QLatin1String(
"mail");
102 keys[ i18n(
"Home Number" ) ] = QLatin1String(
"homePhone");
103 keys[ i18n(
"Work Number" ) ] = QLatin1String(
"telephoneNumber");
104 keys[ i18n(
"Mobile Number" ) ] = QLatin1String(
"mobile");
105 keys[ i18n(
"Fax Number" ) ] = QLatin1String(
"facsimileTelephoneNumber");
106 keys[ i18n(
"Pager" ) ] = QLatin1String(
"pager");
107 keys[ i18n(
"Street" ) ] = QLatin1String(
"street");
108 keys[ i18nc(
"@item LDAP search key",
"State" ) ] = QLatin1String(
"st");
109 keys[ i18n(
"Country" ) ] = QLatin1String(
"co");
110 keys[ i18n(
"City" ) ] = QLatin1String(
"l");
111 keys[ i18n(
"Organization" ) ] = QLatin1String(
"o");
112 keys[ i18n(
"Company" ) ] = QLatin1String(
"Company");
113 keys[ i18n(
"Department" ) ] = QLatin1String(
"department");
114 keys[ i18n(
"Zip Code" ) ] = QLatin1String(
"postalCode");
115 keys[ i18n(
"Postal Address" ) ] = QLatin1String(
"postalAddress");
116 keys[ i18n(
"Description" ) ] = QLatin1String(
"description");
117 keys[ i18n(
"User ID" ) ] = QLatin1String(
"uid");
123 static QString
makeFilter(
const QString &query,
const QString &attr,
bool startsWith )
131 QString result( QLatin1String(
"&(|(objectclass=person)(objectclass=groupofnames)(mail=*))(") );
132 if ( query.isEmpty() ) {
134 return result + QLatin1String(
"|(cn=*)(sn=*)") + QLatin1Char(
')');
137 if ( attr == i18nc(
"Search attribute: Name of contact",
"Name" ) ) {
138 result += startsWith ? QLatin1String(
"|(cn=%1*)(sn=%2*)") : QLatin1String(
"|(cn=*%1*)(sn=*%2*)");
139 result = result.arg( query ).arg( query );
141 result += startsWith ? QLatin1String(
"%1=%2*") : QLatin1String(
"%1=*%2*");
142 if ( attr == i18nc(
"Search attribute: Email of the contact",
"Email" ) ) {
143 result = result.arg( QLatin1String(
"mail") ).arg( query );
144 }
else if ( attr == i18n(
"Home Number" ) ) {
145 result = result.arg( QLatin1String(
"homePhone") ).arg( query );
146 }
else if ( attr == i18n(
"Work Number" ) ) {
147 result = result.arg( QLatin1String(
"telephoneNumber") ).arg( query );
154 result += QLatin1Char(
')');
160 KABC::Addressee addr;
163 if ( !attrs.value( QLatin1String(
"cn") ).isEmpty() ) {
164 addr.setNameFromString(
asUtf8( attrs[QLatin1String(
"cn")].first() ) );
168 KLDAP::LdapAttrValue lst = attrs[QLatin1String(
"mail")];
169 KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin();
171 while ( it != lst.constEnd() ) {
172 addr.insertEmail(
asUtf8( *it ), pref );
177 if ( !attrs.value( QLatin1String(
"o") ).isEmpty() ) {
178 addr.setOrganization(
asUtf8( attrs[ QLatin1String(
"o") ].first() ) );
180 if ( addr.organization().isEmpty() && !attrs.value( QLatin1String(
"Company") ).isEmpty() ) {
181 addr.setOrganization(
asUtf8( attrs[ QLatin1String(
"Company") ].first() ) );
185 KABC::Address workAddr( KABC::Address::Work );
187 if ( !attrs.value( QLatin1String(
"department") ).isEmpty() ) {
188 addr.setDepartment(
asUtf8( attrs[ QLatin1String(
"department") ].first() ) );
191 if ( !workAddr.isEmpty() ) {
192 addr.insertAddress( workAddr );
196 if ( !attrs.value( QLatin1String(
"homePhone") ).isEmpty() ) {
197 KABC::PhoneNumber homeNr =
asUtf8( attrs[ QLatin1String(
"homePhone") ].first() );
198 homeNr.setType( KABC::PhoneNumber::Home );
199 addr.insertPhoneNumber( homeNr );
202 if ( !attrs.value( QLatin1String(
"telephoneNumber") ).isEmpty() ) {
203 KABC::PhoneNumber workNr =
asUtf8( attrs[ QLatin1String(
"telephoneNumber") ].first() );
204 workNr.setType( KABC::PhoneNumber::Work );
205 addr.insertPhoneNumber( workNr );
208 if ( !attrs.value( QLatin1String(
"facsimileTelephoneNumber") ).isEmpty() ) {
209 KABC::PhoneNumber faxNr =
asUtf8( attrs[ QLatin1String(
"facsimileTelephoneNumber") ].first() );
210 faxNr.setType( KABC::PhoneNumber::Fax );
211 addr.insertPhoneNumber( faxNr );
214 if ( !attrs.value( QLatin1String(
"mobile") ).isEmpty() ) {
215 KABC::PhoneNumber cellNr =
asUtf8( attrs[ QLatin1String(
"mobile") ].first() );
216 cellNr.setType( KABC::PhoneNumber::Cell );
217 addr.insertPhoneNumber( cellNr );
220 if ( !attrs.value( QLatin1String(
"pager") ).isEmpty() ) {
221 KABC::PhoneNumber pagerNr =
asUtf8( attrs[ QLatin1String(
"pager") ].first() );
222 pagerNr.setType( KABC::PhoneNumber::Pager );
223 addr.insertPhoneNumber( pagerNr );
229 class ContactListModel :
public QAbstractTableModel
233 ServerRole = Qt::UserRole + 1
236 ContactListModel(
QObject *parent )
237 : QAbstractTableModel( parent )
241 void addContact(
const KLDAP::LdapAttrMap &contact,
const QString &server )
243 mContactList.append( contact );
244 mServerList.append( server );
248 QPair<KLDAP::LdapAttrMap, QString> contact(
const QModelIndex &index )
const
250 if ( !index.isValid() || index.row() < 0 || index.row() >= mContactList.count() ) {
251 return qMakePair( KLDAP::LdapAttrMap(), QString() );
254 return qMakePair( mContactList.at( index.row() ), mServerList.at( index.row() ) );
257 QString email(
const QModelIndex &index )
const
259 if ( !index.isValid() || index.row() < 0 || index.row() >= mContactList.count() ) {
263 return asUtf8( mContactList.at( index.row() ).value( QLatin1String(
"mail") ).first() ).trimmed();
266 QString fullName(
const QModelIndex &index )
const
268 if ( !index.isValid() || index.row() < 0 || index.row() >= mContactList.count() ) {
272 return asUtf8( mContactList.at( index.row() ).value( QLatin1String(
"cn") ).first() ).trimmed();
277 mContactList.clear();
282 virtual int rowCount(
const QModelIndex &parent = QModelIndex() )
const
284 if ( !parent.isValid() ) {
285 return mContactList.count();
291 virtual int columnCount(
const QModelIndex &parent = QModelIndex() )
const
293 if ( !parent.isValid() ) {
300 virtual QVariant headerData(
int section, Qt::Orientation orientation,
301 int role = Qt::DisplayRole )
const
303 if ( orientation == Qt::Vertical || role != Qt::DisplayRole || section < 0 || section > 17 ) {
309 return i18n(
"Full Name" );
312 return i18nc(
"@title:column Column containing email addresses",
"Email" );
315 return i18n(
"Home Number" );
318 return i18n(
"Work Number" );
321 return i18n(
"Mobile Number" );
324 return i18n(
"Fax Number" );
327 return i18n(
"Company" );
330 return i18n(
"Organization" );
333 return i18n(
"Street" );
336 return i18nc(
"@title:column Column containing the residential state of the address",
340 return i18n(
"Country" );
343 return i18n(
"Zip Code" );
346 return i18n(
"Postal Address" );
349 return i18n(
"City" );
352 return i18n(
"Department" );
355 return i18n(
"Description" );
358 return i18n(
"User ID" );
361 return i18nc(
"@title:column Column containing title of the person",
"Title" );
371 virtual QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const
373 if ( !index.isValid() ) {
377 if ( index.row() < 0 || index.row() >= mContactList.count() ||
378 index.column() < 0 || index.column() > 17 ) {
382 if ( role == ServerRole ) {
383 return mServerList.at( index.row() );
386 if ( (role != Qt::DisplayRole) && (role != Qt::ToolTipRole) ) {
390 const KLDAP::LdapAttrMap map = mContactList.at( index.row() );
392 switch ( index.column() ) {
394 return join( map.value( QLatin1String(
"cn") ), QLatin1String(
", ") );
397 return join( map.value( QLatin1String(
"mail") ), QLatin1String(
", ") );
400 return join( map.value( QLatin1String(
"homePhone") ), QLatin1String(
", ") );
403 return join( map.value( QLatin1String(
"telephoneNumber") ), QLatin1String(
", ") );
406 return join( map.value( QLatin1String(
"mobile") ), QLatin1String(
", ") );
409 return join( map.value( QLatin1String(
"facsimileTelephoneNumber") ), QLatin1String(
", ") );
412 return join( map.value( QLatin1String(
"Company") ), QLatin1String(
", ") );
415 return join( map.value( QLatin1String(
"o") ), QLatin1String(
", " ));
418 return join( map.value( QLatin1String(
"street") ), QLatin1String(
", ") );
421 return join( map.value( QLatin1String(
"st") ), QLatin1String(
", " ));
424 return join( map.value( QLatin1String(
"co") ), QLatin1String(
", ") );
427 return join( map.value( QLatin1String(
"postalCode") ), QLatin1String(
", ") );
430 return join( map.value( QLatin1String(
"postalAddress") ), QLatin1String(
", ") );
433 return join( map.value( QLatin1String(
"l") ), QLatin1String(
", ") );
436 return join( map.value( QLatin1String(
"department") ),QLatin1String(
", " ));
439 return join( map.value( QLatin1String(
"description") ), QLatin1String(
", ") );
442 return join( map.value( QLatin1String(
"uid") ), QLatin1String(
", ") );
445 return join( map.value( QLatin1String(
"title") ), QLatin1String(
", ") );
457 QStringList mServerList;
460 class LdapSearchDialog::Private
466 mIsConfigured( false ),
475 const QModelIndexList selected = mResultView->selectionModel()->selectedRows();
476 for (
int i = 0; i < selected.count(); ++i ) {
477 contacts.append( mModel->contact( sortproxy->mapToSource(selected.at( i )) ) );
485 void restoreSettings();
489 void slotSetScope(
bool );
490 void slotStartSearch();
491 void slotStopSearch();
492 void slotSearchDone();
493 void slotError(
const QString& );
494 void slotSelectAll();
495 void slotUnselectAll();
496 void slotSelectionChanged();
502 KABC::Addressee::List mSelectedContacts;
508 QCheckBox *mRecursiveCheckbox;
509 QTableView *mResultView;
510 QPushButton *mSearchButton;
511 ContactListModel *mModel;
512 KPIMUtils::ProgressIndicatorLabel *progressIndication;
513 QSortFilterProxyModel *sortproxy;
517 :
KDialog( parent ), d( new Private( this ) )
519 setCaption( i18n(
"Import Contacts from LDAP" ) );
521 setButtons( User1 | Cancel );
523 setButtons( User1 | User2 | Cancel );
525 setDefaultButton( User1 );
527 showButtonSeparator(
true );
528 setButtonGuiItem( KDialog::Cancel, KStandardGuiItem::close() );
530 setMainWidget( page );
531 QVBoxLayout *topLayout =
new QVBoxLayout( page );
532 topLayout->setSpacing( spacingHint() );
533 topLayout->setMargin( marginHint() );
535 QGroupBox *groupBox =
new QGroupBox( i18n(
"Search for Addresses in Directory" ),
537 QGridLayout *boxLayout =
new QGridLayout();
538 groupBox->setLayout( boxLayout );
539 boxLayout->setSpacing( spacingHint() );
540 boxLayout->setColumnStretch( 1, 1 );
542 QLabel *label =
new QLabel( i18n(
"Search for:" ), groupBox );
543 boxLayout->addWidget( label, 0, 0 );
545 d->mSearchEdit =
new KLineEdit( groupBox );
546 d->mSearchEdit->setClearButtonShown(
true);
547 boxLayout->addWidget( d->mSearchEdit, 0, 1 );
548 label->setBuddy( d->mSearchEdit );
550 label =
new QLabel( i18nc(
"In LDAP attribute",
"in" ), groupBox );
551 boxLayout->addWidget( label, 0, 2 );
553 d->mFilterCombo =
new KComboBox( groupBox );
554 d->mFilterCombo->addItem( i18nc(
"@item:inlistbox Name of the contact",
"Name" ) );
555 d->mFilterCombo->addItem( i18nc(
"@item:inlistbox email address of the contact",
"Email" ) );
556 d->mFilterCombo->addItem( i18nc(
"@item:inlistbox",
"Home Number" ) );
557 d->mFilterCombo->addItem( i18nc(
"@item:inlistbox",
"Work Number" ) );
558 boxLayout->addWidget( d->mFilterCombo, 0, 3 );
561 d->mSearchButton =
new QPushButton( i18n(
"Stop" ), groupBox );
562 buttonSize = d->mSearchButton->sizeHint();
563 d->mSearchButton->setText( i18nc(
"@action:button Start searching",
"&Search" ) );
564 if ( buttonSize.width() < d->mSearchButton->sizeHint().width() ) {
565 buttonSize = d->mSearchButton->sizeHint();
567 d->mSearchButton->setFixedWidth( buttonSize.width() );
569 d->mSearchButton->setDefault(
true );
570 boxLayout->addWidget( d->mSearchButton, 0, 4 );
572 d->mRecursiveCheckbox =
new QCheckBox( i18n(
"Recursive search" ), groupBox );
573 d->mRecursiveCheckbox->setChecked(
true );
574 boxLayout->addWidget( d->mRecursiveCheckbox, 1, 0, 1, 5 );
576 d->mSearchType =
new KComboBox( groupBox );
577 d->mSearchType->addItem( i18n(
"Contains" ) );
578 d->mSearchType->addItem( i18n(
"Starts With" ) );
579 boxLayout->addWidget( d->mSearchType, 1, 3, 1, 2 );
581 topLayout->addWidget( groupBox );
583 d->mResultView =
new QTableView( page );
584 d->mResultView->setSelectionMode( QTableView::MultiSelection );
585 d->mResultView->setSelectionBehavior( QTableView::SelectRows );
586 d->mModel =
new ContactListModel( d->mResultView );
588 d->sortproxy =
new QSortFilterProxyModel(
this );
589 d->sortproxy->setSourceModel( d->mModel );
591 d->mResultView->setModel( d->sortproxy );
592 d->mResultView->verticalHeader()->hide();
593 d->mResultView->setSortingEnabled(
true);
594 d->mResultView->horizontalHeader()->setSortIndicatorShown(
true);
595 connect( d->mResultView, SIGNAL(clicked(QModelIndex)),
596 SLOT(slotSelectionChanged()) );
597 topLayout->addWidget( d->mResultView );
599 d->mResultView->setContextMenuPolicy(Qt::CustomContextMenu);
600 connect(d->mResultView, SIGNAL(customContextMenuRequested(QPoint)),
604 QHBoxLayout *buttonLayout =
new QHBoxLayout;
605 buttonLayout->setMargin(0);
606 topLayout->addLayout(buttonLayout);
608 d->progressIndication =
new KPIMUtils::ProgressIndicatorLabel(i18n(
"Searching..."));
609 buttonLayout->addWidget(d->progressIndication);
611 KDialogButtonBox *buttons =
new KDialogButtonBox( page, Qt::Horizontal );
612 buttons->addButton( i18n(
"Select All" ),
613 QDialogButtonBox::ActionRole,
this, SLOT(slotSelectAll()) );
614 buttons->addButton( i18n(
"Unselect All" ),
615 QDialogButtonBox::ActionRole,
this, SLOT(slotUnselectAll()) );
617 buttonLayout->addWidget( buttons );
621 setButtonText( User1, i18n(
"Add Selected" ) );
623 setButtonText( User2, i18n(
"Configure LDAP Servers..." ) );
626 connect( d->mRecursiveCheckbox, SIGNAL(toggled(
bool)),
627 this, SLOT(slotSetScope(
bool)) );
628 connect( d->mSearchButton, SIGNAL(clicked()),
629 this, SLOT(slotStartSearch()) );
631 setTabOrder( d->mSearchEdit, d->mFilterCombo );
632 setTabOrder( d->mFilterCombo, d->mSearchButton );
633 d->mSearchEdit->setFocus();
635 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(
slotUser1()) );
637 connect(
this, SIGNAL(user2Clicked()),
this, SLOT(
slotUser2()) );
639 d->slotSelectionChanged();
640 d->restoreSettings();
651 d->mSearchEdit->setText( text );
656 return d->mSelectedContacts;
661 const QModelIndex index = d->mResultView->indexAt(pos);
662 if (index.isValid()) {
664 QAction *act = menu.addAction(i18n(
"Copy"));
665 if (menu.exec(QCursor::pos()) == act) {
666 QClipboard *cb = QApplication::clipboard();
667 cb->setText(index.data().toString(), QClipboard::Clipboard);
673 void LdapSearchDialog::Private::slotSelectionChanged()
675 q->enableButton( KDialog::User1, mResultView->selectionModel()->hasSelection() );
678 void LdapSearchDialog::Private::restoreSettings()
684 qDeleteAll( mLdapClientList ) ;
685 mLdapClientList.clear();
687 KConfig *config = KLDAP::LdapClientSearchConfig::config();
689 KConfigGroup searchGroup( config,
"LDAPSearch" );
690 mSearchType->setCurrentIndex( searchGroup.readEntry(
"SearchType", 0 ) );
694 KConfigGroup group( config,
"LDAP" );
695 mNumHosts = group.readEntry(
"NumSelectedHosts", 0 );
697 mIsConfigured =
false;
699 mIsConfigured =
true;
700 KLDAP::LdapClientSearchConfig *clientSearchConfig =
new KLDAP::LdapClientSearchConfig;
701 for (
int j = 0; j < mNumHosts; ++j ) {
702 KLDAP::LdapServer ldapServer;
704 clientSearchConfig->readConfig( ldapServer, group, j,
true );
709 for ( QMap<QString, QString>::ConstIterator it =
adrbookattr2ldap().constBegin();
718 q->connect( ldapClient, SIGNAL(done()),
719 q, SLOT(slotSearchDone()) );
720 q->connect( ldapClient, SIGNAL(error(QString)),
721 q, SLOT(slotError(QString)) );
723 mLdapClientList.append( ldapClient );
725 delete clientSearchConfig;
729 KConfigGroup groupHeader( config,
"Headers" );
730 mResultView->horizontalHeader()->restoreState(groupHeader.readEntry(
"HeaderState",QByteArray()));
732 KConfigGroup groupSize( config,
"Size" );
733 const QSize dialogSize = groupSize.readEntry(
"Size", QSize() );
734 if ( dialogSize.isValid() ) {
735 q->resize( dialogSize );
737 q->resize( QSize( 600, 400 ).expandedTo( q->minimumSizeHint() ) );
741 void LdapSearchDialog::Private::saveSettings()
743 KConfig *config = KLDAP::LdapClientSearchConfig::config();
744 KConfigGroup group( config,
"LDAPSearch" );
745 group.writeEntry(
"SearchType", mSearchType->currentIndex() );
747 KConfigGroup groupHeader( config,
"Headers" );
748 groupHeader.writeEntry(
"HeaderState", mResultView->horizontalHeader()->saveState());
751 KConfigGroup size( config,
"Size" );
752 size.writeEntry(
"Size", q->size());
758 void LdapSearchDialog::Private::cancelQuery()
766 const KLDAP::LdapObject &obj )
768 mModel->addContact( obj.attributes(), client.
server().host() );
771 void LdapSearchDialog::Private::slotSetScope(
bool rec )
775 client->
setScope( QLatin1String(
"sub") );
777 client->
setScope( QLatin1String(
"one") );
782 void LdapSearchDialog::Private::slotStartSearch()
786 if ( !mIsConfigured ) {
787 KMessageBox::error( q, i18n(
"You must select an LDAP server before searching." ) );
793 QApplication::setOverrideCursor( Qt::WaitCursor );
795 mSearchButton->setText( i18n(
"Stop" ) );
796 progressIndication->start();
798 q->disconnect( mSearchButton, SIGNAL(clicked()),
799 q, SLOT(slotStartSearch()) );
800 q->connect( mSearchButton, SIGNAL(clicked()),
801 q, SLOT(slotStopSearch()) );
803 const bool startsWith = (mSearchType->currentIndex() == 1);
805 const QString filter =
makeFilter( mSearchEdit->text().trimmed(),
806 mFilterCombo->currentText(), startsWith );
817 void LdapSearchDialog::Private::slotStopSearch()
823 void LdapSearchDialog::Private::slotSearchDone()
832 q->disconnect( mSearchButton, SIGNAL(clicked()),
833 q, SLOT(slotStopSearch()) );
834 q->connect( mSearchButton, SIGNAL(clicked()),
835 q, SLOT(slotStartSearch()) );
837 mSearchButton->setText( i18nc(
"@action:button Start searching",
"&Search" ) );
838 progressIndication->stop();
840 QApplication::restoreOverrideCursor();
844 void LdapSearchDialog::Private::slotError(
const QString &error )
847 QApplication::restoreOverrideCursor();
849 KMessageBox::error( q, error );
858 void LdapSearchDialog::Private::slotUnselectAll()
860 mResultView->clearSelection();
861 slotSelectionChanged();
864 void LdapSearchDialog::Private::slotSelectAll()
866 mResultView->selectAll();
867 slotSelectionChanged();
874 d->mSelectedContacts.clear();
878 if ( !items.isEmpty() ) {
879 const QDateTime now = QDateTime::currentDateTime();
881 for (
int i = 0; i < items.count(); ++i ) {
885 contact.setNote( i18nc(
"arguments are host name, datetime",
886 "Imported from LDAP directory %1 on %2",
887 items.at( i ).second, KGlobal::locale()->formatDateTime( now ) ) );
889 d->mSelectedContacts.append( contact );
902 KCMultiDialog dialog(
this );
903 dialog.setCaption( i18n(
"Configure the Address Book LDAP Settings" ) );
904 dialog.addModule( QLatin1String(
"kcmldap.desktop") );
906 if ( dialog.exec() ) {
907 d->restoreSettings();
911 #include "ldapsearchdialog.moc"
~LdapSearchDialog()
Destroys the ldap search dialog.
const KLDAP::LdapServer server() const
Returns the ldap server information that are used by this client.
void closeEvent(QCloseEvent *)
void slotCustomContextMenuRequested(const QPoint &)
void contactsAdded()
This signal is emitted whenever the user clicked the 'Add Selected' button.
bool isActive() const
Returns whether this client is currently running a search query.
LdapSearchDialog(QWidget *parent=0)
Creates a new ldap search dialog.
static KABC::Addressee convertLdapAttributesToAddressee(const KLDAP::LdapAttrMap &attrs)
void startQuery(const QString &filter)
Starts the query with the given filter.
static QString join(const KLDAP::LdapAttrValue &lst, const QString &sep)
void setSearchText(const QString &text)
Sets the text in the search line edit.
void setAttributes(const QStringList &attributes)
Sets the LDAP attributes that should be returned in the query result.
A dialog to search contacts in a LDAP directory.
static QString makeFilter(const QString &query, const QString &attr, bool startsWith)
void setServer(const KLDAP::LdapServer &server)
Sets the LDAP server information that shall be used by this client.
KABC::Addressee::List selectedContacts() const
Returns a list of contacts that have been selected in the LDAP search.
An object that represents a configured LDAP server.
static QString asUtf8(const QByteArray &val)
void setScope(const QString scope)
Sets the scope of the LDAP query.
static QMap< QString, QString > & adrbookattr2ldap()
void cancelQuery()
Cancels a running query.