zanshin/0001-Remove-the-delegation-feature.patch

12622 lines
436 KiB
Diff
Raw Normal View History

commit 6268f648311f200a1c4ea9a9d2ecabdff739ef83
Author: Kevin Ottens <ervin@kde.org>
Date: Thu Jan 3 18:12:48 2019 +0100
Remove the delegation feature
Summary: It's brittle and barely used anyway.
Reviewers: bensi, dfaure
Differential Revision: https://phabricator.kde.org/D18056
diff --git a/3rdparty/kdepim/libkdepim/CMakeLists.txt b/3rdparty/kdepim/libkdepim/CMakeLists.txt
index 94698d3..631f700 100644
--- a/3rdparty/kdepim/libkdepim/CMakeLists.txt
+++ b/3rdparty/kdepim/libkdepim/CMakeLists.txt
@@ -2,63 +2,15 @@ add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DTRANSLATION_DOMAIN=\"libkdepim\")
-option(KDEPIM_INPROCESS_LDAP "Use in-process rather than KIO slave LDAP" FALSE)
-if (KDEPIM_INPROCESS_LDAP)
- add_definitions( -DKDEPIM_INPROCESS_LDAP )
-endif ()
-
set(kdepim_LIB_SRCS
- addressline/addresseelineedit.cpp
- addressline/addresseelineedit_p.cpp
- addressline/addresseelineeditstatic.cpp
- addressline/baloocompletionemail.cpp
- addressline/kmailcompletion.cpp
- blacklistbaloocompletion/blacklistbalooemailcompletiondialog.cpp
- blacklistbaloocompletion/blacklistbalooemailcompletionwidget.cpp
- blacklistbaloocompletion/blacklistbalooemaillist.cpp
- blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp
- blacklistbaloocompletion/blacklistbalooemailutil.cpp
- blacklistbaloocompletion/blacklistbalooemailwarning.cpp
- completionorder/completionordereditor.cpp
- completionorder/completionorderwidget.cpp
- completionconfiguredialog/completionconfiguredialog.cpp
- recentaddress/recentaddressdialog.cpp
- recentaddress/recentaddresses.cpp
- recentaddress/recentaddresswidget.cpp
kdateedit.cpp
kdatepickerpopup.cpp
- ldap/ldapclient.cpp
- ldap/ldapclient_debug.cpp
- ldap/ldapclientsearch.cpp
- ldap/ldapclientsearchconfig.cpp
- libkdepim_debug.cpp
)
-if (KDEPIM_INPROCESS_LDAP)
- set(kdepim_LIB_SRCS ${kdepim_LIB_SRCS}
- ldap/ldapsession.cpp
- ldap/ldapqueryjob.cpp
- )
-endif ()
-
add_library(zanshinkdepimstatic STATIC ${kdepim_LIB_SRCS})
generate_export_header(zanshinkdepimstatic BASE_NAME kdepim)
target_link_libraries(zanshinkdepimstatic
- KF5::AkonadiContact
- KF5::AkonadiSearchPIM
- KF5::Codecs
- KF5::Completion
- KF5::ConfigCore
- KF5::ConfigWidgets
- KF5::I18n
- KF5::ItemViews
- KF5::JobWidgets
- KF5::KIOCore
- KF5::Ldap
- KF5::Wallet
KF5::WidgetsAddons
- Qt5::DBus
- Qt5::Network
+ KF5::I18n
)
-add_subdirectory(tests)
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.cpp b/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.cpp
deleted file mode 100644
index d49fea4..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.cpp
+++ /dev/null
@@ -1,971 +0,0 @@
-/*
- This file is part of libkdepim.
-
- Copyright (c) 2002 Helge Deller <deller@gmx.de>
- Copyright (c) 2002 Lubos Lunak <llunak@suse.cz>
- Copyright (c) 2001,2003 Carsten Pfeiffer <pfeiffer@kde.org>
- Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
- Copyright (c) 2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
- Copyright (c) 2004 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "addresseelineedit.h"
-#include "addresseelineedit_p.h"
-#include "ldap/ldapclientsearch.h"
-
-#include <Job>
-#include <QRegularExpression>
-#include <QUrl>
-#include <kconfiggroup.h>
-
-#include <KEmailAddress>
-#include <KColorScheme>
-#include <KJobWidgets>
-#include <kdelibs4configmigrator.h>
-#include <KContacts/Addressee>
-#include <KContacts/ContactGroup>
-#include <KContacts/VCardConverter>
-#include <kcontacts/contactgrouptool.h>
-#include <KIO/StoredTransferJob>
-#include <Akonadi/Contact/ContactGroupExpandJob>
-#include <Akonadi/Contact/ContactGroupSearchJob>
-#include "recentaddress/recentaddresses.h"
-#include <KLDAP/LdapServer>
-
-#include <KCompletionBox>
-#include "libkdepim_debug.h"
-#include <KLocalizedString>
-#include <KStandardShortcut>
-#include <KCodecs>
-
-#include <QMimeData>
-#include <QApplication>
-#include <QObject>
-#include <QBuffer>
-#include <QRegExp>
-#include <QEvent>
-#include <QClipboard>
-#include <QKeyEvent>
-#include <QDropEvent>
-#include <QMouseEvent>
-#include <QMenu>
-#include <KSharedConfig>
-#include <KMessageBox>
-#include <ContactGroupExpandJob>
-#include <kcontacts/vcarddrag.h>
-#include "completionconfiguredialog/completionconfiguredialog.h"
-
-using namespace KPIM;
-
-inline bool itemIsHeader(const QListWidgetItem *item)
-{
- return item && !item->text().startsWith(QStringLiteral(" "));
-}
-
-// needs to be unique, but the actual name doesn't matter much
-static QString newLineEditObjectName()
-{
- static int s_count = 0;
- QString name(QStringLiteral("KPIM::AddresseeLineEdit"));
- if (s_count++) {
- name += QLatin1Char('-');
- name += QString::number(s_count);
- }
- return name;
-}
-
-AddresseeLineEdit::AddresseeLineEdit(QWidget *parent, bool enableCompletion)
- : KLineEdit(parent), d(new AddresseeLineEditPrivate(this, enableCompletion))
-{
- Kdelibs4ConfigMigrator migrate(QStringLiteral("addressline"));
- migrate.setConfigFiles(QStringList() << QStringLiteral("kpimbalooblacklist") << QStringLiteral("kpimcompletionorder"));
- migrate.migrate();
-
- setObjectName(newLineEditObjectName());
- setPlaceholderText(QString());
-
- d->init();
-}
-
-AddresseeLineEdit::~AddresseeLineEdit()
-{
- delete d;
-}
-
-void AddresseeLineEdit::setFont(const QFont &font)
-{
- KLineEdit::setFont(font);
-
- if (d->useCompletion()) {
- completionBox()->setFont(font);
- }
-}
-
-bool AddresseeLineEdit::expandIntern() const
-{
- return d->expandIntern();
-}
-
-bool AddresseeLineEdit::groupsIsEmpty() const
-{
- return d->groupsIsEmpty();
-}
-
-void AddresseeLineEdit::setExpandIntern(bool expand)
-{
- d->setExpandIntern(expand);
-}
-
-bool AddresseeLineEdit::autoGroupExpand() const
-{
- return d->autoGroupExpand();
-}
-
-void AddresseeLineEdit::setAutoGroupExpand(bool autoGroupExpand)
-{
- d->setAutoGroupExpand(autoGroupExpand);
-}
-
-void AddresseeLineEdit::setEnableBalooSearch(bool enable)
-{
- d->setEnableBalooSearch(enable);
-}
-
-void AddresseeLineEdit::allowSemicolonAsSeparator(bool useSemicolonAsSeparator)
-{
- d->setUseSemicolonAsSeparator(useSemicolonAsSeparator);
-}
-
-bool AddresseeLineEdit::showRecentAddresses() const
-{
- return d->showRecentAddresses();
-}
-
-void AddresseeLineEdit::setShowRecentAddresses(bool b)
-{
- d->setShowRecentAddresses(b);
-}
-
-void AddresseeLineEdit::keyPressEvent(QKeyEvent *event)
-{
- bool accept = false;
-
- const int key = event->key() | event->modifiers();
-
- if (KStandardShortcut::shortcut(KStandardShortcut::SubstringCompletion).contains(key)) {
- //TODO: add LDAP substring lookup, when it becomes available in KPIM::LDAPSearch
- d->updateSearchString();
- d->startSearches();
- d->doCompletion(true);
- accept = true;
- } else if (KStandardShortcut::shortcut(KStandardShortcut::TextCompletion).contains(key)) {
- const int len = text().length();
-
- if (len == cursorPosition()) { // at End?
- d->updateSearchString();
- d->startSearches();
- d->doCompletion(true);
- accept = true;
- }
- }
-
- const QString oldContent = text();
- if (!accept) {
- KLineEdit::keyPressEvent(event);
- }
-
- // if the text didn't change (eg. because a cursor navigation key was pressed)
- // we don't need to trigger a new search
- if (oldContent == text()) {
- return;
- }
-
- if (event->isAccepted()) {
- d->updateSearchString();
-
- QString searchString(d->searchString());
- //LDAP does not know about our string manipulation, remove it
- if (d->searchExtended()) {
- searchString = d->searchString().mid(1);
- }
-
- d->restartTime(searchString);
- }
-}
-
-void AddresseeLineEdit::insert(const QString &t)
-{
- if (!d->smartPaste()) {
- KLineEdit::insert(t);
- return;
- }
-
- QString newText = t.trimmed();
- if (newText.isEmpty()) {
- return;
- }
-
- // remove newlines in the to-be-pasted string
- QStringList lines = newText.split(QRegExp(QLatin1String("\r?\n")), QString::SkipEmptyParts);
- QStringList::iterator end(lines.end());
- for (QStringList::iterator it = lines.begin(); it != end; ++it) {
- // remove trailing commas and whitespace
- (*it).remove(QRegExp(QLatin1String(",?\\s*$")));
- }
- newText = lines.join(QStringLiteral(", "));
-
- if (newText.startsWith(QStringLiteral("mailto:"))) {
- const QUrl url(newText);
- newText = url.path();
- } else if (newText.indexOf(QStringLiteral(" at ")) != -1) {
- // Anti-spam stuff
- newText.replace(QStringLiteral(" at "), QStringLiteral("@"));
- newText.replace(QStringLiteral(" dot "), QStringLiteral("."));
- } else if (newText.indexOf(QStringLiteral("(at)")) != -1) {
- newText.replace(QRegularExpression(QStringLiteral("\\s*\\(at\\)\\s*")), QStringLiteral("@"));
- }
-
- QString contents = text();
- int start_sel = 0;
- int pos = cursorPosition();
-
- if (hasSelectedText()) {
- // Cut away the selection.
- start_sel = selectionStart();
- pos = start_sel;
- contents = contents.left(start_sel) + contents.mid(start_sel + selectedText().length());
- }
-
- int eot = contents.length();
- while ((eot > 0) && contents.at(eot - 1).isSpace()) {
- --eot;
- }
- if (eot == 0) {
- contents.clear();
- } else if (pos >= eot) {
- if (contents.at(eot - 1) == QLatin1Char(',')) {
- --eot;
- }
- contents.truncate(eot);
- contents += QStringLiteral(", ");
- pos = eot + 2;
- }
-
- contents = contents.left(pos) + newText + contents.mid(pos);
- setText(contents);
- setModified(true);
- setCursorPosition(pos + newText.length());
-}
-
-void AddresseeLineEdit::setText(const QString &text)
-{
- const int cursorPos = cursorPosition();
- KLineEdit::setText(text.trimmed());
- setCursorPosition(cursorPos);
-}
-
-void AddresseeLineEdit::paste()
-{
- if (d->useCompletion()) {
- d->setSmartPaste(true);
- }
-
- KLineEdit::paste();
- d->setSmartPaste(false);
-}
-
-void AddresseeLineEdit::mouseReleaseEvent(QMouseEvent *event)
-{
- // reimplemented from QLineEdit::mouseReleaseEvent()
-#ifndef QT_NO_CLIPBOARD
- if (d->useCompletion() &&
- QApplication::clipboard()->supportsSelection() &&
- !isReadOnly() &&
- event->button() == Qt::MidButton) {
- d->setSmartPaste(true);
- }
-#endif
-
- KLineEdit::mouseReleaseEvent(event);
- d->setSmartPaste(false);
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void AddresseeLineEdit::dropEvent(QDropEvent *event)
-{
- const QMimeData *md = event->mimeData();
-
- // Case one: The user dropped a text/directory (i.e. vcard), so decode its
- // contents
- if (KContacts::VCardDrag::canDecode(md)) {
- KContacts::Addressee::List list;
- KContacts::VCardDrag::fromMimeData(md, list);
-
- KContacts::Addressee::List::ConstIterator ait;
- KContacts::Addressee::List::ConstIterator end(list.constEnd());
- for (ait = list.constBegin(); ait != end; ++ait) {
- insertEmails((*ait).emails());
- }
- }
-
- // Case two: The user dropped a list or Urls.
- // Iterate over that list. For mailto: Urls, just add the addressee to the list,
- // and for other Urls, download the Url and assume it points to a vCard
- else if (md->hasUrls()) {
- QList<QUrl> urls = md->urls();
- KContacts::Addressee::List list;
-
- foreach (const QUrl &url, urls) {
-
- // First, let's deal with mailto Urls. The path() part contains the
- // email-address.
- if (url.scheme() == QLatin1String("mailto")) {
- KContacts::Addressee addressee;
- addressee.insertEmail(KEmailAddress::decodeMailtoUrl(url), true /* preferred */);
- list += addressee;
- }
-
- // Otherwise, download the vCard to which the Url points
- else {
- KContacts::VCardConverter converter;
- auto job = KIO::storedGet(url);
- KJobWidgets::setWindow(job, parentWidget());
- if (job->exec()) {
- QByteArray data = job->data();
- list += converter.parseVCards(data);
-
- if (list.isEmpty()) { // try to parse a contact group
- KContacts::ContactGroup group;
- QBuffer dataStream(&data);
- dataStream.open(QIODevice::ReadOnly);
- QString error;
- if (KContacts::ContactGroupTool::convertFromXml(&dataStream, group, &error)) {
- Akonadi::ContactGroupExpandJob *expandJob = new Akonadi::ContactGroupExpandJob(group);
- connect(expandJob, &Akonadi::ContactGroupExpandJob::result, this, &AddresseeLineEdit::groupExpandResult);
- expandJob->start();
- }
- }
- } else {
- const QString caption(i18n("vCard Import Failed"));
- const QString text = i18n("<qt>Unable to access <b>%1</b>.</qt>", url.url());
- KMessageBox::error(parentWidget(), text, caption);
- }
- }
- }
-
- // Now, let the user choose which addressee to add.
- foreach (const KContacts::Addressee &addressee, list) {
- insertEmails(addressee.emails());
- }
- }
-
- // Case three: Let AddresseeLineEdit deal with the rest
- else {
- if (!isReadOnly()) {
- const QList<QUrl> uriList = event->mimeData()->urls();
- if (!uriList.isEmpty()) {
- QString contents = text();
- // remove trailing white space and comma
- int eot = contents.length();
- while ((eot > 0) && contents.at(eot - 1).isSpace()) {
- --eot;
- }
- if (eot == 0) {
- contents.clear();
- } else if (contents.at(eot - 1) == QLatin1Char(',')) {
- --eot;
- contents.truncate(eot);
- }
- bool mailtoURL = false;
- // append the mailto URLs
- foreach (const QUrl &url, uriList) {
- if (url.scheme() == QLatin1String("mailto")) {
- mailtoURL = true;
- QString address;
- address = QUrl::fromPercentEncoding(url.path().toLatin1());
- address = KCodecs::decodeRFC2047String(address);
- if (!contents.isEmpty()) {
- contents.append(QStringLiteral(", "));
- }
- contents.append(address);
- }
- }
- if (mailtoURL) {
- setText(contents);
- setModified(true);
- return;
- }
- } else {
- // Let's see if this drop contains a comma separated list of emails
- const QMimeData *mimeData = event->mimeData();
- if (mimeData->hasText()) {
- const QString dropData = mimeData->text();
- const QStringList addrs = KEmailAddress::splitAddressList(dropData);
- if (!addrs.isEmpty()) {
- setText(KEmailAddress::normalizeAddressesAndDecodeIdn(dropData));
- setModified(true);
- return;
- }
- }
- }
- }
-
- if (d->useCompletion()) {
- d->setSmartPaste(true);
- }
-
- QLineEdit::dropEvent(event);
- d->setSmartPaste(false);
- }
-}
-#endif // QT_NO_DRAGANDDROP
-
-void AddresseeLineEdit::groupExpandResult(KJob *job)
-{
- Akonadi::ContactGroupExpandJob *expandJob = qobject_cast<Akonadi::ContactGroupExpandJob *>(job);
-
- if (!expandJob) {
- return;
- }
-
- const KContacts::Addressee::List contacts = expandJob->contacts();
- foreach (const KContacts::Addressee &addressee, contacts) {
- if (d->expandIntern() || text().isEmpty()) {
- insertEmails(QStringList() << addressee.fullEmail());
- } else {
- Q_EMIT addAddress(addressee.fullEmail());
- }
- }
-
- job->deleteLater();
-}
-
-void AddresseeLineEdit::insertEmails(const QStringList &emails)
-{
- if (emails.empty()) {
- return;
- }
-
- QString contents = text();
- if (!contents.isEmpty()) {
- contents += QLatin1Char(',');
- }
- // only one address, don't need kpopup to choose
- if (emails.size() == 1) {
- setText(contents + emails.front());
- return;
- }
- //multiple emails, let the user choose one
- QMenu menu(this);
- menu.setTitle(i18n("Select email from contact"));
- menu.setObjectName(QStringLiteral("Addresschooser"));
- for (QStringList::const_iterator it = emails.constBegin(), end = emails.constEnd(); it != end; ++it) {
- menu.addAction(*it);
- }
- const QAction *result = menu.exec(QCursor::pos());
- if (!result) {
- return;
- }
- setText(contents + KLocalizedString::removeAcceleratorMarker(result->text()));
-}
-
-void AddresseeLineEdit::cursorAtEnd()
-{
- setCursorPosition(text().length());
-}
-
-void AddresseeLineEdit::enableCompletion(bool enable)
-{
- d->setUseCompletion(enable);
-}
-
-bool AddresseeLineEdit::isCompletionEnabled() const
-{
- return d->useCompletion();
-}
-
-void AddresseeLineEdit::addItem(const Akonadi::Item &item, int weight, int source)
-{
- //Let Akonadi results always have a higher weight than baloo results
- if (item.hasPayload<KContacts::Addressee>()) {
- addContact(item.payload<KContacts::Addressee>(), weight + 1, source);
- } else if (item.hasPayload<KContacts::ContactGroup>()) {
- addContactGroup(item.payload<KContacts::ContactGroup>(), weight + 1, source);
- }
-}
-
-void AddresseeLineEdit::addContactGroup(const KContacts::ContactGroup &group, int weight, int source)
-{
- d->addCompletionItem(group.name(), weight, source);
-}
-
-void AddresseeLineEdit::addContact(const KContacts::Addressee &addr, int weight, int source, QString append)
-{
- const QStringList emails = addr.emails();
- QStringList::ConstIterator it;
- int isPrefEmail = 1; //first in list is preferredEmail
- QStringList::ConstIterator end(emails.constEnd());
- for (it = emails.constBegin(); it != end; ++it) {
- //TODO: highlight preferredEmail
- const QString email((*it));
- const QString givenName = addr.givenName();
- const QString familyName = addr.familyName();
- const QString nickName = addr.nickName();
- QString fullEmail = addr.fullEmail(email);
-
- QString appendix;
-
- if (!append.isEmpty()) {
- appendix = QStringLiteral(" (%1)");
- append = append.replace(QStringLiteral("("), QStringLiteral("["));
- append = append.replace(QStringLiteral(")"), QStringLiteral("]"));
- appendix = appendix.arg(append);
- }
-
- // Prepare "givenName" + ' ' + "familyName"
- QString fullName = givenName;
- if (!familyName.isEmpty()) {
- if (!fullName.isEmpty()) {
- fullName += QLatin1Char(' ');
- }
- fullName += familyName;
- }
-
- // Finally, we can add the completion items
- if (!fullName.isEmpty()) {
- const QString address = KEmailAddress::normalizedAddress(fullName, email, QString());
- if (fullEmail != address) {
- // This happens when fullEmail contains a middle name, while our own fullName+email only has "first last".
- // Let's offer both, the fullEmail with 3 parts, looks a tad formal.
- d->addCompletionItem(address + appendix, weight + isPrefEmail, source);
- }
- }
-
- QStringList keyWords;
- if (!nickName.isEmpty()) {
- keyWords.append(nickName);
- }
-
- d->addCompletionItem(fullEmail + appendix, weight + isPrefEmail, source, &keyWords);
-
- isPrefEmail = 0;
- }
-}
-
-#ifndef QT_NO_CONTEXTMENU
-void AddresseeLineEdit::contextMenuEvent(QContextMenuEvent *event)
-{
- QMenu *menu = createStandardContextMenu();
- if (menu) { // can be 0 on platforms with only a touch interface
- menu->exec(event->globalPos());
- delete menu;
- }
-}
-
-QMenu *AddresseeLineEdit::createStandardContextMenu()
-{
- // disable modes not supported by KMailCompletion
- setCompletionModeDisabled(KCompletion::CompletionMan);
- setCompletionModeDisabled(KCompletion::CompletionPopupAuto);
-
- QMenu *menu = KLineEdit::createStandardContextMenu();
- if (!menu) {
- return Q_NULLPTR;
- }
- if (d->useCompletion()) {
- QAction *showOU = new QAction(i18n("Show Organization Unit for LDAP results"), menu);
- showOU->setCheckable(true);
-
- showOU->setChecked(d->showOU());
- connect(showOU, &QAction::triggered, d, &AddresseeLineEditPrivate::slotShowOUChanged);
- menu->addAction(showOU);
- }
- if (isCompletionEnabled()) {
- menu->addSeparator();
- QAction *act = menu->addAction(i18n("Configure Completion..."));
- connect(act, &QAction::triggered, this, &AddresseeLineEdit::configureCompletion);
- }
- menu->addSeparator();
- QAction *act = menu->addAction(i18n("Automatically expand groups"));
- act->setCheckable(true);
- act->setChecked(autoGroupExpand());
- connect(act, &QAction::triggered, this, &AddresseeLineEdit::slotToggleExpandGroups);
-
- if (!groupsIsEmpty()) {
- act = menu->addAction(i18n("Expand Groups..."));
- connect(act, &QAction::triggered, this, &AddresseeLineEdit::expandGroups);
- }
- return menu;
-}
-#endif
-
-void AddresseeLineEdit::configureCompletion()
-{
- QScopedPointer<KPIM::CompletionConfigureDialog> dlg(new KPIM::CompletionConfigureDialog(this));
- dlg->setRecentAddresses(KPIM::RecentAddresses::self(recentAddressConfig())->addresses());
- dlg->setLdapClientSearch(ldapSearch());
- dlg->setEmailBlackList(balooBlackList());
- dlg->load();
- if (dlg->exec() && dlg) {
- if (dlg->recentAddressWasChanged()) {
- KPIM::RecentAddresses::self(recentAddressConfig())->clear();
- dlg->storeAddresses(recentAddressConfig());
- loadContacts();
- updateBalooBlackList();
- updateCompletionOrder();
- }
- }
-}
-
-void AddresseeLineEdit::slotToggleExpandGroups()
-{
- setAutoGroupExpand(!autoGroupExpand());
- KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
- group.writeEntry("AutoGroupExpand", autoGroupExpand());
-}
-
-void AddresseeLineEdit::loadContacts()
-{
- const QString recentAddressGroupName = i18n("Recent Addresses");
- if (showRecentAddresses()) {
- const QStringList recent =
- cleanupEmailList(KPIM::RecentAddresses::self(recentAddressConfig())->addresses());
- QStringList::ConstIterator it = recent.constBegin();
- QString name, email;
-
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimcompletionorder"));
- KConfigGroup group(config, "CompletionWeights");
- const int weight = group.readEntry("Recent Addresses", 10);
- removeCompletionSource(recentAddressGroupName);
- const int idx = addCompletionSource(recentAddressGroupName, weight);
-
- QStringList::ConstIterator end = recent.constEnd();
- for (; it != end; ++it) {
- KContacts::Addressee addr;
- KEmailAddress::extractEmailAddressAndName(*it, email, name);
- name = KEmailAddress::quoteNameIfNecessary(name);
- if ((name[0] == QLatin1Char('"')) && (name[name.length() - 1] == QLatin1Char('"'))) {
- name.remove(0, 1);
- name.truncate(name.length() - 1);
- }
- addr.setNameFromString(name);
- addr.insertEmail(email, true);
- addContact(addr, weight, idx);
- }
- } else {
- removeCompletionSource(recentAddressGroupName);
- }
-}
-
-void KPIM::AddresseeLineEdit::removeCompletionSource(const QString &source)
-{
- d->removeCompletionSource(source);
-}
-
-int KPIM::AddresseeLineEdit::addCompletionSource(const QString &source, int weight)
-{
- return d->addCompletionSource(source, weight);
-}
-
-bool KPIM::AddresseeLineEdit::eventFilter(QObject *object, QEvent *event)
-{
- if (d->completionInitialized() &&
- (object == completionBox() ||
- completionBox()->findChild<QWidget *>(object->objectName()) == object)) {
- if (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::MouseMove ||
- event->type() == QEvent::MouseButtonRelease ||
- event->type() == QEvent::MouseButtonDblClick) {
-
- const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
- // find list box item at the event position
- QListWidgetItem *item = completionBox()->itemAt(mouseEvent->pos());
- if (!item) {
- // In the case of a mouse move outside of the box we don't want
- // the parent to fuzzy select a header by mistake.
- const bool eat = event->type() == QEvent::MouseMove;
- return eat;
- }
- // avoid selection of headers on button press, or move or release while
- // a button is pressed
- const Qt::MouseButtons buttons = mouseEvent->buttons();
- if (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::MouseButtonDblClick ||
- buttons & Qt::LeftButton || buttons & Qt::MidButton ||
- buttons & Qt::RightButton) {
- if (itemIsHeader(item)) {
- return true; // eat the event, we don't want anything to happen
- } else {
- // if we are not on one of the group heading, make sure the item
- // below or above is selected, not the heading, inadvertedly, due
- // to fuzzy auto-selection from QListBox
- completionBox()->setCurrentItem(item);
- item->setSelected(true);
- if (event->type() == QEvent::MouseMove) {
- return true; // avoid fuzzy selection behavior
- }
- }
- }
- }
- }
-
- if ((object == this) &&
- (event->type() == QEvent::ShortcutOverride)) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
- if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down ||
- keyEvent->key() == Qt::Key_Tab) {
- keyEvent->accept();
- return true;
- }
- }
-
- if ((object == this) &&
- (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) &&
- completionBox()->isVisible()) {
- const QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
- int currentIndex = completionBox()->currentRow();
- if (currentIndex < 0) {
- return true;
- }
- if (keyEvent->key() == Qt::Key_Up) {
- //qCDebug(LIBKDEPIM_LOG) <<"EVENTFILTER: Qt::Key_Up currentIndex=" << currentIndex;
- // figure out if the item we would be moving to is one we want
- // to ignore. If so, go one further
- const QListWidgetItem *itemAbove = completionBox()->item(currentIndex);
- if (itemAbove && itemIsHeader(itemAbove)) {
- // there is a header above is, check if there is even further up
- // and if so go one up, so it'll be selected
- if (currentIndex > 0 && completionBox()->item(currentIndex - 1)) {
- //qCDebug(LIBKDEPIM_LOG) <<"EVENTFILTER: Qt::Key_Up -> skipping" << currentIndex - 1;
- completionBox()->setCurrentRow(currentIndex - 1);
- completionBox()->item(currentIndex - 1)->setSelected(true);
- } else if (currentIndex == 0) {
- // nothing to skip to, let's stay where we are, but make sure the
- // first header becomes visible, if we are the first real entry
- completionBox()->scrollToItem(completionBox()->item(0));
- QListWidgetItem *item = completionBox()->item(currentIndex);
- if (item) {
- if (itemIsHeader(item)) {
- currentIndex++;
- item = completionBox()->item(currentIndex);
- }
- completionBox()->setCurrentItem(item);
- item->setSelected(true);
- }
- }
-
- return true;
- }
- } else if (keyEvent->key() == Qt::Key_Down) {
- // same strategy for downwards
- //qCDebug(LIBKDEPIM_LOG) <<"EVENTFILTER: Qt::Key_Down. currentIndex=" << currentIndex;
- const QListWidgetItem *itemBelow = completionBox()->item(currentIndex);
- if (itemBelow && itemIsHeader(itemBelow)) {
- if (completionBox()->item(currentIndex + 1)) {
- //qCDebug(LIBKDEPIM_LOG) <<"EVENTFILTER: Qt::Key_Down -> skipping" << currentIndex+1;
- completionBox()->setCurrentRow(currentIndex + 1);
- completionBox()->item(currentIndex + 1)->setSelected(true);
- } else {
- // nothing to skip to, let's stay where we are
- QListWidgetItem *item = completionBox()->item(currentIndex);
- if (item) {
- completionBox()->setCurrentItem(item);
- item->setSelected(true);
- }
- }
-
- return true;
- }
- // special case of the initial selection, which is unfortunately a header.
- // Setting it to selected tricks KCompletionBox into not treating is special
- // and selecting making it current, instead of the one below.
- QListWidgetItem *item = completionBox()->item(currentIndex);
- if (item && itemIsHeader(item)) {
- completionBox()->setCurrentItem(item);
- item->setSelected(true);
- }
- } else if (event->type() == QEvent::KeyRelease &&
- (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt::Key_Backtab)) {
- /// first, find the header of the current section
- QListWidgetItem *myHeader = Q_NULLPTR;
- int myHeaderIndex = -1;
- const int iterationStep = keyEvent->key() == Qt::Key_Tab ? 1 : -1;
- int index = qMin(qMax(currentIndex - iterationStep, 0), completionBox()->count() - 1);
- while (index >= 0) {
- if (itemIsHeader(completionBox()->item(index))) {
- myHeader = completionBox()->item(index);
- myHeaderIndex = index;
- break;
- }
-
- index--;
- }
- Q_ASSERT(myHeader); // we should always be able to find a header
-
- // find the next header (searching backwards, for Qt::Key_Backtab)
- QListWidgetItem *nextHeader = Q_NULLPTR;
-
- // when iterating forward, start at the currentindex, when backwards,
- // one up from our header, or at the end
- uint j;
- if (keyEvent->key() == Qt::Key_Tab) {
- j = currentIndex;
- } else {
- index = myHeaderIndex;
- if (index == 0) {
- j = completionBox()->count() - 1;
- } else {
- j = (index - 1) % completionBox()->count();
- }
- }
- while ((nextHeader = completionBox()->item(j)) && nextHeader != myHeader) {
- if (itemIsHeader(nextHeader)) {
- break;
- }
- j = (j + iterationStep) % completionBox()->count();
- }
-
- if (nextHeader && nextHeader != myHeader) {
- QListWidgetItem *item = completionBox()->item(j + 1);
- if (item && !itemIsHeader(item)) {
- completionBox()->setCurrentItem(item);
- item->setSelected(true);
- }
- }
-
- return true;
- }
- }
-
- return KLineEdit::eventFilter(object, event);
-}
-
-void AddresseeLineEdit::emitTextCompleted()
-{
- Q_EMIT textCompleted();
-}
-
-void AddresseeLineEdit::callUserCancelled(const QString &str)
-{
- userCancelled(str);
-}
-
-void AddresseeLineEdit::callSetCompletedText(const QString &text, bool marked)
-{
- setCompletedText(text, marked);
-}
-
-void AddresseeLineEdit::callSetCompletedText(const QString &text)
-{
- setCompletedText(text);
-}
-
-void AddresseeLineEdit::callSetUserSelection(bool b)
-{
- setUserSelection(b);
-}
-
-void AddresseeLineEdit::updateBalooBlackList()
-{
- d->updateBalooBlackList();
-}
-
-void AddresseeLineEdit::updateCompletionOrder()
-{
- d->updateCompletionOrder();
-}
-
-KLDAP::LdapClientSearch *AddresseeLineEdit::ldapSearch() const
-{
- return d->ldapSearch();
-}
-
-QStringList AddresseeLineEdit::balooBlackList() const
-{
- return d->balooBlackList();
-}
-
-void AddresseeLineEdit::slotEditingFinished()
-{
- foreach (KJob *job, d->mightBeGroupJobs()) {
- disconnect(job);
- job->deleteLater();
- }
-
- d->mightBeGroupJobsClear();
- d->groupsClear();
-
- if (!text().isEmpty()) {
- const QStringList addresses = KEmailAddress::splitAddressList(text());
- Q_FOREACH (const QString &address, addresses) {
- Akonadi::ContactGroupSearchJob *job = new Akonadi::ContactGroupSearchJob();
- connect(job, &Akonadi::ContactGroupSearchJob::result, this, &AddresseeLineEdit::slotGroupSearchResult);
- d->mightBeGroupJobsAdd(job);
- job->setQuery(Akonadi::ContactGroupSearchJob::Name, address);
- }
- }
-}
-
-void AddresseeLineEdit::slotGroupSearchResult(KJob *job)
-{
- Akonadi::ContactGroupSearchJob *searchJob = qobject_cast<Akonadi::ContactGroupSearchJob *>(job);
-
- // Laurent I don't understand why Akonadi::ContactGroupSearchJob send two "result(...)" signal. For the moment
- // avoid to go in this method twice, until I understand it.
- if (!d->mightBeGroupJobs().contains(searchJob)) {
- return;
- }
- //Q_ASSERT(d->mMightBeGroupJobs.contains(searchJob));
- d->mightBeGroupJobsRemoveOne(searchJob);
-
- const KContacts::ContactGroup::List contactGroups = searchJob->contactGroups();
- if (contactGroups.isEmpty()) {
- return; // Nothing todo, probably a normal email address was entered
- }
-
- d->addGroups(contactGroups);
- searchJob->deleteLater();
-
- if (autoGroupExpand()) {
- expandGroups();
- }
-}
-
-void AddresseeLineEdit::expandGroups()
-{
- QStringList addresses = KEmailAddress::splitAddressList(text());
-
- foreach (const KContacts::ContactGroup &group, d->groups()) {
- Akonadi::ContactGroupExpandJob *expandJob = new Akonadi::ContactGroupExpandJob(group);
- connect(expandJob, &Akonadi::ContactGroupExpandJob::result, this, &AddresseeLineEdit::groupExpandResult);
- addresses.removeAll(group.name());
- expandJob->start();
- }
- setText(addresses.join(QStringLiteral(", ")));
- d->groupsClear();
-}
-
-void AddresseeLineEdit::setRecentAddressConfig(KConfig *config)
-{
- d->setRecentAddressConfig(config);
-}
-
-KConfig *AddresseeLineEdit::recentAddressConfig() const
-{
- return d->recentAddressConfig();
-}
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.h b/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.h
deleted file mode 100644
index 62ff774..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- This file is part of libkdepim.
-
- Copyright (c) 2002 Helge Deller <deller@gmx.de>
- Copyright (c) 2002 Lubos Lunak <llunak@suse.cz>
- Copyright (c) 2001,2003 Carsten Pfeiffer <pfeiffer@kde.org>
- Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
- Copyright (c) 2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
- Copyright (c) 2004 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KDEPIM_ADDRESSEELINEEDIT_H
-#define KDEPIM_ADDRESSEELINEEDIT_H
-
-#include "kdepim_export.h"
-
-#include <KLineEdit>
-
-class QDropEvent;
-class QEvent;
-class QKeyEvent;
-class QMenu;
-class QMouseEvent;
-class QObject;
-class KJob;
-class KConfig;
-namespace Akonadi
-{
-class Item;
-}
-
-namespace KContacts
-{
-class Addressee;
-class ContactGroup;
-}
-namespace KLDAP
-{
-class LdapClientSearch;
-}
-
-namespace KPIM
-{
-
-class AddresseeLineEditPrivate;
-class KDEPIM_EXPORT AddresseeLineEdit : public KLineEdit
-{
- Q_OBJECT
-
-public:
- /**
- * Creates a new addressee line edit.
- *
- * @param parent The parent object.
- * @param enableCompletion Whether autocompletion shall be enabled.
- */
- explicit AddresseeLineEdit(QWidget *parent, bool enableCompletion = true);
-
- /**
- * Destroys the addressee line edit.
- */
- virtual ~AddresseeLineEdit();
-
- /**
- * Sets whether semicolons are allowed as separators.
- */
- void allowSemicolonAsSeparator(bool allow);
-
- /**
- * Reimplemented for setting the @p font for line edit and completion box.
- */
- void setFont(const QFont &font);
-
- void setEnableBalooSearch(bool enable);
-
- bool isCompletionEnabled() const;
-
- void setExpandIntern(bool);
-
- bool expandIntern() const;
-
- bool groupsIsEmpty() const;
- /**
- * Adds a new @p contact to the completion with a given
- * @p weight
- * @p source index
- * @p append is added to completion string, but removed, when mail is selected.
- */
- void addContact(const KContacts::Addressee &contact, int weight, int source = -1, QString append = QString());
-
- /**
- * Same as the above, but this time with contact groups.
- */
- void addContactGroup(const KContacts::ContactGroup &group, int weight, int source = -1);
-
- void addItem(const Akonadi::Item &item, int weight, int source = -1);
-
- /**
- * Adds the @p name of a completion source and its @p weight
- * to the internal list of completion sources and returns its index,
- * which can be used for insertion of items associated with that source.
- *
- * If the source already exists, the weight will be updated.
- */
- int addCompletionSource(const QString &name, int weight);
-
- void removeCompletionSource(const QString &source);
- void emitTextCompleted();
-
- void callUserCancelled(const QString &str);
- void callSetCompletedText(const QString & /*text*/, bool /*marked*/);
- void callSetCompletedText(const QString &text);
- void callSetUserSelection(bool);
-
- void updateBalooBlackList();
- void updateCompletionOrder();
- KLDAP::LdapClientSearch *ldapSearch() const;
- QStringList balooBlackList() const;
-
- void setAutoGroupExpand(bool autoGroupExpand);
- bool autoGroupExpand() const;
- void setShowRecentAddresses(bool b);
- bool showRecentAddresses() const;
- void setRecentAddressConfig(KConfig *config);
- KConfig *recentAddressConfig() const;
- void configureCompletion();
-
-Q_SIGNALS:
- void textCompleted();
- void addAddress(const QString &address);
-
-public Q_SLOTS:
- /**
- * Moves the cursor at the end of the line edit.
- */
- void cursorAtEnd();
-
- /**
- * Sets whether autocompletion shall be enabled.
- */
- void enableCompletion(bool enable);
-
- /**
- * Reimplemented for stripping whitespace after completion
- * Danger: This is _not_ virtual in the base class!
- */
- void setText(const QString &text) Q_DECL_OVERRIDE;
-
- void expandGroups();
- void slotEditingFinished();
- void slotGroupSearchResult(KJob *job);
-
-protected:
- /**
- * Reimplemented for smart insertion of email addresses.
- * Features:
- * - Automatically adds ',' if necessary to separate email addresses
- * - Correctly decodes mailto URLs
- * - Recognizes email addresses which are protected against address
- * harvesters, i.e. "name at kde dot org" and "name(at)kde.org"
- */
- virtual void insert(const QString &);
-
- /**
- * Reimplemented for smart insertion of pasted email addresses.
- */
- virtual void paste();
-
- /**
- * Reimplemented for smart insertion with middle mouse button.
- */
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
-
-#ifndef QT_NO_DRAGANDDROP
- /**
- * Reimplemented for smart insertion of dragged email addresses.
- */
- void dropEvent(QDropEvent *) Q_DECL_OVERRIDE;
-#endif
-
- /**
- * Reimplemented for internal reasons.
- */
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
-
-#ifndef QT_NO_CONTEXTMENU
- /**
- * Reimplemented for subclass access to menu
- */
- virtual QMenu *createStandardContextMenu();
-
- /**
- * Reimplemented for internal reasons. API not affected.
- *
- * See QLineEdit::contextMenuEvent().
- */
- void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE;
-#endif
-
- QStringList cleanupEmailList(const QStringList &inputList);
- void insertEmails(const QStringList &emails);
- void loadContacts();
-
-private Q_SLOTS:
- void groupExpandResult(KJob *job);
- void slotToggleExpandGroups();
-private:
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
-
- AddresseeLineEditPrivate *const d;
-};
-
-}
-
-#endif
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.cpp b/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.cpp
deleted file mode 100644
index 4c62872..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.cpp
+++ /dev/null
@@ -1,1071 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- 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 "completionorder/completionordereditor.h"
-#include "addresseelineeditstatic.h"
-#include "addresseelineedit_p.h"
-#include "addresseelineedit.h"
-#include "kmailcompletion.h"
-#include "libkdepim_debug.h"
-#include <QMap>
-#include <QTimer>
-#include <kcolorscheme.h>
-#include <kcompletionbox.h>
-#include <AkonadiCore/Session>
-#include <Akonadi/Contact/ContactSearchJob>
-#include <Akonadi/Contact/ContactGroupSearchJob>
-#include <AkonadiCore/CollectionFetchJob>
-#include <AkonadiCore/ItemFetchScope>
-#include <AkonadiCore/Job>
-#include <QApplication>
-#include <KConfigGroup>
-#include <KLocalizedString>
-#include <AkonadiSearch/PIM/contactcompleter.h>
-
-#include <ldap/ldapclientsearch.h>
-#include <addressline/baloocompletionemail.h>
-#include <akonadi/contact/contactsearchjob.h>
-#include <QNetworkConfigurationManager>
-
-#include <blacklistbaloocompletion/blacklistbalooemailcompletiondialog.h>
-static QNetworkConfigurationManager *s_networkConfigMgr = 0;
-
-namespace KPIM
-{
-Q_GLOBAL_STATIC(AddresseeLineEditStatic, s_static)
-AddresseeLineEditPrivate::AddresseeLineEditPrivate(KPIM::AddresseeLineEdit *qq, bool enableCompletion)
- : QObject(qq),
- q(qq),
- m_recentAddressConfig(Q_NULLPTR),
- m_useCompletion(enableCompletion),
- m_completionInitialized(false),
- m_smartPaste(false),
- m_addressBookConnected(false),
- m_lastSearchMode(false),
- m_searchExtended(false),
- m_useSemicolonAsSeparator(false),
- m_showOU(false),
- m_enableBalooSearch(true),
- mExpandIntern(true),
- mAutoGroupExpand(false),
- mShowRecentAddresses(true)
-{
- if (!s_networkConfigMgr) {
- s_networkConfigMgr = new QNetworkConfigurationManager(QCoreApplication::instance());
- }
-
- m_delayedQueryTimer.setSingleShot(true);
- connect(&m_delayedQueryTimer, &QTimer::timeout, this, &AddresseeLineEditPrivate::slotTriggerDelayedQueries);
-
-}
-
-AddresseeLineEditPrivate::~AddresseeLineEditPrivate()
-{
- if (s_static->ldapSearch && s_static->ldapLineEdit == q) {
- stopLDAPLookup();
- }
-}
-
-void AddresseeLineEditPrivate::restartTime(const QString &searchString)
-{
- if (useCompletion() && s_static->ldapTimer) {
- if (s_static->ldapText != searchString || s_static->ldapLineEdit != q) {
- stopLDAPLookup();
- }
-
- s_static->ldapText = searchString;
- s_static->ldapLineEdit = q;
- s_static->ldapTimer->setSingleShot(true);
- s_static->ldapTimer->start(500);
- }
-}
-
-static const QString s_completionItemIndentString = QStringLiteral(" ");
-
-class SourceWithWeight
-{
-public:
- int weight; // the weight of the source
- int index; // index into s_static->completionSources
- QString sourceName; // the name of the source, e.g. "LDAP Server"
-
- bool operator< (const SourceWithWeight &other) const
- {
- if (weight > other.weight) {
- return true;
- }
-
- if (weight < other.weight) {
- return false;
- }
-
- return sourceName < other.sourceName;
- }
-};
-
-void AddresseeLineEditPrivate::init()
-{
- if (!s_static.exists()) {
- s_static->completion->setOrder(KCompletion::Weighted);
- s_static->completion->setIgnoreCase(true);
- }
-
- if (m_useCompletion) {
- if (!s_static->ldapTimer) {
- s_static->ldapTimer = new QTimer;
- s_static->ldapSearch = new KLDAP::LdapClientSearch;
-
- /* The reasoning behind this filter is:
- * If it's a person, or a distlist, show it, even if it doesn't have an email address.
- * If it's not a person, or a distlist, only show it if it has an email attribute.
- * This allows both resource accounts with an email address which are not a person and
- * person entries without an email address to show up, while still not showing things
- * like structural entries in the ldap tree.
- */
-
-#if 0
- s_static->ldapSearch->setFilter(QStringLiteral("&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))"
- "(|(cn=%1*)(mail=%1*)(mail=*@%1*)(givenName=%1*)(sn=%1*))"));
-#endif
- //Fix bug 323272 "Exchange doesn't like any queries beginning with *."
- s_static->ldapSearch->setFilter(QStringLiteral("&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))"
- "(|(cn=%1*)(mail=%1*)(givenName=%1*)(sn=%1*))"));
-
- }
-
- s_static->balooCompletionSource = q->addCompletionSource(i18nc("@title:group", "Contacts found in your data"), -1);
-
- s_static->updateLDAPWeights();
- if (!m_completionInitialized) {
- q->setCompletionObject(s_static->completion, false);
- connect(q, &KLineEdit::completion,
- this, &AddresseeLineEditPrivate::slotCompletion);
- connect(q, SIGNAL(returnPressed(QString)),
- this, SLOT(slotReturnPressed(QString)));
-
- KCompletionBox *box = q->completionBox();
- connect(box, SIGNAL(activated(QString)),
- this, SLOT(slotPopupCompletion(QString)));
- connect(box, &KCompletionBox::userCancelled,
- this, &AddresseeLineEditPrivate::slotUserCancelled);
- connect(s_static->ldapTimer, &QTimer::timeout, this, &AddresseeLineEditPrivate::slotStartLDAPLookup);
- connect(s_static->ldapSearch, SIGNAL(searchData(KLDAP::LdapResult::List)),
- SLOT(slotLDAPSearchData(KLDAP::LdapResult::List)));
-
- m_completionInitialized = true;
- }
-
- KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
- m_showOU = group.readEntry("ShowOU", false);
- mAutoGroupExpand = group.readEntry("AutoGroupExpand", false);
-
- loadBalooBlackList();
- }
-}
-
-void AddresseeLineEditPrivate::startLoadingLDAPEntries()
-{
- QString text(s_static->ldapText);
-
- // TODO cache last?
- QString prevAddr;
- const int index = text.lastIndexOf(QLatin1Char(','));
- if (index >= 0) {
- prevAddr = text.left(index + 1) + QLatin1Char(' ');
- text = text.mid(index + 1, 255).trimmed();
- }
-
- if (text.isEmpty()) {
- return;
- }
-
- s_static->ldapSearch->startSearch(text);
-}
-
-void AddresseeLineEditPrivate::stopLDAPLookup()
-{
- s_static->ldapSearch->cancelSearch();
- s_static->ldapLineEdit = 0;
-}
-
-QStringList AddresseeLineEdit::cleanupEmailList(const QStringList &inputList)
-{
- return d->cleanupEmailList(inputList);
-}
-
-QStringList AddresseeLineEditPrivate::cleanupEmailList(const QStringList &inputList)
-{
- KPIM::BalooCompletionEmail completionEmail;
- completionEmail.setEmailList(inputList);
- completionEmail.setBlackList(m_balooBlackList);
- completionEmail.setExcludeDomain(m_domainExcludeList);
- const QStringList listEmail = completionEmail.cleanupEmailList();
- return listEmail;
-}
-
-void AddresseeLineEditPrivate::searchInBaloo()
-{
- const QString trimmedString = m_searchString.trimmed();
- Akonadi::Search::PIM::ContactCompleter com(trimmedString, 20);
- const QStringList listEmail = cleanupEmailList(com.complete());
- Q_FOREACH (const QString &email, listEmail) {
- addCompletionItem(email, 1, s_static->balooCompletionSource);
- }
- doCompletion(m_lastSearchMode);
- // if ( q->hasFocus() || q->completionBox()->hasFocus() ) {
- //}
-}
-
-void AddresseeLineEditPrivate::alternateColor()
-{
- const KColorScheme colorScheme(QPalette::Active, KColorScheme::View);
- m_alternateColor = colorScheme.background(KColorScheme::AlternateBackground).color();
-}
-
-void AddresseeLineEditPrivate::setCompletedItems(const QStringList &items, bool autoSuggest)
-{
- KCompletionBox *completionBox = q->completionBox();
-
- if (!items.isEmpty() &&
- !(items.count() == 1 && m_searchString == items.first())) {
-
- completionBox->clear();
- const int numberOfItems(items.count());
- for (int i = 0; i < numberOfItems; ++i) {
- QListWidgetItem *item = new QListWidgetItem(items.at(i), completionBox);
- if (!items.at(i).startsWith(s_completionItemIndentString)) {
- if (!m_alternateColor.isValid()) {
- alternateColor();
- }
- item->setFlags(item->flags() & ~ Qt::ItemIsSelectable);
- item->setBackgroundColor(m_alternateColor);
- }
- completionBox->addItem(item);
- }
- if (!completionBox->isVisible()) {
- if (!m_searchString.isEmpty()) {
- completionBox->setCancelledText(m_searchString);
- }
- completionBox->popup();
- // we have to install the event filter after popup(), since that
- // calls show(), and that's where KCompletionBox installs its filter.
- // We want to be first, though, so do it now.
- if (s_static->completion->order() == KCompletion::Weighted) {
- qApp->installEventFilter(q);
- }
- }
-
- QListWidgetItem *item = completionBox->item(1);
- if (item) {
- completionBox->blockSignals(true);
- completionBox->setCurrentItem(item);
- item->setSelected(true);
- completionBox->blockSignals(false);
- }
-
- if (autoSuggest) {
- const int index = items.first().indexOf(m_searchString);
- const QString newText = items.first().mid(index);
- q->callSetUserSelection(false);
- q->callSetCompletedText(newText, true);
- }
- } else {
- if (completionBox && completionBox->isVisible()) {
- completionBox->hide();
- completionBox->setItems(QStringList());
- }
- }
-}
-
-void AddresseeLineEditPrivate::addCompletionItem(const QString &string, int weight,
- int completionItemSource,
- const QStringList *keyWords)
-{
- // Check if there is an exact match for item already, and use the
- // maximum weight if so. Since there's no way to get the information
- // from KCompletion, we have to keep our own QMap.
- // We also update the source since the item should always be shown from the source with the highest weight
-
- AddresseeLineEditStatic::CompletionItemsMap::iterator it = s_static->completionItemMap.find(string);
- if (it != s_static->completionItemMap.end()) {
- weight = qMax((*it).first, weight);
- (*it).first = weight;
- (*it).second = completionItemSource;
- } else {
- s_static->completionItemMap.insert(string, qMakePair(weight, completionItemSource));
- }
-
- s_static->completion->addItem(string, weight);
- if (keyWords && !keyWords->isEmpty()) {
- s_static->completion->addItemWithKeys(string, weight, keyWords); // see kmailcompletion.cpp
- }
-}
-
-const QStringList KPIM::AddresseeLineEditPrivate::adjustedCompletionItems(bool fullSearch)
-{
- QStringList items = fullSearch ?
- s_static->completion->allMatches(m_searchString) :
- s_static->completion->substringCompletion(m_searchString);
-
- //force items to be sorted by email
- items.sort();
-
- // For weighted mode, the algorithm is the following:
- // In the first loop, we add each item to its section (there is one section per completion source)
- // We also add spaces in front of the items.
- // The sections are appended to the items list.
- // In the second loop, we then walk through the sections and add all the items in there to the
- // sorted item list, which is the final result.
- //
- // The algo for non-weighted mode is different.
-
- int lastSourceIndex = -1;
- unsigned int i = 0;
-
- // Maps indices of the items list, which are section headers/source items,
- // to a QStringList which are the items of that section/source.
- QMap<int, QStringList> sections;
- QStringList sortedItems;
- for (QStringList::Iterator it = items.begin(); it != items.end(); ++it, ++i) {
- AddresseeLineEditStatic::CompletionItemsMap::const_iterator cit = s_static->completionItemMap.constFind(*it);
- if (cit == s_static->completionItemMap.constEnd()) {
- continue;
- }
-
- const int index = (*cit).second;
-
- if (s_static->completion->order() == KCompletion::Weighted) {
- if (lastSourceIndex == -1 || lastSourceIndex != index) {
- const QString sourceLabel(s_static->completionSources.at(index));
- if (sections.find(index) == sections.end()) {
- it = items.insert(it, sourceLabel);
- ++it; //skip new item
- }
- lastSourceIndex = index;
- }
-
- (*it) = (*it).prepend(s_completionItemIndentString);
- // remove preferred email sort <blank> added in addContact()
- (*it).replace(QLatin1String(" <"), QStringLiteral(" <"));
- }
- sections[ index ].append(*it);
-
- if (s_static->completion->order() == KCompletion::Sorted) {
- sortedItems.append(*it);
- }
- }
-
- if (s_static->completion->order() == KCompletion::Weighted) {
-
- // Sort the sections
- QList<SourceWithWeight> sourcesAndWeights;
- const int numberOfCompletionSources(s_static->completionSources.size());
- sourcesAndWeights.reserve(numberOfCompletionSources);
- for (int i = 0; i < numberOfCompletionSources; ++i) {
- SourceWithWeight sww;
- sww.sourceName = s_static->completionSources.at(i);
- sww.weight = s_static->completionSourceWeights[sww.sourceName];
- sww.index = i;
- sourcesAndWeights.append(sww);
- }
-
- qSort(sourcesAndWeights.begin(), sourcesAndWeights.end());
- // Add the sections and their items to the final sortedItems result list
- const int numberOfSources(sourcesAndWeights.size());
- for (int i = 0; i < numberOfSources; ++i) {
- const SourceWithWeight source = sourcesAndWeights.at(i);
- const QStringList sectionItems = sections[source.index];
- if (!sectionItems.isEmpty()) {
- sortedItems.append(source.sourceName);
- foreach (const QString &itemInSection, sectionItems) {
- sortedItems.append(itemInSection);
- }
- }
- }
- } else {
- sortedItems.sort();
- }
-
- return sortedItems;
-}
-
-void AddresseeLineEditPrivate::updateSearchString()
-{
- m_searchString = q->text();
-
- int n = -1;
- bool inQuote = false;
- const int searchStringLength = m_searchString.length();
- for (int i = 0; i < searchStringLength; ++i) {
- const QChar searchChar = m_searchString.at(i);
- if (searchChar == QLatin1Char('"')) {
- inQuote = !inQuote;
- }
-
- if (searchChar == QLatin1Char('\\') &&
- (i + 1) < searchStringLength && m_searchString.at(i + 1) == QLatin1Char('"')) {
- ++i;
- }
-
- if (inQuote) {
- continue;
- }
-
- if (i < searchStringLength &&
- (searchChar == QLatin1Char(',') ||
- (m_useSemicolonAsSeparator && searchChar == QLatin1Char(';')))) {
- n = i;
- }
- }
-
- if (n >= 0) {
- ++n; // Go past the ","
-
- const int len = m_searchString.length();
-
- // Increment past any whitespace...
- while (n < len && m_searchString.at(n).isSpace()) {
- ++n;
- }
-
- m_previousAddresses = m_searchString.left(n);
- m_searchString = m_searchString.mid(n).trimmed();
- } else {
- m_previousAddresses.clear();
- }
-}
-
-void AddresseeLineEditPrivate::slotTriggerDelayedQueries()
-{
- if (m_searchString.isEmpty() || m_searchString.trimmed().size() <= 2) {
- return;
- }
-
- if (m_enableBalooSearch) {
- searchInBaloo();
- }
-
- // We send a contactsearch job through akonadi.
- // This not only searches baloo but also servers if remote search is enabled
- akonadiPerformSearch();
-}
-
-void AddresseeLineEditPrivate::startSearches()
-{
- if (!m_delayedQueryTimer.isActive()) {
- m_delayedQueryTimer.start(50);
- }
-}
-
-void AddresseeLineEditPrivate::akonadiPerformSearch()
-{
- qCDebug(LIBKDEPIM_LOG) << "searching akonadi with:" << m_searchString;
-
- // first, kill all job still in flight, they are no longer current
- Q_FOREACH (const QWeakPointer<Akonadi::Job> &job, s_static->akonadiJobsInFlight) {
- if (!job.isNull()) {
- job.data()->kill();
- }
- }
- s_static->akonadiJobsInFlight.clear();
-
- // now start new jobs
- Akonadi::ContactSearchJob *contactJob = new Akonadi::ContactSearchJob(s_static->akonadiSession);
- contactJob->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
- contactJob->setQuery(Akonadi::ContactSearchJob::NameOrEmail, m_searchString,
- Akonadi::ContactSearchJob::ContainsWordBoundaryMatch);
- connect(contactJob, &Akonadi::ItemSearchJob::itemsReceived,
- this, &AddresseeLineEditPrivate::slotAkonadiHandleItems);
- connect(contactJob, &KJob::result,
- this, &AddresseeLineEditPrivate::slotAkonadiSearchResult);
-
- Akonadi::ContactGroupSearchJob *groupJob = new Akonadi::ContactGroupSearchJob(s_static->akonadiSession);
- groupJob->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
- groupJob->setQuery(Akonadi::ContactGroupSearchJob::Name, m_searchString,
- Akonadi::ContactGroupSearchJob::ContainsMatch);
- connect(contactJob, &Akonadi::ItemSearchJob::itemsReceived,
- this, &AddresseeLineEditPrivate::slotAkonadiHandleItems);
- connect(groupJob, &KJob::result,
- this, &AddresseeLineEditPrivate::slotAkonadiSearchResult);
-
- s_static->akonadiJobsInFlight.append(contactJob);
- s_static->akonadiJobsInFlight.append(groupJob);
- akonadiHandlePending();
-}
-
-void AddresseeLineEditPrivate::akonadiHandlePending()
-{
- qCDebug(LIBKDEPIM_LOG) << "Pending items: " << s_static->akonadiPendingItems.size();
- Akonadi::Item::List::iterator it = s_static->akonadiPendingItems.begin();
- while (it != s_static->akonadiPendingItems.end()) {
- const Akonadi::Item item = *it;
-
- const AddresseeLineEditStatic::collectionInfo sourceIndex =
- s_static->akonadiCollectionToCompletionSourceMap.value(item.parentCollection().id(), AddresseeLineEditStatic::collectionInfo());
- if (sourceIndex.index >= 0) {
- qCDebug(LIBKDEPIM_LOG) << "identified collection: " << s_static->completionSources[sourceIndex.index];
- if (sourceIndex.enabled) {
- q->addItem(item, 1, sourceIndex.index);
- }
-
- // remove from the pending
- it = s_static->akonadiPendingItems.erase(it);
- } else {
- ++it;
- }
- }
-}
-
-void AddresseeLineEditPrivate::doCompletion(bool ctrlT)
-{
- m_lastSearchMode = ctrlT;
-
- const KCompletion::CompletionMode mode = q->completionMode();
-
- if (mode == KCompletion::CompletionNone) {
- return;
- }
-
- s_static->completion->setOrder(KCompletion::Weighted);
-
- // cursor at end of string - or Ctrl+T pressed for substring completion?
- if (ctrlT) {
- const QStringList completions = adjustedCompletionItems(false);
-
- if (completions.count() > 1) {
- ; //m_previousAddresses = prevAddr;
- } else if (completions.count() == 1) {
- q->setText(m_previousAddresses + completions.first().trimmed());
- }
-
- // Make sure the completion popup is closed if no matching items were found
- setCompletedItems(completions, true);
-
- q->cursorAtEnd();
- q->setCompletionMode(mode); //set back to previous mode
- return;
- }
-
- switch (mode) {
- case KCompletion::CompletionPopupAuto: {
- if (m_searchString.isEmpty()) {
- break;
- }
- //else: fall-through to the CompletionPopup case
- }
-
- case KCompletion::CompletionPopup: {
- const QStringList items = adjustedCompletionItems(false);
- setCompletedItems(items, false);
- }
- break;
-
- case KCompletion::CompletionShell: {
- const QString match = s_static->completion->makeCompletion(m_searchString);
- if (!match.isNull() && match != m_searchString) {
- q->setText(m_previousAddresses + match);
- q->setModified(true);
- q->cursorAtEnd();
- }
- }
- break;
-
- case KCompletion::CompletionMan: // Short-Auto in fact
- case KCompletion::CompletionAuto: {
- //force autoSuggest in KLineEdit::keyPressed or setCompletedText will have no effect
- q->setCompletionMode(q->completionMode());
-
- if (!m_searchString.isEmpty()) {
-
- //if only our \" is left, remove it since user has not typed it either
- if (m_searchExtended && m_searchString == QLatin1String("\"")) {
- m_searchExtended = false;
- m_searchString.clear();
- q->setText(m_previousAddresses);
- break;
- }
-
- QString match = s_static->completion->makeCompletion(m_searchString);
-
- if (!match.isEmpty()) {
- if (match != m_searchString) {
- QString adds = m_previousAddresses + match;
- q->callSetCompletedText(adds);
- }
- } else {
- if (!m_searchString.startsWith(QLatin1Char('\"'))) {
- //try with quoted text, if user has not type one already
- match = s_static->completion->makeCompletion(QLatin1String("\"") + m_searchString);
- if (!match.isEmpty() && match != m_searchString) {
- m_searchString = QLatin1String("\"") + m_searchString;
- m_searchExtended = true;
- q->setText(m_previousAddresses + m_searchString);
- q->callSetCompletedText(m_previousAddresses + match);
- }
- } else if (m_searchExtended) {
- //our added \" does not work anymore, remove it
- m_searchString = m_searchString.mid(1);
- m_searchExtended = false;
- q->setText(m_previousAddresses + m_searchString);
- //now try again
- match = s_static->completion->makeCompletion(m_searchString);
- if (!match.isEmpty() && match != m_searchString) {
- const QString adds = m_previousAddresses + match;
- q->setCompletedText(adds);
- }
- }
- }
- }
- }
- break;
-
- case KCompletion::CompletionNone:
- default: // fall through
- break;
- }
-}
-
-void AddresseeLineEditPrivate::slotCompletion()
-{
- // Called by KLineEdit's keyPressEvent for CompletionModes
- // Auto,Popup -> new text, update search string.
- // not called for CompletionShell, this is been taken care of
- // in AddresseeLineEdit::keyPressEvent
-
- updateSearchString();
- if (q->completionBox()) {
- q->completionBox()->setCancelledText(m_searchString);
- }
-
- startSearches();
- doCompletion(false);
-}
-
-void AddresseeLineEditPrivate::slotPopupCompletion(const QString &completion)
-{
- QString c = completion.trimmed();
- if (c.endsWith(QLatin1Char(')'))) {
- c = completion.mid(0, completion.lastIndexOf(QLatin1String(" ("))).trimmed();
- }
- q->setText(m_previousAddresses + c);
- q->cursorAtEnd();
- updateSearchString();
- q->emitTextCompleted();
-}
-
-void AddresseeLineEditPrivate::slotReturnPressed(const QString &)
-{
- if (!q->completionBox()->selectedItems().isEmpty()) {
- slotPopupCompletion(q->completionBox()->selectedItems().first()->text());
- }
-}
-
-void AddresseeLineEditPrivate::slotStartLDAPLookup()
-{
- if (s_networkConfigMgr->isOnline()) {
-
- const KCompletion::CompletionMode mode = q->completionMode();
- if (mode == KCompletion::CompletionNone) {
- return;
- }
- if (!s_static->ldapSearch->isAvailable()) {
- return;
- }
- if (s_static->ldapLineEdit != q) {
- return;
- }
- startLoadingLDAPEntries();
- }
-}
-
-void AddresseeLineEditPrivate::slotLDAPSearchData(const KLDAP::LdapResult::List &results)
-{
- if (results.isEmpty() || s_static->ldapLineEdit != q) {
- return;
- }
-
- foreach (const KLDAP::LdapResult &result, results) {
- KContacts::Addressee contact;
- contact.setNameFromString(result.name);
- contact.setEmails(result.email);
- QString ou;
-
- if (m_showOU) {
- const int depth = result.dn.depth();
- for (int i = 0; i < depth; ++i) {
- const QString rdnStr = result.dn.rdnString(i);
- if (rdnStr.startsWith(QStringLiteral("ou="), Qt::CaseInsensitive)) {
- ou = rdnStr.mid(3);
- break;
- }
- }
- }
-
- if (!s_static->ldapClientToCompletionSourceMap.contains(result.clientNumber)) {
- s_static->updateLDAPWeights(); // we got results from a new source, so update the completion sources
- }
-
- q->addContact(contact, result.completionWeight,
- s_static->ldapClientToCompletionSourceMap[ result.clientNumber ], ou);
- }
-
- if ((q->hasFocus() || q->completionBox()->hasFocus()) &&
- q->completionMode() != KCompletion::CompletionNone &&
- q->completionMode() != KCompletion::CompletionShell) {
- q->setText(m_previousAddresses + m_searchString);
- // only complete again if the user didn't change the selection while
- // we were waiting; otherwise the completion box will be closed
- const QListWidgetItem *current = q->completionBox()->currentItem();
- if (!current || m_searchString.trimmed() != current->text().trimmed()) {
- doCompletion(m_lastSearchMode);
- }
- }
-}
-
-void AddresseeLineEditPrivate::slotEditCompletionOrder()
-{
- init(); // for s_static->ldapSearch
- if (m_useCompletion) {
- s_static->slotEditCompletionOrder();
- }
-}
-
-KLDAP::LdapClientSearch *AddresseeLineEditPrivate::ldapSearch()
-{
- init(); // for s_static->ldapSearch
- return s_static->ldapSearch;
-}
-
-void AddresseeLineEditPrivate::slotUserCancelled(const QString &cancelText)
-{
- if (s_static->ldapSearch && s_static->ldapLineEdit == q) {
- stopLDAPLookup();
- }
-
- q->callUserCancelled(m_previousAddresses + cancelText); // in KLineEdit
-}
-
-void AddresseeLineEditPrivate::slotAkonadiHandleItems(const Akonadi::Item::List &items)
-{
- /* We have to fetch the collections of the items, so that
- the source name can be correctly labeled.*/
- foreach (const Akonadi::Item &item, items) {
-
- // check the local cache of collections
- const AddresseeLineEditStatic::collectionInfo sourceIndex =
- s_static->akonadiCollectionToCompletionSourceMap.value(item.parentCollection().id(), AddresseeLineEditStatic::collectionInfo());
- if (sourceIndex.index == -1) {
- qCDebug(LIBKDEPIM_LOG) << "Fetching New collection: " << item.parentCollection().id();
- // the collection isn't there, start the fetch job.
- Akonadi::CollectionFetchJob *collectionJob =
- new Akonadi::CollectionFetchJob(item.parentCollection(),
- Akonadi::CollectionFetchJob::Base,
- s_static->akonadiSession);
- connect(collectionJob, &Akonadi::CollectionFetchJob::collectionsReceived,
- this, &AddresseeLineEditPrivate::slotAkonadiCollectionsReceived);
- /* we don't want to start multiple fetch jobs for the same collection,
- so insert the collection with an index value of -2 */
- AddresseeLineEditStatic::collectionInfo info;
- info.index = -2;
- s_static->akonadiCollectionToCompletionSourceMap.insert(item.parentCollection().id(), info);
- s_static->akonadiPendingItems.append(item);
- } else if (sourceIndex.index == -2) {
- /* fetch job already started, don't need to start another one,
- so just append the item as pending */
- s_static->akonadiPendingItems.append(item);
- } else {
- if (sourceIndex.enabled) {
- q->addItem(item, 1, sourceIndex.index);
- }
- }
- }
-
- if (!items.isEmpty()) {
- const QListWidgetItem *current = q->completionBox()->currentItem();
- if (!current || m_searchString.trimmed() != current->text().trimmed()) {
- doCompletion(m_lastSearchMode);
- }
- }
-}
-
-void AddresseeLineEditPrivate::slotAkonadiSearchResult(KJob *job)
-{
- if (job->error()) {
- qCWarning(LIBKDEPIM_LOG) << "Akonadi search job failed: " << job->errorString();
- } else {
- Akonadi::ItemSearchJob *searchJob = static_cast<Akonadi::ItemSearchJob *>(job);
- qCDebug(LIBKDEPIM_LOG) << "Found" << searchJob->items().size() << "items";
- }
- const int index = s_static->akonadiJobsInFlight.indexOf(qobject_cast<Akonadi::Job *>(job));
- if (index != -1) {
- s_static->akonadiJobsInFlight.remove(index);
- }
-}
-
-void AddresseeLineEditPrivate::slotAkonadiCollectionsReceived(
- const Akonadi::Collection::List &collections)
-{
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimcompletionorder"));
- KConfigGroup groupCompletionWeights(config, "CompletionWeights");
- KConfigGroup groupCompletionEnabled(config, "CompletionEnabled");
- foreach (const Akonadi::Collection &collection, collections) {
- if (collection.isValid()) {
- const QString sourceString = collection.displayName();
- const int weight = groupCompletionWeights.readEntry(QString::number(collection.id()), 1);
- const int index = q->addCompletionSource(sourceString, weight);
- AddresseeLineEditStatic::collectionInfo info;
- info.index = index;
- info.enabled = groupCompletionEnabled.readEntry(QString::number(collection.id()), true);
- qCDebug(LIBKDEPIM_LOG) << "\treceived: " << sourceString << "index: " << index;
- s_static->akonadiCollectionToCompletionSourceMap.insert(collection.id(), info);
- }
- }
-
- // now that we have added the new collections, recheck our list of pending contacts
- akonadiHandlePending();
- // do completion
- const QListWidgetItem *current = q->completionBox()->currentItem();
- if (!current || m_searchString.trimmed() != current->text().trimmed()) {
- doCompletion(m_lastSearchMode);
- }
-}
-
-void AddresseeLineEditPrivate::slotShowOUChanged(bool checked)
-{
- if (checked != m_showOU) {
- KConfigGroup group(KSharedConfig::openConfig(), "AddressLineEdit");
- group.writeEntry("ShowOU", checked);
- m_showOU = checked;
- }
-}
-
-void AddresseeLineEditPrivate::updateBalooBlackList()
-{
- loadBalooBlackList();
- q->removeCompletionSource(i18nc("@title:group", "Contacts found in your data"));
- s_static->balooCompletionSource = q->addCompletionSource(i18nc("@title:group", "Contacts found in your data"), -1);
-}
-
-void AddresseeLineEditPrivate::updateCompletionOrder()
-{
- s_static->updateCompletionOrder();
-}
-
-void AddresseeLineEditPrivate::slotConfigureBalooBlackList()
-{
- QPointer<KPIM::BlackListBalooEmailCompletionDialog> dlg = new KPIM::BlackListBalooEmailCompletionDialog(q);
- dlg->setEmailBlackList(m_balooBlackList);
- if (dlg->exec()) {
- updateBalooBlackList();
- }
- delete dlg;
-}
-
-KConfig *AddresseeLineEditPrivate::recentAddressConfig() const
-{
- return m_recentAddressConfig;
-}
-
-bool AddresseeLineEditPrivate::showRecentAddresses() const
-{
- return mShowRecentAddresses;
-}
-
-void AddresseeLineEditPrivate::setRecentAddressConfig(KConfig *config)
-{
- m_recentAddressConfig = config;
-}
-
-KContacts::ContactGroup::List AddresseeLineEditPrivate::groups() const
-{
- return mGroups;
-}
-
-void AddresseeLineEditPrivate::setGroups(const KContacts::ContactGroup::List &groups)
-{
- mGroups = groups;
-}
-
-QList<KJob *> AddresseeLineEditPrivate::mightBeGroupJobs() const
-{
- return mMightBeGroupJobs;
-}
-
-void AddresseeLineEditPrivate::setMightBeGroupJobs(const QList<KJob *> &mightBeGroupJobs)
-{
- mMightBeGroupJobs = mightBeGroupJobs;
-}
-
-bool AddresseeLineEditPrivate::autoGroupExpand() const
-{
- return mAutoGroupExpand;
-}
-
-void AddresseeLineEditPrivate::setAutoGroupExpand(bool autoGroupExpand)
-{
- mAutoGroupExpand = autoGroupExpand;
-}
-
-QStringList AddresseeLineEditPrivate::balooBlackList() const
-{
- return m_balooBlackList;
-}
-
-void AddresseeLineEditPrivate::setExpandIntern(bool b)
-{
- mExpandIntern = b;
-}
-
-bool AddresseeLineEditPrivate::expandIntern() const
-{
- return mExpandIntern;
-}
-
-bool AddresseeLineEditPrivate::useSemicolonAsSeparator() const
-{
- return m_useSemicolonAsSeparator;
-}
-
-void AddresseeLineEditPrivate::setUseSemicolonAsSeparator(bool useSemicolonAsSeparator)
-{
- m_useSemicolonAsSeparator = useSemicolonAsSeparator;
-}
-
-bool AddresseeLineEditPrivate::enableBalooSearch() const
-{
- return m_enableBalooSearch;
-}
-
-void AddresseeLineEditPrivate::setEnableBalooSearch(bool enableBalooSearch)
-{
- m_enableBalooSearch = enableBalooSearch;
-}
-
-QString AddresseeLineEditPrivate::searchString() const
-{
- return m_searchString;
-}
-
-void AddresseeLineEditPrivate::setSearchString(const QString &searchString)
-{
- m_searchString = searchString;
-}
-
-bool AddresseeLineEditPrivate::searchExtended() const
-{
- return m_searchExtended;
-}
-
-void AddresseeLineEditPrivate::setSearchExtended(bool searchExtended)
-{
- m_searchExtended = searchExtended;
-}
-
-bool AddresseeLineEditPrivate::smartPaste() const
-{
- return m_smartPaste;
-}
-
-void AddresseeLineEditPrivate::setSmartPaste(bool smartPaste)
-{
- m_smartPaste = smartPaste;
-}
-
-bool AddresseeLineEditPrivate::completionInitialized() const
-{
- return m_completionInitialized;
-}
-
-void AddresseeLineEditPrivate::setCompletionInitialized(bool completionInitialized)
-{
- m_completionInitialized = completionInitialized;
-}
-
-bool AddresseeLineEditPrivate::useCompletion() const
-{
- return m_useCompletion;
-}
-
-void AddresseeLineEditPrivate::setUseCompletion(bool useCompletion)
-{
- m_useCompletion = useCompletion;
-}
-
-bool AddresseeLineEditPrivate::showOU() const
-{
- return m_showOU;
-}
-
-void AddresseeLineEditPrivate::setShowOU(bool showOU)
-{
- m_showOU = showOU;
-}
-
-void AddresseeLineEditPrivate::loadBalooBlackList()
-{
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
- KConfigGroup group(config, "AddressLineEdit");
- m_balooBlackList = group.readEntry("BalooBackList", QStringList());
- m_domainExcludeList = group.readEntry("ExcludeDomain", QStringList());
-}
-
-void AddresseeLineEditPrivate::removeCompletionSource(const QString &source)
-{
- s_static->removeCompletionSource(source);
-}
-
-int AddresseeLineEditPrivate::addCompletionSource(const QString &source, int weight)
-{
- return s_static->addCompletionSource(source, weight);
-}
-
-void AddresseeLineEditPrivate::mightBeGroupJobsClear()
-{
- mMightBeGroupJobs.clear();
-}
-
-bool AddresseeLineEditPrivate::groupsIsEmpty() const
-{
- return mGroups.isEmpty();
-}
-
-void AddresseeLineEditPrivate::setShowRecentAddresses(bool b)
-{
- mShowRecentAddresses = b;
-}
-
-void AddresseeLineEditPrivate::groupsClear()
-{
- mGroups.clear();
-}
-
-void AddresseeLineEditPrivate::addGroups(const KContacts::ContactGroup::List &lst)
-{
- mGroups << lst;
-}
-
-void AddresseeLineEditPrivate::mightBeGroupJobsRemoveOne(Akonadi::ContactGroupSearchJob *search)
-{
- mMightBeGroupJobs.removeOne(search);
-}
-
-void AddresseeLineEditPrivate::mightBeGroupJobsAdd(Akonadi::ContactGroupSearchJob *job)
-{
- mMightBeGroupJobs.append(job);
-}
-
-}
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.h b/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.h
deleted file mode 100644
index b3eb45d..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineedit_p.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- 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
-*/
-
-#ifndef ADDRESSEELINEEDIT_P_H
-#define ADDRESSEELINEEDIT_P_H
-#include <QStringList>
-#include <QObject>
-#include <QTimer>
-#include <QList>
-#include <QColor>
-#include <ContactGroupSearchJob>
-#include "ldap/ldapclient.h"
-#include "ldap/ldapclientsearch.h"
-#include <AkonadiCore/Item>
-#include <AkonadiCore/Collection>
-#include <KLDAP/LdapServer>
-#include <kcontacts/contactgroup.h>
-
-class KConfig;
-
-namespace KPIM
-{
-class AddresseeLineEdit;
-class AddresseeLineEditPrivate : public QObject
-{
- Q_OBJECT
-public:
- AddresseeLineEditPrivate(AddresseeLineEdit *qq, bool enableCompletion);
- ~AddresseeLineEditPrivate();
- QStringList cleanupEmailList(const QStringList &inputList);
- void loadBalooBlackList();
- void alternateColor();
- void init();
- void startLoadingLDAPEntries();
- void stopLDAPLookup();
- void setCompletedItems(const QStringList &items, bool autoSuggest);
- void addCompletionItem(const QString &string, int weight, int source,
- const QStringList *keyWords = Q_NULLPTR);
- const QStringList adjustedCompletionItems(bool fullSearch);
- void updateSearchString();
- void startSearches();
- void akonadiPerformSearch();
- void akonadiHandlePending();
- void doCompletion(bool ctrlT);
-
- bool showOU() const;
- void setShowOU(bool showOU);
-
- bool useCompletion() const;
- void setUseCompletion(bool useCompletion);
-
- bool completionInitialized() const;
- void setCompletionInitialized(bool completionInitialized);
-
- bool smartPaste() const;
- void setSmartPaste(bool smartPaste);
-
- bool searchExtended() const;
- void setSearchExtended(bool searchExtended);
-
- QString searchString() const;
- void setSearchString(const QString &searchString);
-
- bool enableBalooSearch() const;
- void setEnableBalooSearch(bool enableBalooSearch);
-
- bool useSemicolonAsSeparator() const;
- void setUseSemicolonAsSeparator(bool useSemicolonAsSeparator);
-
- void removeCompletionSource(const QString &source);
- int addCompletionSource(const QString &source, int weight);
- void restartTime(const QString &searchString);
- void updateBalooBlackList();
- void updateCompletionOrder();
-
- KLDAP::LdapClientSearch *ldapSearch();
- QStringList balooBlackList() const;
-
- void setExpandIntern(bool);
- bool expandIntern() const;
-
- bool autoGroupExpand() const;
- void setAutoGroupExpand(bool autoGroupExpand);
-
- QList<KJob *> mightBeGroupJobs() const;
- void setMightBeGroupJobs(const QList<KJob *> &mightBeGroupJobs);
-
- KContacts::ContactGroup::List groups() const;
- void setGroups(const KContacts::ContactGroup::List &groups);
-
- void mightBeGroupJobsClear();
- void groupsClear();
- void addGroups(const KContacts::ContactGroup::List &lst);
- void mightBeGroupJobsRemoveOne(Akonadi::ContactGroupSearchJob *search);
- void mightBeGroupJobsAdd(Akonadi::ContactGroupSearchJob *job);
- bool groupsIsEmpty() const;
- void setShowRecentAddresses(bool b);
- bool showRecentAddresses() const;
- void setRecentAddressConfig(KConfig *config);
-
- KConfig *recentAddressConfig() const;
-
-public Q_SLOTS:
- void slotShowOUChanged(bool);
-
-private Q_SLOTS:
- void slotCompletion();
- void slotPopupCompletion(const QString &);
- void slotReturnPressed(const QString &);
- void slotStartLDAPLookup();
- void slotLDAPSearchData(const KLDAP::LdapResult::List &);
- void slotEditCompletionOrder();
- void slotUserCancelled(const QString &);
- void slotAkonadiHandleItems(const Akonadi::Item::List &items);
- void slotAkonadiSearchResult(KJob *);
- void slotAkonadiCollectionsReceived(const Akonadi::Collection::List &);
- void searchInBaloo();
- void slotTriggerDelayedQueries();
- void slotConfigureBalooBlackList();
-
-private:
- AddresseeLineEdit *q;
- QTimer m_delayedQueryTimer;
- QColor m_alternateColor;
- QStringList m_balooBlackList;
- QStringList m_domainExcludeList;
- QString m_previousAddresses;
- QString m_searchString;
- QList<KJob *> mMightBeGroupJobs;
- KContacts::ContactGroup::List mGroups;
- KConfig *m_recentAddressConfig;
- bool m_useCompletion;
- bool m_completionInitialized;
- bool m_smartPaste;
- bool m_addressBookConnected;
- bool m_lastSearchMode;
- bool m_searchExtended; //has \" been added?
- bool m_useSemicolonAsSeparator;
- bool m_showOU;
- bool m_enableBalooSearch;
- bool mExpandIntern;
- bool mAutoGroupExpand;
- bool mShowRecentAddresses;
-};
-}
-
-#endif // ADDRESSEELINEEDIT_P_H
-
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.cpp b/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.cpp
deleted file mode 100644
index 56791fc..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- 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 "addresseelineeditstatic.h"
-#include "kmailcompletion.h"
-
-#include "ldap/ldapclient.h"
-#include <KLocalizedString>
-#include <QTimer>
-#include <completionorder/completionordereditor.h>
-#include <KLDAP/LdapServer>
-#include <AkonadiCore/Session>
-using namespace KPIM;
-
-AddresseeLineEditStatic::AddresseeLineEditStatic()
- : completion(new KMailCompletion),
- ldapTimer(0),
- ldapSearch(0),
- ldapLineEdit(0),
- akonadiSession(new Akonadi::Session("contactsCompletionSession")),
- balooCompletionSource(0)
-{
-}
-
-AddresseeLineEditStatic::~AddresseeLineEditStatic()
-{
- delete completion;
- delete ldapTimer;
- delete ldapSearch;
-}
-
-void AddresseeLineEditStatic::slotEditCompletionOrder()
-{
- QPointer<CompletionOrderEditor> dlg = new CompletionOrderEditor(ldapSearch, 0);
- if (dlg->exec()) {
- updateCompletionOrder();
- }
- delete dlg;
-}
-
-void AddresseeLineEditStatic::updateCompletionOrder()
-{
- updateLDAPWeights();
- updateCollectionWeights();
-}
-
-void AddresseeLineEditStatic::updateCollectionWeights()
-{
- akonadiCollectionToCompletionSourceMap.clear();
-}
-
-void AddresseeLineEditStatic::updateLDAPWeights()
-{
- /* Add completion sources for all ldap server, 0 to n. Added first so
- * that they map to the LdapClient::clientNumber() */
- ldapSearch->updateCompletionWeights();
- int clientIndex = 0;
- foreach (const KLDAP::LdapClient *client, ldapSearch->clients()) {
- const int sourceIndex =
- addCompletionSource(i18n("LDAP server: %1", client->server().host()),
- client->completionWeight());
-
- ldapClientToCompletionSourceMap.insert(clientIndex, sourceIndex);
-
- ++clientIndex;
- }
-}
-
-int AddresseeLineEditStatic::addCompletionSource(const QString &source, int weight)
-{
- QMap<QString, int>::iterator it = completionSourceWeights.find(source);
- if (it == completionSourceWeights.end()) {
- completionSourceWeights.insert(source, weight);
- } else {
- completionSourceWeights[source] = weight;
- }
-
- const int sourceIndex = completionSources.indexOf(source);
- if (sourceIndex == -1) {
- completionSources.append(source);
- return completionSources.size() - 1;
- } else {
- return sourceIndex;
- }
-}
-
-void AddresseeLineEditStatic::removeCompletionSource(const QString &source)
-{
- QMap<QString, int>::iterator it = completionSourceWeights.find(source);
- if (it != completionSourceWeights.end()) {
- completionSourceWeights.remove(source);
- completion->clear();
- }
-}
diff --git a/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.h b/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.h
deleted file mode 100644
index 0f9b307..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/addresseelineeditstatic.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- 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
-*/
-
-#ifndef ADDRESSEELINEEDITSTATIC_H
-#define ADDRESSEELINEEDITSTATIC_H
-
-#include <QMap>
-#include <AkonadiCore/Collection>
-
-#include <AkonadiCore/Item>
-#include <AkonadiCore/Session>
-#include <QVector>
-#include <QWeakPointer>
-#include <ldap/ldapclientsearch.h>
-#include <qstringlist.h>
-class QTimer;
-namespace KPIM
-{
-class KMailCompletion;
-class AddresseeLineEdit;
-class AddresseeLineEditStatic
-{
-public:
- typedef QMap< QString, QPair<int, int> > CompletionItemsMap;
-
- AddresseeLineEditStatic();
-
- ~AddresseeLineEditStatic();
-
- void slotEditCompletionOrder();
-
- void updateCollectionWeights();
-
- void updateLDAPWeights();
- void updateCompletionOrder();
-
- int addCompletionSource(const QString &source, int weight);
-
- void removeCompletionSource(const QString &source);
-
- KMailCompletion *completion;
- CompletionItemsMap completionItemMap;
- QStringList completionSources;
-
- QTimer *ldapTimer;
- KLDAP::LdapClientSearch *ldapSearch;
-
- QString ldapText;
- AddresseeLineEdit *ldapLineEdit;
- // The weights associated with the completion sources in s_static->completionSources.
- // Both are maintained by addCompletionSource(), don't attempt to modifiy those yourself.
- QMap<QString, int> completionSourceWeights;
- // maps LDAP client indices to completion source indices
- // the assumption that they are always the first n indices in s_static->completion
- // does not hold when clients are added later on
- QMap<int, int> ldapClientToCompletionSourceMap;
- // holds the cached mapping from akonadi collection id to the completion source index
- struct collectionInfo {
- collectionInfo()
- : index(-1),
- enabled(true)
- {
-
- }
- int index;
- bool enabled;
- };
-
- QMap<Akonadi::Collection::Id, collectionInfo> akonadiCollectionToCompletionSourceMap;
- // a list of akonadi items (contacts) that have not had their collection fetched yet
- Akonadi::Item::List akonadiPendingItems;
- Akonadi::Session *akonadiSession;
- QVector<QWeakPointer<Akonadi::Job> > akonadiJobsInFlight;
- int balooCompletionSource;
-};
-}
-#endif // ADDRESSEELINEEDITSTATIC_H
diff --git a/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.cpp b/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.cpp
deleted file mode 100644
index 605608e..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "baloocompletionemail.h"
-#include <QMap>
-#include <KEmailAddress>
-#include "libkdepim_debug.h"
-using namespace KPIM;
-
-BalooCompletionEmail::BalooCompletionEmail()
-{
-
-}
-
-void BalooCompletionEmail::setEmailList(const QStringList &lst)
-{
- mListEmail = lst;
-}
-
-void BalooCompletionEmail::setExcludeDomain(const QStringList &lst)
-{
- mExcludeDomain = lst;
-}
-
-void BalooCompletionEmail::setBlackList(const QStringList &lst)
-{
- mBlackList = lst;
-}
-
-QStringList BalooCompletionEmail::cleanupEmailList()
-{
- if (mListEmail.isEmpty()) {
- return mListEmail;
- }
- QMap<QString, QString> hashEmail;
- Q_FOREACH (QString email, mListEmail) {
- if (!mBlackList.contains(email)) {
- QString address;
- email = stripEmail(email, address);
- if (address.isEmpty()) {
- address = email;
- }
- bool excludeMail = false;
- Q_FOREACH (const QString &excludeDomain, mExcludeDomain) {
- if (!excludeDomain.isEmpty()) {
- if (address.endsWith(excludeDomain)) {
- excludeMail = true;
- continue;
- }
- }
- }
- if (!excludeMail && !hashEmail.contains(address.toLower())) {
- hashEmail.insert(address.toLower(), email);
- }
- }
- }
- return hashEmail.values();
-}
-
-/* stips the name of an email address email
- *
- * 'a' <a@example.com> -> a <a@example.com>
- * "a" <a@example.com> -> a <a@example.com>
- * "\"'a'\"" <a@example.com> -> a <a@example.com>
- *
- * but "\"'a" <a@example.com> -> "\"'a" <a@example.com>
- * cause the start and end is not the same.
- */
-QString BalooCompletionEmail::stripEmail(const QString &email, QString &address)
-{
- QString displayName, addrSpec, comment;
- if (KEmailAddress::AddressOk == KEmailAddress::splitAddress(email, displayName, addrSpec, comment)) {
- address = addrSpec;
- while ((displayName.startsWith(QLatin1Char('\'')) && displayName.endsWith(QLatin1Char('\''))) ||
- (displayName.startsWith(QLatin1Char('"')) && displayName.endsWith(QLatin1Char('"'))) ||
- (displayName.startsWith(QStringLiteral("\\\"")) && displayName.endsWith(QStringLiteral("\\\"")))) {
- if (displayName.startsWith(QStringLiteral("\\\""))) {
- displayName = displayName.mid(2, displayName.length() - 4).trimmed();
- } else {
- displayName = displayName.mid(1, displayName.length() - 2).trimmed();
- }
- }
- return KEmailAddress::normalizedAddress(displayName, addrSpec, comment);
- } else {
- return email;
- }
-}
-
diff --git a/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.h b/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.h
deleted file mode 100644
index 930181a..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/baloocompletionemail.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BALOOCOMPLETIONEMAIL_H
-#define BALOOCOMPLETIONEMAIL_H
-#include <QStringList>
-
-namespace KPIM
-{
-class BalooCompletionEmail
-{
-public:
- BalooCompletionEmail();
- void setEmailList(const QStringList &lst);
- void setExcludeDomain(const QStringList &lst);
-
- void setBlackList(const QStringList &lst);
-
- QStringList cleanupEmailList();
-private:
- QString stripEmail(const QString &email, QString &address);
- QStringList mListEmail;
- QStringList mExcludeDomain;
- QStringList mBlackList;
-};
-}
-
-#endif // BALOOCOMPLETIONEMAIL_H
diff --git a/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.cpp b/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.cpp
deleted file mode 100644
index e619ea2..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- This file is part of libkdepim.
-
- Copyright (c) 2006 Christian Schaarschmidt <schaarsc@gmx.de>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "kmailcompletion.h"
-#include <QRegExp>
-#include <QSet>
-
-using namespace KPIM;
-
-KMailCompletion::KMailCompletion()
-{
- setIgnoreCase(true);
-}
-
-void KMailCompletion::clear()
-{
- m_keyMap.clear();
- KCompletion::clear();
-}
-
-QString KMailCompletion::makeCompletion(const QString &string)
-{
- QString match = KCompletion::makeCompletion(string);
-
- // this should be in postProcessMatch, but postProcessMatch is const and will not allow nextMatch
- if (!match.isEmpty()) {
- const QString firstMatch(match);
- while (match.indexOf(QRegExp(QLatin1String("(@)|(<.*>)"))) == -1) {
- /* local email do not require @domain part, if match is an address we'll
- * find last+first <match> in m_keyMap and we'll know that match is
- * already a valid email.
- *
- * Distribution list do not have last+first <match> entry, they will be
- * in mailAddr
- */
- const QStringList &mailAddr = m_keyMap[ match ]; //get all mailAddr for this keyword
- bool isEmail = false;
- for (QStringList::ConstIterator sit(mailAddr.begin()), sEnd(mailAddr.end());
- sit != sEnd; ++sit) {
- if ((*sit).indexOf(QLatin1Char('<') + match + QLatin1Char('>')) != -1 || (*sit) == match) {
- isEmail = true;
- break;
- }
- }
-
- if (!isEmail) {
- // match is a keyword, skip it and try to find match <email@domain>
- match = nextMatch();
- if (firstMatch == match) {
- match.clear();
- break;
- }
- } else {
- break;
- }
- }
- }
- return match;
-}
-
-void KMailCompletion::addItemWithKeys(const QString &email, int weight,
- const QStringList *keyWords)
-{
- Q_ASSERT(keyWords != 0);
- QStringList::ConstIterator end = keyWords->constEnd();
- for (QStringList::ConstIterator it(keyWords->constBegin()); it != end; ++it) {
- QStringList &emailList = m_keyMap[(*it) ]; //lookup email-list for given keyword
- if (emailList.indexOf(email) == -1) { //add email if not there
- emailList.append(email);
- }
- addItem((*it), weight); //inform KCompletion about keyword
- }
-}
-
-void KMailCompletion::postProcessMatches(QStringList *pMatches) const
-{
- Q_ASSERT(pMatches != 0);
- if (pMatches->isEmpty()) {
- return;
- }
-
- //KCompletion has found the keywords for us, we can now map them to mail-addr
- QSet< QString > mailAddrDistinct;
- for (QStringList::ConstIterator sit(pMatches->begin()), sEnd(pMatches->end());
- sit != sEnd; ++sit) {
- const QStringList &mailAddr = m_keyMap[(*sit) ]; //get all mailAddr for this keyword
- for (QStringList::ConstIterator sit(mailAddr.begin()), sEnd(mailAddr.end());
- sit != sEnd; ++sit) {
- mailAddrDistinct.insert(*sit); //store mailAddr, QSet will make them unique
- }
- }
- pMatches->clear(); //delete keywords
- (*pMatches) += mailAddrDistinct.toList(); //add emailAddr
-}
diff --git a/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.h b/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.h
deleted file mode 100644
index a24581c..0000000
--- a/3rdparty/kdepim/libkdepim/addressline/kmailcompletion.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- This file is part of libkdepim.
-
- Copyright (c) 2006 Christian Schaarschmidt <schaarsc@gmx.de>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KDEPIM_KMAILCOMPLETION_H
-#define KDEPIM_KMAILCOMPLETION_H
-
-#include <KCompletion>
-
-#include <QMap>
-#include <QString>
-#include <QStringList>
-
-namespace KPIM
-{
-
-/**
- * KMailCompletion allows lookup of email addresses by keyword.
- * This is used for lookup by nickname, since we don't want the nickname to appear in the final email.
- * E.g. you have a nickname "idiot" for your boss, you want to type "idiot" but you want the completion
- * to offer "Full Name <email@domain>", without the nickname being visible.
- */
-class KMailCompletion : public KCompletion
-{
- Q_OBJECT
-
-public:
- KMailCompletion();
-
- /**
- * clears internal keyword map and calls KCompletion::clear.
- */
- void clear() Q_DECL_OVERRIDE;
-
- /**
- * uses KCompletion::makeCompletion to find email addresses which starts
- * with string. ignores keywords.
- *
- * @returns email address
- */
- QString makeCompletion(const QString &string) Q_DECL_OVERRIDE;
-
- /**
- * specify keywords for email.
- *
- * Items may be added with KCompletion::addItem, those will only be
- * returned as match if they are in one of these formats:
- * \li contains localpart@domain
- * \li contains <email>
- * or if they have also been added with this function.
- */
- void addItemWithKeys(const QString &email, int weight, const QStringList *keyWords);
-
- /**
- * use internal map to replace all keywords in pMatches with corresponding
- * email addresses.
- */
- void postProcessMatches(QStringList *pMatches) const Q_DECL_OVERRIDE;
-
- // We are not using allWeightedMatches() anywhere, therefore we don't need
- // to Q_DECL_OVERRIDE the other postProcessMatches() function
- using KCompletion::postProcessMatches;
-
-private:
- QMap< QString, QStringList > m_keyMap;
-};
-
-}
-
-#endif
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/CMakeLists.txt b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/CMakeLists.txt
deleted file mode 100644
index ed3bf81..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-macro(add_libkdepim_blacklistbaloocompletion_unittest _name)
- ecm_add_test(${ARGN}
- TEST_NAME ${_name}
- NAME_PREFIX "libkdepim-addessline-blaclistbaloocompletion-"
- LINK_LIBRARIES Qt5::Test KF5::Libkdepim KF5::WidgetsAddons KF5::Completion KF5::I18n KF5::ConfigCore KF5::ItemViews KF5::Codecs
- )
-endmacro()
-
-add_libkdepim_blacklistbaloocompletion_unittest(emailcompletiondialogtest
- blacklistbalooemailcompletiondialogtest.cpp
- ../blacklistbalooemailcompletionwidget.cpp
- ../blacklistbalooemailwarning.cpp
-)
-add_libkdepim_blacklistbaloocompletion_unittest(emailcompletionwidgettest
- blacklistbalooemailcompletionwidgettest.cpp
- ../blacklistbalooemailcompletionwidget.cpp
- ../blacklistbalooemailwarning.cpp
-)
-add_libkdepim_blacklistbaloocompletion_unittest(emaillisttest
- blacklistbalooemaillisttest.cpp
-)
-add_libkdepim_blacklistbaloocompletion_unittest(emailsearchjobtest
- blacklistbalooemailsearchjobtest.cpp
-)
-add_libkdepim_blacklistbaloocompletion_unittest(emailutiltest
- blacklistbalooemailutiltest.cpp
-)
-add_libkdepim_blacklistbaloocompletion_unittest(emailwarningtest
- blacklistbalooemailwarningtest.cpp
- ../blacklistbalooemailwarning.cpp
-)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.cpp
deleted file mode 100644
index f43719c..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailcompletiondialogtest.h"
-#include "../blacklistbalooemailcompletiondialog.h"
-#include "../blacklistbalooemaillist.h"
-#include "../blacklistbalooemailcompletionwidget.h"
-#include <QLabel>
-#include <klineedit.h>
-#include <QPushButton>
-#include <qtest.h>
-
-BlackListBalooEmailCompletionDialogTest::BlackListBalooEmailCompletionDialogTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailCompletionDialogTest::~BlackListBalooEmailCompletionDialogTest()
-{
-
-}
-
-void BlackListBalooEmailCompletionDialogTest::shouldHaveDefaultValue()
-{
- KPIM::BlackListBalooEmailCompletionDialog dlg;
-
- QLabel *searchLabel = dlg.findChild<QLabel *>(QStringLiteral("search_label"));
- QVERIFY(searchLabel);
-
- KLineEdit *searchLineEdit = dlg.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
- QVERIFY(searchLineEdit);
- QVERIFY(searchLineEdit->isClearButtonShown());
- QVERIFY(searchLineEdit->trapReturnKey());
- QVERIFY(searchLineEdit->text().isEmpty());
-
- QPushButton *seachButton = dlg.findChild<QPushButton *>(QStringLiteral("search_button"));
- QVERIFY(seachButton);
- QVERIFY(!seachButton->isEnabled());
-
- KPIM::BlackListBalooEmailList *emailList = dlg.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
- QVERIFY(emailList);
-
- QPushButton *selectButton = dlg.findChild<QPushButton *>(QStringLiteral("select_email"));
- QVERIFY(selectButton);
- QPushButton *unselectButton = dlg.findChild<QPushButton *>(QStringLiteral("unselect_email"));
- QVERIFY(unselectButton);
-
-}
-
-void BlackListBalooEmailCompletionDialogTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
-{
- KPIM::BlackListBalooEmailCompletionDialog dlg;
- KLineEdit *searchLineEdit = dlg.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
- QPushButton *seachButton = dlg.findChild<QPushButton *>(QStringLiteral("search_button"));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral("fo"));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral("foo"));
- QVERIFY(seachButton->isEnabled());
-
- searchLineEdit->setText(QStringLiteral("o "));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral(" o "));
- QVERIFY(!seachButton->isEnabled());
-}
-
-QTEST_MAIN(BlackListBalooEmailCompletionDialogTest)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.h
deleted file mode 100644
index 438b773..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletiondialogtest.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-#ifndef BLACKLISTBALOOEMAILCOMPLETIONDIALOGTEST_H
-#define BLACKLISTBALOOEMAILCOMPLETIONDIALOGTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailCompletionDialogTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailCompletionDialogTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailCompletionDialogTest();
-private Q_SLOTS:
- void shouldHaveDefaultValue();
- void shouldEnablePushButtonWhenTestSizeSupperiorToTwo();
-};
-
-#endif // BLACKLISTBALOOEMAILCOMPLETIONDIALOGTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.cpp
deleted file mode 100644
index ca5c609..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailcompletionwidgettest.h"
-#include "../blacklistbalooemailcompletionwidget.h"
-#include "../blacklistbalooemaillist.h"
-#include <KListWidgetSearchLine>
-#include <QLabel>
-#include <klineedit.h>
-#include <qpushbutton.h>
-#include <qtest.h>
-#include <addressline/blacklistbaloocompletion/blacklistbalooemailwarning.h>
-
-BlackListBalooEmailCompletionWidgetTest::BlackListBalooEmailCompletionWidgetTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailCompletionWidgetTest::~BlackListBalooEmailCompletionWidgetTest()
-{
-
-}
-
-void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
-{
- KPIM::BlackListBalooEmailCompletionWidget widget;
- widget.show();
- QTest::qWaitForWindowExposed(&widget);
- QLabel *searchLabel = widget.findChild<QLabel *>(QStringLiteral("search_label"));
- QVERIFY(searchLabel);
-
- KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
- QVERIFY(searchLineEdit);
- QVERIFY(searchLineEdit->isClearButtonShown());
- QVERIFY(searchLineEdit->trapReturnKey());
- QVERIFY(searchLineEdit->text().isEmpty());
-
- QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
- QVERIFY(seachButton);
- QVERIFY(!seachButton->isEnabled());
-
- QLabel *moreResult = widget.findChild<QLabel *>(QStringLiteral("moreresultlabel"));
- QVERIFY(moreResult);
- QVERIFY(!moreResult->isVisible());
-
- QLabel *mNumberOfEmailsFound = widget.findChild<QLabel *>(QStringLiteral("numberofemailsfound"));
- QVERIFY(mNumberOfEmailsFound);
- QVERIFY(mNumberOfEmailsFound->text().isEmpty());
-
- QPushButton *showAllBlackListedEmails = widget.findChild<QPushButton *>(QStringLiteral("show_blacklisted_email_button"));
- QVERIFY(showAllBlackListedEmails);
-
- KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
- QVERIFY(emailList);
-
- QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
- QVERIFY(selectButton);
- QVERIFY(!selectButton->isEnabled());
- QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
- QVERIFY(unselectButton);
- QVERIFY(!unselectButton->isEnabled());
-
- QLabel *excludeDomainLabel = widget.findChild<QLabel *>(QStringLiteral("domain_label"));
- QVERIFY(excludeDomainLabel);
-
- KLineEdit *excludeDomainLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("domain_lineedit"));
- QVERIFY(excludeDomainLineEdit);
- QVERIFY(excludeDomainLineEdit->trapReturnKey());
- QVERIFY(excludeDomainLineEdit->text().isEmpty());
- QVERIFY(excludeDomainLineEdit->isClearButtonShown());
- QVERIFY(!excludeDomainLineEdit->placeholderText().isEmpty());
-
- KListWidgetSearchLine *searchInResult = widget.findChild<KListWidgetSearchLine *>(QStringLiteral("searchinresultlineedit"));
- QVERIFY(searchInResult);
- QVERIFY(!searchInResult->placeholderText().isEmpty());
- QVERIFY(searchInResult->text().isEmpty());
- QVERIFY(searchInResult->isClearButtonEnabled());
-
- KPIM::BlackListBalooEmailWarning *blackListWarning = widget.findChild<KPIM::BlackListBalooEmailWarning *>(QStringLiteral("backlistwarning"));
- QVERIFY(blackListWarning);
-}
-
-void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
-{
- KPIM::BlackListBalooEmailCompletionWidget widget;
- KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
- QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral("fo"));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral("foo"));
- QVERIFY(seachButton->isEnabled());
-
- searchLineEdit->setText(QStringLiteral("o "));
- QVERIFY(!seachButton->isEnabled());
- searchLineEdit->setText(QStringLiteral(" o "));
- QVERIFY(!seachButton->isEnabled());
-}
-
-void BlackListBalooEmailCompletionWidgetTest::shouldChangeEnableSelectUnSelectButton()
-{
- KPIM::BlackListBalooEmailCompletionWidget widget;
-
- QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
- QVERIFY(!selectButton->isEnabled());
-
- QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
- QVERIFY(!unselectButton->isEnabled());
-
- KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
- emailList->setEmailFound(QStringList() << QStringLiteral("foo") << QStringLiteral("bla") << QStringLiteral("bli"));
-
- emailList->selectAll();
- QVERIFY(unselectButton->isEnabled());
- QVERIFY(selectButton->isEnabled());
-
- emailList->clearSelection();
- QVERIFY(!unselectButton->isEnabled());
- QVERIFY(!selectButton->isEnabled());
-
-}
-
-QTEST_MAIN(BlackListBalooEmailCompletionWidgetTest)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.h
deleted file mode 100644
index 26d553a..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailcompletionwidgettest.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
-#define BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailCompletionWidgetTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailCompletionWidgetTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailCompletionWidgetTest();
-
-private Q_SLOTS:
- void shouldHaveDefaultValue();
- void shouldEnablePushButtonWhenTestSizeSupperiorToTwo();
- void shouldChangeEnableSelectUnSelectButton();
-};
-
-#endif // BLACKLISTBALOOEMAILCOMPLETIONWIDGETTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.cpp
deleted file mode 100644
index e5d85bf..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemaillisttest.h"
-#include "../blacklistbalooemaillist.h"
-#include <qtest.h>
-
-BlackListBalooEmailListTest::BlackListBalooEmailListTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailListTest::~BlackListBalooEmailListTest()
-{
-
-}
-
-void BlackListBalooEmailListTest::shouldHaveDefaultValue()
-{
- KPIM::BlackListBalooEmailList blackList;
- QVERIFY(blackList.count() == 0);
-}
-
-void BlackListBalooEmailListTest::shouldFillListEmail()
-{
- KPIM::BlackListBalooEmailList blackList;
- blackList.setEmailFound(QStringList() << QStringLiteral("foo") << QStringLiteral("bla") << QStringLiteral("bli"));
- QCOMPARE(blackList.count(), 3);
- for (int i = 0; i < blackList.count(); ++i) {
- QListWidgetItem *item = blackList.item(i);
- QVERIFY(item);
- KPIM::BlackListBalooEmailListItem *blackListItem = static_cast<KPIM::BlackListBalooEmailListItem *>(item);
- QVERIFY(!blackListItem->initializeStatus());
- QCOMPARE(blackListItem->checkState(), Qt::Unchecked);
- }
- QVERIFY(blackList.blackListItemChanged().isEmpty());
-}
-
-void BlackListBalooEmailListTest::shouldFillListWithAlreadyBlackListedEmail()
-{
- KPIM::BlackListBalooEmailList blackList;
- QStringList emails = QStringList() << QStringLiteral("foo") << QStringLiteral("bla") << QStringLiteral("bli");
- blackList.setEmailBlackList(emails);
- blackList.setEmailFound(emails);
-
- QCOMPARE(blackList.count(), 3);
- for (int i = 0; i < blackList.count(); ++i) {
- QListWidgetItem *item = blackList.item(i);
- QVERIFY(item);
- KPIM::BlackListBalooEmailListItem *blackListItem = static_cast<KPIM::BlackListBalooEmailListItem *>(item);
- QVERIFY(blackListItem->initializeStatus());
- QCOMPARE(blackListItem->checkState(), Qt::Checked);
- }
-
- QVERIFY(blackList.blackListItemChanged().isEmpty());
-}
-
-void BlackListBalooEmailListTest::shouldReturnChangedItems()
-{
- KPIM::BlackListBalooEmailList blackList;
- const QStringList emails = QStringList() << QStringLiteral("foo") << QStringLiteral("bla") << QStringLiteral("bli");
- blackList.setEmailBlackList(emails);
- blackList.setEmailFound(emails);
- QListWidgetItem *item = blackList.item(1);
- QVERIFY(item);
- item->setCheckState(Qt::Unchecked);
- QVERIFY(!blackList.blackListItemChanged().isEmpty());
-}
-
-void BlackListBalooEmailListTest::shouldNotAddDuplicateEmails()
-{
- KPIM::BlackListBalooEmailList blackList;
- QStringList emails = QStringList() << QStringLiteral("foo") << QStringLiteral("bli") << QStringLiteral("bli");
- blackList.setEmailBlackList(emails);
- blackList.setEmailFound(emails);
-
- QCOMPARE(blackList.count(), 2);
-}
-
-void BlackListBalooEmailListTest::shouldExcludeDomain()
-{
- KPIM::BlackListBalooEmailList blackList;
- blackList.setExcludeDomain(QStringList() << QStringLiteral("kde.org") << QStringLiteral("toto.fr"));
- QStringList emails = QStringList() << QStringLiteral("foo@kde.org") << QStringLiteral("bli@fr.fr") << QStringLiteral("bli@toto.fr");
- blackList.setEmailBlackList(emails);
- blackList.setEmailFound(emails);
-
- QCOMPARE(blackList.count(), 1);
-
- blackList.setExcludeDomain(QStringList() << QStringLiteral("kde.org") << QStringLiteral("toto.fr"));
- emails = QStringList() << QStringLiteral("<foo@kde.org>") << QStringLiteral("bli@fr.fr") << QStringLiteral("bli@toto.fr");
- blackList.setEmailBlackList(emails);
- blackList.setEmailFound(emails);
- QCOMPARE(blackList.count(), 1);
-
-}
-
-QTEST_MAIN(BlackListBalooEmailListTest)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.h
deleted file mode 100644
index 2838519..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemaillisttest.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILLISTTEST_H
-#define BLACKLISTBALOOEMAILLISTTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailListTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailListTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailListTest();
-private Q_SLOTS:
- void shouldHaveDefaultValue();
- void shouldFillListEmail();
- void shouldFillListWithAlreadyBlackListedEmail();
- void shouldReturnChangedItems();
- void shouldNotAddDuplicateEmails();
- void shouldExcludeDomain();
-};
-
-#endif // BLACKLISTBALOOEMAILLISTTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.cpp
deleted file mode 100644
index 530a4ed..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-#include "blacklistbalooemailsearchjobtest.h"
-#include "../blacklistbalooemailsearchjob.h"
-#include <qtest.h>
-
-BlackListBalooEmailSearchJobTest::BlackListBalooEmailSearchJobTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailSearchJobTest::~BlackListBalooEmailSearchJobTest()
-{
-
-}
-
-void BlackListBalooEmailSearchJobTest::shouldNotSearchWhenTextIsEmpty()
-{
- KPIM::BlackListBalooEmailSearchJob *job = new KPIM::BlackListBalooEmailSearchJob;
- QVERIFY(!job->start());
-}
-
-QTEST_MAIN(BlackListBalooEmailSearchJobTest)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.h
deleted file mode 100644
index 9fb2fd5..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailsearchjobtest.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILSEARCHJOBTEST_H
-#define BLACKLISTBALOOEMAILSEARCHJOBTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailSearchJobTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailSearchJobTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailSearchJobTest();
-
-private Q_SLOTS:
- void shouldNotSearchWhenTextIsEmpty();
-};
-
-#endif // BLACKLISTBALOOEMAILSEARCHJOBTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.cpp
deleted file mode 100644
index 495fbc7..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailutiltest.h"
-#include "../blacklistbalooemailutil.h"
-#include <qtest.h>
-BlackListBalooEmailUtilTest::BlackListBalooEmailUtilTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailUtilTest::~BlackListBalooEmailUtilTest()
-{
-
-}
-
-void BlackListBalooEmailUtilTest::shouldReturnEmptyResult()
-{
- KPIM::BlackListBalooEmailUtil util;
- QVERIFY(util.createNewBlackList().isEmpty());
-}
-
-void BlackListBalooEmailUtilTest::shouldDontChangeWhenNotChanged()
-{
- KPIM::BlackListBalooEmailUtil util;
- const QStringList lst = QStringList() << QStringLiteral("foo") << QStringLiteral("foo1") << QStringLiteral("foo2");
- util.initialBlackList(lst);
- QCOMPARE(util.createNewBlackList(), lst);
-}
-
-void BlackListBalooEmailUtilTest::shouldCreateNewList()
-{
- KPIM::BlackListBalooEmailUtil util;
- const QStringList lst = QStringList() << QStringLiteral("foo") << QStringLiteral("foo1") << QStringLiteral("foo2");
- util.initialBlackList(lst);
- QHash<QString, bool> newList;
- newList.insert(QStringLiteral("foo"), false);
- util.newBlackList(newList);
- QCOMPARE(util.createNewBlackList(), QStringList() << QStringLiteral("foo1") << QStringLiteral("foo2"));
-}
-
-void BlackListBalooEmailUtilTest::shouldAddNewElements()
-{
- KPIM::BlackListBalooEmailUtil util;
- QHash<QString, bool> newList;
- newList.insert(QStringLiteral("foo"), false);
- newList.insert(QStringLiteral("foo1"), false);
- newList.insert(QStringLiteral("foo2"), false);
- util.newBlackList(newList);
- QCOMPARE(util.createNewBlackList().count(), 0);
-
- newList.clear();
- newList.insert(QStringLiteral("foo"), true);
- newList.insert(QStringLiteral("foo1"), true);
- newList.insert(QStringLiteral("foo2"), true);
- util.newBlackList(newList);
- QCOMPARE(util.createNewBlackList().count(), 3);
-}
-
-QTEST_MAIN(BlackListBalooEmailUtilTest)
-
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.h
deleted file mode 100644
index 84850c5..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailutiltest.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILUTILTEST_H
-#define BLACKLISTBALOOEMAILUTILTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailUtilTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailUtilTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailUtilTest();
-private Q_SLOTS:
- void shouldReturnEmptyResult();
- void shouldDontChangeWhenNotChanged();
- void shouldCreateNewList();
- void shouldAddNewElements();
-};
-
-#endif // BLACKLISTBALOOEMAILUTILTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.cpp
deleted file mode 100644
index ed1074d..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailwarningtest.h"
-#include "../blacklistbalooemailwarning.h"
-#include <QTest>
-#include <QSignalSpy>
-#include <QAction>
-
-BlackListBalooEmailWarningTest::BlackListBalooEmailWarningTest(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-BlackListBalooEmailWarningTest::~BlackListBalooEmailWarningTest()
-{
-
-}
-
-void BlackListBalooEmailWarningTest::shouldHaveDefaultValue()
-{
- KPIM::BlackListBalooEmailWarning warning;
- QVERIFY(!warning.isVisible());
- QVERIFY(!warning.isCloseButtonVisible());
- QVERIFY(warning.wordWrap());
-
- QAction *save = warning.findChild<QAction *>(QStringLiteral("saveblacklist"));
- QVERIFY(save);
-
- QAction *search = warning.findChild<QAction *>(QStringLiteral("search"));
- QVERIFY(search);
-}
-
-void BlackListBalooEmailWarningTest::shouldEmitSaveChanges()
-{
- KPIM::BlackListBalooEmailWarning warning;
- QSignalSpy spy1(&warning, SIGNAL(saveChanges()));
-
- QAction *save = warning.findChild<QAction *>(QStringLiteral("saveblacklist"));
- save->trigger();
- QCOMPARE(spy1.count(), 1);
-}
-
-void BlackListBalooEmailWarningTest::shouldEmitNewSearch()
-{
- KPIM::BlackListBalooEmailWarning warning;
- QSignalSpy spy1(&warning, SIGNAL(newSearch()));
-
- QAction *search = warning.findChild<QAction *>(QStringLiteral("search"));
- search->trigger();
- QCOMPARE(spy1.count(), 1);
-}
-QTEST_MAIN(BlackListBalooEmailWarningTest)
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.h
deleted file mode 100644
index 3c5730f..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/autotests/blacklistbalooemailwarningtest.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILWARNINGTEST_H
-#define BLACKLISTBALOOEMAILWARNINGTEST_H
-
-#include <QObject>
-
-class BlackListBalooEmailWarningTest : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailWarningTest(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailWarningTest();
-
-private Q_SLOTS:
- void shouldHaveDefaultValue();
- void shouldEmitSaveChanges();
- void shouldEmitNewSearch();
-};
-
-#endif // BLACKLISTBALOOEMAILWARNINGTEST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.cpp
deleted file mode 100644
index 63d5ac9..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailcompletiondialog.h"
-#include "blacklistbalooemailcompletionwidget.h"
-#include <KLocalizedString>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <KSharedConfig>
-#include <KConfigGroup>
-#include <QDialogButtonBox>
-
-using namespace KPIM;
-class KPIM::BlackListBalooEmailCompletionDialogPrivate
-{
-public:
- BlackListBalooEmailCompletionDialogPrivate()
- : mBlackListWidget(Q_NULLPTR)
- {
-
- }
- BlackListBalooEmailCompletionWidget *mBlackListWidget;
-};
-
-BlackListBalooEmailCompletionDialog::BlackListBalooEmailCompletionDialog(QWidget *parent)
- : QDialog(parent),
- d(new KPIM::BlackListBalooEmailCompletionDialogPrivate)
-{
- setWindowTitle(i18n("Blacklist Email Completion"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
- okButton->setDefault(true);
- okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
- okButton->setDefault(true);
- d->mBlackListWidget = new BlackListBalooEmailCompletionWidget(this);
- d->mBlackListWidget->load();
- d->mBlackListWidget->setObjectName(QStringLiteral("blacklistwidget"));
- mainLayout->addWidget(d->mBlackListWidget);
-
- mainLayout->addWidget(buttonBox);
-
- setModal(true);
- connect(okButton, &QAbstractButton::clicked, this, &BlackListBalooEmailCompletionDialog::slotSave);
- readConfig();
-}
-
-BlackListBalooEmailCompletionDialog::~BlackListBalooEmailCompletionDialog()
-{
- writeConfig();
- delete d;
-}
-
-void BlackListBalooEmailCompletionDialog::setEmailBlackList(const QStringList &list)
-{
- d->mBlackListWidget->setEmailBlackList(list);
-}
-
-void BlackListBalooEmailCompletionDialog::readConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "BlackListBalooEmailCompletionDialog");
- const QSize sizeDialog = group.readEntry("Size", QSize(800, 600));
- if (sizeDialog.isValid()) {
- resize(sizeDialog);
- }
-}
-
-void BlackListBalooEmailCompletionDialog::writeConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "BlackListBalooEmailCompletionDialog");
- group.writeEntry("Size", size());
-}
-
-void BlackListBalooEmailCompletionDialog::slotSave()
-{
- d->mBlackListWidget->save();
- accept();
-}
-
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.h
deleted file mode 100644
index 7287443..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletiondialog.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILCOMPLETIONDIALOG_H
-#define BLACKLISTBALOOEMAILCOMPLETIONDIALOG_H
-
-#include <QDialog>
-#include "kdepim_export.h"
-namespace KPIM
-{
-class BlackListBalooEmailCompletionDialogPrivate;
-class KDEPIM_EXPORT BlackListBalooEmailCompletionDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailCompletionDialog(QWidget *parent = Q_NULLPTR);
- ~BlackListBalooEmailCompletionDialog();
-
- void setEmailBlackList(const QStringList &list);
-
-private Q_SLOTS:
- void slotSave();
-private:
- void writeConfig();
- void readConfig();
- BlackListBalooEmailCompletionDialogPrivate *const d;
-};
-}
-
-#endif // BLACKLISTBALOOEMAILCOMPLETIONDIALOG_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.cpp
deleted file mode 100644
index 6cdb72d..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailcompletionwidget.h"
-#include "blacklistbalooemaillist.h"
-#include "blacklistbalooemailsearchjob.h"
-#include "blacklistbalooemailutil.h"
-#include "blacklistbalooemailwarning.h"
-
-#include <KLocalizedString>
-#include <KLineEdit>
-#include <QPushButton>
-#include <QBoxLayout>
-#include <QLabel>
-#include <KConfigGroup>
-#include <KSharedConfig>
-#include <KListWidgetSearchLine>
-#include "libkdepim_debug.h"
-
-using namespace KPIM;
-BlackListBalooEmailCompletionWidget::BlackListBalooEmailCompletionWidget(QWidget *parent)
- : QWidget(parent),
- mLimit(500)
-{
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
-
- QHBoxLayout *searchLayout = new QHBoxLayout;
- mainLayout->addLayout(searchLayout);
-
- QLabel *lab = new QLabel(i18n("Search email:"));
- lab->setObjectName(QStringLiteral("search_label"));
- searchLayout->addWidget(lab);
-
- mSearchLineEdit = new KLineEdit;
- mSearchLineEdit->setPlaceholderText(i18n("Research is done from 3 characters"));
- mSearchLineEdit->setFocus();
- mSearchLineEdit->setClearButtonShown(true);
- mSearchLineEdit->setTrapReturnKey(true);
- mSearchLineEdit->setObjectName(QStringLiteral("search_lineedit"));
- connect(mSearchLineEdit, &KLineEdit::returnPressed, this, &BlackListBalooEmailCompletionWidget::slotCheckIfUpdateBlackListIsNeeded);
- searchLayout->addWidget(mSearchLineEdit);
-
- mSearchButton = new QPushButton(QIcon::fromTheme(QStringLiteral("edit-find")), i18n("Search"));
- mSearchButton->setObjectName(QStringLiteral("search_button"));
- connect(mSearchButton, &QAbstractButton::clicked, this, &BlackListBalooEmailCompletionWidget::slotCheckIfUpdateBlackListIsNeeded);
- mSearchButton->setEnabled(false);
- searchLayout->addWidget(mSearchButton);
-
- mShowAllBlackListedEmails = new QPushButton(i18n("Show Blacklisted Emails"));
- mShowAllBlackListedEmails->setObjectName(QStringLiteral("show_blacklisted_email_button"));
- connect(mShowAllBlackListedEmails, &QAbstractButton::clicked, this, &BlackListBalooEmailCompletionWidget::slotShowAllBlacklistedEmail);
- searchLayout->addWidget(mShowAllBlackListedEmails);
-
- mEmailList = new BlackListBalooEmailList;
- mEmailList->setObjectName(QStringLiteral("email_list"));
- mainLayout->addWidget(mEmailList);
-
- QHBoxLayout *searchLineLayout = new QHBoxLayout;
- mainLayout->addLayout(searchLineLayout);
- mSearchInResultLineEdit = new KListWidgetSearchLine(this, mEmailList);
- mSearchInResultLineEdit->setObjectName(QStringLiteral("searchinresultlineedit"));
- mSearchInResultLineEdit->setClearButtonEnabled(true);
- mSearchInResultLineEdit->setPlaceholderText(i18n("Search in result..."));
-
- searchLineLayout->addStretch(0);
- mNumberOfEmailsFound = new QLabel;
- mNumberOfEmailsFound->setObjectName(QStringLiteral("numberofemailsfound"));
-
- searchLineLayout->addWidget(mNumberOfEmailsFound);
- searchLineLayout->addWidget(mSearchInResultLineEdit);
-
- QHBoxLayout *selectElementLayout = new QHBoxLayout;
- mainLayout->addLayout(selectElementLayout);
- mSelectButton = new QPushButton(i18n("&Select"), this);
- mSelectButton->setObjectName(QStringLiteral("select_email"));
- connect(mSelectButton, &QAbstractButton::clicked, this, &BlackListBalooEmailCompletionWidget::slotSelectEmails);
- selectElementLayout->addWidget(mSelectButton);
-
- mUnselectButton = new QPushButton(i18n("&Unselect"), this);
- mUnselectButton->setObjectName(QStringLiteral("unselect_email"));
- connect(mUnselectButton, &QAbstractButton::clicked, this, &BlackListBalooEmailCompletionWidget::slotUnselectEmails);
- selectElementLayout->addWidget(mUnselectButton);
-
- mMoreResult = new QLabel(i18n("<qt><a href=\"more_result\">More result...</a></qt>"), this);
- mMoreResult->setObjectName(QStringLiteral("moreresultlabel"));
- selectElementLayout->addWidget(mMoreResult);
-
- mMoreResult->setContextMenuPolicy(Qt::NoContextMenu);
- connect(mMoreResult, &QLabel::linkActivated, this, &BlackListBalooEmailCompletionWidget::slotLinkClicked);
- mMoreResult->setVisible(false);
- selectElementLayout->addStretch(1);
-
- connect(mSearchLineEdit, &QLineEdit::textChanged, this, &BlackListBalooEmailCompletionWidget::slotSearchLineEditChanged);
-
- QHBoxLayout *excludeDomainLayout = new QHBoxLayout;
- excludeDomainLayout->setMargin(0);
- mainLayout->addLayout(excludeDomainLayout);
-
- QLabel *excludeDomainLabel = new QLabel(i18n("Exclude domain names:"));
- excludeDomainLabel->setObjectName(QStringLiteral("domain_label"));
- excludeDomainLayout->addWidget(excludeDomainLabel);
-
- mExcludeDomainLineEdit = new KLineEdit;
- excludeDomainLayout->addWidget(mExcludeDomainLineEdit);
- mExcludeDomainLineEdit->setObjectName(QStringLiteral("domain_lineedit"));
- mExcludeDomainLineEdit->setClearButtonShown(true);
- mExcludeDomainLineEdit->setTrapReturnKey(true);
- mExcludeDomainLineEdit->setPlaceholderText(i18n("Separate domain with \'%1\'", QLatin1Char(',')));
-
- mBlackListWarning = new BlackListBalooEmailWarning(this);
- mBlackListWarning->setObjectName(QStringLiteral("backlistwarning"));
- mainLayout->addWidget(mBlackListWarning);
- connect(mBlackListWarning, &BlackListBalooEmailWarning::newSearch, this, &BlackListBalooEmailCompletionWidget::slotSearch);
- connect(mBlackListWarning, &BlackListBalooEmailWarning::saveChanges, this, &BlackListBalooEmailCompletionWidget::slotSaveChanges);
-
- connect(mEmailList, &QListWidget::itemSelectionChanged, this, &BlackListBalooEmailCompletionWidget::slotSelectionChanged);
- slotSelectionChanged();
-}
-
-BlackListBalooEmailCompletionWidget::~BlackListBalooEmailCompletionWidget()
-{
-
-}
-
-void BlackListBalooEmailCompletionWidget::slotSelectionChanged()
-{
- mSelectButton->setEnabled(!mEmailList->selectedItems().isEmpty());
- mUnselectButton->setEnabled(!mEmailList->selectedItems().isEmpty());
-}
-
-void BlackListBalooEmailCompletionWidget::load()
-{
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
- KConfigGroup group(config, "AddressLineEdit");
- const QStringList lst = group.readEntry("ExcludeDomain", QStringList());
- mEmailList->setExcludeDomain(lst);
- mExcludeDomainLineEdit->setText(lst.join(QStringLiteral(",")));
- mOriginalExcludeDomain = lst;
- slotSelectionChanged();
-}
-
-void BlackListBalooEmailCompletionWidget::slotUnselectEmails()
-{
- Q_FOREACH (QListWidgetItem *item, mEmailList->selectedItems()) {
- item->setCheckState(Qt::Unchecked);
- }
-}
-
-void BlackListBalooEmailCompletionWidget::slotSelectEmails()
-{
- Q_FOREACH (QListWidgetItem *item, mEmailList->selectedItems()) {
- item->setCheckState(Qt::Checked);
- }
-}
-
-void BlackListBalooEmailCompletionWidget::slotSearchLineEditChanged(const QString &text)
-{
- mSearchButton->setEnabled(text.trimmed().count() > 2);
- hideMoreResultAndChangeLimit();
-}
-
-void BlackListBalooEmailCompletionWidget::hideMoreResultAndChangeLimit()
-{
- mMoreResult->setVisible(false);
- mLimit = 500;
-}
-
-void BlackListBalooEmailCompletionWidget::slotSearch()
-{
- const QString searchEmail = mSearchLineEdit->text().trimmed();
- if (searchEmail.length() > 2) {
- mSearchInResultLineEdit->clear();
- KPIM::BlackListBalooEmailSearchJob *job = new KPIM::BlackListBalooEmailSearchJob(this);
- job->setSearchEmail(searchEmail);
- job->setLimit(mLimit);
- connect(job, &BlackListBalooEmailSearchJob::emailsFound, this, &BlackListBalooEmailCompletionWidget::slotEmailFound);
- job->start();
- }
-}
-
-void BlackListBalooEmailCompletionWidget::slotEmailFound(const QStringList &list)
-{
- mEmailList->setEmailFound(list);
- mMoreResult->setVisible(list.count() == mLimit);
- mEmailList->scrollToBottom();
- if (list.count() == 0) {
- mNumberOfEmailsFound->setText(i18n("No email found."));
- } else {
- mNumberOfEmailsFound->setText(i18np("1 email found", "%1 emails found", list.count()));
- }
-}
-
-void BlackListBalooEmailCompletionWidget::setEmailBlackList(const QStringList &list)
-{
- mEmailList->setEmailBlackList(list);
-}
-
-void BlackListBalooEmailCompletionWidget::slotSaveChanges()
-{
- //TODO avoid to save a lot.
- const QHash<QString, bool> result = mEmailList->blackListItemChanged();
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
- KConfigGroup group(config, "AddressLineEdit");
- QStringList blackList = group.readEntry("BalooBackList", QStringList());
- KPIM::BlackListBalooEmailUtil util;
- util.initialBlackList(blackList);
- util.newBlackList(result);
- blackList = util.createNewBlackList();
- group.writeEntry("BalooBackList", blackList);
- group.sync();
- mEmailList->setEmailBlackList(blackList);
- slotSearch();
-}
-
-void BlackListBalooEmailCompletionWidget::slotCheckIfUpdateBlackListIsNeeded()
-{
- const QHash<QString, bool> result = mEmailList->blackListItemChanged();
- if (result.isEmpty()) {
- slotSearch();
- } else {
- mBlackListWarning->animatedShow();
- }
-}
-
-void BlackListBalooEmailCompletionWidget::save()
-{
- const QString domain = mExcludeDomainLineEdit->text().remove(QLatin1Char(' '));
- const QStringList newExcludeDomain = domain.split(QStringLiteral(","), QString::SkipEmptyParts);
- bool needToSave = (mOriginalExcludeDomain != newExcludeDomain);
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
- KConfigGroup group(config, "AddressLineEdit");
- const QHash<QString, bool> result = mEmailList->blackListItemChanged();
- if (!result.isEmpty()) {
- needToSave = true;
- QStringList blackList = group.readEntry("BalooBackList", QStringList());
- KPIM::BlackListBalooEmailUtil util;
- util.initialBlackList(blackList);
- util.newBlackList(result);
- blackList = util.createNewBlackList();
- group.writeEntry("BalooBackList", blackList);
- }
- if (needToSave) {
- group.writeEntry("ExcludeDomain", newExcludeDomain);
- group.sync();
- }
-}
-
-void BlackListBalooEmailCompletionWidget::slotLinkClicked(const QString &link)
-{
- if (link == QLatin1String("more_result")) {
- mLimit += 200;
- slotSearch();
- }
-}
-
-void BlackListBalooEmailCompletionWidget::slotShowAllBlacklistedEmail()
-{
- KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kpimbalooblacklist"));
- KConfigGroup group(config, "AddressLineEdit");
- const QStringList balooBlackList = group.readEntry("BalooBackList", QStringList());
- slotEmailFound(balooBlackList);
-}
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.h
deleted file mode 100644
index 6b9c4d3..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILCOMPLETIONWIDGET_H
-#define BLACKLISTBALOOEMAILCOMPLETIONWIDGET_H
-
-#include <QWidget>
-class QPushButton;
-class KLineEdit;
-class QLabel;
-class KListWidgetSearchLine;
-namespace KPIM
-{
-class BlackListBalooEmailList;
-class BlackListBalooEmailWarning;
-class BlackListBalooEmailCompletionWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailCompletionWidget(QWidget *parent = Q_NULLPTR);
- ~BlackListBalooEmailCompletionWidget();
-
- void save();
- void load();
- void setEmailBlackList(const QStringList &list);
-private Q_SLOTS:
- void slotSelectionChanged();
- void slotUnselectEmails();
- void slotSelectEmails();
- void slotSearchLineEditChanged(const QString &text);
- void slotSearch();
- void slotLinkClicked(const QString &link);
- void slotEmailFound(const QStringList &list);
- void slotCheckIfUpdateBlackListIsNeeded();
- void slotSaveChanges();
- void slotShowAllBlacklistedEmail();
-private:
- void hideMoreResultAndChangeLimit();
- QStringList mOriginalExcludeDomain;
- QLabel *mNumberOfEmailsFound;
- KLineEdit *mSearchLineEdit;
- KLineEdit *mExcludeDomainLineEdit;
- BlackListBalooEmailList *mEmailList;
- QPushButton *mSearchButton;
- QPushButton *mSelectButton;
- QPushButton *mUnselectButton;
- QPushButton *mShowAllBlackListedEmails;
- QLabel *mMoreResult;
- KListWidgetSearchLine *mSearchInResultLineEdit;
- BlackListBalooEmailWarning *mBlackListWarning;
- int mLimit;
-};
-}
-
-#endif // BLACKLISTBALOOEMAILCOMPLETIONWIDGET_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.cpp
deleted file mode 100644
index 929cc38..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemaillist.h"
-#include "libkdepim_debug.h"
-#include <QPainter>
-#include <QEvent>
-#include <KLocalizedString>
-#include <KEmailAddress>
-using namespace KPIM;
-
-BlackListBalooEmailList::BlackListBalooEmailList(QWidget *parent)
- : QListWidget(parent),
- mFirstResult(false)
-{
- setSelectionMode(QAbstractItemView::ExtendedSelection);
- setSortingEnabled(true);
-}
-
-BlackListBalooEmailList::~BlackListBalooEmailList()
-{
-
-}
-
-void BlackListBalooEmailList::changeEvent(QEvent *event)
-{
- if (event->type() == QEvent::PaletteChange) {
- generalPaletteChanged();
- }
- QListWidget::changeEvent(event);
-}
-
-void BlackListBalooEmailList::setEmailBlackList(const QStringList &list)
-{
- mEmailBlackList = list;
-}
-
-QHash<QString, bool> BlackListBalooEmailList::blackListItemChanged() const
-{
- QHash<QString, bool> result;
- for (int i = 0; i < count(); ++i) {
- QListWidgetItem *element = item(i);
- KPIM::BlackListBalooEmailListItem *blackListItem = static_cast<KPIM::BlackListBalooEmailListItem *>(element);
- bool currentStatus = (blackListItem->checkState() == Qt::Checked);
- if (blackListItem->initializeStatus() != currentStatus) {
- result.insert(blackListItem->text(), currentStatus);
- }
- }
- return result;
-}
-
-void BlackListBalooEmailList::setExcludeDomain(const QStringList &domain)
-{
- mExcludeDomain = domain;
-}
-
-void BlackListBalooEmailList::setEmailFound(const QStringList &list)
-{
- mFirstResult = true;
- clear();
- QStringList emailsAdded;
- Q_FOREACH (const QString &mail, list) {
- bool excludeDomain = false;
- QString email, name;
- KEmailAddress::extractEmailAddressAndName(mail, email, name);
-
- Q_FOREACH (const QString &domain, mExcludeDomain) {
- if (email.endsWith(domain)) {
- excludeDomain = true;
- break;
- }
- }
- if (excludeDomain) {
- continue;
- }
- if (!emailsAdded.contains(mail)) {
- BlackListBalooEmailListItem *item = new BlackListBalooEmailListItem(this);
- if (mEmailBlackList.contains(mail)) {
- item->setCheckState(Qt::Checked);
- item->setInitializeStatus(true);
- } else {
- item->setCheckState(Qt::Unchecked);
- }
- item->setText(mail);
- emailsAdded << mail;
- }
- }
-}
-
-void BlackListBalooEmailList::generalPaletteChanged()
-{
- const QPalette palette = viewport()->palette();
- QColor color = palette.text().color();
- color.setAlpha(128);
- mTextColor = color;
-}
-
-void BlackListBalooEmailList::paintEvent(QPaintEvent *event)
-{
- if (mFirstResult && (!model() || model()->rowCount() == 0)) {
- QPainter p(viewport());
-
- QFont font = p.font();
- font.setItalic(true);
- p.setFont(font);
-
- if (!mTextColor.isValid()) {
- generalPaletteChanged();
- }
- p.setPen(mTextColor);
-
- p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, i18n("No result found"));
- } else {
- QListWidget::paintEvent(event);
- }
-}
-
-BlackListBalooEmailListItem::BlackListBalooEmailListItem(QListWidget *parent)
- : QListWidgetItem(parent),
- mInitializeStatus(false)
-{
- setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
-}
-
-BlackListBalooEmailListItem::~BlackListBalooEmailListItem()
-{
-
-}
-
-bool BlackListBalooEmailListItem::initializeStatus() const
-{
- return mInitializeStatus;
-}
-
-void BlackListBalooEmailListItem::setInitializeStatus(bool initializeStatus)
-{
- mInitializeStatus = initializeStatus;
-}
-
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.h
deleted file mode 100644
index 9329275..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemaillist.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILLIST_H
-#define BLACKLISTBALOOEMAILLIST_H
-
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QHash>
-#include "kdepim_export.h"
-
-namespace KPIM
-{
-
-class KDEPIM_EXPORT BlackListBalooEmailListItem : public QListWidgetItem
-{
-public:
- explicit BlackListBalooEmailListItem(QListWidget *parent = Q_NULLPTR);
- ~BlackListBalooEmailListItem();
-
- bool initializeStatus() const;
- void setInitializeStatus(bool initializeStatus);
-
-private:
- bool mInitializeStatus;
-};
-
-class KDEPIM_EXPORT BlackListBalooEmailList : public QListWidget
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailList(QWidget *parent = Q_NULLPTR);
- ~BlackListBalooEmailList();
-
- void setEmailBlackList(const QStringList &list);
-
- QHash<QString, bool> blackListItemChanged() const;
-
- void setExcludeDomain(const QStringList &domain);
- void setEmailFound(const QStringList &);
-protected:
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
-
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
-
-private:
- void generalPaletteChanged();
- QStringList mEmailBlackList;
- QStringList mExcludeDomain;
- QColor mTextColor;
- bool mFirstResult;
-};
-}
-
-#endif // BLACKLISTBALOOEMAILLIST_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp
deleted file mode 100644
index 0993808..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailsearchjob.h"
-
-#include <AkonadiSearch/PIM/contactcompleter.h>
-#include <QStringList>
-using namespace KPIM;
-
-BlackListBalooEmailSearchJob::BlackListBalooEmailSearchJob(QObject *parent)
- : QObject(parent),
- mLimit(500)
-{
-
-}
-
-BlackListBalooEmailSearchJob::~BlackListBalooEmailSearchJob()
-{
-
-}
-
-bool BlackListBalooEmailSearchJob::start()
-{
- const QString trimmedString = mSearchEmail.trimmed();
- if (trimmedString.isEmpty()) {
- deleteLater();
- return false;
- }
-
- Akonadi::Search::PIM::ContactCompleter com(trimmedString, mLimit);
- Q_EMIT emailsFound(com.complete());
- deleteLater();
- return true;
-}
-
-void BlackListBalooEmailSearchJob::setSearchEmail(const QString &searchEmail)
-{
- mSearchEmail = searchEmail;
-}
-
-void BlackListBalooEmailSearchJob::setLimit(int limit)
-{
- mLimit = qMax(10, limit);
-}
-
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.h
deleted file mode 100644
index 5292314..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailsearchjob.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILSEARCHJOB_H
-#define BLACKLISTBALOOEMAILSEARCHJOB_H
-
-#include <QObject>
-
-#include "kdepim_export.h"
-namespace KPIM
-{
-class KDEPIM_EXPORT BlackListBalooEmailSearchJob : public QObject
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailSearchJob(QObject *parent = Q_NULLPTR);
- ~BlackListBalooEmailSearchJob();
-
- bool start();
-
- void setSearchEmail(const QString &searchEmail);
-
- void setLimit(int limit);
-
-Q_SIGNALS:
- void emailsFound(const QStringList &list);
-
-private:
- QString mSearchEmail;
- int mLimit;
-};
-}
-
-#endif // BLACKLISTBALOOEMAILSEARCHJOB_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.cpp
deleted file mode 100644
index 78d904a..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailutil.h"
-
-using namespace KPIM;
-BlackListBalooEmailUtil::BlackListBalooEmailUtil()
-{
-
-}
-
-BlackListBalooEmailUtil::~BlackListBalooEmailUtil()
-{
-
-}
-
-void BlackListBalooEmailUtil::initialBlackList(const QStringList &blackList)
-{
- mInitialList = blackList;
-}
-
-void BlackListBalooEmailUtil::newBlackList(const QHash<QString, bool> &list)
-{
- mNewBlackList = list;
-}
-
-QStringList BlackListBalooEmailUtil::createNewBlackList()
-{
- if (mNewBlackList.isEmpty()) {
- return mInitialList;
- }
-
- QHashIterator<QString, bool> i(mNewBlackList);
- while (i.hasNext()) {
- i.next();
- const QString newEmail(i.key());
- if (i.value()) {
- if (!mInitialList.contains(newEmail)) {
- mInitialList.append(newEmail);
- }
- } else {
- if (mInitialList.contains(newEmail)) {
- mInitialList.removeAll(newEmail);
- }
- }
- }
- return mInitialList;
-}
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.h
deleted file mode 100644
index c510eb6..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailutil.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILUTIL_H
-#define BLACKLISTBALOOEMAILUTIL_H
-
-#include "kdepim_export.h"
-#include <QStringList>
-#include <QHash>
-namespace KPIM
-{
-class KDEPIM_EXPORT BlackListBalooEmailUtil
-{
-public:
- BlackListBalooEmailUtil();
- ~BlackListBalooEmailUtil();
- void initialBlackList(const QStringList &blackList);
- void newBlackList(const QHash<QString, bool> &);
- QStringList createNewBlackList();
-private:
- QStringList mInitialList;
- QHash<QString, bool> mNewBlackList;
-};
-}
-#endif // BLACKLISTBALOOEMAILUTIL_H
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.cpp b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.cpp
deleted file mode 100644
index db4439e..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "blacklistbalooemailwarning.h"
-#include <KLocalizedString>
-#include <QAction>
-
-using namespace KPIM;
-
-BlackListBalooEmailWarning::BlackListBalooEmailWarning(QWidget *parent)
- : KMessageWidget(parent)
-{
- setVisible(false);
- setCloseButtonVisible(false);
- setMessageType(Warning);
- setWordWrap(true);
-
- setText(i18n("The list was changed. Do you want to save before to make another search ?"));
- QAction *saveAction = new QAction(i18n("Save"), this);
- saveAction->setObjectName(QStringLiteral("saveblacklist"));
- connect(saveAction, &QAction::triggered, this, &BlackListBalooEmailWarning::slotSaveBlackList);
- addAction(saveAction);
-
- QAction *searchAction = new QAction(i18n("Search"), this);
- searchAction->setObjectName(QStringLiteral("search"));
- connect(searchAction, &QAction::triggered, this, &BlackListBalooEmailWarning::slotSearch);
- addAction(searchAction);
-}
-
-BlackListBalooEmailWarning::~BlackListBalooEmailWarning()
-{
-
-}
-
-void BlackListBalooEmailWarning::slotSaveBlackList()
-{
- animatedHide();
- Q_EMIT saveChanges();
-}
-
-void BlackListBalooEmailWarning::slotSearch()
-{
- animatedHide();
- Q_EMIT newSearch();
-}
diff --git a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.h b/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.h
deleted file mode 100644
index e3aa1a8..0000000
--- a/3rdparty/kdepim/libkdepim/blacklistbaloocompletion/blacklistbalooemailwarning.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef BLACKLISTBALOOEMAILWARNING_H
-#define BLACKLISTBALOOEMAILWARNING_H
-
-#include <KMessageWidget>
-
-namespace KPIM
-{
-class BlackListBalooEmailWarning : public KMessageWidget
-{
- Q_OBJECT
-public:
- explicit BlackListBalooEmailWarning(QWidget *parent = Q_NULLPTR);
- ~BlackListBalooEmailWarning();
-
-Q_SIGNALS:
- void newSearch();
- void saveChanges();
-
-private Q_SLOTS:
- void slotSaveBlackList();
- void slotSearch();
-};
-}
-#endif // BLACKLISTBALOOEMAILWARNING_H
diff --git a/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.cpp b/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.cpp
deleted file mode 100644
index 2ca3114..0000000
--- a/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "completionconfiguredialog.h"
-#include <KLocalizedString>
-#include <QVBoxLayout>
-#include <QDialogButtonBox>
-#include <QTabWidget>
-#include <KConfigGroup>
-#include <KSharedConfig>
-#include <ldap/ldapclientsearch.h>
-#include <completionorder/completionorderwidget.h>
-#include <blacklistbaloocompletion/blacklistbalooemailcompletionwidget.h>
-#include <recentaddress/recentaddresswidget.h>
-
-using namespace KPIM;
-
-class KPIM::CompletionConfigureDialogPrivate
-{
-public:
- CompletionConfigureDialogPrivate()
- : mTabWidget(Q_NULLPTR),
- mCompletionOrderWidget(Q_NULLPTR),
- mBlackListBalooWidget(Q_NULLPTR),
- mRecentaddressWidget(Q_NULLPTR)
- {
-
- }
-
- QTabWidget *mTabWidget;
- KPIM::CompletionOrderWidget *mCompletionOrderWidget;
- KPIM::BlackListBalooEmailCompletionWidget *mBlackListBalooWidget;
- KPIM::RecentAddressWidget *mRecentaddressWidget;
-};
-
-CompletionConfigureDialog::CompletionConfigureDialog(QWidget *parent)
- : QDialog(parent),
- d(new KPIM::CompletionConfigureDialogPrivate)
-{
- setWindowTitle(i18n("Configure completion"));
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
-
- d->mTabWidget = new QTabWidget;
- d->mTabWidget->setObjectName(QStringLiteral("tabwidget"));
- mainLayout->addWidget(d->mTabWidget);
-
- d->mCompletionOrderWidget = new KPIM::CompletionOrderWidget();
- d->mCompletionOrderWidget->setObjectName(QStringLiteral("completionorder_widget"));
- d->mTabWidget->addTab(d->mCompletionOrderWidget, i18n("Completion Order"));
-
- d->mRecentaddressWidget = new KPIM::RecentAddressWidget;
- d->mRecentaddressWidget->setObjectName(QStringLiteral("recentaddress_widget"));
- d->mTabWidget->addTab(d->mRecentaddressWidget, i18n("Recent Address"));
-
- d->mBlackListBalooWidget = new KPIM::BlackListBalooEmailCompletionWidget;
- d->mBlackListBalooWidget->setObjectName(QStringLiteral("blacklistbaloo_widget"));
- d->mTabWidget->addTab(d->mBlackListBalooWidget, i18n("Blacklist Email Address"));
-
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- buttonBox->setObjectName(QStringLiteral("buttonbox"));
- connect(buttonBox, &QDialogButtonBox::accepted, this, &CompletionConfigureDialog::slotSave);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
- mainLayout->addWidget(buttonBox);
- readConfig();
-}
-
-CompletionConfigureDialog::~CompletionConfigureDialog()
-{
- writeConfig();
- delete d;
-}
-
-void CompletionConfigureDialog::readConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "CompletionConfigureDialog");
- const QSize size = group.readEntry("Size", QSize(600, 400));
- if (size.isValid()) {
- resize(size);
- }
-}
-
-void CompletionConfigureDialog::writeConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "CompletionConfigureDialog");
- group.writeEntry("Size", size());
- group.sync();
-}
-
-void CompletionConfigureDialog::setRecentAddresses(const QStringList &lst)
-{
- d->mRecentaddressWidget->setAddresses(lst);
-}
-
-void CompletionConfigureDialog::setLdapClientSearch(KLDAP::LdapClientSearch *ldapSearch)
-{
- d->mCompletionOrderWidget->setLdapClientSearch(ldapSearch);
-}
-
-void CompletionConfigureDialog::load()
-{
- d->mCompletionOrderWidget->loadCompletionItems();
- d->mBlackListBalooWidget->load();
-}
-
-bool CompletionConfigureDialog::recentAddressWasChanged() const
-{
- return d->mRecentaddressWidget->wasChanged();
-}
-
-void CompletionConfigureDialog::storeAddresses(KConfig *config)
-{
- d->mRecentaddressWidget->storeAddresses(config);
-}
-
-void CompletionConfigureDialog::slotSave()
-{
- d->mBlackListBalooWidget->save();
- d->mCompletionOrderWidget->save();
- accept();
-}
-
-void CompletionConfigureDialog::setEmailBlackList(const QStringList &lst)
-{
- d->mBlackListBalooWidget->setEmailBlackList(lst);
-}
diff --git a/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.h b/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.h
deleted file mode 100644
index 4114b8e..0000000
--- a/3rdparty/kdepim/libkdepim/completionconfiguredialog/completionconfiguredialog.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef COMPLETIONCONFIGUREDIALOG_H
-#define COMPLETIONCONFIGUREDIALOG_H
-
-#include "kdepim_export.h"
-
-#include <QDialog>
-class KConfig;
-namespace KLDAP
-{
-class LdapClientSearch;
-}
-namespace KPIM
-{
-class CompletionConfigureDialogPrivate;
-class KDEPIM_EXPORT CompletionConfigureDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit CompletionConfigureDialog(QWidget *parent = Q_NULLPTR);
- ~CompletionConfigureDialog();
-
- void load();
- void setEmailBlackList(const QStringList &lst);
- void setLdapClientSearch(KLDAP::LdapClientSearch *ldapSearch);
- void setRecentAddresses(const QStringList &lst);
- bool recentAddressWasChanged() const;
- void storeAddresses(KConfig *config);
-private Q_SLOTS:
- void slotSave();
-
-private:
- void readConfig();
- void writeConfig();
- CompletionConfigureDialogPrivate *const d;
-};
-}
-
-#endif // COMPLETIONCONFIGUREDIALOG_H
diff --git a/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.cpp b/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.cpp
deleted file mode 100644
index 767cedf..0000000
--- a/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/** -*- c++ -*-
- * completionordereditor.cpp
- *
- * Copyright (c) 2004 David Faure <faure@kde.org>
- * 2010 Tobias Koenig <tokoe@kde.org>
- *
- * 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; version 2 of the License
- *
- * 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.
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of this program with any edition of
- * the Qt library by Trolltech AS, Norway (or with modified versions
- * of Qt that use the same license as Qt), and distribute linked
- * combinations including the two. You must obey the GNU General
- * Public License in all respects for all of the code used other than
- * Qt. If you modify this file, you may extend this exception to
- * your version of the file, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from
- * your version.
- */
-
-#include "completionordereditor.h"
-#include "completionorderwidget.h"
-#include <kdescendantsproxymodel.h>
-#include "ldap/ldapclient.h"
-#include "ldap/ldapclientsearch.h"
-#include "ldap/ldapclientsearchconfig.h"
-
-#include <kcontacts/addressee.h>
-#include <kcontacts/contactgroup.h>
-#include <kldap/ldapserver.h>
-
-#include <KConfigGroup>
-#include <KLocalizedString>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QtDBus/QDBusConnection>
-#include <QTreeWidget>
-#include <KSharedConfig>
-#include <QDialogButtonBox>
-
-using namespace KPIM;
-
-class KPIM::CompletionOrderEditorPrivate
-{
-public:
- CompletionOrderEditorPrivate()
- : mCompletionOrderWidget(Q_NULLPTR)
- {
-
- }
-
- CompletionOrderWidget *mCompletionOrderWidget;
-};
-
-CompletionOrderEditor::CompletionOrderEditor(KLDAP::LdapClientSearch *ldapSearch,
- QWidget *parent)
- : QDialog(parent), d(new KPIM::CompletionOrderEditorPrivate)
-{
- setWindowTitle(i18n("Edit Completion Order"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
- okButton->setDefault(true);
- okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &CompletionOrderEditor::slotOk);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &CompletionOrderEditor::reject);
- okButton->setDefault(true);
-
- QWidget *page = new QWidget(this);
- QHBoxLayout *pageHBoxLayout = new QHBoxLayout(page);
- pageHBoxLayout->setMargin(0);
-
- d->mCompletionOrderWidget = new CompletionOrderWidget(this);
- d->mCompletionOrderWidget->setObjectName(QStringLiteral("completionorderwidget"));
-
- mainLayout->addWidget(d->mCompletionOrderWidget);
- mainLayout->addWidget(buttonBox);
-
- d->mCompletionOrderWidget->setLdapClientSearch(ldapSearch);
-
- d->mCompletionOrderWidget->loadCompletionItems();
- readConfig();
-}
-
-CompletionOrderEditor::~CompletionOrderEditor()
-{
- writeConfig();
- delete d;
-}
-
-void CompletionOrderEditor::readConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "CompletionOrderEditor");
- const QSize size = group.readEntry("Size", QSize(600, 400));
- if (size.isValid()) {
- resize(size);
- }
-}
-
-void CompletionOrderEditor::writeConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "CompletionOrderEditor");
- group.writeEntry("Size", size());
- group.sync();
-}
-
-void CompletionOrderEditor::slotOk()
-{
- d->mCompletionOrderWidget->save();
- accept();
-}
-
diff --git a/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.h b/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.h
deleted file mode 100644
index 8a2eb84..0000000
--- a/3rdparty/kdepim/libkdepim/completionorder/completionordereditor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- c++ -*-
- * completionordereditor.h
- *
- * Copyright (c) 2004 David Faure <faure@kde.org>
- *
- * 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; version 2 of the License
- *
- * 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.
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of this program with any edition of
- * the Qt library by Trolltech AS, Norway (or with modified versions
- * of Qt that use the same license as Qt), and distribute linked
- * combinations including the two. You must obey the GNU General
- * Public License in all respects for all of the code used other than
- * Qt. If you modify this file, you may extend this exception to
- * your version of the file, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from
- * your version.
- */
-
-#ifndef KDEPIM_COMPLETIONORDEREDITOR_H
-#define KDEPIM_COMPLETIONORDEREDITOR_H
-
-#include "kdepim_export.h"
-#include <QDialog>
-
-namespace KLDAP
-{
-class LdapClientSearch;
-}
-
-namespace KPIM
-{
-class CompletionOrderEditorPrivate;
-class KDEPIM_EXPORT CompletionOrderEditor : public QDialog
-{
- Q_OBJECT
-
-public:
- CompletionOrderEditor(KLDAP::LdapClientSearch *ldapSearch, QWidget *parent);
- ~CompletionOrderEditor();
-
-private Q_SLOTS:
- void slotOk();
-
-private:
- void readConfig();
- void writeConfig();
- CompletionOrderEditorPrivate *const d;
-};
-
-} // namespace
-
-#endif /* COMPLETIONORDEREDITOR_H */
-
diff --git a/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.cpp b/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.cpp
deleted file mode 100644
index 80773a2..0000000
--- a/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "completionorderwidget.h"
-
-#include <kdescendantsproxymodel.h>
-#include "ldap/ldapclient.h"
-#include "ldap/ldapclientsearch.h"
-#include "ldap/ldapclientsearchconfig.h"
-
-#include <AkonadiCore/ChangeRecorder>
-#include <AkonadiCore/CollectionFilterProxyModel>
-#include <AkonadiCore/EntityTreeModel>
-#include <AkonadiCore/Monitor>
-
-#include <KContacts/Addressee>
-#include <KContacts/ContactGroup>
-#include <kldap/ldapserver.h>
-
-#include <KConfigGroup>
-#include <KLocalizedString>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QHBoxLayout>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QToolButton>
-#include <QDBusConnection>
-
-using namespace KPIM;
-
-CompletionOrderEditorAdaptor::CompletionOrderEditorAdaptor(QObject *parent)
- : QDBusAbstractAdaptor(parent)
-{
- setAutoRelaySignals(true);
-}
-
-class LDAPCompletionItem : public CompletionItem
-{
-public:
- LDAPCompletionItem(KLDAP::LdapClient *ldapClient)
- : mLdapClient(ldapClient)
- {
- mWeight = mLdapClient->completionWeight();
- }
-
- QString label() const Q_DECL_OVERRIDE
- {
- return i18n("LDAP server %1", mLdapClient->server().host());
- }
-
- QIcon icon() const Q_DECL_OVERRIDE
- {
- return QIcon::fromTheme(QStringLiteral("view-ldap-resource"));
- }
-
- int completionWeight() const Q_DECL_OVERRIDE
- {
- return mWeight;
- }
-
- void save(CompletionOrderWidget *) Q_DECL_OVERRIDE {
- KConfig *config = KLDAP::LdapClientSearchConfig::config();
- KConfigGroup group(config, "LDAP");
- group.writeEntry(QStringLiteral("SelectedCompletionWeight%1").arg(mLdapClient->clientNumber()),
- mWeight);
- group.sync();
- }
-
- bool hasEnableSupport() const Q_DECL_OVERRIDE
- {
- return false;
- }
-
- bool isEnabled() const Q_DECL_OVERRIDE
- {
- return true;
- }
-
- void setIsEnabled(bool b) Q_DECL_OVERRIDE {
- Q_UNUSED(b);
- }
-
-protected:
- void setCompletionWeight(int weight) Q_DECL_OVERRIDE {
- mWeight = weight;
- }
-
-private:
- KLDAP::LdapClient *mLdapClient;
- int mWeight;
-};
-
-class SimpleCompletionItem : public CompletionItem
-{
-public:
- SimpleCompletionItem(CompletionOrderWidget *editor, const QString &label, const QString &identifier, int weight, bool enableSupport = false)
- : mLabel(label), mIdentifier(identifier), mHasEnableSupport(enableSupport), mEnabled(true)
- {
- KConfigGroup groupCompletionWeights(editor->configFile(), "CompletionWeights");
- mWeight = groupCompletionWeights.readEntry(mIdentifier, weight);
- if (mHasEnableSupport) {
- KConfigGroup groupEnabled(editor->configFile(), "CompletionEnabled");
- mEnabled = groupEnabled.readEntry(mIdentifier, true);
- }
- }
-
- bool isEnabled() const Q_DECL_OVERRIDE
- {
- return mEnabled;
- }
-
- bool hasEnableSupport() const Q_DECL_OVERRIDE
- {
- return mHasEnableSupport;
- }
-
- void setIcon(const QIcon &icon)
- {
- mIcon = icon;
- }
-
- QString label() const Q_DECL_OVERRIDE
- {
- return mLabel;
- }
-
- QIcon icon() const Q_DECL_OVERRIDE
- {
- return mIcon;
- }
-
- int completionWeight() const Q_DECL_OVERRIDE
- {
- return mWeight;
- }
-
- void setIsEnabled(bool b) Q_DECL_OVERRIDE {
- mEnabled = b;
- }
-
- void save(CompletionOrderWidget *editor) Q_DECL_OVERRIDE {
- KConfigGroup group(editor->configFile(), "CompletionWeights");
- group.writeEntry(mIdentifier, mWeight);
- if (mHasEnableSupport)
- {
- KConfigGroup groupEnabled(editor->configFile(), "CompletionEnabled");
- //groupEnabled.writeEntry(mIdentifier, );
- }
- }
-
-protected:
- void setCompletionWeight(int weight) Q_DECL_OVERRIDE {
- mWeight = weight;
- }
-
-private:
- QString mLabel;
- QString mIdentifier;
- int mWeight;
- QIcon mIcon;
- bool mHasEnableSupport;
- bool mEnabled;
-};
-
-/////////
-
-class CompletionViewItem : public QTreeWidgetItem
-{
-public:
- CompletionViewItem(QTreeWidget *parent, CompletionItem *item)
- : QTreeWidgetItem(parent)
- {
- setItem(item);
- }
-
- void setItem(CompletionItem *item)
- {
- mItem = item;
- setText(0, mItem->label());
- setIcon(0, mItem->icon());
- if (mItem->hasEnableSupport()) {
- setFlags(flags() | Qt::ItemIsUserCheckable);
- setCheckState(0, mItem->isEnabled() ? Qt::Checked : Qt::Unchecked);
- } else {
- setFlags(flags() & ~ Qt::ItemIsUserCheckable);
- }
-
- }
-
- CompletionItem *item() const
- {
- return mItem;
- }
-
- bool operator<(const QTreeWidgetItem &other) const Q_DECL_OVERRIDE
- {
- const QTreeWidgetItem *otherItem = &other;
- const CompletionViewItem *completionItem = static_cast<const CompletionViewItem *>(otherItem);
- // item with weight 100 should be on the top -> reverse sorting
- return (mItem->completionWeight() > completionItem->item()->completionWeight());
- }
-
-private:
- CompletionItem *mItem;
-};
-
-CompletionOrderWidget::CompletionOrderWidget(QWidget *parent)
- : QWidget(parent),
- mConfig(QStringLiteral("kpimcompletionorder")),
- mCollectionModel(Q_NULLPTR),
- mLdapSearch(0),
- mDirty(false)
-{
- new CompletionOrderEditorAdaptor(this);
- QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), this, QDBusConnection::ExportAdaptors);
-
- QHBoxLayout *hbox = new QHBoxLayout;
- setLayout(hbox);
-
- QWidget *page = new QWidget(this);
- QHBoxLayout *pageHBoxLayout = new QHBoxLayout(page);
- pageHBoxLayout->setMargin(0);
- hbox->addWidget(page);
- mListView = new QTreeWidget(page);
- mListView->setObjectName(QStringLiteral("listview"));
-
- pageHBoxLayout->addWidget(mListView);
- mListView->setColumnCount(1);
- mListView->setAlternatingRowColors(true);
- mListView->setIndentation(0);
- mListView->setAllColumnsShowFocus(true);
- mListView->setHeaderHidden(true);
- mListView->setSortingEnabled(true);
-
- QWidget *upDownBox = new QWidget(page);
- QVBoxLayout *upDownBoxVBoxLayout = new QVBoxLayout(upDownBox);
- upDownBoxVBoxLayout->setMargin(0);
- pageHBoxLayout->addWidget(upDownBox);
- mUpButton = new QPushButton(upDownBox);
- upDownBoxVBoxLayout->addWidget(mUpButton);
- mUpButton->setAutoRepeat(true);
- mUpButton->setObjectName(QStringLiteral("mUpButton"));
- mUpButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up")));
- mUpButton->setEnabled(false); // b/c no item is selected yet
- mUpButton->setFocusPolicy(Qt::StrongFocus);
-
- mDownButton = new QPushButton(upDownBox);
- upDownBoxVBoxLayout->addWidget(mDownButton);
- mDownButton->setAutoRepeat(true);
- mDownButton->setObjectName(QStringLiteral("mDownButton"));
- mDownButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down")));
- mDownButton->setEnabled(false); // b/c no item is selected yet
- mDownButton->setFocusPolicy(Qt::StrongFocus);
-
- QWidget *spacer = new QWidget(upDownBox);
- upDownBoxVBoxLayout->addWidget(spacer);
- upDownBoxVBoxLayout->setStretchFactor(spacer, 100);
-
- connect(mListView, &QTreeWidget::itemSelectionChanged,
- this, &CompletionOrderWidget::slotSelectionChanged);
- connect(mListView, &QTreeWidget::currentItemChanged,
- this, &CompletionOrderWidget::slotSelectionChanged);
- connect(mUpButton, &QAbstractButton::clicked, this, &CompletionOrderWidget::slotMoveUp);
- connect(mDownButton, &QAbstractButton::clicked, this, &CompletionOrderWidget::slotMoveDown);
-
-}
-
-CompletionOrderWidget::~CompletionOrderWidget()
-{
-}
-
-void CompletionOrderWidget::save()
-{
- if (mDirty) {
- int w = 100;
- //Clean up order
- KConfigGroup group(configFile(), "CompletionWeights");
- group.deleteGroup();
-
- for (int itemIndex = 0; itemIndex < mListView->topLevelItemCount(); ++itemIndex) {
- CompletionViewItem *item =
- static_cast<CompletionViewItem *>(mListView->topLevelItem(itemIndex));
- item->item()->setCompletionWeight(w);
- item->item()->setIsEnabled(item->checkState(0) == Qt::Checked);
- item->item()->save(this);
- --w;
- }
- Q_EMIT completionOrderChanged();
- }
-}
-
-KConfig *CompletionOrderWidget::configFile()
-{
- return &mConfig;
-}
-
-void CompletionOrderWidget::addRecentAddressItem()
-{
- //Be default it's the first.
- SimpleCompletionItem *item = new SimpleCompletionItem(this, i18n("Recent Addresses"), QStringLiteral("Recent Addresses"), 10);
- item->setIcon(QIcon::fromTheme(QStringLiteral("kmail")));
- new CompletionViewItem(mListView, item);
-}
-
-void CompletionOrderWidget::addCompletionItemForCollection(const QModelIndex &index)
-{
- const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
- if (!collection.isValid()) {
- return;
- }
-
- SimpleCompletionItem *item = new SimpleCompletionItem(this, index.data().toString(), QString::number(collection.id()), 60);
- item->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
-
- new CompletionViewItem(mListView, item);
-}
-
-void CompletionOrderWidget::loadCompletionItems()
-{
- if (mLdapSearch) {
- // The first step is to gather all the data, creating CompletionItem objects
- foreach (KLDAP::LdapClient *client, mLdapSearch->clients()) {
- new CompletionViewItem(mListView, new LDAPCompletionItem(client));
- }
- }
-
- Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(this);
- monitor->fetchCollection(true);
- monitor->setCollectionMonitored(Akonadi::Collection::root());
- monitor->setMimeTypeMonitored(KContacts::Addressee::mimeType(), true);
- monitor->setMimeTypeMonitored(KContacts::ContactGroup::mimeType(), true);
-
- Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel(monitor, this);
- model->setItemPopulationStrategy(Akonadi::EntityTreeModel::NoItemPopulation);
-
- KDescendantsProxyModel *descendantsProxy = new KDescendantsProxyModel(this);
- descendantsProxy->setDisplayAncestorData(true);
- descendantsProxy->setSourceModel(model);
-
- Akonadi::CollectionFilterProxyModel *mimeTypeProxy = new Akonadi::CollectionFilterProxyModel(this);
- mimeTypeProxy->addMimeTypeFilters(QStringList() << KContacts::Addressee::mimeType()
- << KContacts::ContactGroup::mimeType());
- mimeTypeProxy->setSourceModel(descendantsProxy);
- mimeTypeProxy->setExcludeVirtualCollections(true);
-
- mCollectionModel = mimeTypeProxy;
-
- connect(mimeTypeProxy, &QAbstractItemModel::rowsInserted,
- this, &CompletionOrderWidget::rowsInserted);
-
- for (int row = 0; row < mCollectionModel->rowCount(); ++row) {
- addCompletionItemForCollection(mCollectionModel->index(row, 0));
- }
-
- addRecentAddressItem();
-
- mListView->sortItems(0, Qt::AscendingOrder);
-}
-
-void CompletionOrderWidget::setLdapClientSearch(KLDAP::LdapClientSearch *ldapSearch)
-{
- mLdapSearch = ldapSearch;
-}
-
-void CompletionOrderWidget::rowsInserted(const QModelIndex &parent, int start, int end)
-{
- for (int row = start; row <= end; ++row) {
- addCompletionItemForCollection(mCollectionModel->index(row, 0, parent));
- }
-
- mListView->sortItems(0, Qt::AscendingOrder);
-}
-
-void CompletionOrderWidget::slotSelectionChanged()
-{
- QTreeWidgetItem *item = mListView->currentItem();
- mDownButton->setEnabled(item && mListView->itemBelow(item));
- mUpButton->setEnabled(item && mListView->itemAbove(item));
-}
-
-static void swapItems(CompletionViewItem *one, CompletionViewItem *other)
-{
- CompletionItem *oneCompletion = one->item();
- CompletionItem *otherCompletion = other->item();
-
- int weight = otherCompletion->completionWeight();
- otherCompletion->setCompletionWeight(oneCompletion->completionWeight());
- oneCompletion->setCompletionWeight(weight);
-
- one->setItem(otherCompletion);
- other->setItem(oneCompletion);
-}
-
-void CompletionOrderWidget::slotMoveUp()
-{
- CompletionViewItem *item = static_cast<CompletionViewItem *>(mListView->currentItem());
- if (!item) {
- return;
- }
- CompletionViewItem *above = static_cast<CompletionViewItem *>(mListView->itemAbove(item));
- if (!above) {
- return;
- }
- swapItems(item, above);
- mListView->setCurrentItem(above, 0, QItemSelectionModel::Select | QItemSelectionModel::Current);
- mListView->sortItems(0, Qt::AscendingOrder);
- mDirty = true;
-}
-
-void CompletionOrderWidget::slotMoveDown()
-{
- CompletionViewItem *item = static_cast<CompletionViewItem *>(mListView->currentItem());
- if (!item) {
- return;
- }
- CompletionViewItem *below = static_cast<CompletionViewItem *>(mListView->itemBelow(item));
- if (!below) {
- return;
- }
- swapItems(item, below);
- mListView->setCurrentItem(below);
- mListView->setCurrentItem(below, 0, QItemSelectionModel::Select | QItemSelectionModel::Current);
- mListView->sortItems(0, Qt::AscendingOrder);
- mDirty = true;
-}
diff --git a/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.h b/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.h
deleted file mode 100644
index cb1c0a9..0000000
--- a/3rdparty/kdepim/libkdepim/completionorder/completionorderwidget.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef COMPLETIONORDERWIDGET_H
-#define COMPLETIONORDERWIDGET_H
-
-#include <QWidget>
-#include "kdepim_export.h"
-#include <QDBusAbstractAdaptor>
-#include <KConfig>
-
-class QPushButton;
-class QAbstractItemModel;
-class QModelIndex;
-class QTreeWidget;
-
-namespace KLDAP
-{
-class LdapClientSearch;
-}
-
-namespace KPIM
-{
-
-class CompletionOrderEditorAdaptor : public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.kde.pim.CompletionOrder")
-public:
- explicit CompletionOrderEditorAdaptor(QObject *parent);
-Q_SIGNALS:
- void completionOrderChanged();
-};
-
-class CompletionOrderWidget;
-
-// Base class for items in the list
-class CompletionItem
-{
-public:
- virtual ~CompletionItem() {}
- virtual QString label() const = 0;
- virtual QIcon icon() const = 0;
- virtual int completionWeight() const = 0;
- virtual void setCompletionWeight(int weight) = 0;
- virtual void save(CompletionOrderWidget *) = 0;
- virtual bool hasEnableSupport() const = 0;
- virtual bool isEnabled() const = 0;
- virtual void setIsEnabled(bool b) = 0;
-};
-
-class KDEPIM_EXPORT CompletionOrderWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit CompletionOrderWidget(QWidget *parent = Q_NULLPTR);
- ~CompletionOrderWidget();
- void save();
-
- KConfig *configFile();
- void loadCompletionItems();
- void setLdapClientSearch(KLDAP::LdapClientSearch *ldapSearch);
-
-Q_SIGNALS:
- void completionOrderChanged();
-
-private Q_SLOTS:
- void rowsInserted(const QModelIndex &parent, int start, int end);
- void slotSelectionChanged();
- void slotMoveUp();
- void slotMoveDown();
-
-private:
- void readConfig();
- void writeConfig();
- void addRecentAddressItem();
- void addCompletionItemForCollection(const QModelIndex &);
-
- KConfig mConfig;
- QTreeWidget *mListView;
- QPushButton *mUpButton;
- QPushButton *mDownButton;
- QAbstractItemModel *mCollectionModel;
- KLDAP::LdapClientSearch *mLdapSearch;
-
- bool mDirty;
-
-};
-}
-
-#endif // COMPLETIONORDERWIDGET_H
diff --git a/3rdparty/kdepim/libkdepim/ldap/addhostdialog.cpp b/3rdparty/kdepim/libkdepim/ldap/addhostdialog.cpp
deleted file mode 100644
index 0378118..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/addhostdialog.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- This file is part of libkldap.
-
- Copyright (c) 2002-2010 Tobias Koenig <tokoe@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "addhostdialog.h"
-
-#include <QHBoxLayout>
-#include <KSharedConfig>
-#include <kacceleratormanager.h>
-#include <kldap/ldapserver.h>
-#include <kldap/ldapconfigwidget.h>
-#include <KLocalizedString>
-#include <QDialogButtonBox>
-#include <KConfigGroup>
-#include <QPushButton>
-#include <QVBoxLayout>
-
-using namespace KLDAP;
-class KLDAP::AddHostDialogPrivate
-{
-public:
- AddHostDialogPrivate(AddHostDialog *qq)
- : mCfg(Q_NULLPTR),
- mServer(Q_NULLPTR),
- mOkButton(Q_NULLPTR),
- q(qq)
- {
- }
- ~AddHostDialogPrivate()
- {
- writeConfig();
- }
-
- void readConfig();
- void writeConfig();
- KLDAP::LdapConfigWidget *mCfg;
- KLDAP::LdapServer *mServer;
- QPushButton *mOkButton;
- AddHostDialog *q;
-};
-
-void AddHostDialogPrivate::readConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "AddHostDialog");
- const QSize size = group.readEntry("Size", QSize(600, 400));
- if (size.isValid()) {
- q->resize(size);
- }
-}
-
-void AddHostDialogPrivate::writeConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "AddHostDialog");
- group.writeEntry("Size", q->size());
- group.sync();
-}
-
-AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
- : QDialog(parent),
- d(new KLDAP::AddHostDialogPrivate(this))
-{
- setWindowTitle(i18n("Add Host"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- d->mOkButton = buttonBox->button(QDialogButtonBox::Ok);
- d->mOkButton->setDefault(true);
- d->mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &AddHostDialog::reject);
- d->mOkButton->setDefault(true);
- setModal(true);
-
- d->mServer = server;
-
- QWidget *page = new QWidget(this);
- mainLayout->addWidget(page);
- mainLayout->addWidget(buttonBox);
- QHBoxLayout *layout = new QHBoxLayout(page);
- layout->setMargin(0);
-
- d->mCfg = new KLDAP::LdapConfigWidget(
- KLDAP::LdapConfigWidget::W_USER |
- KLDAP::LdapConfigWidget::W_PASS |
- KLDAP::LdapConfigWidget::W_BINDDN |
- KLDAP::LdapConfigWidget::W_REALM |
- KLDAP::LdapConfigWidget::W_HOST |
- KLDAP::LdapConfigWidget::W_PORT |
- KLDAP::LdapConfigWidget::W_VER |
- KLDAP::LdapConfigWidget::W_TIMELIMIT |
- KLDAP::LdapConfigWidget::W_SIZELIMIT |
- KLDAP::LdapConfigWidget::W_PAGESIZE |
- KLDAP::LdapConfigWidget::W_DN |
- KLDAP::LdapConfigWidget::W_FILTER |
- KLDAP::LdapConfigWidget::W_SECBOX |
- KLDAP::LdapConfigWidget::W_AUTHBOX,
- page);
-
- layout->addWidget(d->mCfg);
- d->mCfg->setHost(d->mServer->host());
- d->mCfg->setPort(d->mServer->port());
- d->mCfg->setDn(d->mServer->baseDn());
- d->mCfg->setUser(d->mServer->user());
- d->mCfg->setBindDn(d->mServer->bindDn());
- d->mCfg->setPassword(d->mServer->password());
- d->mCfg->setTimeLimit(d->mServer->timeLimit());
- d->mCfg->setSizeLimit(d->mServer->sizeLimit());
- d->mCfg->setPageSize(d->mServer->pageSize());
- d->mCfg->setVersion(d->mServer->version());
- d->mCfg->setFilter(d->mServer->filter());
- switch (d->mServer->security()) {
- case KLDAP::LdapServer::TLS:
- d->mCfg->setSecurity(KLDAP::LdapConfigWidget::TLS);
- break;
- case KLDAP::LdapServer::SSL:
- d->mCfg->setSecurity(KLDAP::LdapConfigWidget::SSL);
- break;
- default:
- d->mCfg->setSecurity(KLDAP::LdapConfigWidget::None);
- }
-
- switch (d->mServer->auth()) {
- case KLDAP::LdapServer::Simple:
- d->mCfg->setAuth(KLDAP::LdapConfigWidget::Simple);
- break;
- case KLDAP::LdapServer::SASL:
- d->mCfg->setAuth(KLDAP::LdapConfigWidget::SASL);
- break;
- default:
- d->mCfg->setAuth(KLDAP::LdapConfigWidget::Anonymous);
- }
- d->mCfg->setMech(d->mServer->mech());
-
- KAcceleratorManager::manage(this);
- connect(d->mCfg, &KLDAP::LdapConfigWidget::hostNameChanged, this, &AddHostDialog::slotHostEditChanged);
- connect(d->mOkButton, &QPushButton::clicked, this, &AddHostDialog::slotOk);
- d->mOkButton->setEnabled(!d->mServer->host().isEmpty());
- d->readConfig();
-}
-
-AddHostDialog::~AddHostDialog()
-{
- delete d;
-}
-
-void AddHostDialog::slotHostEditChanged(const QString &text)
-{
- d->mOkButton->setEnabled(!text.isEmpty());
-}
-
-void AddHostDialog::slotOk()
-{
- d->mServer->setHost(d->mCfg->host());
- d->mServer->setPort(d->mCfg->port());
- d->mServer->setBaseDn(d->mCfg->dn());
- d->mServer->setUser(d->mCfg->user());
- d->mServer->setBindDn(d->mCfg->bindDn());
- d->mServer->setPassword(d->mCfg->password());
- d->mServer->setTimeLimit(d->mCfg->timeLimit());
- d->mServer->setSizeLimit(d->mCfg->sizeLimit());
- d->mServer->setPageSize(d->mCfg->pageSize());
- d->mServer->setVersion(d->mCfg->version());
- d->mServer->setFilter(d->mCfg->filter());
- switch (d->mCfg->security()) {
- case KLDAP::LdapConfigWidget::TLS:
- d->mServer->setSecurity(KLDAP::LdapServer::TLS);
- break;
- case KLDAP::LdapConfigWidget::SSL:
- d->mServer->setSecurity(KLDAP::LdapServer::SSL);
- break;
- default:
- d->mServer->setSecurity(KLDAP::LdapServer::None);
- }
- switch (d->mCfg->auth()) {
- case KLDAP::LdapConfigWidget::Simple:
- d->mServer->setAuth(KLDAP::LdapServer::Simple);
- break;
- case KLDAP::LdapConfigWidget::SASL:
- d->mServer->setAuth(KLDAP::LdapServer::SASL);
- break;
- default:
- d->mServer->setAuth(KLDAP::LdapServer::Anonymous);
- }
- d->mServer->setMech(d->mCfg->mech());
- QDialog::accept();
-}
-
-#include "moc_addhostdialog.cpp"
diff --git a/3rdparty/kdepim/libkdepim/ldap/addhostdialog.h b/3rdparty/kdepim/libkdepim/ldap/addhostdialog.h
deleted file mode 100644
index d4e9c08..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/addhostdialog.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of libkldap.
-
- Copyright (c) 2002-2010 Tobias Koenig <tokoe@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef ADDHOSTDIALOG_H
-#define ADDHOSTDIALOG_H
-
-#include "kdepim_export.h"
-#include <qdialog.h>
-
-namespace KLDAP
-{
-class LdapServer;
-class AddHostDialogPrivate;
-class KDEPIM_EXPORT AddHostDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit AddHostDialog(KLDAP::LdapServer *server, QWidget *parent = Q_NULLPTR);
- ~AddHostDialog();
-
-Q_SIGNALS:
- void changed(bool);
-
-private Q_SLOTS:
- void slotHostEditChanged(const QString &);
- void slotOk();
-
-private:
- AddHostDialogPrivate *const d;
-};
-
-}
-
-#endif // ADDHOSTDIALOG_H
diff --git a/3rdparty/kdepim/libkdepim/ldap/kcmldap.cpp b/3rdparty/kdepim/libkdepim/ldap/kcmldap.cpp
deleted file mode 100644
index 3858161..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/kcmldap.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- This file is part of libkldap.
-
- Copyright (c) 2002-2009 Tobias Koenig <tokoe@kde.org>
- Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "kcmldap_p.h"
-
-#include <QGroupBox>
-#include <QLabel>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QToolButton>
-#include <QVBoxLayout>
-#include <QPushButton>
-
-#include <KAboutData>
-#include <kconfig.h>
-#include <kconfiggroup.h>
-#include <qdialogbuttonbox.h>
-#include <KPluginFactory>
-#include <QHBoxLayout>
-#include <kiconloader.h>
-#include <KLocalizedString>
-#include <KMessageBox>
-
-#include "ldapclientsearch.h"
-#include "ldapclientsearchconfig.h"
-#include <kldap/ldapserver.h>
-
-#include "addhostdialog.h"
-
-K_PLUGIN_FACTORY_WITH_JSON(KCMLdapFactory, "kcmldap.json", registerPlugin<KCMLdap>();)
-
-class LDAPItem : public QListWidgetItem
-{
-public:
- LDAPItem(QListWidget *parent, const KLDAP::LdapServer &server, bool isActive = false)
- : QListWidgetItem(parent, QListWidgetItem::UserType),
- mIsActive(isActive)
- {
- setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
- setCheckState(isActive ? Qt::Checked : Qt::Unchecked);
- setServer(server);
- }
-
- void setServer(const KLDAP::LdapServer &server)
- {
- mServer = server;
-
- setText(mServer.host());
- }
-
- const KLDAP::LdapServer &server() const
- {
- return mServer;
- }
-
- void setIsActive(bool isActive)
- {
- mIsActive = isActive;
- }
- bool isActive() const
- {
- return mIsActive;
- }
-
-private:
- KLDAP::LdapServer mServer;
- bool mIsActive;
-};
-
-KCMLdap::KCMLdap(QWidget *parent, const QVariantList &)
- : KCModule(parent)
-{
- setButtons(KCModule::Apply);
- KAboutData *about = new KAboutData(QStringLiteral("kcmldap"),
- i18n("kcmldap"),
- QString(),
- i18n("LDAP Server Settings"),
- KAboutLicense::LGPL,
- i18n("(c) 2009 - 2010 Tobias Koenig"));
- about->addAuthor(i18n("Tobias Koenig"), QString(), QStringLiteral("tokoe@kde.org"));
- setAboutData(about);
-
- mClientSearchConfig = new KLDAP::LdapClientSearchConfig;
- initGUI();
-
- connect(mHostListView, &QListWidget::currentItemChanged, this, &KCMLdap::slotSelectionChanged);
- connect(mHostListView, &QListWidget::itemDoubleClicked, this, &KCMLdap::slotEditHost);
- connect(mHostListView, &QListWidget::itemClicked, this, &KCMLdap::slotItemClicked);
-
- connect(mUpButton, &QToolButton::clicked, this, &KCMLdap::slotMoveUp);
- connect(mDownButton, &QToolButton::clicked, this, &KCMLdap::slotMoveDown);
-}
-
-KCMLdap::~KCMLdap()
-{
- delete mClientSearchConfig;
-}
-
-void KCMLdap::slotSelectionChanged(QListWidgetItem *item)
-{
- bool state = (item != Q_NULLPTR);
- mEditButton->setEnabled(state);
- mRemoveButton->setEnabled(state);
- mDownButton->setEnabled(item && (mHostListView->row(item) != (mHostListView->count() - 1)));
- mUpButton->setEnabled(item && (mHostListView->row(item) != 0));
-}
-
-void KCMLdap::slotItemClicked(QListWidgetItem *item)
-{
- LDAPItem *ldapItem = dynamic_cast<LDAPItem *>(item);
- if (!ldapItem) {
- return;
- }
-
- if ((ldapItem->checkState() == Qt::Checked) != ldapItem->isActive()) {
- Q_EMIT changed(true);
- ldapItem->setIsActive(ldapItem->checkState() == Qt::Checked);
- }
-}
-
-void KCMLdap::slotAddHost()
-{
- KLDAP::LdapServer server;
- KLDAP::AddHostDialog dlg(&server, dialogParent());
-
- if (dlg.exec() && !server.host().isEmpty()) { //krazy:exclude=crashy
- new LDAPItem(mHostListView, server);
-
- Q_EMIT changed(true);
- }
-}
-
-void KCMLdap::slotEditHost()
-{
- LDAPItem *item = dynamic_cast<LDAPItem *>(mHostListView->currentItem());
- if (!item) {
- return;
- }
-
- KLDAP::LdapServer server = item->server();
- KLDAP::AddHostDialog dlg(&server, dialogParent());
- dlg.setWindowTitle(i18n("Edit Host"));
-
- if (dlg.exec() && !server.host().isEmpty()) { //krazy:exclude=crashy
- item->setServer(server);
-
- Q_EMIT changed(true);
- }
-}
-
-void KCMLdap::slotRemoveHost()
-{
- QListWidgetItem *item = mHostListView->currentItem();
- if (!item) {
- return;
- }
- LDAPItem *ldapItem = dynamic_cast<LDAPItem *>(item);
- if (KMessageBox::No == KMessageBox::questionYesNo(this, i18n("Do you want to remove setting for host \"%1\"?", ldapItem->server().host()), i18n("Remove Host"))) {
- return;
- }
-
- delete mHostListView->takeItem(mHostListView->currentRow());
-
- slotSelectionChanged(mHostListView->currentItem());
-
- Q_EMIT changed(true);
-}
-
-static void swapItems(LDAPItem *item, LDAPItem *other)
-{
- KLDAP::LdapServer server = item->server();
- bool isActive = item->isActive();
- item->setServer(other->server());
- item->setIsActive(other->isActive());
- item->setCheckState(other->isActive() ? Qt::Checked : Qt::Unchecked);
- other->setServer(server);
- other->setIsActive(isActive);
- other->setCheckState(isActive ? Qt::Checked : Qt::Unchecked);
-}
-
-void KCMLdap::slotMoveUp()
-{
- const QList<QListWidgetItem *> selectedItems = mHostListView->selectedItems();
- if (selectedItems.isEmpty()) {
- return;
- }
-
- LDAPItem *item = static_cast<LDAPItem *>(mHostListView->selectedItems().first());
- if (!item) {
- return;
- }
-
- LDAPItem *above = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) - 1));
- if (!above) {
- return;
- }
-
- swapItems(item, above);
-
- mHostListView->setCurrentItem(above);
- above->setSelected(true);
-
- Q_EMIT changed(true);
-}
-
-void KCMLdap::slotMoveDown()
-{
- const QList<QListWidgetItem *> selectedItems = mHostListView->selectedItems();
- if (selectedItems.isEmpty()) {
- return;
- }
-
- LDAPItem *item = static_cast<LDAPItem *>(mHostListView->selectedItems().first());
- if (!item) {
- return;
- }
-
- LDAPItem *below = static_cast<LDAPItem *>(mHostListView->item(mHostListView->row(item) + 1));
- if (!below) {
- return;
- }
-
- swapItems(item, below);
-
- mHostListView->setCurrentItem(below);
- below->setSelected(true);
-
- Q_EMIT changed(true);
-}
-
-void KCMLdap::load()
-{
- mHostListView->clear();
- KConfig *config = KLDAP::LdapClientSearchConfig::config();
- KConfigGroup group(config, "LDAP");
-
- uint count = group.readEntry("NumSelectedHosts", 0);
- for (uint i = 0; i < count; ++i) {
- KLDAP::LdapServer server;
- mClientSearchConfig->readConfig(server, group, i, true);
- LDAPItem *item = new LDAPItem(mHostListView, server, true);
- item->setCheckState(Qt::Checked);
- }
-
- count = group.readEntry("NumHosts", 0);
- for (uint i = 0; i < count; ++i) {
- KLDAP::LdapServer server;
- mClientSearchConfig->readConfig(server, group, i, false);
- new LDAPItem(mHostListView, server);
- }
-
- Q_EMIT changed(false);
-}
-
-void KCMLdap::save()
-{
- KConfig *config = KLDAP::LdapClientSearchConfig::config();
- config->deleteGroup("LDAP");
-
- KConfigGroup group(config, "LDAP");
-
- uint selected = 0;
- uint unselected = 0;
- for (int i = 0; i < mHostListView->count(); ++i) {
- LDAPItem *item = dynamic_cast<LDAPItem *>(mHostListView->item(i));
- if (!item) {
- continue;
- }
-
- KLDAP::LdapServer server = item->server();
- if (item->checkState() == Qt::Checked) {
- mClientSearchConfig->writeConfig(server, group, selected, true);
- selected++;
- } else {
- mClientSearchConfig->writeConfig(server, group, unselected, false);
- unselected++;
- }
- }
-
- group.writeEntry("NumSelectedHosts", selected);
- group.writeEntry("NumHosts", unselected);
- config->sync();
-
- Q_EMIT changed(false);
-}
-
-void KCMLdap::defaults()
-{
- // add default configuration here
-}
-
-void KCMLdap::initGUI()
-{
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
- setLayout(layout);
-
- QGroupBox *groupBox = new QGroupBox(i18n("LDAP Servers"), this);
- QVBoxLayout *mainLayout = new QVBoxLayout(groupBox);
-
- // Contents of the QVGroupBox: label and hbox
- QLabel *label = new QLabel(i18n("Check all servers that should be used:"));
- mainLayout->addWidget(label);
-
- QWidget *hBox = new QWidget;
- QHBoxLayout *hBoxHBoxLayout = new QHBoxLayout(hBox);
- hBoxHBoxLayout->setMargin(0);
- hBoxHBoxLayout->setSpacing(6);
- mainLayout->addWidget(hBox);
- // Contents of the hbox: listview and up/down buttons on the right (vbox)
- mHostListView = new QListWidget(hBox);
- hBoxHBoxLayout->addWidget(mHostListView);
- mHostListView->setSortingEnabled(false);
-
- QWidget *upDownBox = new QWidget(hBox);
- QVBoxLayout *upDownBoxVBoxLayout = new QVBoxLayout(upDownBox);
- upDownBoxVBoxLayout->setMargin(0);
- hBoxHBoxLayout->addWidget(upDownBox);
- upDownBoxVBoxLayout->setSpacing(6);
- mUpButton = new QToolButton(upDownBox);
- upDownBoxVBoxLayout->addWidget(mUpButton);
- mUpButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up")));
- mUpButton->setIconSize(QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall));
- mUpButton->setEnabled(false); // b/c no item is selected yet
-
- mDownButton = new QToolButton(upDownBox);
- upDownBoxVBoxLayout->addWidget(mDownButton);
- mDownButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down")));
- mDownButton->setIconSize(QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall));
- mDownButton->setEnabled(false); // b/c no item is selected yet
-
- QWidget *spacer = new QWidget(upDownBox);
- upDownBoxVBoxLayout->addWidget(spacer);
- upDownBoxVBoxLayout->setStretchFactor(spacer, 100);
-
- layout->addWidget(groupBox);
-
- QDialogButtonBox *buttons = new QDialogButtonBox(this);
- QPushButton *add = buttons->addButton(i18n("&Add Host..."),
- QDialogButtonBox::ActionRole);
- connect(add, &QPushButton::clicked, this, &KCMLdap::slotAddHost);
- mEditButton = buttons->addButton(i18n("&Edit Host..."),
- QDialogButtonBox::ActionRole);
- connect(mEditButton, &QPushButton::clicked, this, &KCMLdap::slotEditHost);
- mEditButton->setEnabled(false);
- mRemoveButton = buttons->addButton(i18n("&Remove Host"),
- QDialogButtonBox::ActionRole);
- connect(mRemoveButton, &QPushButton::clicked, this, &KCMLdap::slotRemoveHost);
- mRemoveButton->setEnabled(false);
- buttons->layout();
-
- layout->addWidget(buttons);
-
- resize(QSize(460, 300).expandedTo(sizeHint()));
-}
-
-QWidget *KCMLdap::dialogParent()
-{
- return this;
-}
-
-#include "kcmldap.moc"
diff --git a/3rdparty/kdepim/libkdepim/ldap/kcmldap.desktop b/3rdparty/kdepim/libkdepim/ldap/kcmldap.desktop
deleted file mode 100644
index f54ded7..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/kcmldap.desktop
+++ /dev/null
@@ -1,79 +0,0 @@
-[Desktop Entry]
-Icon=view-ldap-resource
-Type=Service
-X-KDE-ServiceTypes=KCModule
-
-X-KDE-Library=kcm_ldap
-X-KDE-ParentApp=kaddressbook
-X-KDE-ParentComponents=kaddressbook,kontact_kaddressbookplugin
-X-KDE-CfgDlgHierarchy=KAddressBook
-X-KDE-Weight=200
-
-Name=LDAP Server Settings
-Name[bs]=Postavke LDAP servera
-Name[ca]=Arranjament del servidor LDAP
-Name[ca@valencia]=Arranjament del servidor LDAP
-Name[cs]=Nastavení serveru LDAP
-Name[da]=Indstillinger for LDAP-server
-Name[de]=LDAP-Server-Einstellungen
-Name[en_GB]=LDAP Server Settings
-Name[es]=Preferencias del servidor LDAP
-Name[fi]=LDAP-palvelinasetukset
-Name[fr]=Configuration du serveur LDAP
-Name[gl]=Configuración do servidor de LDAP
-Name[it]=Impostazioni server LDAP
-Name[nl]=LDAP-serverinstellingen
-Name[pl]=Ustawienia serwera LDAP
-Name[pt]=Configuração do Servidor de LDAP
-Name[pt_BR]=Configurações do servidor LDAP
-Name[sk]=Nastavenia servera LDAP
-Name[sv]=LDAP-serverinställningar
-Name[tr]=LDAP Sunucu Ayarları
-Name[uk]=Параметри сервера LDAP
-Name[x-test]=xxLDAP Server Settingsxx
-Name[zh_CN]=LDAP 服务器设置
-Comment=Configure the available LDAP servers
-Comment[bs]=Podešavanje dostupnih LDAP servera
-Comment[ca]=Configura els servidors LDAP disponibles
-Comment[ca@valencia]=Configura els servidors LDAP disponibles
-Comment[cs]=Nastavit dostupné servery LDAP
-Comment[da]=Indstil de tilgængelige LDAP-servere
-Comment[de]=Verfügbare LDAP-Server einrichten
-Comment[en_GB]=Configure the available LDAP servers
-Comment[es]=Configurar los servidores LDAP disponibles
-Comment[fi]=Saatavilla olevien LDAP-palvelinten asetukset
-Comment[fr]=Configurer les serveurs LDAP disponibles
-Comment[gl]=Configurar os servidores de LDAP dispoñíbeis
-Comment[it]=Configura i server LDAP disponibili
-Comment[nl]=De beschikbare LDAP-servers configureren
-Comment[pl]=Ustawienia dostępnych serwerów LDAP
-Comment[pt]=Configurar os servidores de LDAP disponíveis
-Comment[pt_BR]=Configura os servidores LDAP disponíveis
-Comment[sk]=Nastaviť dostupné servery LDAP
-Comment[sv]=Anpassa tillgängliga LDAP-servrar
-Comment[tr]=Kullanılabilir LDAP sunucuları ayarla
-Comment[uk]=Налаштовування доступних серверів LDAP
-Comment[x-test]=xxConfigure the available LDAP serversxx
-Comment[zh_CN]=配置可用的 LDAP 服务器
-X-KDE-Keywords=kaddressbook, configure, settings, LDAP
-X-KDE-Keywords[bs]=kaddressbook, konfigurirati, postavke, LDAP
-X-KDE-Keywords[ca]=kaddressbook, configura, arranjament, LDAP
-X-KDE-Keywords[ca@valencia]=kaddressbook, configura, arranjament, LDAP
-X-KDE-Keywords[da]=kaddressbook, indstil, indstillinger, LDAP
-X-KDE-Keywords[de]=KAddressbook,einstellen,konfigurieren,Konfiguration,Einrichtung,Einstellungen,LDAP
-X-KDE-Keywords[en_GB]=kaddressbook, configure, settings, LDAP
-X-KDE-Keywords[es]=kaddressbook, configurar, preferencias, LDAP
-X-KDE-Keywords[fi]=kaddressbook, configure, settings, asetukset, LDAP
-X-KDE-Keywords[fr]=KAddressBook, configuration, paramètres, LDAP
-X-KDE-Keywords[gl]=kaddressbook, configurar, opcións, LDAP
-X-KDE-Keywords[it]=kaddressbook, configura, impostazioni, LDAP
-X-KDE-Keywords[nl]=kaddressbook, instellen, instellingen, LDAP
-X-KDE-Keywords[pl]=kaddressbook, konfiguruj, ustawienia, LDAP
-X-KDE-Keywords[pt]=kaddressbook, configurar, configuração, LDAP
-X-KDE-Keywords[pt_BR]=kaddressbook,configurar,configurações,LDAP
-X-KDE-Keywords[sk]=kaddressbook, nastaviť, nastavenia, LDAP
-X-KDE-Keywords[sv]=adressbok, anpassa, inställningar, LDAP
-X-KDE-Keywords[tr]=kaddressbook, yapılandır, ayarlar, LDAP
-X-KDE-Keywords[uk]=kaddressbook,налаштувати,адресна,книга,параметри,лдап,configure,settings,LDAP
-X-KDE-Keywords[x-test]=xxkaddressbookxx,xx configurexx,xx settingsxx,xx LDAPxx
-X-KDE-Keywords[zh_CN]=kaddressbook, configure, settings, LDAP, 配置, 设置
diff --git a/3rdparty/kdepim/libkdepim/ldap/kcmldap_p.h b/3rdparty/kdepim/libkdepim/ldap/kcmldap_p.h
deleted file mode 100644
index 3971947..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/kcmldap_p.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- This file is part of libkldap.
-
- Copyright (c) 2003 - 2009 Tobias Koenig <tokoe@kde.org>
- Copyright (c) 2013 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KCMLDAP_H
-#define KCMLDAP_H
-
-#include <kcmodule.h>
-
-class QListWidget;
-class QListWidgetItem;
-class QPushButton;
-class QToolButton;
-
-namespace KLDAP
-{
-class LdapClientSearchConfig;
-}
-
-class KCMLdap : public KCModule
-{
- Q_OBJECT
-
-public:
- explicit KCMLdap(QWidget *parent, const QVariantList &args);
- ~KCMLdap();
-
- void load() override;
- void save() override;
- void defaults() override;
-
-private Q_SLOTS:
- void slotAddHost();
- void slotEditHost();
- void slotRemoveHost();
- void slotSelectionChanged(QListWidgetItem *);
- void slotItemClicked(QListWidgetItem *);
- void slotMoveUp();
- void slotMoveDown();
-
-private:
- void initGUI();
- QWidget *dialogParent();
-
- QListWidget *mHostListView;
-
- QPushButton *mAddButton;
- QPushButton *mEditButton;
- QPushButton *mRemoveButton;
-
- QToolButton *mUpButton;
- QToolButton *mDownButton;
- KLDAP::LdapClientSearchConfig *mClientSearchConfig;
-};
-
-#endif
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclient.cpp b/3rdparty/kdepim/libkdepim/ldap/ldapclient.cpp
deleted file mode 100644
index 43f4ff0..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclient.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/* kldapclient.cpp - LDAP access
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * Ported to KABC by Daniel Molkentin <molkentin@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "ldapclient.h"
-#include "ldapclient_debug.h"
-
-#include <kldap/ldapobject.h>
-#include <kldap/ldapserver.h>
-#include <kldap/ldapurl.h>
-#include <kldap/ldif.h>
-
-#include <kio/job.h>
-
-#include <QPointer>
-
-using namespace KLDAP;
-
-class Q_DECL_HIDDEN LdapClient::Private
-{
-public:
- Private(LdapClient *qq)
- : q(qq),
- mJob(Q_NULLPTR),
- mActive(false),
- mClientNumber(0)
- {
- }
-
- ~Private()
- {
- q->cancelQuery();
- }
-
- void startParseLDIF();
- void parseLDIF(const QByteArray &data);
- void endParseLDIF();
- void finishCurrentObject();
-
- void slotData(KIO::Job *, const QByteArray &data);
- void slotData(const QByteArray &data);
- void slotInfoMessage(KJob *, const QString &info, const QString &);
- void slotDone();
-
- LdapClient *q;
-
- KLDAP::LdapServer mServer;
- QString mScope;
- QStringList mAttrs;
-
- QPointer<KJob> mJob;
- bool mActive;
-
- KLDAP::LdapObject mCurrentObject;
- KLDAP::Ldif mLdif;
- int mClientNumber;
- int mCompletionWeight;
-
-};
-
-LdapClient::LdapClient(int clientNumber, QObject *parent)
- : QObject(parent), d(new Private(this))
-{
- d->mClientNumber = clientNumber;
- d->mCompletionWeight = 50 - d->mClientNumber;
-}
-
-LdapClient::~LdapClient()
-{
- delete d;
-}
-
-bool LdapClient::isActive() const
-{
- return d->mActive;
-}
-
-void LdapClient::setServer(const KLDAP::LdapServer &server)
-{
- d->mServer = server;
-}
-
-const KLDAP::LdapServer LdapClient::server() const
-{
- return d->mServer;
-}
-
-void LdapClient::setAttributes(const QStringList &attrs)
-{
- d->mAttrs = attrs;
- d->mAttrs << QStringLiteral("objectClass"); // via objectClass we detect distribution lists
-}
-
-QStringList LdapClient::attributes() const
-{
- return d->mAttrs;
-}
-
-void LdapClient::setScope(const QString &scope)
-{
- d->mScope = scope;
-}
-
-void LdapClient::startQuery(const QString &filter)
-{
- cancelQuery();
- KLDAP::LdapUrl url;
-
- url = d->mServer.url();
-
- url.setAttributes(d->mAttrs);
- url.setScope(d->mScope == QLatin1String("one") ? KLDAP::LdapUrl::One : KLDAP::LdapUrl::Sub);
- const QString userFilter = url.filter();
- QString finalFilter = filter;
- // combine the filter set by the user in the config dialog (url.filter()) and the filter from this query
- if (!userFilter.isEmpty()) {
- finalFilter = QLatin1String("&(") + finalFilter + QLatin1String(")(") + userFilter + QLatin1Char(')');
- }
- url.setFilter(QLatin1Char('(') + finalFilter + QLatin1Char(')'));
-
- qCDebug(LDAPCLIENT_LOG) << "LdapClient: Doing query:" << url.toDisplayString();
-
- d->startParseLDIF();
- d->mActive = true;
- d->mJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
- connect(d->mJob, SIGNAL(data(KIO::Job*,QByteArray)),
- this, SLOT(slotData(KIO::Job*,QByteArray)));
- connect(d->mJob, SIGNAL(infoMessage(KJob*,QString,QString)),
- this, SLOT(slotInfoMessage(KJob*,QString,QString)));
- connect(d->mJob, SIGNAL(result(KJob*)),
- this, SLOT(slotDone()));
-}
-
-void LdapClient::cancelQuery()
-{
- if (d->mJob) {
- d->mJob->kill();
- d->mJob = Q_NULLPTR;
- }
-
- d->mActive = false;
-}
-
-void LdapClient::Private::slotData(KIO::Job *, const QByteArray &data)
-{
- parseLDIF(data);
-}
-
-void LdapClient::Private::slotData(const QByteArray &data)
-{
- parseLDIF(data);
-}
-
-void LdapClient::Private::slotInfoMessage(KJob *, const QString &, const QString &)
-{
- //qDebug("Job said \"%s\"", info.toLatin1());
-}
-
-void LdapClient::Private::slotDone()
-{
- endParseLDIF();
- mActive = false;
- if (!mJob) {
- return;
- }
- int err = mJob->error();
- if (err && err != KIO::ERR_USER_CANCELED) {
- Q_EMIT q->error(mJob->errorString());
- }
- Q_EMIT q->done();
-}
-
-void LdapClient::Private::startParseLDIF()
-{
- mCurrentObject.clear();
- mLdif.startParsing();
-}
-
-void LdapClient::Private::endParseLDIF()
-{
-}
-
-void LdapClient::Private::finishCurrentObject()
-{
- mCurrentObject.setDn(mLdif.dn());
- KLDAP::LdapAttrValue objectclasses;
- KLDAP::LdapAttrMap::ConstIterator end = mCurrentObject.attributes().constEnd();
- for (KLDAP::LdapAttrMap::ConstIterator it = mCurrentObject.attributes().constBegin();
- it != end; ++it) {
-
- if (it.key().toLower() == QLatin1String("objectclass")) {
- objectclasses = it.value();
- break;
- }
- }
-
- bool groupofnames = false;
- KLDAP::LdapAttrValue::ConstIterator endValue(objectclasses.constEnd());
- for (KLDAP::LdapAttrValue::ConstIterator it = objectclasses.constBegin();
- it != endValue; ++it) {
-
- const QByteArray sClass = (*it).toLower();
- if (sClass == "groupofnames" || sClass == "kolabgroupofnames") {
- groupofnames = true;
- }
- }
-
- if (groupofnames) {
- KLDAP::LdapAttrMap::ConstIterator it = mCurrentObject.attributes().find(QStringLiteral("mail"));
- if (it == mCurrentObject.attributes().end()) {
- // No explicit mail address found so far?
- // Fine, then we use the address stored in the DN.
- QString sMail;
- const QStringList lMail = mCurrentObject.dn().toString().split(QStringLiteral(",dc="), QString::SkipEmptyParts);
- const int n = lMail.count();
- if (n) {
- if (lMail.first().toLower().startsWith(QStringLiteral("cn="))) {
- sMail = lMail.first().simplified().mid(3);
- if (1 < n) {
- sMail.append(QLatin1Char('@'));
- }
- for (int i = 1; i < n; ++i) {
- sMail.append(lMail.at(i));
- if (i < n - 1) {
- sMail.append(QLatin1Char('.'));
- }
- }
- mCurrentObject.addValue(QStringLiteral("mail"), sMail.toUtf8());
- }
- }
- }
- }
- Q_EMIT q->result(*q, mCurrentObject);
- mCurrentObject.clear();
-}
-
-void LdapClient::Private::parseLDIF(const QByteArray &data)
-{
- //qCDebug(LDAPCLIENT_LOG) <<"LdapClient::parseLDIF(" << QCString(data.data(), data.size()+1) <<" )";
- if (data.size()) {
- mLdif.setLdif(data);
- } else {
- mLdif.endLdif();
- }
- KLDAP::Ldif::ParseValue ret;
- QString name;
- do {
- ret = mLdif.nextItem();
- switch (ret) {
- case KLDAP::Ldif::Item: {
- name = mLdif.attr();
- const QByteArray value = mLdif.value();
- mCurrentObject.addValue(name, value);
- }
- break;
- case KLDAP::Ldif::EndEntry:
- finishCurrentObject();
- break;
- default:
- break;
- }
- } while (ret != KLDAP::Ldif::MoreData);
-}
-
-int LdapClient::clientNumber() const
-{
- return d->mClientNumber;
-}
-
-int LdapClient::completionWeight() const
-{
- return d->mCompletionWeight;
-}
-
-void LdapClient::setCompletionWeight(int weight)
-{
- d->mCompletionWeight = weight;
-}
-
-#include "moc_ldapclient.cpp"
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclient.h b/3rdparty/kdepim/libkdepim/ldap/ldapclient.h
deleted file mode 100644
index e376522..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclient.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* kldapclient.h - LDAP access
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef KLDAP_LDAPCLIENT_H
-#define KLDAP_LDAPCLIENT_H
-
-#include "kdepim_export.h"
-
-#include <QObject>
-#include <QStringList>
-
-class KJob;
-
-namespace KLDAP
-{
-
-class LdapObject;
-class LdapServer;
-
-/**
- * @short An object that represents a configured LDAP server.
- *
- * This class represents a client that to an LDAP server that
- * can be used for LDAP lookups. Every client is identified by
- * a unique numeric id.
- *
- * @since 4.5
- */
-class KDEPIM_EXPORT LdapClient : public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * Creates a new ldap client.
- *
- * @param clientNumber The unique number of this client.
- * @param parent The parent object.
- */
- explicit LdapClient(int clientNumber, QObject *parent = Q_NULLPTR);
-
- /**
- * Destroys the ldap client.
- */
- virtual ~LdapClient();
-
- /**
- * Returns the number of this client.
- */
- int clientNumber() const;
-
- /**
- * Returns whether this client is currently running
- * a search query.
- */
- bool isActive() const;
-
- /**
- * Sets the completion @p weight of this client.
- *
- * This value will be used to sort the results of this
- * client when used for auto completion.
- */
- void setCompletionWeight(int weight);
-
- /**
- * Returns the completion weight of this client.
- */
- int completionWeight() const;
-
- /**
- * Sets the LDAP @p server information that shall be
- * used by this client.
- */
- void setServer(const KLDAP::LdapServer &server);
-
- /**
- * Returns the ldap server information that are used
- * by this client.
- */
- const KLDAP::LdapServer server() const;
-
- /**
- * Sets the LDAP @p attributes that should be returned
- * in the query result.
- *
- * Pass an empty list to include all available attributes.
- */
- void setAttributes(const QStringList &attributes);
-
- /**
- * Returns the LDAP attributes that should be returned
- * in the query result.
- */
- QStringList attributes() const;
-
- /**
- * Sets the @p scope of the LDAP query.
- *
- * Valid values are 'one' or 'sub'.
- */
- void setScope(const QString &scope);
-
- /**
- * Starts the query with the given @p filter.
- */
- void startQuery(const QString &filter);
-
- /**
- * Cancels a running query.
- */
- void cancelQuery();
-
-Q_SIGNALS:
- /**
- * This signal is emitted when the query has finished.
- */
- void done();
-
- /**
- * This signal is emitted in case of an error.
- *
- * @param message A message that describes the error.
- */
- void error(const QString &message);
-
- /**
- * This signal is emitted once for each object that is
- * returned from the query
- */
- void result(const KLDAP::LdapClient &client, const KLDAP::LdapObject &);
-
-private:
- //@cond PRIVATE
- class Private;
- Private *const d;
-
- Q_PRIVATE_SLOT(d, void slotData(KIO::Job *, const QByteArray &))
- Q_PRIVATE_SLOT(d, void slotData(const QByteArray &))
- Q_PRIVATE_SLOT(d, void slotInfoMessage(KJob *, const QString &, const QString &))
- Q_PRIVATE_SLOT(d, void slotDone())
- //@endcond
-};
-
-}
-
-#endif
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.cpp b/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.cpp
deleted file mode 100644
index df29244..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2014-2015 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "ldapclient_debug.h"
-Q_LOGGING_CATEGORY(LDAPCLIENT_LOG, "log_ldapclient")
-
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.h b/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.h
deleted file mode 100644
index bf8cb06..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclient_debug.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2014-2015 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LDAPCLIENT_DEBUG_H
-#define LDAPCLIENT_DEBUG_H
-
-#include <QLoggingCategory>
-Q_DECLARE_LOGGING_CATEGORY(LDAPCLIENT_LOG)
-
-#endif
-
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.cpp b/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.cpp
deleted file mode 100644
index 0be74c6..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/* kldapclient.cpp - LDAP access
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * Ported to KABC by Daniel Molkentin <molkentin@kde.org>
- *
- * Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "ldapclientsearch.h"
-#include "ldapclientsearchconfig.h"
-#include "ldapclient_debug.h"
-
-#include "ldapclient.h"
-
-#include <kldap/ldapobject.h>
-#include <kldap/ldapserver.h>
-#include <kldap/ldapurl.h>
-#include <kldap/ldif.h>
-
-#include <KConfig>
-#include <KConfigGroup>
-#include <KDirWatch>
-#include <KProtocolInfo>
-#include <Kdelibs4ConfigMigrator>
-
-#include <kio/job.h>
-
-#include <QPointer>
-#include <QTimer>
-#include <QStandardPaths>
-
-using namespace KLDAP;
-
-class Q_DECL_HIDDEN LdapClientSearch::Private
-{
-public:
- Private(LdapClientSearch *qq)
- : q(qq),
- mActiveClients(0),
- mNoLDAPLookup(false)
- {
- mClientSearchConfig = new LdapClientSearchConfig;
- }
-
- ~Private()
- {
- delete mClientSearchConfig;
- }
-
- void readWeighForClient(LdapClient *client, const KConfigGroup &config, int clientNumber);
- void readConfig();
- void finish();
- void makeSearchData(QStringList &ret, LdapResult::List &resList);
-
- void slotLDAPResult(const KLDAP::LdapClient &client, const KLDAP::LdapObject &);
- void slotLDAPError(const QString &);
- void slotLDAPDone();
- void slotDataTimer();
- void slotFileChanged(const QString &);
-
- LdapClientSearch *q;
- QList<LdapClient *> mClients;
- QStringList mAttributes;
- QString mSearchText;
- QString mFilter;
- QTimer mDataTimer;
- int mActiveClients;
- bool mNoLDAPLookup;
- LdapResultObject::List mResults;
- QString mConfigFile;
- LdapClientSearchConfig *mClientSearchConfig;
-};
-
-LdapClientSearch::LdapClientSearch(QObject *parent)
- : QObject(parent), d(new Private(this))
-{
- Kdelibs4ConfigMigrator migrate(QStringLiteral("ldapsettings"));
- migrate.setConfigFiles(QStringList() << QStringLiteral("kabldaprc"));
- migrate.migrate();
-
- if (!KProtocolInfo::isKnownProtocol(QUrl(QStringLiteral("ldap://localhost")))) {
- d->mNoLDAPLookup = true;
- return;
- }
-
- d->mAttributes << QStringLiteral("cn")
- << QStringLiteral("mail")
- << QStringLiteral("givenname")
- << QStringLiteral("sn");
-
- // Set the filter, to make sure old usage (before 4.14) of this object still works.
- d->mFilter = QStringLiteral("&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))"
- "(|(cn=%1*)(mail=%1*)(givenName=%1*)(sn=%1*))");
-
- d->readConfig();
- connect(KDirWatch::self(), SIGNAL(dirty(QString)), this,
- SLOT(slotFileChanged(QString)));
-
-}
-
-LdapClientSearch::~LdapClientSearch()
-{
- delete d;
-}
-
-void LdapClientSearch::Private::readWeighForClient(LdapClient *client, const KConfigGroup &config,
- int clientNumber)
-{
- const int completionWeight = config.readEntry(QStringLiteral("SelectedCompletionWeight%1").arg(clientNumber), -1);
- if (completionWeight != -1) {
- client->setCompletionWeight(completionWeight);
- }
-}
-
-void LdapClientSearch::updateCompletionWeights()
-{
- KConfigGroup config(KLDAP::LdapClientSearchConfig::config(), "LDAP");
- for (int i = 0; i < d->mClients.size(); ++i) {
- d->readWeighForClient(d->mClients[ i ], config, i);
- }
-}
-
-QList<LdapClient *> LdapClientSearch::clients() const
-{
- return d->mClients;
-}
-
-QString LdapClientSearch::filter() const
-{
- return d->mFilter;
-}
-
-void LdapClientSearch::setFilter(const QString &filter)
-{
- d->mFilter = filter;
-}
-
-QStringList LdapClientSearch::attributes() const
-{
- return d->mAttributes;
-}
-
-void LdapClientSearch::setAttributes(const QStringList &attrs)
-{
-
- if (attrs != d->mAttributes) {
- d->mAttributes = attrs;
- d->readConfig();
- }
-}
-
-void LdapClientSearch::Private::readConfig()
-{
- q->cancelSearch();
- qDeleteAll(mClients);
- mClients.clear();
-
- // stolen from KAddressBook
- KConfigGroup config(KLDAP::LdapClientSearchConfig::config(), "LDAP");
- const int numHosts = config.readEntry("NumSelectedHosts", 0);
- if (!numHosts) {
- mNoLDAPLookup = true;
- } else {
- for (int j = 0; j < numHosts; ++j) {
- LdapClient *ldapClient = new LdapClient(j, q);
- KLDAP::LdapServer server;
- mClientSearchConfig->readConfig(server, config, j, true);
- if (!server.host().isEmpty()) {
- mNoLDAPLookup = false;
- }
- ldapClient->setServer(server);
-
- readWeighForClient(ldapClient, config, j);
-
- ldapClient->setAttributes(mAttributes);
-
- q->connect(ldapClient, SIGNAL(result(KLDAP::LdapClient,KLDAP::LdapObject)),
- q, SLOT(slotLDAPResult(KLDAP::LdapClient,KLDAP::LdapObject)));
- q->connect(ldapClient, SIGNAL(done()),
- q, SLOT(slotLDAPDone()));
- q->connect(ldapClient, SIGNAL(error(QString)),
- q, SLOT(slotLDAPError(QString)));
-
- mClients.append(ldapClient);
- }
-
- q->connect(&mDataTimer, SIGNAL(timeout()), SLOT(slotDataTimer()));
- }
- mConfigFile = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/kabldaprc");
- KDirWatch::self()->addFile(mConfigFile);
-}
-
-void LdapClientSearch::Private::slotFileChanged(const QString &file)
-{
- if (file == mConfigFile) {
- readConfig();
- }
-}
-
-void LdapClientSearch::startSearch(const QString &txt)
-{
- if (d->mNoLDAPLookup) {
- QMetaObject::invokeMethod(this, "searchDone", Qt::QueuedConnection);
- return;
- }
-
- cancelSearch();
-
- int pos = txt.indexOf(QLatin1Char('\"'));
- if (pos >= 0) {
- ++pos;
- const int pos2 = txt.indexOf(QLatin1Char('\"'), pos);
- if (pos2 >= 0) {
- d->mSearchText = txt.mid(pos, pos2 - pos);
- } else {
- d->mSearchText = txt.mid(pos);
- }
- } else {
- d->mSearchText = txt;
- }
-
- const QString filter = d->mFilter.arg(d->mSearchText);
-
- QList<LdapClient *>::Iterator it;
- QList<LdapClient *>::Iterator end(d->mClients.end());
- for (it = d->mClients.begin(); it != end; ++it) {
- (*it)->startQuery(filter);
- qCDebug(LDAPCLIENT_LOG) << "LdapClientSearch::startSearch()" << filter;
- ++d->mActiveClients;
- }
-}
-
-void LdapClientSearch::cancelSearch()
-{
- QList<LdapClient *>::Iterator it;
- QList<LdapClient *>::Iterator end(d->mClients.end());
- for (it = d->mClients.begin(); it != end; ++it) {
- (*it)->cancelQuery();
- }
-
- d->mActiveClients = 0;
- d->mResults.clear();
-}
-
-void LdapClientSearch::Private::slotLDAPResult(const LdapClient &client,
- const KLDAP::LdapObject &obj)
-{
- LdapResultObject result;
- result.client = &client;
- result.object = obj;
-
- mResults.append(result);
- if (!mDataTimer.isActive()) {
- mDataTimer.setSingleShot(true);
- mDataTimer.start(500);
- }
-}
-
-void LdapClientSearch::Private::slotLDAPError(const QString &)
-{
- slotLDAPDone();
-}
-
-void LdapClientSearch::Private::slotLDAPDone()
-{
- if (--mActiveClients > 0) {
- return;
- }
-
- finish();
-}
-
-void LdapClientSearch::Private::slotDataTimer()
-{
- QStringList lst;
- LdapResult::List reslist;
-
- Q_EMIT q->searchData(mResults);
-
- makeSearchData(lst, reslist);
- if (!lst.isEmpty()) {
- Q_EMIT q->searchData(lst);
- }
- if (!reslist.isEmpty()) {
- Q_EMIT q->searchData(reslist);
- }
-}
-
-void LdapClientSearch::Private::finish()
-{
- mDataTimer.stop();
-
- slotDataTimer(); // Q_EMIT final bunch of data
- Q_EMIT q->searchDone();
-}
-
-void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::List &resList)
-{
-
- LdapResultObject::List::ConstIterator it1;
- LdapResultObject::List::ConstIterator end1(mResults.constEnd());
- for (it1 = mResults.constBegin(); it1 != end1; ++it1) {
- QString name, mail, givenname, sn;
- QStringList mails;
- bool isDistributionList = false;
- bool wasCN = false;
- bool wasDC = false;
-
- //qCDebug(LDAPCLIENT_LOG) <<"\n\nLdapClientSearch::makeSearchData()";
-
- KLDAP::LdapAttrMap::ConstIterator it2;
- for (it2 = (*it1).object.attributes().constBegin();
- it2 != (*it1).object.attributes().constEnd(); ++it2) {
- QByteArray val = (*it2).first();
- int len = val.size();
- if (len > 0 && '\0' == val[len - 1]) {
- --len;
- }
- const QString tmp = QString::fromUtf8(val, len);
- //qCDebug(LDAPCLIENT_LOG) <<" key: \"" << it2.key() <<"\" value: \"" << tmp <<"\"";
- if (it2.key() == QLatin1String("cn")) {
- name = tmp;
- if (mail.isEmpty()) {
- mail = tmp;
- } else {
- if (wasCN) {
- mail.prepend(QStringLiteral("."));
- } else {
- mail.prepend(QStringLiteral("@"));
- }
- mail.prepend(tmp);
- }
- wasCN = true;
- } else if (it2.key() == QLatin1String("dc")) {
- if (mail.isEmpty()) {
- mail = tmp;
- } else {
- if (wasDC) {
- mail.append(QStringLiteral("."));
- } else {
- mail.append(QStringLiteral("@"));
- }
- mail.append(tmp);
- }
- wasDC = true;
- } else if (it2.key() == QLatin1String("mail")) {
- mail = tmp;
- KLDAP::LdapAttrValue::ConstIterator it3 = it2.value().constBegin();
- for (; it3 != it2.value().constEnd(); ++it3) {
- mails.append(QString::fromUtf8((*it3).data(), (*it3).size()));
- }
- } else if (it2.key() == QLatin1String("givenName")) {
- givenname = tmp;
- } else if (it2.key() == QLatin1String("sn")) {
- sn = tmp;
- } else if (it2.key() == QLatin1String("objectClass") &&
- (tmp == QLatin1String("groupOfNames") || tmp == QLatin1String("kolabGroupOfNames"))) {
- isDistributionList = true;
- }
- }
-
- if (mails.isEmpty()) {
- if (!mail.isEmpty()) {
- mails.append(mail);
- }
- if (isDistributionList) {
- //qCDebug(LDAPCLIENT_LOG) <<"\n\nLdapClientSearch::makeSearchData() found a list:" << name;
- ret.append(name);
- // following lines commented out for bugfixing kolab issue #177:
- //
- // Unlike we thought previously we may NOT append the server name here.
- //
- // The right server is found by the SMTP server instead: Kolab users
- // must use the correct SMTP server, by definition.
- //
- //mail = (*it1).client->base().simplified();
- //mail.replace( ",dc=", ".", false );
- //if( mail.startsWith("dc=", false) )
- // mail.remove(0, 3);
- //mail.prepend( '@' );
- //mail.prepend( name );
- //mail = name;
- } else {
- continue; // nothing, bad entry
- }
- } else if (name.isEmpty()) {
- ret.append(mail);
- } else {
- ret.append(QStringLiteral("%1 <%2>").arg(name, mail));
- }
-
- LdapResult sr;
- sr.dn = (*it1).object.dn();
- sr.clientNumber = (*it1).client->clientNumber();
- sr.completionWeight = (*it1).client->completionWeight();
- sr.name = name;
- sr.email = mails;
- resList.append(sr);
- }
-
- mResults.clear();
-}
-
-bool LdapClientSearch::isAvailable() const
-{
- return !d->mNoLDAPLookup;
-}
-
-#include "moc_ldapclientsearch.cpp"
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.h b/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.h
deleted file mode 100644
index d90c9cd..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearch.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* kldapclient.h - LDAP access
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef LDAPCLIENTSEARCH_H
-#define LDAPCLIENTSEARCH_H
-
-#include "kdepim_export.h"
-#include <kldap/ldapobject.h>
-#include <QObject>
-#include <QStringList>
-
-namespace KLDAP
-{
-class LdapClient;
-
-/**
- * Describes the result returned by an LdapClientSearch query.
- *
- * @since 4.14
- */
-struct LdapResultObject {
- typedef QVector<LdapResultObject> List;
- const LdapClient *client;
- KLDAP::LdapObject object;
-};
-
-/**
- * Describes the result returned by an LdapClientSearch query.
- *
- * @since 4.5
- */
-struct LdapResult {
- /**
- * A list of LdapResult objects.
- */
- typedef QVector<LdapResult> List;
-
- LdapDN dn;
- QString name; ///< The full name of the contact.
- QStringList email; ///< The list of emails of the contact.
- int clientNumber; ///< The client the contact comes from (used for sorting in a ldap-only lookup).
- int completionWeight; ///< The weight of the contact (used for sorting in a completion list).
-};
-
-/**
- * @since 4.5
- */
-class KDEPIM_EXPORT LdapClientSearch : public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * Creates a new ldap client search object.
- *
- * @param parent The parent object.
- */
- explicit LdapClientSearch(QObject *parent = Q_NULLPTR);
-
- /**
- * Destroys the ldap client search object.
- */
- ~LdapClientSearch();
-
- /**
- * Starts the LDAP search on all configured LDAP clients with the given search @p query.
- */
- void startSearch(const QString &query);
-
- /**
- * Cancels the currently running search query.
- */
- void cancelSearch();
-
- /**
- * Returns whether LDAP search is possible at all.
- *
- * @note This method can return @c false if either no LDAP is configured
- * or the system does not support the KIO LDAP protocol.
- */
- bool isAvailable() const;
-
- /**
- * Updates the completion weights for the configured LDAP clients from
- * the configuration file.
- */
- void updateCompletionWeights();
-
- /**
- * Returns the list of configured LDAP clients.
- */
- QList<LdapClient *> clients() const;
-
- /**
- * Returns the filter for the Query
- *
- * @since 4.14
- */
- QString filter() const;
-
- /**
- * Sets the filter for the Query
- *
- * @since 4.14
- */
- void setFilter(const QString &);
-
- /**
- * Returns the attributes, that are queried the LDAP Server.
- *
- * @since 4.14
- */
- QStringList attributes() const;
-
- /**
- * Sets the attributes, that are queried the LDAP Server.
- *
- * @since 4.14
- */
- void setAttributes(const QStringList &);
-
-Q_SIGNALS:
- /**
- * This signal is emitted whenever new contacts have been found
- * during the lookup.
- *
- * @param results The contacts in the form "Full Name <email>"
- */
- void searchData(const QStringList &results);
-
- /**
- * This signal is emitted whenever new contacts have been found
- * during the lookup.
- *
- * @param results The list of found contacts.
- */
- void searchData(const KLDAP::LdapResult::List &results);
-
- /**
- * This signal is emitted whenever new contacts have been found
- * during the lookup.
- *
- * @param results The list of found contacts.
- */
- void searchData(const KLDAP::LdapResultObject::List &results);
-
- /**
- * This signal is emitted whenever the lookup is complete or the
- * user has canceled the query.
- */
- void searchDone();
-
-private:
- //@cond PRIVATE
- class Private;
- Private *const d;
-
- Q_PRIVATE_SLOT(d, void slotLDAPResult(const KLDAP::LdapClient &, const KLDAP::LdapObject &))
- Q_PRIVATE_SLOT(d, void slotLDAPError(const QString &))
- Q_PRIVATE_SLOT(d, void slotLDAPDone())
- Q_PRIVATE_SLOT(d, void slotDataTimer())
- Q_PRIVATE_SLOT(d, void slotFileChanged(const QString &))
- //@endcond
-};
-
-}
-Q_DECLARE_TYPEINFO(KLDAP::LdapResult, Q_MOVABLE_TYPE);
-Q_DECLARE_TYPEINFO(KLDAP::LdapResultObject, Q_MOVABLE_TYPE);
-
-#endif // LDAPCLIENTSEARCH_H
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.cpp b/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.cpp
deleted file mode 100644
index 5b01f45..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "ldapclientsearchconfig.h"
-#include <kldap/ldapserver.h>
-
-#include <KConfig>
-#include <KConfigGroup>
-#include <KMessageBox>
-#include <KLocalizedString>
-#include <kwallet.h>
-
-using namespace KLDAP;
-
-class Q_DECL_HIDDEN LdapClientSearchConfig::Private
-{
-public:
- Private()
- : useWallet(false),
- askWallet(true),
- wallet(Q_NULLPTR)
- {
-
- }
- ~Private()
- {
- if (useWallet) {
- wallet->deleteLater();
- wallet = Q_NULLPTR;
- }
- }
- bool useWallet;
- bool askWallet;
- KWallet::Wallet *wallet;
-};
-
-Q_GLOBAL_STATIC_WITH_ARGS(KConfig, s_config, (QLatin1String("kabldaprc"), KConfig::NoGlobals))
-
-KConfig *LdapClientSearchConfig::config()
-{
- return s_config;
-}
-
-LdapClientSearchConfig::LdapClientSearchConfig(QObject *parent)
- : QObject(parent), d(new LdapClientSearchConfig::Private())
-{
-}
-
-LdapClientSearchConfig::~LdapClientSearchConfig()
-{
- delete d;
-}
-
-void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup &config, int j, bool active)
-{
- QString prefix;
- if (active) {
- prefix = QStringLiteral("Selected");
- }
-
- const QString host = config.readEntry(prefix + QStringLiteral("Host%1").arg(j),
- QString()).trimmed();
- if (!host.isEmpty()) {
- server.setHost(host);
- }
-
- const int port = config.readEntry(prefix + QStringLiteral("Port%1").arg(j), 389);
- server.setPort(port);
-
- const QString base = config.readEntry(prefix + QStringLiteral("Base%1").arg(j),
- QString()).trimmed();
- if (!base.isEmpty()) {
- server.setBaseDn(KLDAP::LdapDN(base));
- }
-
- const QString user = config.readEntry(prefix + QStringLiteral("User%1").arg(j),
- QString()).trimmed();
- if (!user.isEmpty()) {
- server.setUser(user);
- }
-
- const QString bindDN = config.readEntry(prefix + QStringLiteral("Bind%1").arg(j), QString()).trimmed();
- if (!bindDN.isEmpty()) {
- server.setBindDn(bindDN);
- }
-
- const QString pwdBindBNEntry = prefix + QStringLiteral("PwdBind%1").arg(j);
- QString pwdBindDN = config.readEntry(pwdBindBNEntry, QString());
- if (!pwdBindDN.isEmpty()) {
- if (d->askWallet && KMessageBox::Yes == KMessageBox::questionYesNo(Q_NULLPTR, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"),
- i18n("Store clear text password in KWallet"),
- KStandardGuiItem::yes(),
- KStandardGuiItem::no(),
- QStringLiteral("DoAskToStoreToKwallet"))) {
- d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
- if (d->wallet) {
- connect(d->wallet, &KWallet::Wallet::walletClosed, this, &LdapClientSearchConfig::slotWalletClosed);
- d->useWallet = true;
- if (!d->wallet->hasFolder(QStringLiteral("ldapclient"))) {
- d->wallet->createFolder(QStringLiteral("ldapclient"));
- }
- d->wallet->setFolder(QStringLiteral("ldapclient"));
- d->wallet->writePassword(pwdBindBNEntry, pwdBindDN);
- config.deleteEntry(pwdBindBNEntry);
- config.sync();
- }
- }
- server.setPassword(pwdBindDN);
- } else if (d->askWallet) { //Look at in Wallet
- d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
- if (d->wallet) {
- d->useWallet = true;
- if (!d->wallet->setFolder(QStringLiteral("ldapclient"))) {
- d->wallet->createFolder(QStringLiteral("ldapclient"));
- d->wallet->setFolder(QStringLiteral("ldapclient"));
- }
- d->wallet->readPassword(pwdBindBNEntry, pwdBindDN);
- if (!pwdBindDN.isEmpty()) {
- server.setPassword(pwdBindDN);
- }
- } else {
- d->useWallet = false;
- }
- }
-
- server.setTimeLimit(config.readEntry(prefix + QStringLiteral("TimeLimit%1").arg(j), 0));
- server.setSizeLimit(config.readEntry(prefix + QStringLiteral("SizeLimit%1").arg(j), 0));
- server.setPageSize(config.readEntry(prefix + QStringLiteral("PageSize%1").arg(j), 0));
- server.setVersion(config.readEntry(prefix + QStringLiteral("Version%1").arg(j), 3));
-
- QString tmp;
- tmp = config.readEntry(prefix + QStringLiteral("Security%1").arg(j),
- QStringLiteral("None"));
- server.setSecurity(KLDAP::LdapServer::None);
- if (tmp == QLatin1String("SSL")) {
- server.setSecurity(KLDAP::LdapServer::SSL);
- } else if (tmp == QLatin1String("TLS")) {
- server.setSecurity(KLDAP::LdapServer::TLS);
- }
-
- tmp = config.readEntry(prefix + QStringLiteral("Auth%1").arg(j),
- QStringLiteral("Anonymous"));
- server.setAuth(KLDAP::LdapServer::Anonymous);
- if (tmp == QLatin1String("Simple")) {
- server.setAuth(KLDAP::LdapServer::Simple);
- } else if (tmp == QLatin1String("SASL")) {
- server.setAuth(KLDAP::LdapServer::SASL);
- }
-
- server.setMech(config.readEntry(prefix + QStringLiteral("Mech%1").arg(j), QString()));
- server.setFilter(config.readEntry(prefix + QStringLiteral("UserFilter%1").arg(j), QString()));
-}
-
-void LdapClientSearchConfig::writeConfig(const KLDAP::LdapServer &server, KConfigGroup &config, int j, bool active)
-{
- QString prefix;
- if (active) {
- prefix = QStringLiteral("Selected");
- }
-
- config.writeEntry(prefix + QStringLiteral("Host%1").arg(j), server.host());
- config.writeEntry(prefix + QStringLiteral("Port%1").arg(j), server.port());
- config.writeEntry(prefix + QStringLiteral("Base%1").arg(j), server.baseDn().toString());
- config.writeEntry(prefix + QStringLiteral("User%1").arg(j), server.user());
- config.writeEntry(prefix + QStringLiteral("Bind%1").arg(j), server.bindDn());
-
- const QString passwordEntry = prefix + QStringLiteral("PwdBind%1").arg(j);
- const QString password = server.password();
- if (!password.isEmpty()) {
- if (d->useWallet && !d->wallet) {
- d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
- }
- if (d->wallet) {
- d->wallet->writePassword(passwordEntry, password);
- } else {
- config.writeEntry(passwordEntry, password);
- d->useWallet = false;
- }
- }
-
- config.writeEntry(prefix + QStringLiteral("TimeLimit%1").arg(j), server.timeLimit());
- config.writeEntry(prefix + QStringLiteral("SizeLimit%1").arg(j), server.sizeLimit());
- config.writeEntry(prefix + QStringLiteral("PageSize%1").arg(j), server.pageSize());
- config.writeEntry(prefix + QStringLiteral("Version%1").arg(j), server.version());
- QString tmp;
- switch (server.security()) {
- case KLDAP::LdapServer::TLS:
- tmp = QStringLiteral("TLS");
- break;
- case KLDAP::LdapServer::SSL:
- tmp = QStringLiteral("SSL");
- break;
- default:
- tmp = QStringLiteral("None");
- }
- config.writeEntry(prefix + QStringLiteral("Security%1").arg(j), tmp);
- switch (server.auth()) {
- case KLDAP::LdapServer::Simple:
- tmp = QStringLiteral("Simple");
- break;
- case KLDAP::LdapServer::SSL:
- tmp = QStringLiteral("SASL");
- break;
- default:
- tmp = QStringLiteral("Anonymous");
- }
- config.writeEntry(prefix + QStringLiteral("Auth%1").arg(j), tmp);
- config.writeEntry(prefix + QStringLiteral("Mech%1").arg(j), server.mech());
- config.writeEntry(prefix + QStringLiteral("UserFilter%1").arg(j), server.filter().trimmed());
-}
-
-void LdapClientSearchConfig::slotWalletClosed()
-{
- delete d->wallet;
- d->wallet = Q_NULLPTR;
-}
-
-void LdapClientSearchConfig::askForWallet(bool askForWallet)
-{
- d->askWallet = askForWallet;
-}
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.h b/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.h
deleted file mode 100644
index 9a5a8c0..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapclientsearchconfig.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2013-2015 Laurent Montel <montel@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef LDAPCLIENTSEARCHCONFIG_H
-#define LDAPCLIENTSEARCHCONFIG_H
-
-#include "kdepim_export.h"
-
-#include <QObject>
-
-class KConfigGroup;
-class KConfig;
-
-namespace KLDAP
-{
-class LdapServer;
-class LdapClient;
-class KDEPIM_EXPORT LdapClientSearchConfig : public QObject
-{
- Q_OBJECT
-public:
- explicit LdapClientSearchConfig(QObject *parent = Q_NULLPTR);
- ~LdapClientSearchConfig();
-
- /**
- * Returns the global config object, which stores the LdapClient configurations.
- */
- static KConfig *config();
-
- /**
- * Reads the LDAP @p server settings from the given config @p group for the
- * given LDAP @p clientNumber.
- *
- * @param active Defines whether the active settings shall be read.
- */
- void readConfig(KLDAP::LdapServer &server, KConfigGroup &group,
- int clientNumber, bool active);
-
- /**
- * Writes the LDAP @p server settings to the given config @p group for the
- * given LDAP @p clientNumber.
- *
- * @param active Defines whether the active settings shall be written.
- */
- void writeConfig(const KLDAP::LdapServer &server, KConfigGroup &group,
- int clientNumber, bool active);
-
- /**
- * Should LdapClientSearchConfig ask, if it should use the KWallet to store passwords
- */
- void askForWallet(bool askForWallet);
-
-private Q_SLOTS:
- void slotWalletClosed();
-
-private:
- //@cond PRIVATE
- class Private;
- Private *const d;
-};
-
-}
-
-#endif // LDAPCLIENTSEARCHCONFIG_H
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.cpp b/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.cpp
deleted file mode 100644
index e5e6097..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.cpp
+++ /dev/null
@@ -1,943 +0,0 @@
-/*
- * This file is part of libkldap.
- *
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "ldapsearchdialog.h"
-
-#include "ldapclient.h"
-#include "ldapclientsearchconfig.h"
-#include "widgets/progressindicatorlabel.h"
-
-#include <QPair>
-#include <QApplication>
-#include <QCheckBox>
-#include <QCloseEvent>
-#include <QFrame>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QHeaderView>
-#include <QLabel>
-#include <QPushButton>
-#include <QTableView>
-#include <QVBoxLayout>
-#include <QSortFilterProxyModel>
-#include <QMenu>
-#include <QClipboard>
-
-#include <KLineEdit>
-#include <collection.h>
-#include <itemcreatejob.h>
-#include <kcombobox.h>
-#include <kconfig.h>
-#include <kconfiggroup.h>
-#include <kcmultidialog.h>
-#include <qdialogbuttonbox.h>
-#include <kldap/ldapobject.h>
-#include <kldap/ldapserver.h>
-#include <qlineedit.h>
-#include <kmessagebox.h>
-
-#include <QLocale>
-#include <KLocalizedString>
-#include <KConfigGroup>
-#include <QDialogButtonBox>
-#include <KGuiItem>
-
-using namespace KLDAP;
-
-static QString asUtf8(const QByteArray &val)
-{
- if (val.isEmpty()) {
- return QString();
- }
-
- const char *data = val.data();
-
- //QString::fromUtf8() bug workaround
- if (data[ val.size() - 1 ] == '\0') {
- return QString::fromUtf8(data, val.size() - 1);
- } else {
- return QString::fromUtf8(data, val.size());
- }
-}
-
-static QString join(const KLDAP::LdapAttrValue &lst, const QString &sep)
-{
- QString res;
- bool alredy = false;
- KLDAP::LdapAttrValue::ConstIterator end(lst.constEnd());
- for (KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin(); it != end; ++it) {
- if (alredy) {
- res += sep;
- }
-
- alredy = true;
- res += asUtf8(*it);
- }
-
- return res;
-}
-
-static QMap<QString, QString> &adrbookattr2ldap()
-{
- static QMap<QString, QString> keys;
-
- if (keys.isEmpty()) {
- keys[ i18nc("@item LDAP search key", "Title") ] = QStringLiteral("title");
- keys[ i18n("Full Name") ] = QStringLiteral("cn");
- keys[ i18nc("@item LDAP search key", "Email") ] = QStringLiteral("mail");
- keys[ i18n("Home Number") ] = QStringLiteral("homePhone");
- keys[ i18n("Work Number") ] = QStringLiteral("telephoneNumber");
- keys[ i18n("Mobile Number") ] = QStringLiteral("mobile");
- keys[ i18n("Fax Number") ] = QStringLiteral("facsimileTelephoneNumber");
- keys[ i18n("Pager") ] = QStringLiteral("pager");
- keys[ i18n("Street") ] = QStringLiteral("street");
- keys[ i18nc("@item LDAP search key", "State") ] = QStringLiteral("st");
- keys[ i18n("Country") ] = QStringLiteral("co");
- keys[ i18n("City") ] = QStringLiteral("l"); //krazy:exclude=doublequote_chars
- keys[ i18n("Organization") ] = QStringLiteral("o"); //krazy:exclude=doublequote_chars
- keys[ i18n("Company") ] = QStringLiteral("Company");
- keys[ i18n("Department") ] = QStringLiteral("department");
- keys[ i18n("Zip Code") ] = QStringLiteral("postalCode");
- keys[ i18n("Postal Address") ] = QStringLiteral("postalAddress");
- keys[ i18n("Description") ] = QStringLiteral("description");
- keys[ i18n("User ID") ] = QStringLiteral("uid");
- }
-
- return keys;
-}
-
-static QString makeFilter(const QString &query, LdapSearchDialog::FilterType attr, bool startsWith)
-{
- /* The reasoning behind this filter is:
- * If it's a person, or a distlist, show it, even if it doesn't have an email address.
- * If it's not a person, or a distlist, only show it if it has an email attribute.
- * This allows both resource accounts with an email address which are not a person and
- * person entries without an email address to show up, while still not showing things
- * like structural entries in the ldap tree. */
- QString result(QStringLiteral("&(|(objectclass=person)(objectclass=groupofnames)(mail=*))("));
- if (query.isEmpty()) {
- // Return a filter that matches everything
- return result + QStringLiteral("|(cn=*)(sn=*)") + QLatin1Char(')');
- }
-
- if (attr == LdapSearchDialog::Name) {
- result += startsWith ? QStringLiteral("|(cn=%1*)(sn=%2*)") : QStringLiteral("|(cn=*%1*)(sn=*%2*)");
- result = result.arg(query, query);
- } else {
- result += startsWith ? QStringLiteral("%1=%2*") : QStringLiteral("%1=*%2*");
- if (attr == LdapSearchDialog::Email) {
- result = result.arg(QStringLiteral("mail"), query);
- } else if (attr == LdapSearchDialog::HomeNumber) {
- result = result.arg(QStringLiteral("homePhone"), query);
- } else if (attr == LdapSearchDialog::WorkNumber) {
- result = result.arg(QStringLiteral("telephoneNumber"), query);
- } else {
- // Error?
- result.clear();
- return result;
- }
- }
- result += QLatin1Char(')');
- return result;
-}
-
-static KContacts::Addressee convertLdapAttributesToAddressee(const KLDAP::LdapAttrMap &attrs)
-{
- KContacts::Addressee addr;
-
- // name
- if (!attrs.value(QStringLiteral("cn")).isEmpty()) {
- addr.setNameFromString(asUtf8(attrs[QStringLiteral("cn")].first()));
- }
-
- // email
- KLDAP::LdapAttrValue lst = attrs[QStringLiteral("mail")];
- KLDAP::LdapAttrValue::ConstIterator it = lst.constBegin();
- bool pref = true;
- while (it != lst.constEnd()) {
- addr.insertEmail(asUtf8(*it), pref);
- pref = false;
- ++it;
- }
-
- if (!attrs.value(QStringLiteral("o")).isEmpty()) {
- addr.setOrganization(asUtf8(attrs[ QStringLiteral("o") ].first()));
- }
- if (addr.organization().isEmpty() && !attrs.value(QStringLiteral("Company")).isEmpty()) {
- addr.setOrganization(asUtf8(attrs[ QStringLiteral("Company") ].first()));
- }
-
- // Address
- KContacts::Address workAddr(KContacts::Address::Work);
-
- if (!attrs.value(QStringLiteral("department")).isEmpty()) {
- addr.setDepartment(asUtf8(attrs[ QStringLiteral("department") ].first()));
- }
-
- if (!workAddr.isEmpty()) {
- addr.insertAddress(workAddr);
- }
-
- // phone
- if (!attrs.value(QStringLiteral("homePhone")).isEmpty()) {
- KContacts::PhoneNumber homeNr = asUtf8(attrs[ QStringLiteral("homePhone") ].first());
- homeNr.setType(KContacts::PhoneNumber::Home);
- addr.insertPhoneNumber(homeNr);
- }
-
- if (!attrs.value(QStringLiteral("telephoneNumber")).isEmpty()) {
- KContacts::PhoneNumber workNr = asUtf8(attrs[ QStringLiteral("telephoneNumber") ].first());
- workNr.setType(KContacts::PhoneNumber::Work);
- addr.insertPhoneNumber(workNr);
- }
-
- if (!attrs.value(QStringLiteral("facsimileTelephoneNumber")).isEmpty()) {
- KContacts::PhoneNumber faxNr = asUtf8(attrs[ QStringLiteral("facsimileTelephoneNumber") ].first());
- faxNr.setType(KContacts::PhoneNumber::Fax);
- addr.insertPhoneNumber(faxNr);
- }
-
- if (!attrs.value(QStringLiteral("mobile")).isEmpty()) {
- KContacts::PhoneNumber cellNr = asUtf8(attrs[ QStringLiteral("mobile") ].first());
- cellNr.setType(KContacts::PhoneNumber::Cell);
- addr.insertPhoneNumber(cellNr);
- }
-
- if (!attrs.value(QStringLiteral("pager")).isEmpty()) {
- KContacts::PhoneNumber pagerNr = asUtf8(attrs[ QStringLiteral("pager") ].first());
- pagerNr.setType(KContacts::PhoneNumber::Pager);
- addr.insertPhoneNumber(pagerNr);
- }
-
- return addr;
-}
-
-class ContactListModel : public QAbstractTableModel
-{
-public:
- enum Role {
- ServerRole = Qt::UserRole + 1
- };
-
- ContactListModel(QObject *parent)
- : QAbstractTableModel(parent)
- {
- }
-
- void addContact(const KLDAP::LdapAttrMap &contact, const QString &server)
- {
- mContactList.append(contact);
- mServerList.append(server);
- reset();
- }
-
- QPair<KLDAP::LdapAttrMap, QString> contact(const QModelIndex &index) const
- {
- if (!index.isValid() || index.row() < 0 || index.row() >= mContactList.count()) {
- return qMakePair(KLDAP::LdapAttrMap(), QString());
- }
-
- return qMakePair(mContactList.at(index.row()), mServerList.at(index.row()));
- }
-
- QString email(const QModelIndex &index) const
- {
- if (!index.isValid() || index.row() < 0 || index.row() >= mContactList.count()) {
- return QString();
- }
-
- return asUtf8(mContactList.at(index.row()).value(QStringLiteral("mail")).first()).trimmed();
- }
-
- QString fullName(const QModelIndex &index) const
- {
- if (!index.isValid() || index.row() < 0 || index.row() >= mContactList.count()) {
- return QString();
- }
-
- return asUtf8(mContactList.at(index.row()).value(QStringLiteral("cn")).first()).trimmed();
- }
-
- void clear()
- {
- mContactList.clear();
- mServerList.clear();
- reset();
- }
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE
- {
- if (!parent.isValid()) {
- return mContactList.count();
- } else {
- return 0;
- }
- }
-
- int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE
- {
- if (!parent.isValid()) {
- return 18;
- } else {
- return 0;
- }
- }
-
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
- {
- if (orientation == Qt::Vertical || role != Qt::DisplayRole || section < 0 || section > 17) {
- return QVariant();
- }
-
- switch (section) {
- case 0:
- return i18n("Full Name");
- break;
- case 1:
- return i18nc("@title:column Column containing email addresses", "Email");
- break;
- case 2:
- return i18n("Home Number");
- break;
- case 3:
- return i18n("Work Number");
- break;
- case 4:
- return i18n("Mobile Number");
- break;
- case 5:
- return i18n("Fax Number");
- break;
- case 6:
- return i18n("Company");
- break;
- case 7:
- return i18n("Organization");
- break;
- case 8:
- return i18n("Street");
- break;
- case 9:
- return i18nc("@title:column Column containing the residential state of the address",
- "State");
- break;
- case 10:
- return i18n("Country");
- break;
- case 11:
- return i18n("Zip Code");
- break;
- case 12:
- return i18n("Postal Address");
- break;
- case 13:
- return i18n("City");
- break;
- case 14:
- return i18n("Department");
- break;
- case 15:
- return i18n("Description");
- break;
- case 16:
- return i18n("User ID");
- break;
- case 17:
- return i18nc("@title:column Column containing title of the person", "Title");
- break;
- default:
- return QVariant();
- break;
- };
-
- return QVariant();
- }
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
- {
- if (!index.isValid()) {
- return QVariant();
- }
-
- if (index.row() < 0 || index.row() >= mContactList.count() ||
- index.column() < 0 || index.column() > 17) {
- return QVariant();
- }
-
- if (role == ServerRole) {
- return mServerList.at(index.row());
- }
-
- if ((role != Qt::DisplayRole) && (role != Qt::ToolTipRole)) {
- return QVariant();
- }
-
- const KLDAP::LdapAttrMap map = mContactList.at(index.row());
-
- switch (index.column()) {
- case 0:
- return join(map.value(QStringLiteral("cn")), QStringLiteral(", "));
- break;
- case 1:
- return join(map.value(QStringLiteral("mail")), QStringLiteral(", "));
- break;
- case 2:
- return join(map.value(QStringLiteral("homePhone")), QStringLiteral(", "));
- break;
- case 3:
- return join(map.value(QStringLiteral("telephoneNumber")), QStringLiteral(", "));
- break;
- case 4:
- return join(map.value(QStringLiteral("mobile")), QStringLiteral(", "));
- break;
- case 5:
- return join(map.value(QStringLiteral("facsimileTelephoneNumber")), QStringLiteral(", "));
- break;
- case 6:
- return join(map.value(QStringLiteral("Company")), QStringLiteral(", "));
- break;
- case 7:
- return join(map.value(QStringLiteral("o")), QStringLiteral(", "));
- break;
- case 8:
- return join(map.value(QStringLiteral("street")), QStringLiteral(", "));
- break;
- case 9:
- return join(map.value(QStringLiteral("st")), QStringLiteral(", "));
- break;
- case 10:
- return join(map.value(QStringLiteral("co")), QStringLiteral(", "));
- break;
- case 11:
- return join(map.value(QStringLiteral("postalCode")), QStringLiteral(", "));
- break;
- case 12:
- return join(map.value(QStringLiteral("postalAddress")), QStringLiteral(", "));
- break;
- case 13:
- return join(map.value(QStringLiteral("l")), QStringLiteral(", "));
- break;
- case 14:
- return join(map.value(QStringLiteral("department")), QStringLiteral(", "));
- break;
- case 15:
- return join(map.value(QStringLiteral("description")), QStringLiteral(", "));
- break;
- case 16:
- return join(map.value(QStringLiteral("uid")), QStringLiteral(", "));
- break;
- case 17:
- return join(map.value(QStringLiteral("title")), QStringLiteral(", "));
- break;
- default:
- return QVariant();
- break;
- }
-
- return QVariant();
- }
-
-private:
- QVector<KLDAP::LdapAttrMap> mContactList;
- QStringList mServerList;
-};
-
-class Q_DECL_HIDDEN LdapSearchDialog::Private
-{
-public:
- Private(LdapSearchDialog *qq)
- : q(qq),
- mNumHosts(0),
- mIsConfigured(false),
- mFilterCombo(Q_NULLPTR),
- mSearchType(Q_NULLPTR),
- mSearchEdit(Q_NULLPTR),
- mRecursiveCheckbox(Q_NULLPTR),
- mResultView(Q_NULLPTR),
- mSearchButton(Q_NULLPTR),
- mModel(Q_NULLPTR),
- progressIndication(Q_NULLPTR),
- sortproxy(Q_NULLPTR),
- searchLine(Q_NULLPTR),
- user1Button(Q_NULLPTR)
- {
- }
-
- QList< QPair<KLDAP::LdapAttrMap, QString> > selectedItems()
- {
- QList< QPair<KLDAP::LdapAttrMap, QString> > contacts;
-
- const QModelIndexList selected = mResultView->selectionModel()->selectedRows();
- const int numberOfSelectedElement(selected.count());
- contacts.reserve(numberOfSelectedElement);
- for (int i = 0; i < numberOfSelectedElement; ++i) {
- contacts.append(mModel->contact(sortproxy->mapToSource(selected.at(i))));
- }
-
- return contacts;
- }
-
- void saveSettings();
- void restoreSettings();
- void cancelQuery();
-
- void slotAddResult(const KLDAP::LdapClient &, const KLDAP::LdapObject &);
- void slotSetScope(bool);
- void slotStartSearch();
- void slotStopSearch();
- void slotSearchDone();
- void slotError(const QString &);
- void slotSelectAll();
- void slotUnselectAll();
- void slotSelectionChanged();
-
- LdapSearchDialog *q;
- KGuiItem startSearchGuiItem;
- KGuiItem stopSearchGuiItem;
- int mNumHosts;
- QList<KLDAP::LdapClient *> mLdapClientList;
- bool mIsConfigured;
- KContacts::Addressee::List mSelectedContacts;
-
- KComboBox *mFilterCombo;
- KComboBox *mSearchType;
- QLineEdit *mSearchEdit;
-
- QCheckBox *mRecursiveCheckbox;
- QTableView *mResultView;
- QPushButton *mSearchButton;
- ContactListModel *mModel;
- KPIM::ProgressIndicatorLabel *progressIndication;
- QSortFilterProxyModel *sortproxy;
- KLineEdit *searchLine;
- QPushButton *user1Button;
-};
-
-LdapSearchDialog::LdapSearchDialog(QWidget *parent)
- : QDialog(parent), d(new Private(this))
-{
- setWindowTitle(i18n("Import Contacts from LDAP"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- d->user1Button = new QPushButton;
- buttonBox->addButton(d->user1Button, QDialogButtonBox::ActionRole);
-
- QPushButton *user2Button = new QPushButton;
- buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
-
- connect(d->user1Button, &QPushButton::clicked, this, &LdapSearchDialog::slotUser1);
- connect(user2Button, &QPushButton::clicked, this, &LdapSearchDialog::slotUser2);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &LdapSearchDialog::slotCancelClicked);
- d->user1Button->setDefault(true);
- setModal(false);
- KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::close());
- QFrame *page = new QFrame(this);
- mainLayout->addWidget(page);
- mainLayout->addWidget(buttonBox);
-
- QVBoxLayout *topLayout = new QVBoxLayout(page);
-
- QGroupBox *groupBox = new QGroupBox(i18n("Search for Addresses in Directory"),
- page);
- QGridLayout *boxLayout = new QGridLayout();
- groupBox->setLayout(boxLayout);
- boxLayout->setColumnStretch(1, 1);
-
- QLabel *label = new QLabel(i18n("Search for:"), groupBox);
- boxLayout->addWidget(label, 0, 0);
-
- d->mSearchEdit = new QLineEdit(groupBox);
- d->mSearchEdit->setClearButtonEnabled(true);
- boxLayout->addWidget(d->mSearchEdit, 0, 1);
- label->setBuddy(d->mSearchEdit);
-
- label = new QLabel(i18nc("In LDAP attribute", "in"), groupBox);
- boxLayout->addWidget(label, 0, 2);
-
- d->mFilterCombo = new KComboBox(groupBox);
- d->mFilterCombo->addItem(i18nc("@item:inlistbox Name of the contact", "Name"), QVariant::fromValue(Name));
- d->mFilterCombo->addItem(i18nc("@item:inlistbox email address of the contact", "Email"), QVariant::fromValue(Email));
- d->mFilterCombo->addItem(i18nc("@item:inlistbox", "Home Number"), QVariant::fromValue(HomeNumber));
- d->mFilterCombo->addItem(i18nc("@item:inlistbox", "Work Number"), QVariant::fromValue(WorkNumber));
- boxLayout->addWidget(d->mFilterCombo, 0, 3);
- d->startSearchGuiItem = KGuiItem(i18nc("@action:button Start searching", "&Search"), QStringLiteral("edit-find"));
- d->stopSearchGuiItem = KStandardGuiItem::stop();
-
- QSize buttonSize;
- d->mSearchButton = new QPushButton(groupBox);
- KGuiItem::assign(d->mSearchButton, d->startSearchGuiItem);
-
- buttonSize = d->mSearchButton->sizeHint();
- if (buttonSize.width() < d->mSearchButton->sizeHint().width()) {
- buttonSize = d->mSearchButton->sizeHint();
- }
- d->mSearchButton->setFixedWidth(buttonSize.width());
-
- d->mSearchButton->setDefault(true);
- boxLayout->addWidget(d->mSearchButton, 0, 4);
-
- d->mRecursiveCheckbox = new QCheckBox(i18n("Recursive search"), groupBox);
- d->mRecursiveCheckbox->setChecked(true);
- boxLayout->addWidget(d->mRecursiveCheckbox, 1, 0, 1, 5);
-
- d->mSearchType = new KComboBox(groupBox);
- d->mSearchType->addItem(i18n("Contains"));
- d->mSearchType->addItem(i18n("Starts With"));
- boxLayout->addWidget(d->mSearchType, 1, 3, 1, 2);
-
- topLayout->addWidget(groupBox);
-
- QHBoxLayout *quickSearchLineLayout = new QHBoxLayout;
- quickSearchLineLayout->addStretch();
- d->searchLine = new KLineEdit;
- d->searchLine->setTrapReturnKey(true);
- d->searchLine->setClearButtonEnabled(true);
- d->searchLine->setPlaceholderText(i18n("Search in result"));
- quickSearchLineLayout->addWidget(d->searchLine);
- topLayout->addLayout(quickSearchLineLayout);
-
- d->mResultView = new QTableView(page);
- d->mResultView->setSelectionMode(QTableView::MultiSelection);
- d->mResultView->setSelectionBehavior(QTableView::SelectRows);
- d->mModel = new ContactListModel(d->mResultView);
-
- d->sortproxy = new QSortFilterProxyModel(this);
- d->sortproxy->setFilterKeyColumn(-1); //Search in all column
- d->sortproxy->setSourceModel(d->mModel);
- d->sortproxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
- connect(d->searchLine, &QLineEdit::textChanged, d->sortproxy, &QSortFilterProxyModel::setFilterFixedString);
-
- d->mResultView->setModel(d->sortproxy);
- d->mResultView->verticalHeader()->hide();
- d->mResultView->setSortingEnabled(true);
- d->mResultView->horizontalHeader()->setSortIndicatorShown(true);
- connect(d->mResultView, SIGNAL(clicked(QModelIndex)),
- SLOT(slotSelectionChanged()));
- topLayout->addWidget(d->mResultView);
-
- d->mResultView->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(d->mResultView, &QTableView::customContextMenuRequested, this, &LdapSearchDialog::slotCustomContextMenuRequested);
-
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- buttonLayout->setMargin(0);
- topLayout->addLayout(buttonLayout);
-
- d->progressIndication = new KPIM::ProgressIndicatorLabel(i18n("Searching..."));
- buttonLayout->addWidget(d->progressIndication);
-
- QDialogButtonBox *buttons = new QDialogButtonBox(page);
- QPushButton *button = buttons->addButton(i18n("Select All"),
- QDialogButtonBox::ActionRole);
- connect(button, SIGNAL(clicked()), this, SLOT(slotSelectAll()));
- button = buttons->addButton(i18n("Unselect All"),
- QDialogButtonBox::ActionRole);
- connect(button, SIGNAL(clicked()), this, SLOT(slotUnselectAll()));
-
- buttonLayout->addWidget(buttons);
-
- d->user1Button->setText(i18n("Add Selected"));
- user2Button->setText(i18n("Configure LDAP Servers..."));
-
- connect(d->mRecursiveCheckbox, SIGNAL(toggled(bool)),
- this, SLOT(slotSetScope(bool)));
- connect(d->mSearchButton, SIGNAL(clicked()),
- this, SLOT(slotStartSearch()));
-
- setTabOrder(d->mSearchEdit, d->mFilterCombo);
- setTabOrder(d->mFilterCombo, d->mSearchButton);
- d->mSearchEdit->setFocus();
-
- d->slotSelectionChanged();
- d->restoreSettings();
-}
-
-LdapSearchDialog::~LdapSearchDialog()
-{
- d->saveSettings();
- delete d;
-}
-
-void LdapSearchDialog::setSearchText(const QString &text)
-{
- d->mSearchEdit->setText(text);
-}
-
-KContacts::Addressee::List LdapSearchDialog::selectedContacts() const
-{
- return d->mSelectedContacts;
-}
-
-void LdapSearchDialog::slotCustomContextMenuRequested(const QPoint &pos)
-{
- const QModelIndex index = d->mResultView->indexAt(pos);
- if (index.isValid()) {
- QMenu menu;
- QAction *act = menu.addAction(i18n("Copy"));
- if (menu.exec(QCursor::pos()) == act) {
- QClipboard *cb = QApplication::clipboard();
- cb->setText(index.data().toString(), QClipboard::Clipboard);
- }
- }
-}
-
-void LdapSearchDialog::Private::slotSelectionChanged()
-{
- user1Button->setEnabled(mResultView->selectionModel()->hasSelection());
-}
-
-void LdapSearchDialog::Private::restoreSettings()
-{
- // Create one KLDAP::LdapClient per selected server and configure it.
-
- // First clean the list to make sure it is empty at
- // the beginning of the process
- qDeleteAll(mLdapClientList);
- mLdapClientList.clear();
-
- KConfig *config = KLDAP::LdapClientSearchConfig::config();
-
- KConfigGroup searchGroup(config, "LDAPSearch");
- mSearchType->setCurrentIndex(searchGroup.readEntry("SearchType", 0));
-
- // then read the config file and register all selected
- // server in the list
- KConfigGroup group(config, "LDAP");
- mNumHosts = group.readEntry("NumSelectedHosts", 0);
- if (!mNumHosts) {
- mIsConfigured = false;
- } else {
- mIsConfigured = true;
- KLDAP::LdapClientSearchConfig *clientSearchConfig = new KLDAP::LdapClientSearchConfig;
- for (int j = 0; j < mNumHosts; ++j) {
- KLDAP::LdapServer ldapServer;
- KLDAP::LdapClient *ldapClient = new KLDAP::LdapClient(0, q);
- clientSearchConfig->readConfig(ldapServer, group, j, true);
- ldapClient->setServer(ldapServer);
- QStringList attrs;
-
- QMap<QString, QString>::ConstIterator end(adrbookattr2ldap().constEnd());
- for (QMap<QString, QString>::ConstIterator it = adrbookattr2ldap().constBegin();
- it != end; ++it) {
- attrs << *it;
- }
-
- ldapClient->setAttributes(attrs);
-
- q->connect(ldapClient, SIGNAL(result(KLDAP::LdapClient,KLDAP::LdapObject)), q, SLOT(slotAddResult(KLDAP::LdapClient,KLDAP::LdapObject)));
- q->connect(ldapClient, SIGNAL(done()), q, SLOT(slotSearchDone()));
- q->connect(ldapClient, SIGNAL(error(QString)), q, SLOT(slotError(QString)));
-
- mLdapClientList.append(ldapClient);
- }
- delete clientSearchConfig;
-
- mModel->clear();
- }
- KConfigGroup groupHeader(config, "Headers");
- mResultView->horizontalHeader()->restoreState(groupHeader.readEntry("HeaderState", QByteArray()));
-
- KConfigGroup groupSize(config, "Size");
- const QSize dialogSize = groupSize.readEntry("Size", QSize());
- if (dialogSize.isValid()) {
- q->resize(dialogSize);
- } else {
- q->resize(QSize(600, 400).expandedTo(q->minimumSizeHint()));
- }
-}
-
-void LdapSearchDialog::Private::saveSettings()
-{
- KConfig *config = KLDAP::LdapClientSearchConfig::config();
- KConfigGroup group(config, "LDAPSearch");
- group.writeEntry("SearchType", mSearchType->currentIndex());
-
- KConfigGroup groupHeader(config, "Headers");
- groupHeader.writeEntry("HeaderState", mResultView->horizontalHeader()->saveState());
- groupHeader.sync();
-
- KConfigGroup size(config, "Size");
- size.writeEntry("Size", q->size());
- size.sync();
-
- group.sync();
-}
-
-void LdapSearchDialog::Private::cancelQuery()
-{
- Q_FOREACH (KLDAP::LdapClient *client, mLdapClientList) {
- client->cancelQuery();
- }
-}
-
-void LdapSearchDialog::Private::slotAddResult(const KLDAP::LdapClient &client,
- const KLDAP::LdapObject &obj)
-{
- mModel->addContact(obj.attributes(), client.server().host());
-}
-
-void LdapSearchDialog::Private::slotSetScope(bool rec)
-{
- Q_FOREACH (KLDAP::LdapClient *client, mLdapClientList) {
- if (rec) {
- client->setScope(QStringLiteral("sub"));
- } else {
- client->setScope(QStringLiteral("one"));
- }
- }
-}
-
-void LdapSearchDialog::Private::slotStartSearch()
-{
- cancelQuery();
-
- if (!mIsConfigured) {
- KMessageBox::error(q, i18n("You must select an LDAP server before searching."));
- q->slotUser2();
- return;
- }
-
-#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
-#endif
- KGuiItem::assign(mSearchButton, stopSearchGuiItem);
- progressIndication->start();
-
- q->disconnect(mSearchButton, SIGNAL(clicked()), q, SLOT(slotStartSearch()));
- q->connect(mSearchButton, SIGNAL(clicked()), q, SLOT(slotStopSearch()));
-
- const bool startsWith = (mSearchType->currentIndex() == 1);
-
- const QString filter = makeFilter(mSearchEdit->text().trimmed(),
- mFilterCombo->currentData().value<FilterType>(), startsWith);
-
- // loop in the list and run the KLDAP::LdapClients
- mModel->clear();
- Q_FOREACH (KLDAP::LdapClient *client, mLdapClientList) {
- client->startQuery(filter);
- }
-
- saveSettings();
-}
-
-void LdapSearchDialog::Private::slotStopSearch()
-{
- cancelQuery();
- slotSearchDone();
-}
-
-void LdapSearchDialog::Private::slotSearchDone()
-{
- // If there are no more active clients, we are done.
- Q_FOREACH (KLDAP::LdapClient *client, mLdapClientList) {
- if (client->isActive()) {
- return;
- }
- }
-
- q->disconnect(mSearchButton, SIGNAL(clicked()), q, SLOT(slotStopSearch()));
- q->connect(mSearchButton, SIGNAL(clicked()), q, SLOT(slotStartSearch()));
-
- KGuiItem::assign(mSearchButton, startSearchGuiItem);
- progressIndication->stop();
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
-}
-
-void LdapSearchDialog::Private::slotError(const QString &error)
-{
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
- KMessageBox::error(q, error);
-}
-
-void LdapSearchDialog::closeEvent(QCloseEvent *e)
-{
- d->slotStopSearch();
- e->accept();
-}
-
-void LdapSearchDialog::Private::slotUnselectAll()
-{
- mResultView->clearSelection();
- slotSelectionChanged();
-}
-
-void LdapSearchDialog::Private::slotSelectAll()
-{
- mResultView->selectAll();
- slotSelectionChanged();
-}
-
-void LdapSearchDialog::slotUser1()
-{
- // Import selected items
-
- d->mSelectedContacts.clear();
-
- const QList< QPair<KLDAP::LdapAttrMap, QString> > &items = d->selectedItems();
-
- if (!items.isEmpty()) {
- const QDateTime now = QDateTime::currentDateTime();
-
- for (int i = 0; i < items.count(); ++i) {
- KContacts::Addressee contact = convertLdapAttributesToAddressee(items.at(i).first);
-
- // set a comment where the contact came from
- contact.setNote(i18nc("arguments are host name, datetime",
- "Imported from LDAP directory %1 on %2",
- items.at(i).second, QLocale().toString(now, QLocale::ShortFormat)));
-
- d->mSelectedContacts.append(contact);
- }
- }
-
- d->slotStopSearch();
- Q_EMIT contactsAdded();
-
- accept();
-}
-
-void LdapSearchDialog::slotUser2()
-{
- // Configure LDAP servers
-
- KCMultiDialog dialog(this);
- dialog.setWindowTitle(i18n("Configure the Address Book LDAP Settings"));
- dialog.addModule(QStringLiteral("kcmldap.desktop"));
-
- if (dialog.exec()) { //krazy:exclude=crashy
- d->restoreSettings();
- }
-}
-
-void LdapSearchDialog::slotCancelClicked()
-{
- d->slotStopSearch();
- reject();
-}
-
-#include "moc_ldapsearchdialog.cpp"
diff --git a/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.h b/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.h
deleted file mode 100644
index d7d797f..0000000
--- a/3rdparty/kdepim/libkdepim/ldap/ldapsearchdialog.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * This file is part of libkldap.
- *
- * Copyright (C) 2002 Klarälvdalens Datakonsult AB
- *
- * Author: Steffen Hansen <hansen@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-//AK_REVIEW: move back to libkdepim, not ready yet
-#ifndef KLDAP_LDAPSEARCHDIALOG_H
-#define KLDAP_LDAPSEARCHDIALOG_H
-
-#include "kdepim_export.h"
-
-#include <kcontacts/addressee.h>
-#include <QDialog>
-
-class QCloseEvent;
-
-namespace KLDAP
-{
-
-class LdapClient;
-class LdapObject;
-
-/**
- * @short A dialog to search contacts in a LDAP directory.
- *
- * This dialog allows the user to search for contacts inside
- * a LDAP directory.
- *
- * @author Steffen Hansen <hansen@kde.org>
- * @since 4.5
- */
-class KDEPIM_EXPORT LdapSearchDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- enum FilterType {
- Name = 0,
- Email,
- HomeNumber,
- WorkNumber
- };
-
- /**
- * Creates a new ldap search dialog.
- *
- * @param parent The parent widget.
- */
- explicit LdapSearchDialog(QWidget *parent = Q_NULLPTR);
-
- /**
- * Destroys the ldap search dialog.
- */
- ~LdapSearchDialog();
-
- /**
- * Sets the @p text in the search line edit.
- */
- void setSearchText(const QString &text);
-
- /**
- * Returns a list of contacts that have been selected
- * in the LDAP search.
- */
- KContacts::Addressee::List selectedContacts() const;
-
-Q_SIGNALS:
- /**
- * This signal is emitted whenever the user clicked the
- * 'Add Selected' button.
- */
- void contactsAdded();
-
-protected Q_SLOTS:
- void slotUser1();
- void slotUser2();
- void slotCustomContextMenuRequested(const QPoint &);
- void slotCancelClicked();
-
-protected:
- void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE;
-
-private:
- //@cond PRIVATE
- class Private;
- Private *const d;
-
- Q_PRIVATE_SLOT(d, void slotAddResult(const KLDAP::LdapClient &, const KLDAP::LdapObject &))
- Q_PRIVATE_SLOT(d, void slotSetScope(bool))
- Q_PRIVATE_SLOT(d, void slotStartSearch())
- Q_PRIVATE_SLOT(d, void slotStopSearch())
- Q_PRIVATE_SLOT(d, void slotSearchDone())
- Q_PRIVATE_SLOT(d, void slotError(const QString &))
- Q_PRIVATE_SLOT(d, void slotSelectAll())
- Q_PRIVATE_SLOT(d, void slotUnselectAll())
- Q_PRIVATE_SLOT(d, void slotSelectionChanged())
- //@endcond
-};
-
-}
-Q_DECLARE_METATYPE(KLDAP::LdapSearchDialog::FilterType)
-#endif
diff --git a/3rdparty/kdepim/libkdepim/libkdepim_debug.cpp b/3rdparty/kdepim/libkdepim/libkdepim_debug.cpp
deleted file mode 100644
index 5c65417..0000000
--- a/3rdparty/kdepim/libkdepim/libkdepim_debug.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2014-2015 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "libkdepim_debug.h"
-Q_LOGGING_CATEGORY(LIBKDEPIM_LOG, "log_libkdepim")
-
diff --git a/3rdparty/kdepim/libkdepim/libkdepim_debug.h b/3rdparty/kdepim/libkdepim/libkdepim_debug.h
deleted file mode 100644
index 4ff5803..0000000
--- a/3rdparty/kdepim/libkdepim/libkdepim_debug.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2014-2015 Laurent Montel <montel@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LIBKDEPIM_DEBUG_H
-#define LIBKDEPIM_DEBUG_H
-
-#include <QLoggingCategory>
-Q_DECLARE_LOGGING_CATEGORY(LIBKDEPIM_LOG)
-
-#endif
-
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.cpp b/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.cpp
deleted file mode 100644
index bbf3e51..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "recentaddressdialog.h"
-#include "recentaddresswidget.h"
-#include "recentaddresses.h"
-
-#include <KConfigGroup>
-#include <KSharedConfig>
-#include <QCoreApplication>
-#include <QLayout>
-#include <QVBoxLayout>
-#include <QDialogButtonBox>
-#include <QPushButton>
-#include <KLocalizedString>
-using namespace KPIM;
-
-RecentAddressDialog::RecentAddressDialog(QWidget *parent)
- : QDialog(parent)
-{
- setWindowTitle(i18n("Edit Recent Addresses"));
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- buttonBox->setObjectName(QStringLiteral("buttonbox"));
- QVBoxLayout *mainLayout = new QVBoxLayout;
- setLayout(mainLayout);
- mRecentAddressWidget = new RecentAddressWidget(this);
- mRecentAddressWidget->setObjectName(QStringLiteral("recentaddresswidget"));
-
- mainLayout->addWidget(mRecentAddressWidget);
- mainLayout->addWidget(buttonBox);
- QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
- okButton->setDefault(true);
- okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &RecentAddressDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &RecentAddressDialog::reject);
- okButton->setDefault(true);
- setModal(true);
- readConfig();
-}
-
-RecentAddressDialog::~RecentAddressDialog()
-{
- writeConfig();
-}
-
-void RecentAddressDialog::setAddresses(const QStringList &addrs)
-{
- mRecentAddressWidget->setAddresses(addrs);
-}
-
-void RecentAddressDialog::storeAddresses(KConfig *config)
-{
- mRecentAddressWidget->storeAddresses(config);
-}
-
-bool RecentAddressDialog::wasChanged() const
-{
- return mRecentAddressWidget->wasChanged();
-}
-
-void RecentAddressDialog::readConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "RecentAddressDialog");
- const QSize size = group.readEntry("Size", QSize(600, 400));
- if (size.isValid()) {
- resize(size);
- }
-}
-
-void RecentAddressDialog::writeConfig()
-{
- KConfigGroup group(KSharedConfig::openConfig(), "RecentAddressDialog");
- group.writeEntry("Size", size());
- group.sync();
-}
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.h b/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.h
deleted file mode 100644
index d1d179d..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddressdialog.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef RECENTADDRESSDIALOG_H
-#define RECENTADDRESSDIALOG_H
-
-#include "kdepim_export.h"
-#include <QDialog>
-#include <QStringList>
-class KConfig;
-
-namespace KPIM
-{
-class RecentAddressWidget;
-class KDEPIM_EXPORT RecentAddressDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit RecentAddressDialog(QWidget *parent = Q_NULLPTR);
- ~RecentAddressDialog();
-
- void setAddresses(const QStringList &addrs);
- void storeAddresses(KConfig *config);
- bool wasChanged() const;
-
-private:
- void readConfig();
- void writeConfig();
- RecentAddressWidget *mRecentAddressWidget;
-};
-}
-
-#endif // RECENTADDRESSDIALOG_H
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.cpp b/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.cpp
deleted file mode 100644
index ce29462..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- *
- * Copyright (c) 2001-2003 Carsten Pfeiffer <pfeiffer@kde.org>
- * Copyright (c) 2003 Zack Rusin <zack@kde.org>
- *
- * KMail is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation.
- *
- * KMail 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of this program with any edition of
- * the Qt library by Trolltech AS, Norway (or with modified versions
- * of Qt that use the same license as Qt), and distribute linked
- * combinations including the two. You must obey the GNU General
- * Public License in all respects for all of the code used other than
- * Qt. If you modify this file, you may extend this exception to
- * your version of the file, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from
- * your version.
- */
-#include "recentaddresses.h"
-
-#include <KEmailAddress>
-#include <KConfig>
-#include <KConfigGroup>
-#include "libkdepim_debug.h"
-#include <KLocalizedString>
-#include <KSharedConfig>
-#include <QCoreApplication>
-
-using namespace KPIM;
-
-RecentAddresses *s_self = Q_NULLPTR;
-
-void deleteGlobalRecentAddresses()
-{
- delete s_self;
- s_self = Q_NULLPTR;
-}
-
-RecentAddresses *RecentAddresses::self(KConfig *config)
-{
- if (!s_self) {
- s_self = new RecentAddresses(config);
- qAddPostRoutine(deleteGlobalRecentAddresses);
- }
- return s_self;
-}
-
-bool RecentAddresses::exists()
-{
- return s_self != Q_NULLPTR;
-}
-
-RecentAddresses::RecentAddresses(KConfig *config)
-{
- if (!config) {
- load(KSharedConfig::openConfig().data());
- } else {
- load(config);
- }
-}
-
-RecentAddresses::~RecentAddresses()
-{
- // if you want this destructor to get called, use K_GLOBAL_STATIC
- // on s_self
-}
-
-void RecentAddresses::load(KConfig *config)
-{
- QStringList addresses;
- QString name;
- QString email;
-
- m_addresseeList.clear();
- KConfigGroup cg(config, "General");
- m_maxCount = cg.readEntry("Maximum Recent Addresses", 40);
- addresses = cg.readEntry("Recent Addresses", QStringList());
- QStringList::ConstIterator end(addresses.constEnd());
- for (QStringList::ConstIterator it = addresses.constBegin(); it != end; ++it) {
- KContacts::Addressee::parseEmailAddress(*it, name, email);
- if (!email.isEmpty()) {
- KContacts::Addressee addr;
- addr.setNameFromString(name);
- addr.insertEmail(email, true);
- m_addresseeList.append(addr);
- }
- }
-
- adjustSize();
-}
-
-void RecentAddresses::save(KConfig *config)
-{
- KConfigGroup cg(config, "General");
- cg.writeEntry("Recent Addresses", addresses());
-}
-
-void RecentAddresses::add(const QString &entry)
-{
- if (!entry.isEmpty() && m_maxCount > 0) {
- const QStringList list = KEmailAddress::splitAddressList(entry);
- QStringList::const_iterator e_itEnd(list.constEnd());
- for (QStringList::const_iterator e_it = list.constBegin(); e_it != e_itEnd; ++e_it) {
- KEmailAddress::EmailParseResult errorCode = KEmailAddress::isValidAddress(*e_it);
- if (errorCode != KEmailAddress::AddressOk) {
- continue;
- }
- QString email;
- QString fullName;
- KContacts::Addressee addr;
-
- KContacts::Addressee::parseEmailAddress(*e_it, fullName, email);
-
- KContacts::Addressee::List::Iterator end(m_addresseeList.end());
- for (KContacts::Addressee::List::Iterator it = m_addresseeList.begin();
- it != end; ++it) {
- if (email == (*it).preferredEmail()) {
- //already inside, remove it here and add it later at pos==1
- m_addresseeList.erase(it);
- break;
- }
- }
- addr.setNameFromString(fullName);
- addr.insertEmail(email, true);
- m_addresseeList.prepend(addr);
- adjustSize();
- }
- }
-}
-
-void RecentAddresses::setMaxCount(int count)
-{
- if (count != m_maxCount) {
- m_maxCount = count;
- adjustSize();
- }
-}
-
-uint RecentAddresses::maxCount() const
-{
- return m_maxCount;
-}
-
-void RecentAddresses::adjustSize()
-{
- while (m_addresseeList.count() > m_maxCount) {
- m_addresseeList.takeLast();
- }
-}
-
-void RecentAddresses::clear()
-{
- m_addresseeList.clear();
- adjustSize();
-}
-
-QStringList RecentAddresses::addresses() const
-{
- QStringList addresses;
- addresses.reserve(m_addresseeList.count());
- KContacts::Addressee::List::ConstIterator end = m_addresseeList.constEnd();
- for (KContacts::Addressee::List::ConstIterator it = m_addresseeList.constBegin();
- it != end; ++it) {
- addresses.append((*it).fullEmail());
- }
- return addresses;
-}
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.h b/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.h
deleted file mode 100644
index 499a8aa..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresses.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *
- * Copyright (c) 2001-2003 Carsten Pfeiffer <pfeiffer@kde.org>
- * Copyright (c) 2003 Zack Rusin <zack@kde.org>
- *
- * KMail is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation.
- *
- * KMail 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
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of this program with any edition of
- * the Qt library by Trolltech AS, Norway (or with modified versions
- * of Qt that use the same license as Qt), and distribute linked
- * combinations including the two. You must obey the GNU General
- * Public License in all respects for all of the code used other than
- * Qt. If you modify this file, you may extend this exception to
- * your version of the file, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from
- * your version.
- */
-#ifndef KDEPIM_RECENTADDRESSES_H
-#define KDEPIM_RECENTADDRESSES_H
-
-#include "kdepim_export.h"
-#include <KContacts/Addressee>
-#include <QStringList>
-class KConfig;
-
-namespace KPIM
-{
-/**
- * Handles a list of "recent email-addresses". Simply set a max-count and
- * call @ref add() to add entries.
- *
- * @author Carsten Pfeiffer <pfeiffer@kde.org>
- */
-
-class KDEPIM_EXPORT RecentAddresses
-{
-public:
- ~RecentAddresses();
- /**
- * @returns the only possible instance of this class.
- */
- static RecentAddresses *self(KConfig *config = Q_NULLPTR);
-
- /*
- * @return true if self() was called, i.e. a RecentAddresses instance exists
- */
- static bool exists();
-
- /**
- * @returns the list of recent addresses.
- * Note: an entry doesn't have to be one email address, it can be multiple,
- * like "Foo <foo@bar.org>, Bar Baz <bar@baz.org>".
- */
- QStringList addresses() const;
-
- /**
- * Adds an entry to the list.
- * Note: an entry doesn't have to be one email address, it can be multiple,
- * like "Foo <foo@bar.org>, Bar Baz <bar@baz.org>".
- */
- void add(const QString &entry);
-
- /**
- * Sets the maximum number, the list can hold. The list adjusts to this
- * size if necessary. Default maximum is 40.
- */
- void setMaxCount(int count);
-
- /**
- * @returns the current maximum number of entries.
- */
- uint maxCount() const;
-
- /**
- * Loads the list of recently used addresses from the configfile.
- * Automatically done on startup.
- */
- void load(KConfig *);
-
- /**
- * Saves the list of recently used addresses to the configfile.
- * Make sure to call KSharedConfig::openConfig()->sync() afterwards, to really save.
- */
- void save(KConfig *);
-
- /**
- * Removes all entries from the history.
- */
- void clear();
-
-private:
- explicit RecentAddresses(KConfig *config = Q_NULLPTR);
- void adjustSize();
-
- KContacts::Addressee::List m_addresseeList;
-
- int m_maxCount;
-};
-
-}
-
-#endif
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.cpp b/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.cpp
deleted file mode 100644
index 53bab2f..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#include "recentaddresswidget.h"
-#include "recentaddresses.h"
-
-#include <KConfig>
-#include <KConfigGroup>
-#include <KLineEdit>
-#include <QPushButton>
-#include <KMessageBox>
-#include <KLocalizedString>
-
-#include <QCoreApplication>
-#include <QLayout>
-#include <QVBoxLayout>
-#include <QListWidget>
-#include <QKeyEvent>
-
-using namespace KPIM;
-RecentAddressWidget::RecentAddressWidget(QWidget *parent)
- : QWidget(parent)
-{
- QVBoxLayout *layout = new QVBoxLayout(this);
-
- mLineEdit = new KLineEdit(this);
- mLineEdit->setObjectName(QStringLiteral("line_edit"));
- layout->addWidget(mLineEdit);
-
- mLineEdit->setTrapReturnKey(true);
- mLineEdit->installEventFilter(this);
-
- connect(mLineEdit, &KLineEdit::textChanged, this, &RecentAddressWidget::slotTypedSomething);
- connect(mLineEdit, &KLineEdit::returnPressed, this, &RecentAddressWidget::slotAddItem);
-
- QHBoxLayout *hboxLayout = new QHBoxLayout;
-
- QVBoxLayout *btnsLayout = new QVBoxLayout;
- btnsLayout->addStretch();
-
- mNewButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), i18n("&Add"), this);
- mNewButton->setObjectName(QStringLiteral("new_button"));
- connect(mNewButton, &QPushButton::clicked, this, &RecentAddressWidget::slotAddItem);
- btnsLayout->insertWidget(0, mNewButton);
-
- mRemoveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), i18n("&Remove"), this);
- mRemoveButton->setObjectName(QStringLiteral("remove_button"));
- mRemoveButton->setEnabled(false);
- connect(mRemoveButton, &QPushButton::clicked, this, &RecentAddressWidget::slotRemoveItem);
- btnsLayout->insertWidget(1, mRemoveButton);
-
- mListView = new QListWidget(this);
- mListView->setObjectName(QStringLiteral("list_view"));
- mListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- mListView->setSortingEnabled(true);
- hboxLayout->addWidget(mListView);
- hboxLayout->addLayout(btnsLayout);
- layout->addLayout(hboxLayout);
- connect(mListView, &QListWidget::itemSelectionChanged, this, &RecentAddressWidget::slotSelectionChanged);
- // maybe supplied lineedit has some text already
- slotTypedSomething(mLineEdit->text());
-}
-
-RecentAddressWidget::~RecentAddressWidget()
-{
-
-}
-
-void RecentAddressWidget::slotTypedSomething(const QString &text)
-{
- if (mListView->currentItem()) {
- if (mListView->currentItem()->text() != mLineEdit->text() && !mLineEdit->text().isEmpty()) {
- // IMHO changeItem() shouldn't do anything with the value
- // of currentItem() ... like changing it or emitting signals ...
- // but TT disagree with me on this one (it's been that way since ages ... grrr)
- bool block = mListView->signalsBlocked();
- mListView->blockSignals(true);
- QListWidgetItem *currentIndex = mListView->currentItem();
- if (currentIndex) {
- currentIndex->setText(text);
- mDirty = true;
- }
- mListView->blockSignals(block);
- }
- }
-}
-
-void RecentAddressWidget::slotAddItem()
-{
- if (mListView->count() > 0) {
- const QString text = mListView->item(0)->text();
- if (text.isEmpty()) {
- return;
- }
- }
- mListView->blockSignals(true);
- mListView->insertItem(0, QString());
- mListView->blockSignals(false);
- mListView->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
- mLineEdit->setFocus();
- mDirty = true;
- updateButtonState();
-}
-
-void RecentAddressWidget::slotRemoveItem()
-{
- QList<QListWidgetItem *> selectedItems = mListView->selectedItems();
- if (selectedItems.isEmpty()) {
- return;
- }
- if (KMessageBox::Yes == KMessageBox::questionYesNo(this, i18np("Do you want to remove this email address?", "Do you want to remove %1 email addresses?", selectedItems.count()), i18n("Remove"))) {
- Q_FOREACH (QListWidgetItem *item, selectedItems) {
- delete mListView->takeItem(mListView->row(item));
- }
- mDirty = true;
- updateButtonState();
- }
-}
-
-void RecentAddressWidget::updateButtonState()
-{
- QList<QListWidgetItem *> selectedItems = mListView->selectedItems();
- const int numberOfElementSelected(selectedItems.count());
- mRemoveButton->setEnabled(numberOfElementSelected);
- mNewButton->setEnabled(numberOfElementSelected <= 1);
- mLineEdit->setEnabled(numberOfElementSelected <= 1);
-
- if (numberOfElementSelected == 1) {
- const QString text = mListView->currentItem()->text();
- if (text != mLineEdit->text()) {
- mLineEdit->setText(text);
- }
- } else {
- mLineEdit->clear();
- }
-}
-
-void RecentAddressWidget::slotSelectionChanged()
-{
- updateButtonState();
-}
-
-void RecentAddressWidget::setAddresses(const QStringList &addrs)
-{
- mListView->clear();
- mListView->addItems(addrs);
-}
-
-bool RecentAddressWidget::eventFilter(QObject *o, QEvent *e)
-{
- if (o == mLineEdit && e->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = (QKeyEvent *)e;
- if (keyEvent->key() == Qt::Key_Down ||
- keyEvent->key() == Qt::Key_Up) {
- return ((QObject *)mListView)->event(e);
- }
- }
-
- return false;
-}
-
-void RecentAddressWidget::storeAddresses(KConfig *config)
-{
- const int numberOfItem(mListView->count());
- for (int i = 0; i < numberOfItem; ++i) {
- KPIM::RecentAddresses::self(config)->add(mListView->item(i)->text());
- }
-}
-
-bool RecentAddressWidget::wasChanged() const
-{
- return mDirty;
-}
diff --git a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.h b/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.h
deleted file mode 100644
index a1ec469..0000000
--- a/3rdparty/kdepim/libkdepim/recentaddress/recentaddresswidget.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- Copyright (c) 2015 Montel Laurent <montel@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
-*/
-
-#ifndef RECENTADDRESSWIDGET_H
-#define RECENTADDRESSWIDGET_H
-
-#include <QWidget>
-#include <QStringList>
-class KConfig;
-class QPushButton;
-class QListWidget;
-class KLineEdit;
-
-namespace KPIM
-{
-class RecentAddressWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit RecentAddressWidget(QWidget *parent = Q_NULLPTR);
- ~RecentAddressWidget();
-
- void setAddresses(const QStringList &addrs);
- void storeAddresses(KConfig *config);
- bool wasChanged() const;
-
-private Q_SLOTS:
- void slotAddItem();
- void slotRemoveItem();
- void slotSelectionChanged();
- void slotTypedSomething(const QString &);
-
-protected:
- void updateButtonState();
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
-
-private:
- QPushButton *mNewButton, *mRemoveButton;
- QListWidget *mListView;
- KLineEdit *mLineEdit;
- bool mDirty;
-};
-}
-#endif // RECENTADDRESSWIDGET_H
diff --git a/3rdparty/kdepim/libkdepim/tests/CMakeLists.txt b/3rdparty/kdepim/libkdepim/tests/CMakeLists.txt
deleted file mode 100644
index 5073b92..0000000
--- a/3rdparty/kdepim/libkdepim/tests/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-include_directories(../)
-set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
-
-########### next target ###############
-
-set(testaddresseelineedit_SRCS testaddresseelineedit.cpp)
-
-add_executable(testaddresseelineedit ${testaddresseelineedit_SRCS})
-ecm_mark_as_test(testaddresseelineedit)
-
-target_link_libraries(testaddresseelineedit zanshinkdepimstatic)
-
-########### next target ###############
-
-set(testldapclient_SRCS testldapclient.cpp)
-
-add_executable(testldapclient ${testldapclient_SRCS})
-ecm_mark_as_test(testldapclient)
-
-target_link_libraries(testldapclient zanshinkdepimstatic)
-
diff --git a/3rdparty/kdepim/libkdepim/tests/testaddresseelineedit.cpp b/3rdparty/kdepim/libkdepim/tests/testaddresseelineedit.cpp
deleted file mode 100644
index 92ea4fd..0000000
--- a/3rdparty/kdepim/libkdepim/tests/testaddresseelineedit.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- This file is part of libkdepim.
-
- Copyright (c) 2004 Daniel Molkentin <danimo@klaralvdalens-datakonsult.se>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-#include <QWidget>
-#include <QVBoxLayout>
-
-#include <KAboutData>
-
-#include <KLocalizedString>
-#include "../addressline/addresseelineedit.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QStandardPaths>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- KAboutData aboutData(QStringLiteral("testaddresseelineedit"), i18n("Test AddresseeLineEdit"), QStringLiteral("0.1"));
- QStandardPaths::setTestModeEnabled(true);
- QCommandLineParser parser;
- KAboutData::setApplicationData(aboutData);
- parser.addVersionOption();
- parser.addHelpOption();
- aboutData.setupCommandLine(&parser);
- parser.process(app);
- aboutData.processCommandLine(&parser);
-
- QWidget *w = new QWidget;
- QVBoxLayout *vbox = new QVBoxLayout(w);
-
- KPIM::AddresseeLineEdit *kale1 = new KPIM::AddresseeLineEdit(Q_NULLPTR);
- vbox->addWidget(kale1);
- KPIM::AddresseeLineEdit *kale2 = new KPIM::AddresseeLineEdit(Q_NULLPTR);
- vbox->addWidget(kale2);
- vbox->addStretch();
-
- w->resize(400, 400);
- w->show();
-
- return app.exec();
-
-}
-
diff --git a/3rdparty/kdepim/libkdepim/tests/testldapclient.cpp b/3rdparty/kdepim/libkdepim/tests/testldapclient.cpp
deleted file mode 100644
index 1ef1750..0000000
--- a/3rdparty/kdepim/libkdepim/tests/testldapclient.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2005 David Faure <faure@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "testldapclient.h"
-
-#include <qdebug.h>
-
-#include <kldap/ldapobject.h>
-
-#include <QEventLoop>
-
-#include <assert.h>
-#include <stdlib.h>
-#include <QApplication>
-#include <KAboutData>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QStandardPaths>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QStandardPaths::setTestModeEnabled(true);
- QCommandLineParser parser;
- parser.addVersionOption();
- parser.addHelpOption();
- parser.process(app);
-
- TestLDAPClient test;
- test.setup();
- test.runAll();
- test.cleanup();
- qDebug() << "All tests OK.";
- return 0;
-}
-
-TestLDAPClient::TestLDAPClient()
- : mClient(Q_NULLPTR)
-{
-}
-
-void TestLDAPClient::setup()
-{
-}
-
-void TestLDAPClient::runAll()
-{
- testIntevation();
-}
-
-bool TestLDAPClient::check(const QString &txt, QString a, QString b)
-{
- if (a.isEmpty()) {
- a.clear();
- }
-
- if (b.isEmpty()) {
- b.clear();
- }
-
- if (a == b) {
- qDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'..." << "ok";
- } else {
- qDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'..." << "KO !";
- cleanup();
- exit(1);
- }
-
- return true;
-}
-
-void TestLDAPClient::cleanup()
-{
- mClient = Q_NULLPTR;
-}
-
-void TestLDAPClient::testIntevation()
-{
- qDebug();
- mClient = new KLDAP::LdapClient(0, this);
-
-#ifdef __GNUC__
-#warning TODO!
-#endif
-#if 0
- mClient->setHost("ca.intevation.de");
- mClient->setPort("389");
- mClient->setBase("o=Intevation GmbH,c=de");
-#endif
-
- // Same list as in kaddressbook's ldapsearchdialog
- QStringList attrs;
- attrs << QStringLiteral("l") << QStringLiteral("Company") << QStringLiteral("co") << QStringLiteral("department") << QStringLiteral("description") << QStringLiteral("mail")
- << QStringLiteral("facsimileTelephoneNumber") << QStringLiteral("cn") << QStringLiteral("homePhone") << QStringLiteral("mobile") << QStringLiteral("o")
- << QStringLiteral("pager") << QStringLiteral("postalAddress") << QStringLiteral("st") << QStringLiteral("street")
- << QStringLiteral("title") << QStringLiteral("uid") << QStringLiteral("telephoneNumber") << QStringLiteral("postalCode") << QStringLiteral("objectClass");
- // the list from ldapclient.cpp
- //attrs << "cn" << "mail" << "givenname" << "sn" << "objectClass";
- mClient->setAttributes(attrs);
-
- // Taken from LdapSearch
- /*
- QString mSearchText = QString::fromUtf8( "Till" );
- QString filter = QString( "&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))"
- "(|(cn=%1*)(mail=%2*)(givenName=%3*)(sn=%4*))" )
- .arg( mSearchText ).arg( mSearchText ).arg( mSearchText ).arg( mSearchText );
- */
-
- // For some reason a fromUtf8 broke the search for me (no results).
- // But this certainly looks fishy, it might break on non-utf8 systems.
- QString filter = QStringLiteral("&(|(objectclass=person)(objectclass=groupofnames)(mail=*))"
- "(|(cn=*Ägypten MDK*)(sn=*Ägypten MDK*))");
-
- connect(mClient, &KLDAP::LdapClient::result, this, &TestLDAPClient::slotLDAPResult);
- connect(mClient, &KLDAP::LdapClient::done, this, &TestLDAPClient::slotLDAPDone);
- connect(mClient, &KLDAP::LdapClient::error, this, &TestLDAPClient::slotLDAPError);
- mClient->startQuery(filter);
-
- QEventLoop eventLoop;
- connect(this, &TestLDAPClient::leaveModality, &eventLoop, &QEventLoop::quit);
- eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
-
- delete mClient;
- mClient = Q_NULLPTR;
-}
-
-// from kaddressbook... ugly though...
-static QString asUtf8(const QByteArray &val)
-{
- if (val.isEmpty()) {
- return QString();
- }
-
- const char *data = val.data();
-
- //QString::fromUtf8() bug workaround
- if (data[ val.size() - 1 ] == '\0') {
- return QString::fromUtf8(data, val.size() - 1);
- } else {
- return QString::fromUtf8(data, val.size());
- }
-}
-
-static QString join(const KLDAP::LdapAttrValue &lst, const QString &sep)
-{
- QString res;
- bool already = false;
- for (KLDAP::LdapAttrValue::ConstIterator it = lst.begin(); it != lst.end(); ++it) {
- if (already) {
- res += sep;
- }
-
- already = true;
- res += asUtf8(*it);
- }
-
- return res;
-}
-
-void TestLDAPClient::slotLDAPResult(const KLDAP::LdapClient &, const KLDAP::LdapObject &obj)
-{
- QString cn = join(obj.attributes()[ QStringLiteral("cn") ], QStringLiteral(", "));
- qDebug() << " cn:" << cn;
- assert(!obj.attributes()[ QStringLiteral("mail") ].isEmpty());
- QString mail = join(obj.attributes()[ QStringLiteral("mail") ], QStringLiteral(", "));
- qDebug() << " mail:" << mail;
- assert(mail.contains(QLatin1Char('@')));
-}
-
-void TestLDAPClient::slotLDAPError(const QString &err)
-{
- qDebug() << err;
- ::exit(1);
-}
-
-void TestLDAPClient::slotLDAPDone()
-{
- qDebug();
- Q_EMIT leaveModality();
-}
-
diff --git a/3rdparty/kdepim/libkdepim/tests/testldapclient.h b/3rdparty/kdepim/libkdepim/tests/testldapclient.h
deleted file mode 100644
index 8af0a43..0000000
--- a/3rdparty/kdepim/libkdepim/tests/testldapclient.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2005 David Faure <faure@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef TESTLDAPCLIENT_H
-#define TESTLDAPCLIENT_H
-
-#include <QObject>
-
-#include "../ldap/ldapclient.h"
-
-namespace KLDAP
-{
-class LdapClient;
-class LdapObject;
-}
-
-class TestLDAPClient : public QObject
-{
- Q_OBJECT
-
-public:
- TestLDAPClient();
- void setup();
- void runAll();
- void cleanup();
-
- // tests
- void testIntevation();
-
-Q_SIGNALS:
- void leaveModality();
-
-private Q_SLOTS:
- void slotLDAPResult(const KLDAP::LdapClient &, const KLDAP::LdapObject &);
- void slotLDAPError(const QString &);
- void slotLDAPDone();
-
-private:
- bool check(const QString &, QString, QString);
-
- KLDAP::LdapClient *mClient;
-};
-
-#endif
diff --git a/src/akonadi/akonadiserializer.cpp b/src/akonadi/akonadiserializer.cpp
index 593712b..64fc213 100644
--- a/src/akonadi/akonadiserializer.cpp
+++ b/src/akonadi/akonadiserializer.cpp
@@ -269,17 +269,6 @@ void Serializer::updateTaskFromItem(Domain::Task::Ptr task, Item item)
});
#endif
task->setAttachments(attachments);
-
- if (todo->attendeeCount() > 0) {
- const auto attendees = todo->attendees();
- const auto delegate = std::find_if(attendees.begin(), attendees.end(),
- [] (const KCalCore::Attendee::Ptr &attendee) {
- return attendee->status() == KCalCore::Attendee::Accepted;
- });
- if (delegate != attendees.end()) {
- task->setDelegate(Domain::Task::Delegate((*delegate)->name(), (*delegate)->email()));
- }
- }
}
bool Serializer::isTaskChild(Domain::Task::Ptr task, Akonadi::Item item)
@@ -362,13 +351,6 @@ Akonadi::Item Serializer::createItemFromTask(Domain::Task::Ptr task)
todo->addAttachment(attach);
}
- if (task->delegate().isValid()) {
- KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(task->delegate().name(),
- task->delegate().email(),
- true,
- KCalCore::Attendee::Accepted));
- todo->addAttendee(attendee);
- }
if (task->isRunning()) {
todo->setCustomProperty("Zanshin", "Running", "1");
} else {
diff --git a/src/akonadi/akonaditaskrepository.cpp b/src/akonadi/akonaditaskrepository.cpp
index 24299bd..f5493a8 100644
--- a/src/akonadi/akonaditaskrepository.cpp
+++ b/src/akonadi/akonaditaskrepository.cpp
@@ -37,11 +37,9 @@ using namespace Akonadi;
using namespace Utils;
TaskRepository::TaskRepository(const StorageInterface::Ptr &storage,
- const SerializerInterface::Ptr &serializer,
- const MessagingInterface::Ptr &messaging)
+ const SerializerInterface::Ptr &serializer)
: m_storage(storage),
- m_serializer(serializer),
- m_messaging(messaging)
+ m_serializer(serializer)
{
}
@@ -309,19 +307,3 @@ KJob *TaskRepository::dissociateAll(Domain::Task::Ptr child)
return job;
}
-
-KJob *TaskRepository::delegate(Domain::Task::Ptr task, Domain::Task::Delegate delegate)
-{
- auto originalDelegate = task->delegate();
-
- task->blockSignals(true);
- task->setDelegate(delegate);
-
- auto item = m_serializer->createItemFromTask(task);
-
- task->setDelegate(originalDelegate);
- task->blockSignals(false);
-
- m_messaging->sendDelegationMessage(item);
- return Q_NULLPTR;
-}
diff --git a/src/akonadi/akonaditaskrepository.h b/src/akonadi/akonaditaskrepository.h
index 9167894..8e719e8 100644
--- a/src/akonadi/akonaditaskrepository.h
+++ b/src/akonadi/akonaditaskrepository.h
@@ -29,7 +29,6 @@
#include <AkonadiCore/Collection>
#include <AkonadiCore/Item>
-#include "akonadi/akonadimessaginginterface.h"
#include "akonadi/akonadiserializerinterface.h"
#include "akonadi/akonadistorageinterface.h"
@@ -42,8 +41,7 @@ public:
typedef QSharedPointer<TaskRepository> Ptr;
TaskRepository(const StorageInterface::Ptr &storage,
- const SerializerInterface::Ptr &serializer,
- const MessagingInterface::Ptr &messaging);
+ const SerializerInterface::Ptr &serializer);
virtual KJob *create(Domain::Task::Ptr task) Q_DECL_OVERRIDE;
virtual KJob *createChild(Domain::Task::Ptr task, Domain::Task::Ptr parent) Q_DECL_OVERRIDE;
@@ -59,12 +57,9 @@ public:
virtual KJob *dissociate(Domain::Task::Ptr child) Q_DECL_OVERRIDE;
virtual KJob *dissociateAll(Domain::Task::Ptr child) Q_DECL_OVERRIDE;
- virtual KJob *delegate(Domain::Task::Ptr task, Domain::Task::Delegate delegate) Q_DECL_OVERRIDE;
-
private:
StorageInterface::Ptr m_storage;
SerializerInterface::Ptr m_serializer;
- MessagingInterface::Ptr m_messaging;
KJob *createItem(const Akonadi::Item &item);
};
diff --git a/src/domain/task.cpp b/src/domain/task.cpp
index f98579e..01dbacc 100644
--- a/src/domain/task.cpp
+++ b/src/domain/task.cpp
@@ -107,11 +107,6 @@ Task::Attachments Task::attachments() const
return m_attachments;
}
-Task::Delegate Task::delegate() const
-{
- return m_delegate;
-}
-
void Task::setRunning(bool running)
{
if (m_running == running)
@@ -147,15 +142,6 @@ void Task::setAttachments(const Task::Attachments &attachments)
emit attachmentsChanged(attachments);
}
-void Task::setDelegate(const Task::Delegate &delegate)
-{
- if (m_delegate == delegate)
- return;
-
- m_delegate = delegate;
- emit delegateChanged(delegate);
-}
-
Task::Attachment::Attachment()
{
@@ -265,69 +251,3 @@ void Task::Attachment::setIconName(const QString &iconName)
{
m_iconName = iconName;
}
-
-
-Task::Delegate::Delegate()
-{
-}
-
-Task::Delegate::Delegate(const QString &name, const QString &email)
- : m_name(name), m_email(email)
-{
-}
-
-Task::Delegate::Delegate(const Task::Delegate &other)
- : m_name(other.m_name), m_email(other.m_email)
-{
-}
-
-Task::Delegate::~Delegate()
-{
-}
-
-Task::Delegate &Task::Delegate::operator=(const Task::Delegate &other)
-{
- Delegate copy(other);
- std::swap(m_name, copy.m_name);
- std::swap(m_email, copy.m_email);
- return *this;
-}
-
-bool Task::Delegate::operator==(const Task::Delegate &other) const
-{
- return m_name == other.m_name
- && m_email == other.m_email;
-}
-
-bool Task::Delegate::isValid() const
-{
- return !m_email.isEmpty();
-}
-
-QString Task::Delegate::display() const
-{
- return !isValid() ? QString()
- : !m_name.isEmpty() ? m_name
- : m_email;
-}
-
-QString Task::Delegate::name() const
-{
- return m_name;
-}
-
-void Task::Delegate::setName(const QString &name)
-{
- m_name = name;
-}
-
-QString Task::Delegate::email() const
-{
- return m_email;
-}
-
-void Task::Delegate::setEmail(const QString &email)
-{
- m_email = email;
-}
-
diff --git a/src/domain/task.h b/src/domain/task.h
index 04e7800..8b70942 100644
--- a/src/domain/task.h
+++ b/src/domain/task.h
@@ -39,7 +39,6 @@ class Task : public Artifact
Q_PROPERTY(QDateTime startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)
Q_PROPERTY(QDateTime dueDate READ dueDate WRITE setDueDate NOTIFY dueDateChanged)
Q_PROPERTY(Domain::Task::Recurrence recurrence READ recurrence WRITE setRecurrence NOTIFY recurrenceChanged)
- Q_PROPERTY(Domain::Task::Delegate delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(Domain::Task::Attachments attachements READ attachments WRITE setAttachments NOTIFY attachmentsChanged)
public:
typedef QSharedPointer<Task> Ptr;
@@ -93,31 +92,6 @@ public:
typedef QList<Attachment> Attachments;
- class Delegate
- {
- public:
- Delegate();
- Delegate(const QString &name, const QString &email);
- Delegate(const Delegate &other);
- ~Delegate();
-
- Delegate &operator=(const Delegate &other);
- bool operator==(const Delegate &other) const;
-
- bool isValid() const;
- QString display() const;
-
- QString name() const;
- void setName(const QString &name);
-
- QString email() const;
- void setEmail(const QString &email);
-
- private:
- QString m_name;
- QString m_email;
- };
-
explicit Task(QObject *parent = Q_NULLPTR);
virtual ~Task();
@@ -128,7 +102,6 @@ public:
QDateTime doneDate() const;
Recurrence recurrence() const;
Attachments attachments() const;
- Delegate delegate() const;
public slots:
void setRunning(bool running);
@@ -138,7 +111,6 @@ public slots:
void setDueDate(const QDateTime &dueDate);
void setRecurrence(Domain::Task::Recurrence recurrence);
void setAttachments(const Domain::Task::Attachments &attachments);
- void setDelegate(const Domain::Task::Delegate &delegate);
signals:
void runningChanged(bool isRunning);
@@ -148,7 +120,6 @@ signals:
void dueDateChanged(const QDateTime &dueDate);
void recurrenceChanged(Domain::Task::Recurrence recurrence);
void attachmentsChanged(const Domain::Task::Attachments &attachments);
- void delegateChanged(const Domain::Task::Delegate &delegate);
private:
bool m_running;
@@ -158,7 +129,6 @@ private:
QDateTime m_doneDate;
Recurrence m_recurrence;
Attachments m_attachments;
- Delegate m_delegate;
};
}
@@ -167,6 +137,5 @@ Q_DECLARE_METATYPE(Domain::Task::Ptr)
Q_DECLARE_METATYPE(Domain::Task::List)
Q_DECLARE_METATYPE(Domain::Task::Attachment)
Q_DECLARE_METATYPE(Domain::Task::Attachments)
-Q_DECLARE_METATYPE(Domain::Task::Delegate)
#endif // DOMAIN_TASK_H
diff --git a/src/domain/taskrepository.h b/src/domain/taskrepository.h
index 88bdb7d..8ade1f8 100644
--- a/src/domain/taskrepository.h
+++ b/src/domain/taskrepository.h
@@ -54,8 +54,6 @@ public:
virtual KJob *associate(Task::Ptr parent, Task::Ptr child) = 0;
virtual KJob *dissociate(Task::Ptr child) = 0;
virtual KJob *dissociateAll(Task::Ptr child) = 0;
-
- virtual KJob *delegate(Task::Ptr task, Task::Delegate delegate) = 0;
};
}
diff --git a/src/presentation/artifacteditormodel.cpp b/src/presentation/artifacteditormodel.cpp
index 78775f0..dcef15a 100644
--- a/src/presentation/artifacteditormodel.cpp
+++ b/src/presentation/artifacteditormodel.cpp
@@ -143,7 +143,6 @@ void ArtifactEditorModel::setArtifact(const Domain::Artifact::Ptr &artifact)
m_due = QDateTime();
m_recurrence = Domain::Task::NoRecurrence;
m_attachmentModel->setTask(Domain::Task::Ptr());
- m_delegateText = QString();
if (m_artifact)
disconnect(m_artifact.data(), Q_NULLPTR, this, Q_NULLPTR);
@@ -164,13 +163,11 @@ void ArtifactEditorModel::setArtifact(const Domain::Artifact::Ptr &artifact)
m_due = task->dueDate();
m_recurrence = task->recurrence();
m_attachmentModel->setTask(task);
- m_delegateText = task->delegate().display();
connect(task.data(), &Domain::Task::doneChanged, this, &ArtifactEditorModel::onDoneChanged);
connect(task.data(), &Domain::Task::startDateChanged, this, &ArtifactEditorModel::onStartDateChanged);
connect(task.data(), &Domain::Task::dueDateChanged, this, &ArtifactEditorModel::onDueDateChanged);
connect(task.data(), &Domain::Task::recurrenceChanged, this, &ArtifactEditorModel::onRecurrenceChanged);
- connect(task.data(), &Domain::Task::delegateChanged, this, &ArtifactEditorModel::onDelegateChanged);
}
emit textChanged(m_text);
@@ -179,7 +176,6 @@ void ArtifactEditorModel::setArtifact(const Domain::Artifact::Ptr &artifact)
emit startDateChanged(m_start);
emit dueDateChanged(m_due);
emit recurrenceChanged(m_recurrence);
- emit delegateTextChanged(m_delegateText);
emit hasTaskPropertiesChanged(hasTaskProperties());
emit artifactChanged(m_artifact);
}
@@ -194,16 +190,6 @@ void ArtifactEditorModel::setSaveFunction(const SaveFunction &function)
m_saveFunction = function;
}
-bool ArtifactEditorModel::hasDelegateFunction() const
-{
- return bool(m_delegateFunction);
-}
-
-void ArtifactEditorModel::setDelegateFunction(const DelegateFunction &function)
-{
- m_delegateFunction = function;
-}
-
bool ArtifactEditorModel::hasTaskProperties() const
{
return m_artifact.objectCast<Domain::Task>();
@@ -244,11 +230,6 @@ QAbstractItemModel *ArtifactEditorModel::attachmentModel() const
return m_attachmentModel;
}
-QString ArtifactEditorModel::delegateText() const
-{
- return m_delegateText;
-}
-
int ArtifactEditorModel::autoSaveDelay()
{
return s_autoSaveDelay;
@@ -312,14 +293,6 @@ void ArtifactEditorModel::setRecurrence(Domain::Task::Recurrence recurrence)
setSaveNeeded(true);
}
-void ArtifactEditorModel::delegate(const QString &name, const QString &email)
-{
- auto task = m_artifact.objectCast<Domain::Task>();
- Q_ASSERT(task);
- auto delegate = Domain::Task::Delegate(name, email);
- m_delegateFunction(task, delegate);
-}
-
void ArtifactEditorModel::addAttachment(const QString &fileName)
{
auto task = m_artifact.objectCast<Domain::Task>();
@@ -426,12 +399,6 @@ void ArtifactEditorModel::onRecurrenceChanged(Domain::Task::Recurrence recurrenc
applyNewRecurrence(recurrence);
}
-void ArtifactEditorModel::onDelegateChanged(const Domain::Task::Delegate &delegate)
-{
- m_delegateText = delegate.display();
- emit delegateTextChanged(m_delegateText);
-}
-
void ArtifactEditorModel::save()
{
if (!isSaveNeeded())
diff --git a/src/presentation/artifacteditormodel.h b/src/presentation/artifacteditormodel.h
index 764f604..fcd849a 100644
--- a/src/presentation/artifacteditormodel.h
+++ b/src/presentation/artifacteditormodel.h
@@ -52,13 +52,11 @@ class ArtifactEditorModel : public QObject, public ErrorHandlingModelBase
Q_PROPERTY(QDateTime dueDate READ dueDate WRITE setDueDate NOTIFY dueDateChanged)
Q_PROPERTY(Domain::Task::Recurrence recurrence READ recurrence WRITE setRecurrence NOTIFY recurrenceChanged)
Q_PROPERTY(QAbstractItemModel* attachmentModel READ attachmentModel CONSTANT)
- Q_PROPERTY(QString delegateText READ delegateText NOTIFY delegateTextChanged)
Q_PROPERTY(bool hasTaskProperties READ hasTaskProperties NOTIFY hasTaskPropertiesChanged)
Q_PROPERTY(bool editingInProgress READ editingInProgress WRITE setEditingInProgress)
public:
typedef std::function<KJob*(const Domain::Artifact::Ptr &)> SaveFunction;
- typedef std::function<KJob*(const Domain::Task::Ptr &, const Domain::Task::Delegate &)> DelegateFunction;
explicit ArtifactEditorModel(QObject *parent = Q_NULLPTR);
~ArtifactEditorModel();
@@ -69,9 +67,6 @@ public:
bool hasSaveFunction() const;
void setSaveFunction(const SaveFunction &function);
- bool hasDelegateFunction() const;
- void setDelegateFunction(const DelegateFunction &function);
-
bool hasTaskProperties() const;
QString text() const;
@@ -81,7 +76,6 @@ public:
QDateTime dueDate() const;
Domain::Task::Recurrence recurrence() const;
QAbstractItemModel *attachmentModel() const;
- QString delegateText() const;
static int autoSaveDelay();
static void setAutoSaveDelay(int delay);
@@ -95,7 +89,6 @@ public slots:
void setStartDate(const QDateTime &start);
void setDueDate(const QDateTime &due);
void setRecurrence(Domain::Task::Recurrence recurrence);
- void delegate(const QString &name, const QString &email);
void addAttachment(const QString &fileName);
void removeAttachment(const QModelIndex &index);
@@ -112,7 +105,6 @@ signals:
void startDateChanged(const QDateTime &date);
void dueDateChanged(const QDateTime &due);
void recurrenceChanged(Domain::Task::Recurrence recurrence);
- void delegateTextChanged(const QString &delegateText);
private slots:
void onTextChanged(const QString &text);
@@ -121,7 +113,6 @@ private slots:
void onStartDateChanged(const QDateTime &start);
void onDueDateChanged(const QDateTime &due);
void onRecurrenceChanged(Domain::Task::Recurrence recurrence);
- void onDelegateChanged(const Domain::Task::Delegate &delegate);
void save();
@@ -137,7 +128,6 @@ private:
Domain::Artifact::Ptr m_artifact;
SaveFunction m_saveFunction;
- DelegateFunction m_delegateFunction;
QString m_text;
QString m_title;
@@ -146,7 +136,6 @@ private:
QDateTime m_due;
Domain::Task::Recurrence m_recurrence;
AttachmentModel *m_attachmentModel;
- QString m_delegateText;
QTimer *m_saveTimer;
bool m_saveNeeded;
diff --git a/src/presentation/metatypes.cpp b/src/presentation/metatypes.cpp
index 48e21ed..f074e01 100644
--- a/src/presentation/metatypes.cpp
+++ b/src/presentation/metatypes.cpp
@@ -37,5 +37,4 @@ void MetaTypes::registerAll()
qRegisterMetaType<QObjectPtrList>();
qRegisterMetaType<Domain::Artifact::Ptr>();
qRegisterMetaType<Domain::DataSource::Ptr>();
- qRegisterMetaType<Domain::Task::Delegate>();
}
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 23b57b0..022b8e1 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -31,5 +31,7 @@ target_link_libraries(widgets
Qt5::Widgets
presentation
zanshinkdepimstatic
+ KF5::ConfigCore
+ KF5::ItemModels
KF5::WindowSystem
)
diff --git a/src/widgets/availablesourcesview.cpp b/src/widgets/availablesourcesview.cpp
index cc714b0..2c9484a 100644
--- a/src/widgets/availablesourcesview.cpp
+++ b/src/widgets/availablesourcesview.cpp
@@ -34,7 +34,6 @@
#include <QTreeView>
#include <QVBoxLayout>
-#include <KLineEdit>
#include <KLocalizedString>
#include "presentation/metatypes.h"
diff --git a/src/widgets/editorview.cpp b/src/widgets/editorview.cpp
index cb07bf9..e84d48b 100644
--- a/src/widgets/editorview.cpp
+++ b/src/widgets/editorview.cpp
@@ -34,7 +34,6 @@
#include <KLocalizedString>
#include "kdateedit.h"
-#include "addressline/addresseelineedit.h"
#include "domain/artifact.h"
@@ -45,8 +44,7 @@ using namespace Widgets;
EditorView::EditorView(QWidget *parent)
: QWidget(parent),
m_model(Q_NULLPTR),
- ui(new Ui::EditorView),
- m_delegateEdit(Q_NULLPTR)
+ ui(new Ui::EditorView)
{
m_requestFileNameFunction = [](QWidget *parent) {
return QFileDialog::getOpenFileName(parent, i18n("Add Attachment"));
@@ -54,18 +52,6 @@ EditorView::EditorView(QWidget *parent)
ui->setupUi(this);
- // To avoid having unit tests talking to akonadi
- // while we don't need the completion for them
- if (qEnvironmentVariableIsEmpty("ZANSHIN_UNIT_TEST_RUN"))
- m_delegateEdit = new KPIM::AddresseeLineEdit(ui->delegateEditPlaceHolder);
- else
- m_delegateEdit = new KLineEdit(ui->delegateEditPlaceHolder);
-
- // placing our special DelegateEdit into the placeholder we prepared
- m_delegateEdit->setObjectName("delegateEdit");
- ui->delegateToLabel->setBuddy(m_delegateEdit);
- ui->delegateEditPlaceHolder->layout()->addWidget(m_delegateEdit);
-
ui->startDateEdit->setMinimumContentsLength(10);
ui->dueDateEdit->setMinimumContentsLength(10);
@@ -79,7 +65,6 @@ EditorView::EditorView(QWidget *parent)
ui->layout->activate();
setMinimumWidth(minimumSizeHint().width());
- ui->delegateLabel->setVisible(false);
ui->taskGroup->setVisible(false);
ui->textEdit->installEventFilter(this);
@@ -87,7 +72,6 @@ EditorView::EditorView(QWidget *parent)
ui->dueDateEdit->installEventFilter(this);
ui->doneButton->installEventFilter(this);
ui->recurrenceCombo->installEventFilter(this);
- m_delegateEdit->installEventFilter(this);
connect(ui->textEdit, &QPlainTextEdit::textChanged, this, &EditorView::onTextEditChanged);
connect(ui->startDateEdit, &KPIM::KDateEdit::dateEntered, this, &EditorView::onStartEditEntered);
@@ -99,7 +83,6 @@ EditorView::EditorView(QWidget *parent)
connect(ui->attachmentList, &QAbstractItemView::doubleClicked, this, &EditorView::onAttachmentDoubleClicked);
connect(ui->addAttachmentButton, &QToolButton::clicked, this, &EditorView::onAddAttachmentClicked);
connect(ui->removeAttachmentButton, &QToolButton::clicked, this, &EditorView::onRemoveAttachmentClicked);
- connect(m_delegateEdit, &KLineEdit::returnPressed, this, &EditorView::onDelegateEntered);
setEnabled(false);
}
@@ -154,7 +137,6 @@ void EditorView::setModel(QObject *model)
onDueDateChanged();
onDoneChanged();
onRecurrenceChanged();
- onDelegateTextChanged();
onAttachmentSelectionChanged();
connect(m_model, SIGNAL(artifactChanged(Domain::Artifact::Ptr)),
@@ -167,7 +149,6 @@ void EditorView::setModel(QObject *model)
connect(m_model, SIGNAL(dueDateChanged(QDateTime)), this, SLOT(onDueDateChanged()));
connect(m_model, SIGNAL(doneChanged(bool)), this, SLOT(onDoneChanged()));
connect(m_model, SIGNAL(recurrenceChanged(Domain::Task::Recurrence)), this, SLOT(onRecurrenceChanged()));
- connect(m_model, SIGNAL(delegateTextChanged(QString)), this, SLOT(onDelegateTextChanged()));
connect(this, SIGNAL(titleChanged(QString)), m_model, SLOT(setTitle(QString)));
connect(this, SIGNAL(textChanged(QString)), m_model, SLOT(setText(QString)));
@@ -206,7 +187,6 @@ void EditorView::onArtifactChanged()
{
auto artifact = m_model->property("artifact").value<Domain::Artifact::Ptr>();
setEnabled(artifact);
- m_delegateEdit->clear();
}
void EditorView::onHasTaskPropertiesChanged()
@@ -250,16 +230,6 @@ void EditorView::onRecurrenceChanged()
}
}
-void EditorView::onDelegateTextChanged()
-{
- const auto delegateText = m_model->property("delegateText").toString();
- const auto labelText = delegateText.isEmpty() ? QString()
- : i18n("Delegated to: <b>%1</b>", delegateText);
-
- ui->delegateLabel->setVisible(!labelText.isEmpty());
- ui->delegateLabel->setText(labelText);
-}
-
void EditorView::onTextEditChanged()
{
const QString plainText = ui->textEdit->toPlainText();
@@ -303,33 +273,6 @@ void EditorView::onRecurrenceComboChanged(int index)
emit recurrenceChanged(recurrence);
}
-void EditorView::onDelegateEntered()
-{
- const auto input = m_delegateEdit->text();
- auto name = QString();
- auto email = QString();
- auto gotMatch = false;
-
- QRegExp fullRx("\\s*(.*) <([\\w\\.]+@[\\w\\.]+)>\\s*");
- QRegExp emailOnlyRx("\\s*<?([\\w\\.]+@[\\w\\.]+)>?\\s*");
-
- if (input.contains(fullRx)) {
- name = fullRx.cap(1);
- email = fullRx.cap(2);
- gotMatch = true;
- } else if (input.contains(emailOnlyRx)) {
- email = emailOnlyRx.cap(1);
- gotMatch = true;
- }
-
- if (gotMatch) {
- QMetaObject::invokeMethod(m_model, "delegate",
- Q_ARG(QString, name),
- Q_ARG(QString, email));
- m_delegateEdit->clear();
- }
-}
-
void EditorView::onAttachmentSelectionChanged()
{
if (!m_model)
diff --git a/src/widgets/editorview.h b/src/widgets/editorview.h
index 8dec5e4..c8c3a76 100644
--- a/src/widgets/editorview.h
+++ b/src/widgets/editorview.h
@@ -84,7 +84,6 @@ private slots:
void onDueDateChanged();
void onDoneChanged();
void onRecurrenceChanged();
- void onDelegateTextChanged();
void onTextEditChanged();
void onStartEditEntered(const QDate &start);
@@ -92,7 +91,6 @@ private slots:
void onDoneButtonChanged(bool checked);
void onStartTodayClicked();
void onRecurrenceComboChanged(int index);
- void onDelegateEntered();
void onAttachmentSelectionChanged();
void onAddAttachmentClicked();
@@ -104,7 +102,6 @@ private:
RequestFileNameFunction m_requestFileNameFunction;
Ui::EditorView *ui;
- KLineEdit *m_delegateEdit;
};
}
diff --git a/src/widgets/editorview.ui b/src/widgets/editorview.ui
index 36dcc43..c63fcf3 100644
--- a/src/widgets/editorview.ui
+++ b/src/widgets/editorview.ui
@@ -13,17 +13,10 @@
<property name="windowTitle">
<string>Editor</string>
</property>
- <layout class="QVBoxLayout" name="layout" stretch="0,1,0">
+ <layout class="QVBoxLayout" name="layout" stretch="1,0">
<property name="bottomMargin">
<number>6</number>
</property>
- <item>
- <widget class="QLabel" name="delegateLabel">
- <property name="text">
- <string>Delegate To: </string>
- </property>
- </widget>
- </item>
<item>
<widget class="QPlainTextEdit" name="textEdit"/>
</item>
@@ -42,28 +35,36 @@
<property name="bottomMargin">
<number>0</number>
</property>
- <item row="0" column="0" colspan="2">
- <widget class="QListView" name="attachmentList">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>100</height>
- </size>
+ <item row="3" column="0">
+ <widget class="QLabel" name="dueDateLabel">
+ <property name="text">
+ <string>D&amp;ue Date </string>
</property>
- <property name="flow">
- <enum>QListView::LeftToRight</enum>
+ <property name="margin">
+ <number>4</number>
</property>
- <property name="isWrapping" stdset="0">
- <bool>true</bool>
+ <property name="buddy">
+ <cstring>dueDateEdit</cstring>
</property>
</widget>
</item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="recurrenceCombo"/>
+ </item>
+ <item row="5" column="0">
+ <layout class="QHBoxLayout" name="doneLayout">
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="doneButton">
+ <property name="text">
+ <string>Done</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@@ -85,7 +86,8 @@
<string>Add Attachment...</string>
</property>
<property name="icon">
- <iconset theme="list-add"/>
+ <iconset theme="list-add">
+ <normaloff>.</normaloff>.</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
@@ -98,7 +100,8 @@
<string>Remove Attachment</string>
</property>
<property name="icon">
- <iconset theme="list-remove"/>
+ <iconset theme="list-remove">
+ <normaloff>.</normaloff>.</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
@@ -107,19 +110,6 @@
</item>
</layout>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="startDateLabel">
- <property name="text">
- <string>St&amp;art Date</string>
- </property>
- <property name="margin">
- <number>4</number>
- </property>
- <property name="buddy">
- <cstring>startDateEdit</cstring>
- </property>
- </widget>
- </item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -134,79 +124,56 @@
</item>
</layout>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="dueDateLabel">
+ <item row="4" column="0">
+ <widget class="QLabel" name="recurrenceLabel">
<property name="text">
- <string>D&amp;ue Date </string>
+ <string>&amp;Recurrence</string>
</property>
<property name="margin">
<number>4</number>
</property>
<property name="buddy">
- <cstring>dueDateEdit</cstring>
+ <cstring>recurrenceCombo</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KPIM::KDateEdit" name="dueDateEdit"/>
</item>
- <item row="4" column="0">
- <widget class="QLabel" name="recurrenceLabel">
+ <item row="2" column="0">
+ <widget class="QLabel" name="startDateLabel">
<property name="text">
- <string>&amp;Recurrence</string>
+ <string>St&amp;art Date</string>
</property>
<property name="margin">
<number>4</number>
</property>
<property name="buddy">
- <cstring>recurrenceCombo</cstring>
+ <cstring>startDateEdit</cstring>
</property>
</widget>
</item>
- <item row="4" column="1">
- <widget class="QComboBox" name="recurrenceCombo"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="delegateToLabel">
- <property name="text">
- <string>De&amp;legate to</string>
+ <item row="0" column="0" colspan="2">
+ <widget class="QListView" name="attachmentList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="margin">
- <number>4</number>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>100</height>
+ </size>
</property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QWidget" name="delegateEditPlaceHolder" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- </layout>
- </widget>
- </item>
- <item row="6" column="0">
- <layout class="QHBoxLayout" name="doneLayout">
- <property name="leftMargin">
- <number>3</number>
+ <property name="flow">
+ <enum>QListView::LeftToRight</enum>
</property>
- <item>
- <widget class="QCheckBox" name="doneButton">
- <property name="text">
- <string>Done</string>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="isWrapping" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
</layout>
</widget>
diff --git a/src/widgets/itemdelegate.cpp b/src/widgets/itemdelegate.cpp
index b0fa49b..35f06b6 100644
--- a/src/widgets/itemdelegate.cpp
+++ b/src/widgets/itemdelegate.cpp
@@ -87,14 +87,11 @@ void ItemDelegate::paint(QPainter *painter,
const auto pastDueDate = dueDate.isValid() && dueDate.date() < QDate::currentDate();
const auto onDueDate = dueDate.isValid() && dueDate.date() == QDate::currentDate();
- const auto taskDelegate = task ? task->delegate() : Domain::Task::Delegate();
-
const auto baseFont = opt.font;
const auto summaryFont = [=] {
auto font = baseFont;
font.setStrikeOut(isDone);
font.setBold(!isDone && (onStartDate || onDueDate || pastDueDate));
- font.setItalic(taskDelegate.isValid());
return font;
}();
const auto summaryMetrics = QFontMetrics(summaryFont);
@@ -110,11 +107,11 @@ void ItemDelegate::paint(QPainter *painter,
: onDueDate ? QColor("orange")
: baseColor;
- const auto summaryText = taskDelegate.isValid() ? i18n("(%1) %2", taskDelegate.display(), opt.text) : opt.text;
+ const auto summaryText = opt.text;
const auto dueDateText = dueDate.isValid() ? QLocale().toString(dueDate.date(), QLocale::ShortFormat)
: QString();
- const auto textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
+ const auto textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
const auto dueDateWidth = dueDate.isValid() ? (summaryMetrics.width(dueDateText) + 2 * textMargin) : 0;
diff --git a/src/zanshin/app/dependencies.cpp b/src/zanshin/app/dependencies.cpp
index 84c6455..4f96111 100644
--- a/src/zanshin/app/dependencies.cpp
+++ b/src/zanshin/app/dependencies.cpp
@@ -34,7 +34,6 @@
#include "akonadi/akonadicache.h"
#include "akonadi/akonadicachingstorage.h"
-#include "akonadi/akonadimessaging.h"
#include "akonadi/akonadimonitorimpl.h"
#include "akonadi/akonadiserializer.h"
#include "akonadi/akonadistorage.h"
@@ -53,7 +52,6 @@ void App::initializeDependencies()
deps.add<Akonadi::Cache,
Akonadi::Cache(Akonadi::SerializerInterface*, Akonadi::MonitorInterface*),
Utils::DependencyManager::UniqueInstance>();
- deps.add<Akonadi::MessagingInterface, Akonadi::Messaging, Utils::DependencyManager::UniqueInstance>();
deps.add<Akonadi::MonitorInterface, Akonadi::MonitorImpl, Utils::DependencyManager::UniqueInstance>();
deps.add<Akonadi::SerializerInterface, Akonadi::Serializer, Utils::DependencyManager::UniqueInstance>();
deps.add<Akonadi::StorageInterface, Utils::DependencyManager::UniqueInstance>([] (Utils::DependencyManager *deps) {
@@ -101,8 +99,7 @@ void App::initializeDependencies()
deps.add<Domain::TaskRepository,
Akonadi::TaskRepository(Akonadi::StorageInterface*,
- Akonadi::SerializerInterface*,
- Akonadi::MessagingInterface*)>();
+ Akonadi::SerializerInterface*)>();
deps.add<Presentation::ArtifactEditorModel>([] (Utils::DependencyManager *deps) {
auto model = new Presentation::ArtifactEditorModel;
@@ -112,9 +109,6 @@ void App::initializeDependencies()
Q_ASSERT(task);
return repository->update(task);
});
- model->setDelegateFunction([repository] (const Domain::Task::Ptr &task, const Domain::Task::Delegate &delegate) {
- return repository->delegate(task, delegate);
- });
return model;
});
diff --git a/src/zanshin/runner/zanshinrunner.cpp b/src/zanshin/runner/zanshinrunner.cpp
index a1f4ec7..7c05148 100644
--- a/src/zanshin/runner/zanshinrunner.cpp
+++ b/src/zanshin/runner/zanshinrunner.cpp
@@ -39,8 +39,7 @@ Domain::TaskRepository::Ptr createTaskRepository()
{
using namespace Akonadi;
auto repository = new TaskRepository(StorageInterface::Ptr(new Storage),
- SerializerInterface::Ptr(new Serializer),
- MessagingInterface::Ptr());
+ SerializerInterface::Ptr(new Serializer));
return Domain::TaskRepository::Ptr(repository);
}
diff --git a/tests/features/cuke-steps.cpp b/tests/features/cuke-steps.cpp
index c9dfaf9..2bfa183 100644
--- a/tests/features/cuke-steps.cpp
+++ b/tests/features/cuke-steps.cpp
@@ -43,7 +43,6 @@
#include "akonadi/akonadicache.h"
#include "akonadi/akonadicachingstorage.h"
#include "akonadi/akonadimonitorimpl.h"
-#include "akonadi/akonadimessaginginterface.h"
#include "akonadi/akonaditimestampattribute.h"
#include "utils/dependencymanager.h"
@@ -138,12 +137,6 @@ public:
Akonadi::StorageInterface::Ptr(m_data.createStorage()));
}
);
- deps.add<Akonadi::MessagingInterface,
- Utils::DependencyManager::UniqueInstance>(
- [this] (Utils::DependencyManager *) -> Akonadi::MessagingInterface* {
- return Q_NULLPTR;
- }
- );
using namespace Presentation;
proxyModel->setDynamicSortFilter(true);
@@ -863,14 +856,12 @@ THEN("^the editor shows \"(.*)\" as (.*)$") {
const QVariant value = (field == QStringLiteral("text")) ? string
: (field == QStringLiteral("title")) ? string
- : (field == QStringLiteral("delegate")) ? string
: (field == QStringLiteral("start date")) ? QDateTime::fromString(string, Qt::ISODate)
: (field == QStringLiteral("due date")) ? QDateTime::fromString(string, Qt::ISODate)
: QVariant();
const QByteArray property = (field == QStringLiteral("text")) ? field.toUtf8()
: (field == QStringLiteral("title")) ? field.toUtf8()
- : (field == QStringLiteral("delegate")) ? "delegateText"
: (field == QStringLiteral("start date")) ? "startDate"
: (field == QStringLiteral("due date")) ? "dueDate"
: QByteArray();
diff --git a/tests/features/zanshin/features/delegation/delegate-display.feature b/tests/features/zanshin/features/delegation/delegate-display.feature
deleted file mode 100644
index a48a9c5..0000000
--- a/tests/features/zanshin/features/delegation/delegate-display.feature
+++ /dev/null
@@ -1,11 +0,0 @@
-Feature: Displaying delegate on tasks
- As a leader ;-)
- I can see who a task was delegated to
- In order to know who to ask if it's not progressing
-
- Scenario: Displaying delegate name
- Given I display the "Inbox" page
- And there is an item named "Buy cheese" in the central list
- When I open the item in the editor
- Then the editor shows "John Doe" as delegate
-
diff --git a/tests/testlib/gentodo.cpp b/tests/testlib/gentodo.cpp
index 99a236c..5bc02c0 100644
--- a/tests/testlib/gentodo.cpp
+++ b/tests/testlib/gentodo.cpp
@@ -155,18 +155,3 @@ GenTodo &GenTodo::withDueDate(const QDateTime &date)
m_item.payload<KCalCore::Todo::Ptr>()->setDtDue(KDateTime(date));
return *this;
}
-
-GenTodo &GenTodo::withDelegate(const QString &name, const QString &email)
-{
- withNoDelegate();
- KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(name, email, true,
- KCalCore::Attendee::Delegated));
- m_item.payload<KCalCore::Todo::Ptr>()->addAttendee(attendee);
- return *this;
-}
-
-GenTodo &GenTodo::withNoDelegate()
-{
- m_item.payload<KCalCore::Todo::Ptr>()->clearAttendees();
- return *this;
-}
diff --git a/tests/testlib/gentodo.h b/tests/testlib/gentodo.h
index d3e424c..408ca64 100644
--- a/tests/testlib/gentodo.h
+++ b/tests/testlib/gentodo.h
@@ -52,8 +52,6 @@ public:
GenTodo &withStartDate(const QDateTime &date);
GenTodo &withDueDate(const QString &date);
GenTodo &withDueDate(const QDateTime &date);
- GenTodo &withDelegate(const QString &name, const QString &email);
- GenTodo &withNoDelegate();
private:
Akonadi::Item m_item;
diff --git a/tests/units/akonadi/akonadiserializertest.cpp b/tests/units/akonadi/akonadiserializertest.cpp
index 936f02c..fa1b736 100644
--- a/tests/units/akonadi/akonadiserializertest.cpp
+++ b/tests/units/akonadi/akonadiserializertest.cpp
@@ -533,13 +533,11 @@ private slots:
QTest::addColumn<QDateTime>("doneDate");
QTest::addColumn<QDateTime>("startDate");
QTest::addColumn<QDateTime>("dueDate");
- QTest::addColumn<QString>("delegateName");
- QTest::addColumn<QString>("delegateEmail");
- QTest::newRow("nominal case") << "summary" << "content" << false << QDateTime() << QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01)) << "John Doe" << "j@d.com";
- QTest::newRow("done case") << "summary" << "content" << true << QDateTime(QDate(2013, 11, 30)) << QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01)) << "John Doe" << "j@d.com";
- QTest::newRow("done without doneDate case") << "summary" << "content" << true << QDateTime() << QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01)) << "John Doe" << "j@d.com";
- QTest::newRow("empty case") << QString() << QString() << false << QDateTime() << QDateTime() << QDateTime() << QString() << QString();
+ QTest::newRow("nominal case") << "summary" << "content" << false << QDate() << QDate(2013, 11, 24) << QDate(2014, 03, 01);
+ QTest::newRow("done case") << "summary" << "content" << true << QDate(2013, 11, 30) << QDate(2013, 11, 24) << QDate(2014, 03, 01);
+ QTest::newRow("done without doneDate case") << "summary" << "content" << true << QDate() << QDate(2013, 11, 24) << QDate(2014, 03, 01);
+ QTest::newRow("empty case") << QString() << QString() << false << QDate() << QDate() << QDate();
}
void shouldCreateTaskFromItem()
@@ -553,8 +551,6 @@ private slots:
QFETCH(QDateTime, doneDate);
QFETCH(QDateTime, startDate);
QFETCH(QDateTime, dueDate);
- QFETCH(QString, delegateName);
- QFETCH(QString, delegateEmail);
// Switch to UTC
doneDate.setTimeSpec(Qt::UTC);
@@ -573,14 +569,6 @@ private slots:
setTodoDates(todo, startDate, dueDate);
todo->setRelatedTo(QStringLiteral("my-uid"));
- if (!delegateName.isEmpty() || !delegateEmail.isEmpty()) {
- KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(delegateName,
- delegateEmail,
- true,
- KCalCore::Attendee::Accepted));
- todo->addAttendee(attendee);
- }
-
// ... as payload of an item
Akonadi::Item item;
@@ -607,8 +595,6 @@ private slots:
QCOMPARE(task->property("relatedUid").toString(), todo->relatedTo());
QCOMPARE(task->property("itemId").toLongLong(), item.id());
QCOMPARE(task->property("parentCollectionId").toLongLong(), collection.id());
- QCOMPARE(task->delegate().name(), delegateName);
- QCOMPARE(task->delegate().email(), delegateEmail);
QVERIFY(!artifact.isNull());
QCOMPARE(artifact->title(), summary);
@@ -621,8 +607,6 @@ private slots:
QCOMPARE(artifact->property("relatedUid").toString(), todo->relatedTo());
QCOMPARE(artifact->property("itemId").toLongLong(), item.id());
QCOMPARE(artifact->property("parentCollectionId").toLongLong(), collection.id());
- QCOMPARE(artifact->delegate().name(), delegateName);
- QCOMPARE(artifact->delegate().email(), delegateEmail);
}
void shouldCreateNullTaskFromInvalidItem()
@@ -679,13 +663,12 @@ private slots:
QTest::addColumn<QStringList>("updatedAttachmentLabels");
QTest::addColumn<QStringList>("updatedAttachmentMimeTypes");
QTest::addColumn<QStringList>("updatedAttachmentIconNames");
- QTest::addColumn<QString>("updatedDelegateName");
- QTest::addColumn<QString>("updatedDelegateEmail");
QTest::addColumn<bool>("updatedRunning");
QTest::newRow("no change") << "summary" << "content" << false << QDateTime() << QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01)) << "my-uid" << false << QByteArrayList() << QStringList() << QStringList() << QStringList() << QStringList() << "John Doe" << "j@d.com" << false;
- QTest::newRow("changed") << "new summary" << "new content" << true << QDateTime(QDate(2013, 11, 28)) << QDateTime(QDate(2013, 11, 25)) << QDateTime(QDate(2014, 03, 02)) << "my-new-uid" << true << QByteArrayList({"foo", "# bar", QByteArray()}) << QStringList({QString(), QString(), "https://www.kde.org"}) << QStringList({"label1", "label2", "label3"}) << QStringList({"text/plain", "text/markdown", "text/html"}) << QStringList({"text-plain", "text-markdown", "text-html"}) << "John Smith" << "j@s.com" << false;
- QTest::newRow("set_to_running") << "summary" << "content" << false << QDateTime() << QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01)) << "my-uid" << false << QByteArrayList() << QStringList() << QStringList() << QStringList() << QStringList() << "John Doe" << "j@d.com" << true;
+ QTest::newRow("no change") << "summary" << "content" << false << QDate() << QDate(2013, 11, 24) << QDate(2014, 03, 01) << "my-uid" << false << QByteArrayList() << QStringList() << QStringList() << QStringList() << QStringList() << false;
+ QTest::newRow("changed") << "new summary" << "new content" << true << QDate(2013, 11, 28) << QDate(2013, 11, 25) << QDate(2014, 03, 02) << "my-new-uid" << true << QByteArrayList({"foo", "# bar", QByteArray()}) << QStringList({QString(), QString(), "https://www.kde.org"}) << QStringList({"label1", "label2", "label3"}) << QStringList({"text/plain", "text/markdown", "text/html"}) << QStringList({"text-plain", "text-markdown", "text-html"}) << false;
+ QTest::newRow("set_to_running") << "summary" << "content" << false << QDate() << QDate(2013, 11, 24) << QDate(2014, 03, 01) << "my-uid" << false << QByteArrayList() << QStringList() << QStringList() << QStringList() << QStringList() << true;
}
void shouldUpdateTaskFromItem()
@@ -743,8 +726,6 @@ private slots:
QFETCH(QStringList, updatedAttachmentLabels);
QFETCH(QStringList, updatedAttachmentMimeTypes);
QFETCH(QStringList, updatedAttachmentIconNames);
- QFETCH(QString, updatedDelegateName);
- QFETCH(QString, updatedDelegateEmail);
QFETCH(bool, updatedRunning);
// Switch to UTC
@@ -789,13 +770,6 @@ private slots:
updatedTodo->addAttachment(attachment);
}
- if (!updatedDelegateName.isEmpty() || !updatedDelegateEmail.isEmpty()) {
- KCalCore::Attendee::Ptr updatedAttendee(new KCalCore::Attendee(updatedDelegateName,
- updatedDelegateEmail,
- true,
- KCalCore::Attendee::Accepted));
- updatedTodo->addAttendee(updatedAttendee);
- }
if (updatedRunning) {
updatedTodo->setCustomProperty("Zanshin", "Running", "1");
} else {
@@ -835,8 +809,6 @@ private slots:
QCOMPARE(attachment.mimeType(), updatedAttachmentMimeTypes.at(i));
QCOMPARE(attachment.iconName(), updatedAttachmentIconNames.at(i));
}
- QCOMPARE(task->delegate().name(), updatedDelegateName);
- QCOMPARE(task->delegate().email(), updatedDelegateEmail);
QCOMPARE(task->isRunning(), updatedRunning);
task = artifact.dynamicCast<Domain::Task>();
@@ -860,8 +832,6 @@ private slots:
QCOMPARE(attachment.mimeType(), updatedAttachmentMimeTypes.at(i));
QCOMPARE(attachment.iconName(), updatedAttachmentIconNames.at(i));
}
- QCOMPARE(task->delegate().name(), updatedDelegateName);
- QCOMPARE(task->delegate().email(), updatedDelegateEmail);
QCOMPARE(task->isRunning(), updatedRunning);
}
@@ -1110,7 +1080,6 @@ private slots:
QTest::addColumn<QString>("todoUid");
QTest::addColumn<Domain::Task::Recurrence>("recurrence");
QTest::addColumn<Domain::Task::Attachments>("attachments");
- QTest::addColumn<Domain::Task::Delegate>("delegate");
QTest::addColumn<bool>("running");
Domain::Task::Attachments attachments;
@@ -1134,42 +1103,36 @@ private slots:
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::NoRecurrence
<< attachments
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("nominal case (daily)") << "summary" << "content" << false << QDateTime()
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::RecursDaily
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("nominal case (weekly)") << "summary" << "content" << false << QDateTime()
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::RecursWeekly
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("nominal case (monthly)") << "summary" << "content" << false << QDateTime()
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::RecursMonthly
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("done case (no id)") << "summary" << "content" << true << QDateTime(QDate(2013, 11, 30))
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("empty case (no id)") << QString() << QString() << false << QDateTime()
<< QDateTime() << QDateTime()
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate()
<< false;
#if 0 // if we ever need time info, then we need a Task::setAllDay(bool) just like KCalCore::Todo has.
QTest::newRow("nominal_with_time_info_noid") << "summary" << "content" << true << QDateTime(QDate(2015, 3, 1), QTime(1, 2, 3), Qt::UTC)
@@ -1177,7 +1140,6 @@ private slots:
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
#endif
@@ -1186,28 +1148,24 @@ private slots:
<< qint64(42) << qint64(43) << "my-uid"
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("done case (with id)") << "summary" << "content" << true << QDateTime(QDate(2013, 11, 30))
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(42) << qint64(43) << "my-uid"
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("j@d.com"))
<< false;
QTest::newRow("empty case (with id)") << QString() << QString() << false << QDateTime()
<< QDateTime() << QDateTime()
<< qint64(42) << qint64(43) << "my-uid"
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate()
<< false;
QTest::newRow("nominal case (running)") << "running" << QString() << false << QDateTime()
<< QDateTime(QDate(2013, 11, 24)) << QDateTime(QDate(2014, 03, 01))
<< qint64(-1) << qint64(-1) << QString()
<< Domain::Task::NoRecurrence
<< Domain::Task::Attachments()
- << Domain::Task::Delegate()
<< true;
}
@@ -1227,7 +1185,6 @@ private slots:
QFETCH(QString, todoUid);
QFETCH(Domain::Task::Recurrence, recurrence);
QFETCH(Domain::Task::Attachments, attachments);
- QFETCH(Domain::Task::Delegate, delegate);
QFETCH(bool, running);
// Switch to UTC
@@ -1245,7 +1202,6 @@ private slots:
task->setDueDate(dueDate);
task->setRecurrence(recurrence);
task->setAttachments(attachments);
- task->setDelegate(delegate);
task->setRunning(running);
if (itemId > 0)
@@ -1325,13 +1281,6 @@ private slots:
#endif
}
- if (delegate.isValid()) {
- auto attendee = todo->attendeeByMail(delegate.email());
- QVERIFY(attendee);
- QCOMPARE(attendee->name(), delegate.name());
- QCOMPARE(attendee->email(), delegate.email());
- }
-
if (!todoUid.isEmpty()) {
QCOMPARE(todo->uid(), todoUid);
}
diff --git a/tests/units/akonadi/akonaditaskrepositorytest.cpp b/tests/units/akonadi/akonaditaskrepositorytest.cpp
index 7b6c1f0..ee49089 100644
--- a/tests/units/akonadi/akonaditaskrepositorytest.cpp
+++ b/tests/units/akonadi/akonaditaskrepositorytest.cpp
@@ -35,7 +35,6 @@
#include "testlib/gencollection.h"
#include "testlib/gentodo.h"
-#include "akonadi/akonadimessaginginterface.h"
#include "akonadi/akonaditaskrepository.h"
#include "akonadi/akonadiserializer.h"
#include "akonadi/akonadistorageinterface.h"
@@ -53,7 +52,6 @@ public:
explicit AkonadiTaskRepositoryTest(QObject *parent = Q_NULLPTR)
: QObject(parent)
{
- qRegisterMetaType<Domain::Task::Delegate>();
}
private slots:
@@ -83,8 +81,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->create(task)->exec();
// THEN
@@ -132,8 +129,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->create(task)->exec();
// THEN
@@ -174,8 +170,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
auto job = repository->create(task);
job->exec();
@@ -216,8 +211,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->createChild(child, parent)->exec();
// THEN
@@ -257,8 +251,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->createInProject(task, project)->exec();
// THEN
@@ -303,8 +296,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->createInContext(task, context)->exec();
@@ -342,8 +334,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->update(task)->exec();
// THEN
@@ -431,8 +422,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->remove(task)->exec();
// THEN
@@ -478,8 +468,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->promoteToProject(task)->exec();
// THEN
@@ -623,8 +612,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
auto associateJob = repository->associate(parent, child);
if (execJob)
associateJob->exec();
@@ -675,8 +663,7 @@ private slots:
auto monitor = Akonadi::MonitorInterface::Ptr(data.createMonitor());
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(Akonadi::StorageInterface::Ptr(data.createStorage()),
- serializer,
- Akonadi::MessagingInterface::Ptr()));
+ serializer));
QSignalSpy spy(monitor.data(), &Akonadi::MonitorInterface::itemChanged);
// WHEN
@@ -738,8 +725,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->dissociate(child)->exec();
// THEN
@@ -781,8 +767,7 @@ private slots:
// WHEN
QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(storageMock.getInstance(),
- serializerMock.getInstance(),
- Akonadi::MessagingInterface::Ptr()));
+ serializerMock.getInstance()));
repository->dissociateAll(child)->exec();
// THEN
@@ -798,39 +783,6 @@ private slots:
// in case of an error (since they use deleteLater() internally)
QTest::qWait(10);
}
-
- void shouldSendDelegationMessage()
- {
- // GIVEN
- auto oldDelegate = Domain::Task::Delegate(QStringLiteral("John Smith"), QStringLiteral("john@smith.com"));
- auto newDelegate = Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.com"));
-
- auto task = Domain::Task::Ptr::create();
- task->setDelegate(oldDelegate);
-
- QSignalSpy spy(task.data(), &Domain::Task::delegateChanged);
-
- auto item = Akonadi::Item(42);
-
- Utils::MockObject<Akonadi::SerializerInterface> serializerMock;
- serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(task).thenReturn(item);
-
- Utils::MockObject<Akonadi::MessagingInterface> messagingMock;
- messagingMock(&Akonadi::MessagingInterface::sendDelegationMessage).when(item).thenReturn();
-
- // WHEN
- QScopedPointer<Akonadi::TaskRepository> repository(new Akonadi::TaskRepository(Akonadi::StorageInterface::Ptr(),
- serializerMock.getInstance(),
- messagingMock.getInstance()));
- repository->delegate(task, newDelegate);
-
- // THEN
- QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(task).exactly(1));
- QVERIFY(messagingMock(&Akonadi::MessagingInterface::sendDelegationMessage).when(item).exactly(1));
-
- QCOMPARE(task->delegate(), oldDelegate);
- QVERIFY(spy.isEmpty());
- }
};
ZANSHIN_TEST_MAIN(AkonadiTaskRepositoryTest)
diff --git a/tests/units/domain/tasktest.cpp b/tests/units/domain/tasktest.cpp
index 5838055..890d077 100644
--- a/tests/units/domain/tasktest.cpp
+++ b/tests/units/domain/tasktest.cpp
@@ -38,7 +38,6 @@ public:
{
qRegisterMetaType<Task::Recurrence>();
qRegisterMetaType<Task::Attachments>();
- qRegisterMetaType<Task::Delegate>();
}
private slots:
@@ -53,7 +52,6 @@ private slots:
QCOMPARE(t.doneDate(), QDateTime());
QCOMPARE(t.recurrence(), Domain::Task::NoRecurrence);
QVERIFY(t.attachments().isEmpty());
- QVERIFY(!t.delegate().isValid());
}
void shouldHaveValueBasedAttachment()
@@ -131,33 +129,6 @@ private slots:
QCOMPARE(a.iconName(), QStringLiteral("text"));
}
- void shouldHaveValueBasedDelegate()
- {
- Task::Delegate d;
- QVERIFY(!d.isValid());
- QCOMPARE(d.name(), QString());
- QCOMPARE(d.email(), QString());
- QCOMPARE(d.display(), QString());
-
- d.setName(QStringLiteral("John Doe"));
- QVERIFY(!d.isValid());
- QCOMPARE(d.name(), QStringLiteral("John Doe"));
- QCOMPARE(d.email(), QString());
- QCOMPARE(d.display(), QString());
-
- d.setEmail(QStringLiteral("doe@somewhere.com"));
- QVERIFY(d.isValid());
- QCOMPARE(d.name(), QStringLiteral("John Doe"));
- QCOMPARE(d.email(), QStringLiteral("doe@somewhere.com"));
- QCOMPARE(d.display(), QStringLiteral("John Doe"));
-
- d.setName(QString());
- QVERIFY(d.isValid());
- QCOMPARE(d.name(), QString());
- QCOMPARE(d.email(), QStringLiteral("doe@somewhere.com"));
- QCOMPARE(d.display(), QStringLiteral("doe@somewhere.com"));
- }
-
void shouldNotifyStatusChanges()
{
Task t;
@@ -256,25 +227,6 @@ private slots:
QCOMPARE(spy.count(), 0);
}
- void shouldNotifyDelegateChanges()
- {
- Task t;
- QSignalSpy spy(&t, &Task::delegateChanged);
- t.setDelegate(Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("doe@somewhere.com")));
- QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.first().first().value<Task::Delegate>(),
- Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("doe@somewhere.com")));
- }
-
- void shouldNotNotifyIdenticalDelegateChanges()
- {
- Task t;
- t.setDelegate(Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("doe@somewhere.com")));
- QSignalSpy spy(&t, &Task::delegateChanged);
- t.setDelegate(Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("doe@somewhere.com")));
- QCOMPARE(spy.count(), 0);
- }
-
void shouldNotifyDoneDateChanges()
{
Task t;
diff --git a/tests/units/presentation/artifacteditormodeltest.cpp b/tests/units/presentation/artifacteditormodeltest.cpp
index f7fd7ed..cba6127 100644
--- a/tests/units/presentation/artifacteditormodeltest.cpp
+++ b/tests/units/presentation/artifacteditormodeltest.cpp
@@ -79,9 +79,7 @@ private slots:
QVERIFY(model.dueDate().isNull());
QCOMPARE(model.recurrence(), Domain::Task::NoRecurrence);
QVERIFY(model.attachmentModel() != nullptr);
- QVERIFY(model.delegateText().isNull());
QVERIFY(!model.hasSaveFunction());
- QVERIFY(!model.hasDelegateFunction());
auto am = model.attachmentModel();
QCOMPARE(am->rowCount(), 0);
}
@@ -97,7 +95,6 @@ private slots:
QSignalSpy dueSpy(&model, &Presentation::ArtifactEditorModel::dueDateChanged);
QSignalSpy recurrenceSpy(&model, &Presentation::ArtifactEditorModel::recurrenceChanged);
QSignalSpy attachmentSpy(model.attachmentModel(), &QAbstractItemModel::modelReset);
- QSignalSpy delegateSpy(&model, &Presentation::ArtifactEditorModel::delegateTextChanged);
Domain::Task::Attachments attachments;
@@ -123,7 +120,6 @@ private slots:
task->setDueDate(QDateTime::currentDateTime().addDays(2));
task->setRecurrence(Domain::Task::RecursDaily);
task->setAttachments(attachments);
- task->setDelegate(Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.com")));
// WHEN
model.setArtifact(task);
@@ -162,10 +158,6 @@ private slots:
QCOMPARE(recurrenceSpy.takeFirst().at(0).value<Domain::Task::Recurrence>(), task->recurrence());
QCOMPARE(model.property("recurrence").value<Domain::Task::Recurrence>(), task->recurrence());
- QCOMPARE(delegateSpy.size(), 1);
- QCOMPARE(delegateSpy.takeFirst().at(0).toString(), task->delegate().display());
- QCOMPARE(model.property("delegateText").toString(), task->delegate().display());
-
QCOMPARE(attachmentSpy.size(), 1);
auto am = model.attachmentModel();
QCOMPARE(am->rowCount(), 2);
@@ -184,7 +176,6 @@ private slots:
QSignalSpy doneSpy(&model, &Presentation::ArtifactEditorModel::doneChanged);
QSignalSpy startSpy(&model, &Presentation::ArtifactEditorModel::startDateChanged);
QSignalSpy dueSpy(&model, &Presentation::ArtifactEditorModel::dueDateChanged);
- QSignalSpy delegateSpy(&model, &Presentation::ArtifactEditorModel::delegateTextChanged);
auto note = Domain::Note::Ptr::create();
note->setText(QStringLiteral("description"));
@@ -218,10 +209,6 @@ private slots:
QCOMPARE(dueSpy.size(), 1);
QVERIFY(dueSpy.takeFirst().at(0).toDateTime().isNull());
QVERIFY(model.property("dueDate").toDateTime().isNull());
-
- QCOMPARE(delegateSpy.size(), 1);
- QVERIFY(delegateSpy.takeFirst().at(0).toString().isEmpty());
- QVERIFY(model.property("delegateText").toString().isEmpty());
}
void shouldReactToArtifactPropertyChanges_data()
@@ -320,23 +307,6 @@ private slots:
QCOMPARE(model.property(propertyName), oldPropertyValue);
}
- void shouldReactToTaskDelegateChanges()
- {
- // GIVEN
- auto task = Domain::Task::Ptr::create();
- Presentation::ArtifactEditorModel model;
- model.setArtifact(task);
- QSignalSpy spy(&model, &Presentation::ArtifactEditorModel::delegateTextChanged);
-
- // WHEN
- task->setDelegate(Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.com")));
-
- // THEN
- QCOMPARE(spy.size(), 1);
- QCOMPARE(spy.takeFirst().at(0).toString(), task->delegate().display());
- QCOMPARE(model.property("delegateText").toString(), task->delegate().display());
- }
-
void shouldApplyChangesBackToArtifactAfterADelay_data()
{
shouldReactToArtifactPropertyChanges_data();
@@ -473,34 +443,6 @@ private slots:
QCOMPARE(artifact->property(propertyName), propertyValue);
}
- void shouldLaunchDelegation()
- {
- // GIVEN
- auto task = Domain::Task::Ptr::create();
- auto expectedDelegate = Domain::Task::Delegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.com"));
-
- auto delegatedTask = Domain::Task::Ptr();
- auto delegate = Domain::Task::Delegate();
- auto delegateFunction = [this, &delegatedTask, &delegate] (const Domain::Task::Ptr &task, const Domain::Task::Delegate &d) {
- delegatedTask = task;
- delegate = d;
- return new FakeJob(this);
- };
-
- Presentation::ArtifactEditorModel model;
- model.setDelegateFunction(delegateFunction);
- QVERIFY(model.hasDelegateFunction());
- model.setArtifact(task);
-
- // WHEN
- model.delegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.com"));
-
- // THEN
- QCOMPARE(delegatedTask, task);
- QCOMPARE(delegate, expectedDelegate);
- QVERIFY(!task->delegate().isValid());
- }
-
void shouldGetAnErrorMessageWhenSaveFailed()
{
// GIVEN
diff --git a/tests/units/testlib/gentodotest.cpp b/tests/units/testlib/gentodotest.cpp
index a0f323d..3622345 100644
--- a/tests/units/testlib/gentodotest.cpp
+++ b/tests/units/testlib/gentodotest.cpp
@@ -202,30 +202,6 @@ private slots:
// THEN
QCOMPARE(item.payload<KCalCore::Todo::Ptr>()->dtDue().date(), QDate(2015, 04, 12));
}
-
- void shouldAllowToSetDelegate()
- {
- // GIVEN
- Akonadi::Item item = GenTodo().withDelegate(QStringLiteral("John Doe"), QStringLiteral("john@doe.net"));
-
- // THEN
- QCOMPARE(item.payload<KCalCore::Todo::Ptr>()->attendeeCount(), 1);
-
- const auto attendees = item.payload<KCalCore::Todo::Ptr>()->attendees();
- const auto delegate = std::find_if(attendees.begin(), attendees.end(),
- [] (const KCalCore::Attendee::Ptr &attendee) {
- return attendee->status() == KCalCore::Attendee::Delegated;
- });
- QVERIFY(delegate != attendees.constEnd());
- QCOMPARE((*delegate)->name(), QStringLiteral("John Doe"));
- QCOMPARE((*delegate)->email(), QStringLiteral("john@doe.net"));
-
- // WHEN
- item = GenTodo(item).withNoDelegate();
-
- // THEN
- QCOMPARE(item.payload<KCalCore::Todo::Ptr>()->attendeeCount(), 0);
- }
};
ZANSHIN_TEST_MAIN(GenTodoTest)
diff --git a/tests/units/widgets/editorviewtest.cpp b/tests/units/widgets/editorviewtest.cpp
index 38e8f85..20fed73 100644
--- a/tests/units/widgets/editorviewtest.cpp
+++ b/tests/units/widgets/editorviewtest.cpp
@@ -37,7 +37,6 @@
#include "widgets/editorview.h"
-#include "addressline/addresseelineedit.h"
#include "kdateedit.h"
class EditorModelStub : public QObject
@@ -72,8 +71,6 @@ public:
emit dueDateChanged(value.toDateTime());
else if (name == "recurrence")
emit recurrenceChanged(value.value<Domain::Task::Recurrence>());
- else if (name == "delegateText")
- emit delegateTextChanged(value.toString());
else if (name == "hasTaskProperties")
emit hasTaskPropertiesChanged(value.toBool());
else
@@ -88,15 +85,8 @@ public slots:
void setStartDate(const QDateTime &start) { setPropertyAndSignal("startDate", start); }
void setDueDate(const QDateTime &due) { setPropertyAndSignal("dueDate", due); }
void setRecurrence(Domain::Task::Recurrence recurrence) { setPropertyAndSignal("recurrence", QVariant::fromValue(recurrence)); }
- void setDelegateText(const QString &text) { setPropertyAndSignal("delegateText", text); }
void makeTaskAvailable() { setArtifact(Domain::Artifact::Ptr(new Domain::Task)); }
- void delegate(const QString &name, const QString &email)
- {
- delegateNames << name;
- delegateEmails << email;
- }
-
void addAttachment(const QString &fileName)
{
auto item = new QStandardItem(fileName);
@@ -118,11 +108,8 @@ signals:
void startDateChanged(const QDateTime &date);
void dueDateChanged(const QDateTime &due);
void recurrenceChanged(Domain::Task::Recurrence recurrence);
- void delegateTextChanged(const QString &delegateText);
public:
- QStringList delegateNames;
- QStringList delegateEmails;
QStandardItemModel attachmentModel;
};
@@ -174,14 +161,6 @@ private slots:
auto removeAttachmentButton = editor.findChild<QToolButton*>(QStringLiteral("removeAttachmentButton"));
QVERIFY(removeAttachmentButton);
QVERIFY(!removeAttachmentButton->isVisibleTo(&editor));
-
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
- QVERIFY(delegateLabel);
- QVERIFY(!delegateLabel->isVisibleTo(&editor));
-
- auto delegateEdit = editor.findChild<KLineEdit*>(QStringLiteral("delegateEdit"));
- QVERIFY(delegateEdit);
- QVERIFY(!delegateEdit->isVisibleTo(&editor));
}
void shouldNotCrashForNullModel()
@@ -219,12 +198,6 @@ private slots:
auto removeAttachmentButton = editor.findChild<QToolButton*>(QStringLiteral("removeAttachmentButton"));
QVERIFY(removeAttachmentButton);
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
- QVERIFY(delegateLabel);
-
- auto delegateEdit = editor.findChild<KLineEdit*>(QStringLiteral("delegateEdit"));
- QVERIFY(delegateEdit);
-
// WHEN
editor.setModel(Q_NULLPTR);
@@ -239,8 +212,6 @@ private slots:
QVERIFY(attachmentList->model() == nullptr);
QVERIFY(!addAttachmentButton->isVisibleTo(&editor));
QVERIFY(!removeAttachmentButton->isVisibleTo(&editor));
- QVERIFY(!delegateLabel->isVisibleTo(&editor));
- QVERIFY(!delegateEdit->isVisibleTo(&editor));
}
void shouldShowTaskPropertiesEditorsOnlyForTasks()
@@ -271,12 +242,6 @@ private slots:
auto removeAttachmentButton = editor.findChild<QToolButton*>(QStringLiteral("removeAttachmentButton"));
QVERIFY(removeAttachmentButton);
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
- QVERIFY(!delegateLabel->isVisibleTo(&editor));
-
- auto delegateEdit = editor.findChild<KLineEdit*>(QStringLiteral("delegateEdit"));
- QVERIFY(!delegateEdit->isVisibleTo(&editor));
-
// WHEN
editor.setModel(&model);
@@ -288,28 +253,6 @@ private slots:
QVERIFY(attachmentList->isVisibleTo(&editor));
QVERIFY(addAttachmentButton->isVisibleTo(&editor));
QVERIFY(removeAttachmentButton->isVisibleTo(&editor));
- QVERIFY(!delegateLabel->isVisibleTo(&editor));
- QVERIFY(delegateEdit->isVisibleTo(&editor));
- }
-
- void shouldDisplayDelegateLabelOnlyWhenNeeded()
- {
- // GIVEN
- Widgets::EditorView editor;
- EditorModelStub model;
- model.makeTaskAvailable();
- model.setDelegateText(QStringLiteral("John Doe"));
-
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
- QVERIFY(!delegateLabel->isVisibleTo(&editor));
-
- // WHEN
- editor.setModel(&model);
-
- // THEN
- auto expectedText = i18n("Delegated to: <b>%1</b>", model.property("delegateText").toString());
- QVERIFY(delegateLabel->isVisibleTo(&editor));
- QCOMPARE(delegateLabel->text(), expectedText);
}
void shouldBeEnabledOnlyWhenAnArtifactIsAvailable()
@@ -429,9 +372,6 @@ private slots:
auto dueDateEdit = editor.findChild<KPIM::KDateEdit*>(QStringLiteral("dueDateEdit"));
auto recurrenceCombo = editor.findChild<QComboBox*>(QStringLiteral("recurrenceCombo"));
auto doneButton = editor.findChild<QAbstractButton*>(QStringLiteral("doneButton"));
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
- auto delegateEdit = editor.findChild<QWidget*>(QStringLiteral("delegateEdit"));
- model.setDelegateText(QStringLiteral("John Doe"));
editor.setModel(&model);
// WHEN
@@ -449,8 +389,6 @@ private slots:
model.setRecurrence(Domain::Task::RecursDaily);
doneButton->setFocus();
model.setDone(false);
- delegateEdit->setFocus();
- model.setDelegateText(QStringLiteral("John Smith"));
// THEN (nothing changed)
QCOMPARE(textEdit->toPlainText(), QStringLiteral("My title\n\nMy text"));
@@ -458,9 +396,6 @@ private slots:
QCOMPARE(dueDateEdit->date(), QDate::currentDate().addDays(2));
QCOMPARE(recurrenceCombo->currentData().value<Domain::Task::Recurrence>(), Domain::Task::RecursWeekly);
QVERIFY(doneButton->isChecked());
- auto expectedText = i18n("Delegated to: <b>%1</b>", QStringLiteral("John Doe"));
- QCOMPARE(delegateLabel->text(), expectedText);
-
}
void shouldReactToTitleChanges()
@@ -778,91 +713,6 @@ private slots:
QCOMPARE(model.attachmentModel.data(model.attachmentModel.index(0, 0)).toString(),
QStringLiteral("/tmp/bar"));
}
-
- void shouldReactToDelegateTextChanges()
- {
- // GIVEN
- Widgets::EditorView editor;
- EditorModelStub model;
- model.makeTaskAvailable();
- model.setDelegateText(QStringLiteral("John Doe"));
- editor.setModel(&model);
-
- auto delegateLabel = editor.findChild<QLabel*>(QStringLiteral("delegateLabel"));
-
- // WHEN
- model.setDelegateText(QStringLiteral("John Smith"));
-
- // THEN
- auto expectedText = i18n("Delegated to: <b>%1</b>", model.property("delegateText").toString());
- QCOMPARE(delegateLabel->text(), expectedText);
- }
-
- void shouldClearDelegateEditOnArtifactChanges()
- {
- // GIVEN
- Widgets::EditorView editor;
- EditorModelStub model;
- model.makeTaskAvailable();
- editor.setModel(&model);
-
- auto delegateEdit = editor.findChild<KLineEdit*>(QStringLiteral("delegateEdit"));
- delegateEdit->setText(QStringLiteral("Foo"));
-
- // WHEN
- model.makeTaskAvailable(); // simulates an artifact change
-
- // THEN
- QVERIFY(delegateEdit->text().isEmpty());
- }
-
- void shouldRequestDelegationOnInput_data()
- {
- QTest::addColumn<QString>("userInput");
- QTest::addColumn<QString>("expectedName");
- QTest::addColumn<QString>("expectedEmail");
- QTest::addColumn<bool>("expectedCall");
-
- QTest::newRow("nominal case") << "John Doe <john@doe.com>" << "John Doe" << "john@doe.com" << true;
- QTest::newRow("nominal case") << "John Doe <j.doe@some.server.com>" << "John Doe" << "j.doe@some.server.com" << true;
- QTest::newRow("only name") << "John Doe" << QString() << QString() << false;
- QTest::newRow("only email") << "john@doe.com" << QString() << "john@doe.com" << true;
- QTest::newRow("only email again") << "<john@doe.com>" << QString() << "john@doe.com" << true;
- QTest::newRow("nonsense case") << "bleh" << QString() << QString() << false;
- }
-
- void shouldRequestDelegationOnInput()
- {
- // GIVEN
- QFETCH(QString, userInput);
- QFETCH(QString, expectedName);
- QFETCH(QString, expectedEmail);
- QFETCH(bool, expectedCall);
-
- Widgets::EditorView editor;
- EditorModelStub model;
- model.makeTaskAvailable();
- editor.setModel(&model);
-
- auto delegateEdit = editor.findChild<KLineEdit*>(QStringLiteral("delegateEdit"));
-
- // WHEN
- QVERIFY(delegateEdit->isEnabled());
- delegateEdit->setText(userInput);
- QTest::keyClick(delegateEdit, Qt::Key_Enter);
-
- // THEN
- if (expectedCall) {
- QCOMPARE(model.delegateNames.size(), 1);
- QCOMPARE(model.delegateNames.first(), expectedName);
- QCOMPARE(model.delegateEmails.size(), 1);
- QCOMPARE(model.delegateEmails.first(), expectedEmail);
- QVERIFY(delegateEdit->text().isEmpty());
- } else {
- QCOMPARE(model.delegateNames.size(), 0);
- QCOMPARE(model.delegateEmails.size(), 0);
- }
- }
};
ZANSHIN_TEST_MAIN(EditorViewTest)