[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdevplatform] /: Move the implementation of hasError and setHasError to iplugin. They are basically
From: Morten Danielsen Volden <mvolden2 () gmail ! com>
Date: 2016-07-18 22:07:34
Message-ID: E1bPGhK-0002ze-4h () code ! kde ! org
[Download RAW message or body]
Git commit 6409161f4db3fd0f2e2929da4a9275a92e0df342 by Morten Danielsen Volden.
Committed on 18/07/2016 at 21:01.
Pushed by volden into branch 'master'.
Move the implementation of hasError and setHasError to iplugin. They are basically \
just getter/setters and actual implementation belong there - not in the individual \
plug-ins. Unified the way plug-ins report errors when failing.
Differential Revision: https://phabricator.kde.org/D2192
M +9 -2 interfaces/iplugin.cpp
M +11 -4 interfaces/iplugin.h
M +2 -13 plugins/bazaar/bazaarplugin.cpp
M +0 -6 plugins/bazaar/bazaarplugin.h
M +1 -13 plugins/git/gitplugin.cpp
M +0 -4 plugins/git/gitplugin.h
M +3 -11 plugins/konsole/kdevkonsoleviewplugin.cpp
M +0 -2 plugins/konsole/kdevkonsoleviewplugin.h
M +1 -14 plugins/perforce/perforceplugin.cpp
M +0 -7 plugins/perforce/perforceplugin.h
http://commits.kde.org/kdevplatform/6409161f4db3fd0f2e2929da4a9275a92e0df342
diff --git a/interfaces/iplugin.cpp b/interfaces/iplugin.cpp
index 31d9fbe..860d9d8 100644
--- a/interfaces/iplugin.cpp
+++ b/interfaces/iplugin.cpp
@@ -78,6 +78,7 @@ public:
IPlugin *q;
ICore *core;
QVector<QByteArray> m_extensions;
+ QString m_errorDescription;
};
IPlugin::IPlugin( const QString &componentName, QObject *parent )
@@ -184,12 +185,18 @@ void KDevelop::IPlugin::createActionsForMainWindow( \
Sublime::MainWindow* /*windo
bool KDevelop::IPlugin::hasError() const
{
- return false;
+ return !d->m_errorDescription.isEmpty();
}
+void KDevelop::IPlugin::setErrorDescription(const QString& description)
+{
+ d->m_errorDescription = description;
+}
+
+
QString KDevelop::IPlugin::errorDescription() const
{
- return QString();
+ return d->m_errorDescription;
}
int KDevelop::IPlugin::configPages() const
diff --git a/interfaces/iplugin.h b/interfaces/iplugin.h
index f67cb5d..1e09f12 100644
--- a/interfaces/iplugin.h
+++ b/interfaces/iplugin.h
@@ -210,14 +210,21 @@ public:
/**
* This function is necessary because there is no proper way to signal errors \
from plugin constructor.
- * @returns True if the plugin has encountered an error, false otherwise.
+ * @returns True if the plugin has encountered an error (and therefore has an \
error description), + * false otherwise.
*/
- virtual bool hasError() const;
-
+ bool hasError() const;
+
/**
* Description of the last encountered error, of an empty string if none.
*/
- virtual QString errorDescription() const;
+ QString errorDescription() const;
+
+ /**
+ * Set a @p description of the errror encountered. An empty error
+ * description implies no error in the plugin.
+ */
+ void setErrorDescription(QString const& description);
/**
* Get the global config page with the \p number, config pages from 0 to
diff --git a/plugins/bazaar/bazaarplugin.cpp b/plugins/bazaar/bazaarplugin.cpp
index 791a07c..ed23c2f 100644
--- a/plugins/bazaar/bazaarplugin.cpp
+++ b/plugins/bazaar/bazaarplugin.cpp
@@ -45,13 +45,11 @@ using namespace KDevelop;
BazaarPlugin::BazaarPlugin(QObject* parent, const QVariantList& args) :
IPlugin(QStringLiteral("kdevbazaar"), parent),
- m_vcsPluginHelper(new KDevelop::VcsPluginHelper(this, this)), m_hasError(false)
+ m_vcsPluginHelper(new KDevelop::VcsPluginHelper(this, this))
{
Q_UNUSED(args); // What is this?
if (QStandardPaths::findExecutable(QStringLiteral("bzr")).isEmpty()) {
- m_hasError = true;
- m_errorDescription = i18n("Bazaar is not installed (bzr executable not"
- " found)");
+ setErrorDescription(i18n("Unable to find Bazaar (bzr) executable Is it \
installed on the system?")); return;
}
@@ -339,12 +337,3 @@ ContextMenuExtension BazaarPlugin::contextMenuExtension(Context* \
context) return menuExt;
}
-bool BazaarPlugin::hasError() const
-{
- return m_hasError;
-}
-
-QString BazaarPlugin::errorDescription() const
-{
- return m_errorDescription;
-}
diff --git a/plugins/bazaar/bazaarplugin.h b/plugins/bazaar/bazaarplugin.h
index d7e9a21..e538f2f 100644
--- a/plugins/bazaar/bazaarplugin.h
+++ b/plugins/bazaar/bazaarplugin.h
@@ -40,9 +40,6 @@ public:
explicit BazaarPlugin(QObject* parent, const QVariantList& args = \
QVariantList()); ~BazaarPlugin() override;
- bool hasError() const override;
- QString errorDescription() const override;
-
QString name() const override;
KDevelop::VcsJob* add(const QList<QUrl>& localLocations, RecursionMode \
recursion=Recursive) override; @@ -75,9 +72,6 @@ private slots:
private:
KDevelop::VcsPluginHelper* m_vcsPluginHelper;
-
- bool m_hasError;
- QString m_errorDescription;
};
#endif // BAZAAR_BAZAARPLUGIN_H
diff --git a/plugins/git/gitplugin.cpp b/plugins/git/gitplugin.cpp
index 1840958..126f6cb 100644
--- a/plugins/git/gitplugin.cpp
+++ b/plugins/git/gitplugin.cpp
@@ -181,8 +181,7 @@ GitPlugin::GitPlugin( QObject *parent, const QVariantList & )
: DistributedVersionControlPlugin(parent, QStringLiteral("kdevgit")), \
m_oldVersion(false), m_usePrefix(true) {
if (QStandardPaths::findExecutable(QStringLiteral("git")).isEmpty()) {
- m_hasError = true;
- m_errorDescription = i18n("git is not installed");
+ setErrorDescription(i18n("Unable to find git executable. Is it installed on \
the system?")); return;
}
@@ -190,7 +189,6 @@ GitPlugin::GitPlugin( QObject *parent, const QVariantList & )
KDEV_USE_EXTENSION_INTERFACE( KDevelop::IDistributedVersionControl )
KDEV_USE_EXTENSION_INTERFACE( KDevelop::IBranchingVersionControl )
- m_hasError = false;
setObjectName(QStringLiteral("Git"));
DVcsJob* versionJob = new DVcsJob(QDir::tempPath(), this, \
KDevelop::OutputJob::Silent); @@ -1458,16 +1456,6 @@ KDevelop::VcsLocationWidget* \
GitPlugin::vcsLocation(QWidget* parent) const return new \
GitVcsLocationWidget(parent); }
-bool GitPlugin::hasError() const
-{
- return m_hasError;
-}
-
-QString GitPlugin::errorDescription() const
-{
- return m_errorDescription;
-}
-
void GitPlugin::registerRepositoryForCurrentBranchChanges(const QUrl& repository)
{
QDir dir = dotGitDirectory(repository);
diff --git a/plugins/git/gitplugin.h b/plugins/git/gitplugin.h
index df624ec..bbf4ed0 100644
--- a/plugins/git/gitplugin.h
+++ b/plugins/git/gitplugin.h
@@ -140,8 +140,6 @@ public:
bool hasModifications(const QDir& repository);
bool hasModifications(const QDir& repo, const QUrl& file);
- bool hasError() const override;
- QString errorDescription() const override;
void registerRepositoryForCurrentBranchChanges(const QUrl& repository) override;
KDevelop::CheckInRepositoryJob* isInRepository(KTextEditor::Document* document) \
override; @@ -216,8 +214,6 @@ private:
/** Tells if it's older than 1.7.0 or not */
bool m_oldVersion;
- bool m_hasError;
- QString m_errorDescription;
KDirWatch* m_watcher;
QList<QUrl> m_branchesChange;
bool m_usePrefix;
diff --git a/plugins/konsole/kdevkonsoleviewplugin.cpp \
b/plugins/konsole/kdevkonsoleviewplugin.cpp index f9bf746..234c6e9 100644
--- a/plugins/konsole/kdevkonsoleviewplugin.cpp
+++ b/plugins/konsole/kdevkonsoleviewplugin.cpp
@@ -62,7 +62,9 @@ KDevKonsoleViewPlugin::KDevKonsoleViewPlugin( KPluginFactory* \
konsoleFactory, QO , m_konsoleFactory(konsoleFactory)
, m_viewFactory(konsoleFactory ? new KDevKonsoleViewFactory(this) : nullptr)
{
- if (m_viewFactory) {
+ if(!m_viewFactory) {
+ setErrorDescription(i18n("Failed to load 'konsolepart' plugin"));
+ } else {
core()->uiController()->addToolView(QStringLiteral("Konsole"), \
m_viewFactory); }
}
@@ -74,16 +76,6 @@ void KDevKonsoleViewPlugin::unload()
}
}
-bool KDevKonsoleViewPlugin::hasError() const
-{
- return !m_viewFactory;
-}
-
-QString KDevKonsoleViewPlugin::errorDescription() const
-{
- return !m_viewFactory ? i18n("Failed to load 'konsolepart' plugin") : QString();
-}
-
KPluginFactory* KDevKonsoleViewPlugin::konsoleFactory() const
{
return m_konsoleFactory;
diff --git a/plugins/konsole/kdevkonsoleviewplugin.h \
b/plugins/konsole/kdevkonsoleviewplugin.h index 655fbf4..4092caa 100644
--- a/plugins/konsole/kdevkonsoleviewplugin.h
+++ b/plugins/konsole/kdevkonsoleviewplugin.h
@@ -28,8 +28,6 @@ public:
~KDevKonsoleViewPlugin() override;
void unload() override;
- bool hasError() const override;
- QString errorDescription() const override;
KPluginFactory* konsoleFactory() const;
diff --git a/plugins/perforce/perforceplugin.cpp \
b/plugins/perforce/perforceplugin.cpp index 139d172..8563c6b 100644
--- a/plugins/perforce/perforceplugin.cpp
+++ b/plugins/perforce/perforceplugin.cpp
@@ -118,19 +118,16 @@ PerforcePlugin::PerforcePlugin(QObject* parent, const \
QVariantList&): , m_perforceConfigName("p4config.txt")
, m_perforceExecutable("p4")
, m_edit_action(nullptr)
- , m_hasError(true)
{
QProcessEnvironment currentEviron(QProcessEnvironment::systemEnvironment());
QString tmp(currentEviron.value("P4CONFIG"));
if (tmp.isEmpty()) {
// We require the P4CONFIG variable to be set because the perforce command \
line client will need it
- m_hasError = true;
- m_errorDescription = i18n("The variable P4CONFIG is not set.");
+ setErrorDescription(i18n("The variable P4CONFIG is not set. Is perforce \
installed on the system?")); return;
} else {
m_perforceConfigName = tmp;
}
- m_hasError = false;
qCDebug(PLUGIN_PERFORCE) << "The value of P4CONFIG is : " << tmp;
KDEV_USE_EXTENSION_INTERFACE(KDevelop::IBasicVersionControl)
@@ -696,14 +693,4 @@ KDevelop::VcsJob* PerforcePlugin::errorsFound(const QString& \
error, KDevelop::Ou return j;
}
-bool PerforcePlugin::hasError() const
-{
- return m_hasError;
-}
-
-QString PerforcePlugin::errorDescription() const
-{
- return m_errorDescription;
-}
-
diff --git a/plugins/perforce/perforceplugin.h b/plugins/perforce/perforceplugin.h
index 04a0e5c..8f67aa8 100644
--- a/plugins/perforce/perforceplugin.h
+++ b/plugins/perforce/perforceplugin.h
@@ -130,9 +130,6 @@ public:
KDevelop::VcsJob* edit(const QList<QUrl>& localLocations);
- bool hasError() const override;
- QString errorDescription() const override;
-
KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context) \
override;
@@ -174,10 +171,6 @@ private:
QString m_perforceConfigName;
QString m_perforceExecutable;
QAction* m_edit_action;
-
- bool m_hasError;
- QString m_errorDescription;
-
};
#endif // PERFORCEPLUGIN_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic