Commit 1e328a07 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Make AkonadiConsole buildable on Windows

On Windows we build without the contentviews in the Browser tab and
without that Item Search tab, because we don't have those dependencies
available yet.
parent 05e4a0f0
......@@ -40,8 +40,6 @@ set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}")
set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}")
set(KDEPIM_LIB_SOVERSION "5")
set(AKONADI_MIMELIB_VERSION "5.7.40")
set(AKONADI_CONTACT_VERSION "5.7.40")
set(CALENDARSUPPORT_LIB_VERSION_LIB "5.7.40")
......@@ -59,7 +57,6 @@ set(LIBKDEPIM_LIB_VERSION_LIB "5.7.40")
set(KCALENDARCORE_LIB_VERSION "5.7.40")
set(KCONTACTS_LIB_VERSION "5.7.40")
set(KMIME_LIB_VERSION "5.7.40")
set(KIMAP_LIB_VERSION "5.7.40")
# Find KF5 package
find_package(KF5Completion ${KF5_VERSION} CONFIG REQUIRED)
......@@ -81,24 +78,31 @@ find_package(KF5KIO ${KF5_VERSION} REQUIRED)
find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(KF5AkonadiSearch ${AKONADI_SEARCH_VERSION} CONFIG REQUIRED)
find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(Xapian CONFIG)
set_package_properties(Xapian PROPERTIES
DESCRIPTION "The Xapian search engine library"
URL "http://xapian.org"
TYPE REQUIRED
)
if (NOT WIN32)
find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED)
find_package(KF5AkonadiSearch ${AKONADI_SEARCH_VERSION} CONFIG REQUIRED)
find_package(Xapian CONFIG)
set_package_properties(Xapian PROPERTIES
DESCRIPTION "The Xapian search engine library"
URL "http://xapian.org"
TYPE REQUIRED
)
set(ENABLE_LIBKDEPIM TRUE)
set(ENABLE_SEARCH TRUE)
set(ENABLE_CONTENTVIEWS TRUE)
endif()
include_directories(${akonadiconsole_SOURCE_DIR} ${akonadiconsole_BINARY_DIR} ${XAPIAN_INCLUDE_DIR})
configure_file(config-akonadiconsole.h.cmake ${CMAKE_BINARY_DIR}/config-akonadiconsole.h)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
......
#cmakedefine ENABLE_LIBKDEPIM 1
#cmakedefine ENABLE_SEARCH 1
#cmakedefine ENABLE_CONTENTVIEWS 1
......@@ -36,11 +36,17 @@ set(libakonadiconsole_SRCS
monitorsmodel.cpp
notificationmodel.cpp
notificationmonitor.cpp
searchwidget.cpp
querydebugger.cpp
tagpropertiesdialog.cpp
${libakonadiconsole_tracker_SRCS}
)
if (ENABLE_SEARCH)
set(libakonadiconsole_SRCS
${libakonadiconsole_SRCS}
searchwidget.cpp
)
endif()
qt5_generate_dbus_interface(jobtracker.h org.freedesktop.Akonadi.JobTracker.xml)
qt5_add_dbus_adaptor(libakonadiconsole_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Akonadi.JobTracker.xml jobtracker.h JobTracker)
......@@ -89,25 +95,39 @@ generate_export_header(libakonadiconsole BASE_NAME libakonadiconsole)
target_link_libraries(libakonadiconsole
KF5::AkonadiCore
KF5::AkonadiPrivate
KF5::AkonadiContact
KF5::AkonadiWidgets
KF5::AkonadiXml
KF5::AkonadiSearchCore
KF5::AkonadiSearchXapian
KF5::CalendarSupport
KF5::Mime
KF5::Contacts
KF5::CalendarCore
KF5::Libkdepim
KF5::MessageViewer
KF5::DBusAddons
KF5::PimTextEdit
Qt5::Sql
KF5::Crash
KF5::Completion
KF5::ItemViews
KF5::TextWidgets
KF5::XmlGui
)
if (ENABLE_SEARCH)
target_link_libraries(libakonadiconsole
KF5::AkonadiSearchCore
KF5::AkonadiSearchXapian
)
endif()
if (ENABLE_CONTENTVIEWS)
target_link_libraries(libakonadiconsole
KF5::AkonadiContact
KF5::CalendarSupport
KF5::MessageViewer
)
endif()
if (ENABLE_LIBKDEPIM)
target_link_libraries(libakonadiconsole
KF5::Libkdepim
)
endif()
set_target_properties(libakonadiconsole
PROPERTIES OUTPUT_NAME akonadiconsole
VERSION ${KDEPIM_LIB_VERSION}
......@@ -128,25 +148,10 @@ add_executable(akonadiconsole ${akonadiconsole_SRCS})
target_link_libraries(akonadiconsole
libakonadiconsole
KF5::AkonadiCore
KF5::AkonadiPrivate
KF5::AkonadiContact
KF5::AkonadiXml
KF5::AkonadiSearchCore
KF5::AkonadiSearchXapian
KF5::CalendarSupport
KF5::CalendarCore
KF5::Libkdepim
KF5::MessageViewer
KF5::DBusAddons
KF5::PimTextEdit
Qt5::Sql
KF5::CoreAddons
KF5::Crash
KF5::Completion
KF5::ItemViews
KF5::TextWidgets
KF5::XmlGui
)
)
install(TARGETS akonadiconsole ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS org.kde.akonadiconsole.desktop DESTINATION ${KDE_INSTALL_APPDIR})
......
......@@ -25,6 +25,7 @@
#include "dbaccess.h"
#include "akonadibrowsermodel.h"
#include "tagpropertiesdialog.h"
#include "config-akonadiconsole.h"
#include <AkonadiCore/attributefactory.h>
#include <AkonadiCore/changerecorder.h>
......@@ -76,6 +77,13 @@
#include <QFileDialog>
#include <QSqlError>
#ifdef ENABLE_CONTENTVIEWS
#include <CalendarSupport/IncidenceViewer>
#include <messageviewer/viewer.h>
#include <Akonadi/Contact/ContactViewer>
#include <Akonadi/Contact/ContactGroupViewer>
#endif
using namespace Akonadi;
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY(CollectionAttributePageFactory, CollectionAttributePage)
......@@ -209,6 +217,28 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget *parent) :
connect(contentUi.saveButton, &QPushButton::clicked, this, &BrowserWidget::save);
splitter3->addWidget(contentViewParent);
#ifdef ENABLE_CONTENTVIEWS
auto w = new QWidget;
w->setLayout(new QVBoxLayout);
w->layout()->addWidget(mContactView = new Akonadi::ContactViewer);
contentUi.stack->addWidget(w);
w = new QWidget;
w->setLayout(new QVBoxLayout);
w->layout()->addWidget(mContactGroupView = new Akonadi::ContactGroupViewer);
contentUi.stack->addWidget(w);
w = new QWidget;
w->setLayout(new QVBoxLayout);
w->layout()->addWidget(mIncidenceView = new CalendarSupport::IncidenceViewer);
contentUi.stack->addWidget(w);
w = new QWidget;
w->setLayout(new QVBoxLayout);
w->layout()->addWidget(mMailView = new MessageViewer::Viewer(this));
contentUi.stack->addWidget(w);
#endif
connect(contentUi.attrAddButton, &QPushButton::clicked, this, &BrowserWidget::addAttribute);
connect(contentUi.attrDeleteButton, &QPushButton::clicked, this, &BrowserWidget::delAttribute);
connect(contentUi.flags, &KEditListWidget::changed, this, &BrowserWidget::contentViewChanged);
......@@ -295,20 +325,23 @@ void BrowserWidget::contentViewChanged()
void BrowserWidget::setItem(const Akonadi::Item &item)
{
mCurrentItem = item;
#ifdef ENABLE_CONTENTVIEWS
if (item.hasPayload<KContacts::Addressee>()) {
contentUi.contactView->setItem(item);
contentUi.stack->setCurrentWidget(contentUi.contactViewPage);
mContactView->setItem(item);
contentUi.stack->setCurrentWidget(mContactView->parentWidget());
} else if (item.hasPayload<KContacts::ContactGroup>()) {
contentUi.contactGroupView->setItem(item);
contentUi.stack->setCurrentWidget(contentUi.contactGroupViewPage);
mContactGroupView->setItem(item);
contentUi.stack->setCurrentWidget(mContactGroupView->parentWidget());
} else if (item.hasPayload<KCalCore::Incidence::Ptr>()) {
contentUi.incidenceView->setItem(item);
contentUi.stack->setCurrentWidget(contentUi.incidenceViewPage);
mIncidenceView->setItem(item);
contentUi.stack->setCurrentWidget(mIncidenceView->parentWidget());
} else if (item.mimeType() == QLatin1String("message/rfc822")
|| item.mimeType() == QLatin1String("message/news")) {
contentUi.mailView->setMessageItem(item, MimeTreeParser::Force);
contentUi.stack->setCurrentWidget(contentUi.mailViewPage);
} else if (item.hasPayload<QPixmap>()) {
mMailView->setMessageItem(item, MimeTreeParser::Force);
contentUi.stack->setCurrentWidget(mMailView->parentWidget());
} else
#endif
if (item.hasPayload<QPixmap>()) {
contentUi.imageView->setPixmap(item.payload<QPixmap>());
contentUi.stack->setCurrentWidget(contentUi.imageViewPage);
} else {
......
......@@ -49,6 +49,16 @@ class StandardActionManager;
class Monitor;
class TagModel;
class StatisticsProxyModel;
class ContactViewer;
class ContactGroupViewer;
}
namespace CalendarSupport {
class IncidenceViewer;
}
namespace MessageViewer {
class Viewer;
}
class BrowserWidget: public QWidget
......@@ -103,6 +113,11 @@ private:
KToggleAction *mCacheOnlyAction = nullptr;
QTreeView *mTagView = nullptr;
Akonadi::TagModel *mTagModel = nullptr;
Akonadi::ContactViewer *mContactView = nullptr;
Akonadi::ContactGroupViewer *mContactGroupView = nullptr;
CalendarSupport::IncidenceViewer *mIncidenceView = nullptr;
MessageViewer::Viewer *mMailView = nullptr;
};
#endif
......@@ -94,58 +94,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="contactViewPage">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="Akonadi::ContactViewer" name="contactView" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="contactGroupViewPage">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="Akonadi::ContactGroupViewer" name="contactGroupView" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="incidenceViewPage">
<layout class="QVBoxLayout">
<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>
<item>
<widget class="CalendarSupport::IncidenceViewer" name="incidenceView" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="mailViewPage">
<layout class="QGridLayout" name="gridLayout1">
<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>
<item row="0" column="0">
<widget class="MessageViewer::Viewer" name="mailView"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......@@ -431,28 +379,6 @@
<header>keditlistwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>CalendarSupport::IncidenceViewer</class>
<extends>QWidget</extends>
<header location="global">CalendarSupport/IncidenceViewer</header>
</customwidget>
<customwidget>
<class>MessageViewer::Viewer</class>
<extends>QTextBrowser</extends>
<header location="global">messageviewer/viewer.h</header>
</customwidget>
<customwidget>
<class>Akonadi::ContactViewer</class>
<extends>QWidget</extends>
<header location="global">Akonadi/Contact/ContactViewer</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Akonadi::ContactGroupViewer</class>
<extends>QWidget</extends>
<header location="global">Akonadi/Contact/ContactGroupViewer</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -21,11 +21,14 @@
#include "mainwidget.h"
#include "config-akonadiconsole.h"
#include "agentwidget.h"
#include "dbbrowser.h"
#include "dbconsole.h"
#include "debugwidget.h"
#ifdef ENABLE_SEARCH
#include "searchwidget.h"
#endif
#include "jobtrackerwidget.h"
#include "notificationmonitor.h"
#include "monitorswidget.h"
......@@ -63,7 +66,9 @@ MainWidget::MainWidget(KXmlGuiWindow *parent)
tabWidget->addTab(new JobTrackerWidget("jobtracker", tabWidget, QStringLiteral("Enable job tracker")), QStringLiteral("Job Tracker"));
tabWidget->addTab(new JobTrackerWidget("resourcesJobtracker", tabWidget, QStringLiteral("Enable tracking of Resource Schedulers")), QStringLiteral("Resources Schedulers"));
tabWidget->addTab(new NotificationMonitor(tabWidget), QStringLiteral("Notification Monitor"));
#ifdef ENABLE_SEARCH
tabWidget->addTab(new SearchWidget(tabWidget), QStringLiteral("Item Search"));
#endif
tabWidget->addTab(new MonitorsWidget(tabWidget), QStringLiteral("Monitors"));
auto action = parent->actionCollection()->addAction(QStringLiteral("akonadiconsole_akonadi2xml"));
......
......@@ -20,8 +20,11 @@
*/
#include "mainwindow.h"
#include "config-akonadiconsole.h"
#ifdef ENABLE_LIBKDEPIM
#include <Libkdepim/UiStateSaver>
#endif
#include <KActionCollection>
#include <KConfigGroup>
......@@ -39,9 +42,9 @@ MainWindow::MainWindow(QWidget *parent)
KStandardAction::quit(qApp, &QApplication::quit, actionCollection());
setupGUI(Keys /*| ToolBar | StatusBar*/ | Save | Create, QStringLiteral("akonadiconsoleui.rc"));
#ifdef ENABLE_LIBKDEPIM
KPIM::UiStateSaver::restoreState(this, KConfigGroup(KSharedConfig::openConfig(), "UiState"));
#endif
KMessageBox::information(this, QStringLiteral("<p>Akonadi Console is purely a development tool. "
"It allows you to view and change internal data structures of Akonadi. "
"You should only change data in here if you know what you are doing, otherwise "
......@@ -57,8 +60,10 @@ MainWindow::~MainWindow()
void MainWindow::closeEvent(QCloseEvent *event)
{
#ifdef ENABLE_LIBKDEPIM
KConfigGroup config(KSharedConfig::openConfig(), "UiState");
KPIM::UiStateSaver::saveState(this, config);
KSharedConfig::openConfig()->sync();
#endif
KXmlGuiWindow::closeEvent(event);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment