• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkdepim

  • sources
  • kde-4.14
  • kdepim
  • libkdepim
  • addressline
  • addresslineedit
addresseelineeditstatic.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "addresseelineeditstatic.h"
19 #include "kmailcompletion.h"
20 
21 #include <ldap/ldapclient.h>
22 #include <KGlobal>
23 #include <KLocalizedString>
24 #include <QTimer>
25 #include <addressline/completionorder/completionordereditor.h>
26 #include <KLDAP/LdapServer>
27 #include <Akonadi/Session>
28 using namespace KPIM;
29 
30 AddresseeLineEditStatic::AddresseeLineEditStatic()
31  : completion( new KMailCompletion ),
32  ldapTimer( 0 ),
33  ldapSearch( 0 ),
34  ldapLineEdit( 0 ),
35  akonadiSession( new Akonadi::Session("contactsCompletionSession") ),
36  balooCompletionSource( 0 )
37 {
38 }
39 
40 AddresseeLineEditStatic::~AddresseeLineEditStatic()
41 {
42  delete completion;
43  delete ldapTimer;
44  delete ldapSearch;
45 }
46 
47 void AddresseeLineEditStatic::slotEditCompletionOrder()
48 {
49  CompletionOrderEditor editor( ldapSearch, 0 );
50  if( editor.exec() ) {
51  updateLDAPWeights();
52  updateCollectionWeights();
53  }
54 }
55 
56 void AddresseeLineEditStatic::updateCollectionWeights()
57 {
58  akonadiCollectionToCompletionSourceMap.clear();
59 }
60 
61 void AddresseeLineEditStatic::updateLDAPWeights()
62 {
63  /* Add completion sources for all ldap server, 0 to n. Added first so
64  * that they map to the LdapClient::clientNumber() */
65  ldapSearch->updateCompletionWeights();
66  int clientIndex = 0;
67  foreach ( const KLDAP::LdapClient *client, ldapSearch->clients() ) {
68  const int sourceIndex =
69  addCompletionSource( i18n( "LDAP server: %1" ,client->server().host()),
70  client->completionWeight() );
71 
72  ldapClientToCompletionSourceMap.insert( clientIndex, sourceIndex );
73 
74  ++clientIndex;
75  }
76 }
77 
78 int AddresseeLineEditStatic::addCompletionSource(const QString &source, int weight)
79 {
80  QMap<QString,int>::iterator it = completionSourceWeights.find( source );
81  if ( it == completionSourceWeights.end() ) {
82  completionSourceWeights.insert( source, weight );
83  } else {
84  completionSourceWeights[source] = weight;
85  }
86 
87  const int sourceIndex = completionSources.indexOf( source );
88  if ( sourceIndex == -1 ) {
89  completionSources.append( source );
90  return completionSources.size() - 1;
91  } else {
92  return sourceIndex;
93  }
94 }
95 
96 void AddresseeLineEditStatic::removeCompletionSource(const QString &source)
97 {
98  QMap<QString,int>::iterator it = completionSourceWeights.find( source );
99  if ( it != completionSourceWeights.end() ) {
100  completionSourceWeights.remove(source);
101  completion->clear();
102  }
103 }
KLDAP::LdapClient::server
const KLDAP::LdapServer server() const
Returns the ldap server information that are used by this client.
Definition: ldapclient.cpp:114
KPIM::CompletionOrderEditor
Definition: completionordereditor.h:44
KLDAP::LdapClient::completionWeight
int completionWeight() const
Returns the completion weight of this client.
Definition: ldapclient.cpp:312
QMap
KPIM::AddresseeLineEditStatic::completionSourceWeights
QMap< QString, int > completionSourceWeights
Definition: addresseelineeditstatic.h:64
kmailcompletion.h
QList::size
int size() const
KLDAP::LdapClientSearch::clients
QList< LdapClient * > clients() const
Returns the list of configured LDAP clients.
Definition: ldapclientsearch.cpp:137
KPIM::AddresseeLineEditStatic::akonadiCollectionToCompletionSourceMap
QMap< Akonadi::Collection::Id, collectionInfo > akonadiCollectionToCompletionSourceMap
Definition: addresseelineeditstatic.h:81
ldapclient.h
KPIM::AddresseeLineEditStatic::slotEditCompletionOrder
void slotEditCompletionOrder()
Definition: addresseelineeditstatic.cpp:47
KPIM::AddresseeLineEditStatic::updateLDAPWeights
void updateLDAPWeights()
Definition: addresseelineeditstatic.cpp:61
QList::append
void append(const T &value)
KPIM::KMailCompletion::clear
virtual void clear()
clears internal keyword map and calls KCompletion::clear.
Definition: kmailcompletion.cpp:33
KPIM::AddresseeLineEditStatic::AddresseeLineEditStatic
AddresseeLineEditStatic()
Definition: addresseelineeditstatic.cpp:30
KPIM::AddresseeLineEditStatic::ldapSearch
KLDAP::LdapClientSearch * ldapSearch
Definition: addresseelineeditstatic.h:58
KPIM::AddresseeLineEditStatic::addCompletionSource
int addCompletionSource(const QString &source, int weight)
Definition: addresseelineeditstatic.cpp:78
QString
QMap::end
iterator end()
KPIM::AddresseeLineEditStatic::ldapTimer
QTimer * ldapTimer
Definition: addresseelineeditstatic.h:57
completionordereditor.h
KPIM::AddresseeLineEditStatic::removeCompletionSource
void removeCompletionSource(const QString &source)
Definition: addresseelineeditstatic.cpp:96
KPIM::AddresseeLineEditStatic::completion
KMailCompletion * completion
Definition: addresseelineeditstatic.h:53
KPIM::KMailCompletion
KMailCompletion allows lookup of email addresses by keyword.
Definition: kmailcompletion.h:39
KPIM::AddresseeLineEditStatic::updateCollectionWeights
void updateCollectionWeights()
Definition: addresseelineeditstatic.cpp:56
KPIM::AddresseeLineEditStatic::completionSources
QStringList completionSources
Definition: addresseelineeditstatic.h:55
KPIM::AddresseeLineEditStatic::~AddresseeLineEditStatic
~AddresseeLineEditStatic()
Definition: addresseelineeditstatic.cpp:40
QStringList::indexOf
int indexOf(const QRegExp &rx, int from) const
QMap::insert
iterator insert(const Key &key, const T &value)
KPIM::AddresseeLineEditStatic::ldapClientToCompletionSourceMap
QMap< int, int > ldapClientToCompletionSourceMap
Definition: addresseelineeditstatic.h:68
KLDAP::LdapClient
An object that represents a configured LDAP server.
Definition: ldapclient.h:46
addresseelineeditstatic.h
QMap::find
iterator find(const Key &key)
KLDAP::LdapClientSearch::updateCompletionWeights
void updateCompletionWeights()
Updates the completion weights for the configured LDAP clients from the configuration file...
Definition: ldapclientsearch.cpp:129
QMap::remove
int remove(const Key &key)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdepim

Skip menu "libkdepim"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal