Commit 832efc03 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Port to new KPluginMetaData-based KParts API

NO_CHANGELOG
parent 5e29587c
add_definitions(-DTRANSLATION_DOMAIN=\"kompare\")
configure_file(komparenavtreepart.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/komparenavtreepart.desktop @ONLY)
set(komparenavtreepart_PART_SRCS komparenavtreepart.cpp )
ecm_qt_declare_logging_category(komparenavtreepart_PART_SRCS
......@@ -11,7 +13,7 @@ ecm_qt_declare_logging_category(komparenavtreepart_PART_SRCS
)
add_library(komparenavtreepart MODULE ${komparenavtreepart_PART_SRCS})
kcoreaddons_desktop_to_json(komparenavtreepart komparenavtreepart.desktop)
kcoreaddons_desktop_to_json(komparenavtreepart ${CMAKE_CURRENT_BINARY_DIR}/komparenavtreepart.desktop)
target_link_libraries(komparenavtreepart
Qt5::Widgets
......@@ -21,5 +23,5 @@ target_link_libraries(komparenavtreepart
)
install(TARGETS komparenavtreepart DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts)
install(FILES komparenavtreepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/komparenavtreepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......@@ -12,7 +12,11 @@
#include <QTreeWidgetItemIterator>
#include <KLocalizedString>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <KAboutData>
#endif
#include <KPluginFactory>
#include <libkomparediff2/difference.h>
......@@ -21,7 +25,9 @@
#include <libkomparediff2/komparemodellist.h>
#include <komparenavviewdebug.h>
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 77, 0)
#include "../kompare_version.h"
#endif
#define COL_SOURCE 0
#define COL_DESTINATION 1
......@@ -30,6 +36,7 @@
using namespace Diff2;
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 77, 0)
static KAboutData aboutData()
{
KAboutData about(
......@@ -41,8 +48,14 @@ static KAboutData aboutData()
about.addAuthor(i18n("Otto Bruggeman"), i18n("Author"), QStringLiteral("bruggie@gmail.com"));
return about;
}
#endif
KompareNavTreePart::KompareNavTreePart(QWidget* parentWidget, QObject* parent, const QVariantList&)
KompareNavTreePart::KompareNavTreePart(QWidget* parentWidget, QObject* parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData, const QVariantList&)
#else
const QVariantList&)
#endif
: KParts::ReadOnlyPart(parent),
m_splitter(nullptr),
m_modelList(nullptr),
......@@ -58,7 +71,11 @@ KompareNavTreePart::KompareNavTreePart(QWidget* parentWidget, QObject* parent, c
m_destination(),
m_info(nullptr)
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
setComponentData(aboutData());
#endif
m_splitter = new QSplitter(Qt::Horizontal, parentWidget);
......
......@@ -64,3 +64,11 @@ ServiceTypes=Kompare/NavigationPart
X-KDE-Library=kf5/parts/komparenavtreepart
Type=Service
Icon=kompare
X-KDE-PluginInfo-Name=komparenavtreepart
X-KDE-PluginInfo-Version=@Kompare_VERSION@
X-KDE-PluginInfo-License=GPLv2+
X-KDE-PluginInfo-Copyright=
X-KDE-PluginInfo-Authors=John Firebaugh,Otto Bruggeman,Kevin Kofler
X-KDE-PluginInfo-Emails=jfirebaugh@kde.org,bruggie@gmail.com,kevin.kofler@chello.at
X-KDE-PluginInfo-Website=https://commits.kde.org/kompare
......@@ -9,13 +9,15 @@
#ifndef KOMPARENAVTREEPART_H
#define KOMPARENAVTREEPART_H
// Qt
#include <QHash>
#include <QSplitter>
#include <QTreeWidget>
#include <QTreeWidgetItem>
// KF
#include <kparts_version.h>
#include <KParts/ReadOnlyPart>
// libkomparediff2
#include <libkomparediff2/kompare.h>
#include <libkomparediff2/diffmodellist.h>
......@@ -33,7 +35,12 @@ class KompareNavTreePart : public KParts::ReadOnlyPart
Q_OBJECT
public:
explicit KompareNavTreePart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
explicit KompareNavTreePart(QWidget* parentWidget, QObject* parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData, const QVariantList& args);
#else
const QVariantList& args);
#endif
~KompareNavTreePart() override;
public:
......
add_definitions(-DTRANSLATION_DOMAIN=\"kompare\")
configure_file(komparepart.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/komparepart.desktop @ONLY)
set( komparepart_PART_SRCS
kompare_part.cpp
kompare_partfactory.cpp
......@@ -38,6 +40,6 @@ target_link_libraries(komparepart
)
install(TARGETS komparepart DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts)
kcoreaddons_desktop_to_json(komparepart komparepart.desktop)
kcoreaddons_desktop_to_json(komparepart ${CMAKE_CURRENT_BINARY_DIR}/komparepart.desktop)
install(FILES komparepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/komparepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......@@ -22,7 +22,11 @@
#include <QTemporaryDir>
#include <QTemporaryFile>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <KAboutData>
#endif
#include <KActionCollection>
#include <KJobWidgets>
#include <KLocalizedString>
......@@ -55,11 +59,19 @@ using namespace Diff2;
ViewSettings* KomparePart::m_viewSettings = nullptr;
DiffSettings* KomparePart::m_diffSettings = nullptr;
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
KomparePart::KomparePart(QWidget* parentWidget, QObject* parent, const KPluginMetaData& metaData, Modus modus) :
#else
KomparePart::KomparePart(QWidget* parentWidget, QObject* parent, const KAboutData& aboutData, Modus modus) :
#endif
KParts::ReadWritePart(parent),
m_info()
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
setComponentData(aboutData);
#endif
// set our XML-UI resource file
setXMLFile(QStringLiteral("komparepartui.rc"));
......
......@@ -10,20 +10,26 @@
#ifndef KOMPAREPART_H
#define KOMPAREPART_H
#include <KParts/ReadWritePart>
#include <QVariantList>
#include <libkomparediff2/kompare.h>
#include <komparepartdebug.h>
#include "kompareinterface.h"
// libkomparediff2
#include <libkomparediff2/kompare.h>
// KF
#include <kparts_version.h>
#include <KParts/ReadWritePart>
// Qt
#include <QVariantList>
class QAction;
class QPrinter;
class QUrl;
class QWidget;
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
class KPluginMetaData;
#else
class KAboutData;
#endif
namespace Diff2 {
class Difference;
......@@ -59,7 +65,11 @@ public:
/**
* Default constructor
*/
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
KomparePart(QWidget* parentWidget, QObject* parent, const KPluginMetaData& metaData, Modus modus);
#else
KomparePart(QWidget* parentWidget, QObject* parent, const KAboutData& aboutData, Modus modus);
#endif
/**
* Destructor
......
......@@ -7,12 +7,20 @@
#include "kompare_partfactory.h"
#include "kompare_part.h"
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 77, 0)
#include "../kompare_version.h"
#endif
// KF
#include <KLocalizedString>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#endif
KomparePartFactory::KomparePartFactory()
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
{
#else
: m_aboutData(QStringLiteral("komparepart"),
i18n("KomparePart"),
QStringLiteral(KOMPARE_VERSION_STRING),
......@@ -23,6 +31,7 @@ KomparePartFactory::KomparePartFactory()
m_aboutData.addAuthor(i18n("John Firebaugh"), i18n("Author"), QStringLiteral("jfirebaugh@kde.org"));
m_aboutData.addAuthor(i18n("Otto Bruggeman"), i18n("Author"), QStringLiteral("bruggie@gmail.com"));
m_aboutData.addAuthor(i18n("Kevin Kofler"), i18n("Author"), QStringLiteral("kevin.kofler@chello.at"));
#endif
}
KomparePartFactory::~KomparePartFactory() = default;
......@@ -39,7 +48,11 @@ QObject* KomparePartFactory::create(const char* iface,
wantReadOnly ? KomparePart::ReadOnlyModus :
/* else */ KomparePart::ReadWriteModus;
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
KomparePart* part = new KomparePart(parentWidget, parent, metaData(), modus);
#else
KomparePart* part = new KomparePart(parentWidget, parent, m_aboutData, modus);
#endif
return part;
}
......@@ -7,8 +7,12 @@
#ifndef KOMPAREPARTFACTORY_H
#define KOMPAREPARTFACTORY_H
// KF
#include <KPluginFactory>
#include <kparts_version.h>
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 77, 0)
#include <KAboutData>
#endif
class KomparePartFactory : public KPluginFactory
......@@ -25,8 +29,10 @@ public:
QWidget* parentWidget, QObject* parent,
const QVariantList& args, const QString& keyword) override;
#if KPARTS_VERSION < QT_VERSION_CHECK(5, 77, 0)
private:
KAboutData m_aboutData;
#endif
};
#endif
......@@ -69,3 +69,11 @@ X-KDE-Library=kf5/parts/komparepart
Type=Service
Icon=kompare
InitialPreference=10
X-KDE-PluginInfo-Name=komparepart
X-KDE-PluginInfo-Version=@Kompare_VERSION@
X-KDE-PluginInfo-License=GPLv2+
X-KDE-PluginInfo-Copyright=
X-KDE-PluginInfo-Authors=John Firebaugh,Otto Bruggeman,Kevin Kofler
X-KDE-PluginInfo-Emails=jfirebaugh@kde.org,bruggie@gmail.com,kevin.kofler@chello.at
X-KDE-PluginInfo-Website=https://commits.kde.org/kompare
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