From ba3a0e4c1d232b05daddd9ded110e15e0a3c9005 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 29 Aug 2023 20:29:23 +0200 Subject: [PATCH] Added Akonadi version check for some renamed components Akonadi renamed the contact viewer and editors namespace. --- CMakeLists.txt | 10 +++++++++- src/CMakeLists.txt | 1 + src/addressselectorwidget.cpp | 16 +++++++++++----- src/addressselectorwidget.h | 15 +++++++++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f5541da..0cd73f99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,15 @@ set_package_properties(${AKO_PREFIX}AkonadiContact PROPERTIES TYPE OPTIONAL ) -if(${AKO_PREFIX}Akonadi_FOUND AND ${AKO_PREFIX}AkonadiContact_FOUND) +find_package(${AKO_PREFIX}ContactEditor) +set_package_properties(${AKO_PREFIX}ContactEditor PROPERTIES + DESCRIPTION "Library for editing contacts stored in Akonadi" + URL "https://www.kde.org/" + PURPOSE "Optionally used for addressbook integration" + TYPE OPTIONAL +) + +if(${AKO_PREFIX}Akonadi_FOUND AND ${AKO_PREFIX}AkonadiContact_FOUND AND ${AKO_PREFIX}ContactEditor_FOUND) add_definitions(-DHAVE_AKONADI) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2bc5dcf..eac624d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,6 +173,7 @@ if(${AKO_PREFIX}Akonadi_FOUND) list(APPEND KRAFT_LINK_LIBS ${AKO_PREFIX}::AkonadiCore ${AKO_PREFIX}::AkonadiContact + ${AKO_PREFIX}::ContactEditor ${AKO_PREFIX}::AkonadiAgentBase ${AKO_PREFIX}::AkonadiWidgets ${AKO_PREFIX}::AkonadiXml diff --git a/src/addressselectorwidget.cpp b/src/addressselectorwidget.cpp index fd083634..504d5a6b 100644 --- a/src/addressselectorwidget.cpp +++ b/src/addressselectorwidget.cpp @@ -235,7 +235,11 @@ KraftContactViewer::KraftContactViewer(QWidget *parent) lay->setMargin(0); setLayout(lay); #ifdef HAVE_AKONADI +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) + _contactViewer = new ContactEditor::ContactViewer; +#else _contactViewer = new Akonadi::ContactViewer; +#endif _contactViewer->setShowQRCode(false); lay->addWidget(_contactViewer); @@ -372,9 +376,12 @@ bool AddressSelectorWidget::backendUp() const void AddressSelectorWidget::slotCreateNewContact() { #ifdef HAVE_AKONADI - // FIXME -_addressEditor.reset(new Akonadi::ContactEditorDialog( Akonadi::ContactEditorDialog::CreateMode, this )); -_addressEditor->show(); +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) + _addressEditor = new ContactEditor::ContactEditorDialog(ContactEditor::ContactEditorDialog::EditMode, this ); +#else + _addressEditor = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::CreateMode, this ); +#endif + _addressEditor->show(); #endif } @@ -398,13 +405,12 @@ void AddressSelectorWidget::slotAddresseeSelected(QModelIndex index) void AddressSelectorWidget::slotEditContact() { #ifdef HAVE_AKONADI - if( _addressTreeView->selectionModel()->hasSelection() ) { QModelIndex index = _addressTreeView->selectionModel()->currentIndex(); if ( index.isValid() ) { const Akonadi::Item item = index.data( Akonadi::EntityTreeModel::ItemRole ).value(); if ( item.isValid() && item.hasPayload() ) { - _addressEditor.reset(new Akonadi::ContactEditorDialog( Akonadi::ContactEditorDialog::EditMode, this )); + _addressEditor = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::EditMode, this); _addressEditor->setContact( item ); _addressEditor->show(); } diff --git a/src/addressselectorwidget.h b/src/addressselectorwidget.h index 4c5ec3e2..70d97590 100644 --- a/src/addressselectorwidget.h +++ b/src/addressselectorwidget.h @@ -30,7 +30,10 @@ #else #define AKONADICONTACT_VERSION AKONADI_VERSION #endif -#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 20, 0) +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) +#include +#include +#elif AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 20, 0) #include #include #else @@ -66,8 +69,12 @@ class KraftContactViewer : public QWidget private: #ifdef HAVE_AKONADI +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) + ContactEditor::ContactViewer *_contactViewer; +#else Akonadi::ContactViewer *_contactViewer; #endif +#endif }; class AddressSortProxyModel : public QSortFilterProxyModel @@ -124,7 +131,11 @@ private slots: QTreeView *_addressTreeView; KraftContactViewer *_contactViewer; #ifdef HAVE_AKONADI - QScopedPointer _addressEditor; +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) + ContactEditor::ContactEditorDialog *_addressEditor; +#else + Akonadi::ContactEditorDialog *_addressEditor; +#endif #endif }; From 052bfe5903cc1f33a27b0dc77512458ff39cfdb5 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 29 Aug 2023 20:54:08 +0200 Subject: [PATCH] more version checks added --- src/addressselectorwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/addressselectorwidget.cpp b/src/addressselectorwidget.cpp index 504d5a6..1cf2317 100644 --- a/src/addressselectorwidget.cpp +++ b/src/addressselectorwidget.cpp @@ -410,7 +410,11 @@ void AddressSelectorWidget::slotEditContact() if ( index.isValid() ) { const Akonadi::Item item = index.data( Akonadi::EntityTreeModel::ItemRole ).value(); if ( item.isValid() && item.hasPayload() ) { - _addressEditor = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::EditMode, this); +#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0) + _addressEditor = new ContactEditor::ContactEditorDialog(ContactEditor::ContactEditorDialog::EditMode, this ); +#else + _addressEditor = new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::CreateMode, this ); +#endif _addressEditor->setContact( item ); _addressEditor->show(); }