Commit ce2ab0ec authored by Laurent Montel's avatar Laurent Montel 😁

Move from libkdepim

parent a4d7a0d1
Pipeline #23702 passed with stage
in 9 minutes and 52 seconds
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.14.45")
set(PIM_VERSION "5.14.46")
project(pimcommon VERSION ${PIM_VERSION})
......@@ -22,7 +22,7 @@ include(FeatureSummary)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
include(ECMInstallIcons)
include(ECMAddQtDesignerPlugin)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......@@ -69,6 +69,16 @@ find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG REQUIRED)
option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON)
add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer")
option(FORCE_DISABLE_AKONADI_SEARCH "Disable features and API that require akonadi-search, e.g. because xapian isn't available" OFF)
if (NOT FORCE_DISABLE_AKONADI_SEARCH)
find_package(KF5AkonadiSearch ${AKONADISEARCH_LIB_VERSION} CONFIG REQUIRED)
set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "https://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi")
endif()
set(DISABLE_AKONADI_SEARCH ${FORCE_DISABLE_AKONADI_SEARCH})
configure_file(config-akonadi-search.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config-akonadi-search.h)
find_package(Xsltproc)
set_package_properties(Xsltproc PROPERTIES DESCRIPTION "XSLT processor from libxslt" TYPE REQUIRED PURPOSE "Required to generate D-Bus interfaces for all Akonadi resources.")
......
#cmakedefine01 DISABLE_AKONADI_SEARCH
......@@ -83,6 +83,37 @@ set(libpimcommonakonadi_collection_SRCS
collectionpage/contenttypewidget.cpp
)
set(libpimcommonakonadi_addressline_LIB_SRCS
addressline/completionorder/completionordereditor.cpp
addressline/completionorder/completionorderwidget.cpp
addressline/addresslineedit/addresseelineedit.cpp
addressline/addresslineedit/addresseelineedit_p.cpp
addressline/addresslineedit/addresseelineeditmanager.cpp
addressline/addresslineedit/addresseelineeditldap.cpp
addressline/addresslineedit/addresseelineeditakonadi.cpp
addressline/addresslineedit/addresseelineeditbaloo.cpp
addressline/addresslineedit/kmailcompletion.cpp
addressline/addresslineedit/baloocompletionemail.cpp
addressline/completionconfiguredialog/completionconfiguredialog.cpp
addressline/addresslineedit/addresseelineeditutil.cpp
addressline/recentaddress/recentaddresswidget.cpp
addressline/recentaddress/recentaddresses.cpp
)
if (NOT FORCE_DISABLE_AKONADI_SEARCH)
set(libpimcommonakonadi_addressline_blacklist_baloo_LIB_SRCS
addressline/blacklistbaloocompletion/blacklistbalooemaillist.cpp
addressline/blacklistbaloocompletion/blacklistbalooemailutil.cpp
addressline/blacklistbaloocompletion/blacklistbalooemailcompletionwidget.cpp
addressline/blacklistbaloocompletion/blacklistbalooemailwarning.cpp
addressline/blacklistbaloocompletion/blacklistbalooemailsearchjob.cpp
)
endif()
set(libpimcommonakonadi_addressline_plugin_LIB_SRCS
addressline/plugins/addressesslineeditabstractplugin.cpp
addressline/plugins/addressesslineeditpluginmanager.cpp
)
set(libpimcommonakonadi_SRCS
${libpimcommonakonadi_ldap_SRCS}
......@@ -95,6 +126,9 @@ set(libpimcommonakonadi_SRCS
${libpimcommonakonadi_widgets_SRCS}
${libpimcommonakonadi_util_SRCS}
${libpimcommonakonadi_progresswidget_SRCS}
${libpimcommonakonadi_addressline_LIB_SRCS}
${libpimcommonakonadi_addressline_blacklist_baloo_LIB_SRCS}
${libpimcommonakonadi_addressline_plugin_LIB_SRCS}
)
......@@ -129,8 +163,14 @@ target_link_libraries(KF5PimCommonAkonadi
KF5::KIOWidgets
KF5::KCMUtils
KF5::Ldap
KF5::ItemViews
)
if (NOT FORCE_DISABLE_AKONADI_SEARCH)
target_link_libraries(KF5PimCommonAkonadi PRIVATE KF5::AkonadiSearchPIM)
endif()
target_include_directories(KF5PimCommonAkonadi INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/PimCommonAkonadi/;${KDE_INSTALL_INCLUDEDIR_KF5}/pimcommonakonadi>")
target_include_directories(KF5PimCommonAkonadi PUBLIC "$<BUILD_INTERFACE:${pimcommon_SOURCE_DIR}/src;${pimcommon_BINARY_DIR}/src>")
......@@ -152,8 +192,53 @@ if (BUILD_TESTING)
add_subdirectory(folderdialog/tests/)
add_subdirectory(collectionpage/autotests/)
add_subdirectory(ldap/tests)
add_subdirectory(addressline/tests)
add_subdirectory(addressline/autotests)
if (NOT FORCE_DISABLE_AKONADI_SEARCH)
add_subdirectory(addressline/blacklistbaloocompletion/autotests)
endif()
endif()
if(BUILD_DESIGNERPLUGIN)
add_subdirectory(designer)
endif()
ecm_generate_headers(PimCommonAkonadi_Camelcaseaddressline_HEADERS
HEADER_NAMES
AddresseeLineEdit
REQUIRED_HEADERS PimCommonAkonadi_addressline_HEADERS
PREFIX PimCommonAkonadi
RELATIVE addressline/addresslineedit/
)
ecm_generate_headers(PimCommonAkonadi_Camelcaserecentaddress_HEADERS
HEADER_NAMES
RecentAddresses
REQUIRED_HEADERS PimCommonAkonadi_recentaddress_HEADERS
PREFIX PimCommonAkonadi
RELATIVE addressline/recentaddress/
)
ecm_generate_headers(PimCommonAkonadi_Camelcasecompletionorder_HEADERS
HEADER_NAMES
CompletionOrderEditor
REQUIRED_HEADERS PimCommonAkonadi_completionorder_HEADERS
PREFIX PimCommonAkonadi
RELATIVE addressline/completionorder
)
ecm_generate_headers(PimCommonAkonadi_Camelcasecompletionconfiguredialog_HEADERS
HEADER_NAMES
CompletionConfigureDialog
REQUIRED_HEADERS PimCommonAkonadi_completionconfiguredialog_HEADERS
PREFIX PimCommonAkonadi
RELATIVE addressline/completionconfiguredialog/
)
ecm_generate_headers(PimCommonAkonadi_Camelcasecollectionpage_HEADERS
HEADER_NAMES
IncidencesForWidget
......@@ -183,7 +268,7 @@ ecm_generate_headers(PimCommonAkonadiUtil_CamelCase_HEADERS
RELATIVE util
)
ecm_generate_headers(libkdepimakonadi_Camelcaseprogresswidget_HEADERS
ecm_generate_headers(PimCommonAkonadi_Camelcaseprogresswidget_HEADERS
HEADER_NAMES
ProgressManagerAkonadi
REQUIRED_HEADERS libkdepimakonadi_progresswidget_HEADERS
......@@ -258,7 +343,11 @@ install(FILES
${PimCommon_Camelcasemanagerserversidesubscription_HEADERS}
${PimCommonAkonadi_Camelcasewidgets_HEADERS}
${PimCommonAkonadiUtil_CamelCase_HEADERS}
${libkdepimakonadi_Camelcaseprogresswidget_HEADERS}
${PimCommonAkonadiCamel_caseprogresswidget_HEADERS}
${PimCommonAkonadi_Camelcasecompletionconfiguredialog_HEADERS}
${PimCommonAkonadi_Camelcasecompletionorder_HEADERS}
${PimCommonAkonadi_Camelcaseaddressline_HEADERS}
${PimCommonAkonadi_Camelcaserecentaddress_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/PimCommonAkonadi
COMPONENT Devel
)
......@@ -276,7 +365,12 @@ install(FILES
${PimCommonAkonadi_widgets_HEADERS}
${PimCommon_managerserversidesubscription_HEADERS}
${PimCommonAkonadiUtil_HEADERS}
${libkdepimakonadi_progresswidget_HEADERS}
${PimCommonAkonadi_progresswidget_HEADERS}
${PimCommonAkonadi_completionconfiguredialog_HEADERS}
${PimCommonAkonadi_completionorder_HEADERS}
${PimCommonAkonadi_addressline_HEADERS}
${PimCommonAkonadi_recentaddress_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/pimcommonakonadi
COMPONENT Devel
......
/*
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>
Copyright (C) 2017-2020 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 KDEPIM_ADDRESSEELINEEDIT_H
#define KDEPIM_ADDRESSEELINEEDIT_H
#include "pimcommonakonadi_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 PimCommon {
class AddresseeLineEditPrivate;
class PIMCOMMONAKONADI_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 = nullptr, bool enableCompletion = true);
/**
* Destroys the addressee line edit.
*/
~AddresseeLineEdit() override;
/**
* 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);
Q_REQUIRED_RESULT bool enableBalooSearch() const;
void setEnableAkonadiSearch(bool enable);
Q_REQUIRED_RESULT bool enableAkonadiSearch() const;
void setExpandIntern(bool);
Q_REQUIRED_RESULT bool expandIntern() const;
Q_REQUIRED_RESULT bool isCompletionEnabled() 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.
*/
Q_REQUIRED_RESULT 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();
Q_REQUIRED_RESULT KLDAP::LdapClientSearch *ldapSearch() const;
void setShowRecentAddresses(bool b);
bool showRecentAddresses() const;
void setRecentAddressConfig(KConfig *config);
Q_REQUIRED_RESULT KConfig *recentAddressConfig() const;
void configureCompletion();
void setIcon(const QIcon &icon, const QString &tooltip = QString());
bool canDeleteLineEdit() const;
Q_SIGNALS:
void textCompleted();
void addAddress(const QString &address);
void iconClicked();
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) 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 *) override;
#ifndef QT_NO_DRAGANDDROP
/**
* Reimplemented for smart insertion of dragged email addresses.
*/
void dropEvent(QDropEvent *) override;
#endif
/**
* Reimplemented for internal reasons.
*/
void keyPressEvent(QKeyEvent *) 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 *) override;
#endif
void insertEmails(const QStringList &emails);
void loadContacts();
private:
void groupExpandResult(KJob *job);
bool eventFilter(QObject *, QEvent *) override;
AddresseeLineEditPrivate *const d;
};
}
#endif
/*
Copyright (c) 2015-2020 Laurent Montel <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 as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADDRESSEELINEEDIT_P_H
#define ADDRESSEELINEEDIT_P_H
#include <QStringList>
#include <QObject>
#include <QList>
#include <KLDAP/LdapClientSearch>
#include <AkonadiCore/Item>
#include <AkonadiCore/Collection>
#include <kcontacts/contactgroup.h>
class KConfig;
class QToolButton;
class QTimer;
namespace Akonadi {
class ContactGroupSearchJob;
}
namespace PimCommon {
class AddresseeLineEdit;
class AddresseeLineEditPrivate : public QObject
{
Q_OBJECT
public:
AddresseeLineEditPrivate(AddresseeLineEdit *qq, bool enableCompletion);
~AddresseeLineEditPrivate();
void init();
void setCompletedItems(const QStringList &items, bool autoSuggest);
void addCompletionItem(const QString &string, int weight, int source, const QStringList *keyWords = nullptr);
const QStringList adjustedCompletionItems(bool fullSearch);
void updateSearchString();
void startSearches();
void akonadiPerformSearch();
void akonadiHandlePending();
void doCompletion(bool ctrlT);
bool showOU() const;
void setIcon(const QIcon &icon, const QString &tooltip);
bool useCompletion() const;
void setUseCompletion(bool useCompletion);
bool completionInitialized() const;
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);
bool enableAkonadiSearch() const;
void setEnableAkonadiSearch(bool enableAkonadiSearch);
void removeCompletionSource(const QString &source);
int addCompletionSource(const QString &source, int weight);
void restartTime(const QString &searchString);
void updateBalooBlackList();
void updateCompletionOrder();
KLDAP::LdapClientSearch *ldapSearch();
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;
bool canDeleteLineEdit() const;
void setCanDeleteLineEdit(bool inprogressToConfigureCompletion);
public Q_SLOTS:
void slotToggleExpandGroups(bool);
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();
private:
AddresseeLineEdit *q = nullptr;
QToolButton *mToolButton = nullptr;
QTimer *mDelayedQueryTimer = nullptr;
QString mPreviousAddresses;
QString mSearchString;
QList<KJob *> mMightBeGroupJobs;
KContacts::ContactGroup::List mGroups;
KConfig *mRecentAddressConfig = nullptr;
bool mUseCompletion = false;
bool mCompletionInitialized = false;
bool mSmartPaste = false;
bool mLastSearchMode = false;
bool mSearchExtended = false; //has \" been added?
bool mUseSemicolonAsSeparator = false;
bool mEnableBalooSearch = true;
bool mEnableAkonadiSearch = true;
bool mExpandIntern = true;
bool mShowRecentAddresses = true;
bool mCanDeleteLineEdit = true;
};
}
#endif // ADDRESSEELINEEDIT_P_H
/*
Copyright (C) 2017-2020 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 "addresseelineeditakonadi.h"
#include <AkonadiCore/Session>
using namespace PimCommon;