Commit 1b2def5c authored by David Faure's avatar David Faure
Browse files

Use KParts::Part instead of ReadOnlyPart. We are not opening a document, just...

Use KParts::Part instead of ReadOnlyPart. We are not opening a document, just providing a XMLGUI-based plugin.
parent 55bc72a7
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.14.40")
set(PIM_VERSION "5.14.41")
project(KontactInterface VERSION ${PIM_VERSION})
......
......@@ -47,7 +47,7 @@ public:
QString lastErrorMessage;
QDate mLastDate;
QMap<QByteArray, KParts::ReadOnlyPart *> mParts;
QMap<QByteArray, KParts::Part *> mParts;
};
Core::Private::Private(Core *qq)
......@@ -69,11 +69,11 @@ Core::~Core()
delete d;
}
KParts::ReadOnlyPart *Core::createPart(const char *libname)
KParts::Part *Core::createPart(const char *libname)
{
qCDebug(KONTACTINTERFACE_LOG) << libname;
QMap<QByteArray, KParts::ReadOnlyPart *>::ConstIterator it;
QMap<QByteArray, KParts::Part *>::ConstIterator it;
it = d->mParts.constFind(libname);
if (it != d->mParts.constEnd()) {
return it.value();
......@@ -84,14 +84,14 @@ KParts::ReadOnlyPart *Core::createPart(const char *libname)
KPluginLoader loader(QString::fromLatin1(libname));
qCDebug(KONTACTINTERFACE_LOG) << loader.fileName();
KPluginFactory *factory = loader.factory();
KParts::ReadOnlyPart *part = nullptr;
KParts::Part *part = nullptr;
if (factory) {
part = factory->create<KParts::ReadOnlyPart>(this);
part = factory->create<KParts::Part>(this);
}
if (part) {
d->mParts.insert(libname, part);
QObject::connect(part, &KParts::ReadOnlyPart::destroyed,
QObject::connect(part, &KParts::Part::destroyed,
this, [this](QObject* obj) { d->slotPartDestroyed(obj);});
} else {
d->lastErrorMessage = loader.errorString();
......@@ -106,8 +106,8 @@ void Core::Private::slotPartDestroyed(QObject *obj)
{
// the part was deleted, we need to remove it from the part map to not return
// a dangling pointer in createPart
const QMap<QByteArray, KParts::ReadOnlyPart *>::Iterator end = mParts.end();
QMap<QByteArray, KParts::ReadOnlyPart *>::Iterator it = mParts.begin();
const QMap<QByteArray, KParts::Part *>::Iterator end = mParts.end();
QMap<QByteArray, KParts::Part *>::Iterator it = mParts.begin();
for (; it != end; ++it) {
if (it.value() == obj) {
mParts.erase(it);
......
......@@ -26,7 +26,7 @@
#include "kontactinterface_export.h"
#include <KParts/MainWindow>
#include <KParts/ReadOnlyPart>
#include <KParts/Part>
namespace KontactInterface
{
......@@ -75,14 +75,14 @@ public:
* @param library the library to create part from
* Creates a part from the given @p library.
*/
Q_REQUIRED_RESULT KParts::ReadOnlyPart *createPart(const char *library);
Q_REQUIRED_RESULT KParts::Part *createPart(const char *library);
/**
* @internal (for Plugin)
*
* Tells the kontact core that a part has been loaded.
*/
virtual void partLoaded(Plugin *plugin, KParts::ReadOnlyPart *part) = 0;
virtual void partLoaded(Plugin *plugin, KParts::Part *part) = 0;
Q_SIGNALS:
/**
......
......@@ -65,7 +65,7 @@ public:
QString serviceName;
QByteArray partLibraryName;
QByteArray pluginName;
KParts::ReadOnlyPart *part = nullptr;
KParts::Part *part = nullptr;
bool hasPart;
bool disabled;
};
......@@ -140,7 +140,7 @@ bool Plugin::isRunningStandalone() const
return false;
}
KParts::ReadOnlyPart *Plugin::loadPart()
KParts::Part *Plugin::loadPart()
{
return core()->createPart(d->partLibraryName.constData());
}
......@@ -150,12 +150,12 @@ const KAboutData Plugin::aboutData()
return part()->componentData();
}
KParts::ReadOnlyPart *Plugin::part()
KParts::Part *Plugin::part()
{
if (!d->part) {
d->part = createPart();
if (d->part) {
connect(d->part, &KParts::ReadOnlyPart::destroyed, this, [this]() { d->partDestroyed(); });
connect(d->part, &KParts::Part::destroyed, this, [this]() { d->partDestroyed(); });
d->removeInvisibleToolbarActions(this);
core()->partLoaded(this, d->part);
}
......
......@@ -42,7 +42,7 @@ class QStringList;
class QWidget;
namespace KParts
{
class ReadOnlyPart;
class Part;
}
/**
......@@ -166,7 +166,7 @@ public:
* sure that you always get the same pointer as long as the part has not been
* deleted.
*/
Q_REQUIRED_RESULT KParts::ReadOnlyPart *part();
Q_REQUIRED_RESULT KParts::Part *part();
/**
* This function is called when the plugin is selected by the user before the
......@@ -305,12 +305,12 @@ protected:
* Reimplement and return the part here. Reimplementing createPart() is
* mandatory!
*/
virtual KParts::ReadOnlyPart *createPart() = 0;
virtual KParts::Part *createPart() = 0;
/**
* Returns the loaded part.
*/
KParts::ReadOnlyPart *loadPart();
KParts::Part *loadPart();
/**
* Virtual hook for BC extension.
......
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