Commit c0811bef authored by Alexander Semke's avatar Alexander Semke
Browse files

Made couple of functions pure virtual in backend.h.

parent 8803a9a8
......@@ -57,5 +57,32 @@ Cantor::Backend::Capabilities NullBackend::capabilities() const
return Cantor::Backend::Nothing;
}
QWidget* NullBackend::settingsWidget(QWidget* parent) const
{
Q_UNUSED(parent)
return nullptr;
}
KConfigSkeleton* NullBackend::config() const
{
return nullptr;
}
QUrl NullBackend::helpUrl() const
{
return QUrl();
}
QString NullBackend::version() const
{
return QLatin1String();
}
bool NullBackend::requirementsFullfilled(QString* const reason) const
{
Q_UNUSED(reason);
return true;
}
K_PLUGIN_FACTORY_WITH_JSON(nullbackend, "nullbackend.json", registerPlugin<NullBackend>();)
#include "nullbackend.moc"
......@@ -34,7 +34,11 @@ class NullBackend : public Cantor::Backend
Cantor::Session *createSession() override;
Cantor::Backend::Capabilities capabilities() const override;
QWidget* settingsWidget(QWidget* parent) const override;
KConfigSkeleton* config() const override;
bool requirementsFullfilled(QString* const reason) const override;
QUrl helpUrl() const override;
QString version() const override;
};
......
......@@ -86,5 +86,11 @@ KConfigSkeleton* Python2Backend::config() const
return PythonSettings::self();
}
bool Python2Backend::requirementsFullfilled(QString* const reason) const
{
const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_python2server"));
return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python2 Server"), path, reason);
}
K_PLUGIN_FACTORY_WITH_JSON(python2backend, "python2backend.json", registerPlugin<Python2Backend>();)
#include "python2backend.moc"
......@@ -36,7 +36,7 @@ class Python2Backend : public PythonBackend
Cantor::Backend::Capabilities capabilities() const override;
QUrl helpUrl() const override;
QString description() const override;
bool requirementsFullfilled(QString* const reason = nullptr) const override;
KConfigSkeleton* config() const override;
};
......
......@@ -82,5 +82,11 @@ KConfigSkeleton* Python3Backend::config() const
return PythonSettings::self();
}
bool Python3Backend::requirementsFullfilled(QString* const reason) const
{
const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_python3server"));
return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python3 Server"), path, reason);
}
K_PLUGIN_FACTORY_WITH_JSON(python3backend, "python3backend.json", registerPlugin<Python3Backend>();)
#include "python3backend.moc"
......@@ -35,7 +35,7 @@ class Python3Backend : public PythonBackend
Cantor::Backend::Capabilities capabilities() const override;
QUrl helpUrl() const override;
QString description() const override;
bool requirementsFullfilled(QString* const reason = nullptr) const override;
KConfigSkeleton* config() const override;
};
......
......@@ -71,21 +71,11 @@ QString Backend::icon() const
return d->icon;
}
QString Backend::version() const
{
return QLatin1String();
}
QString Backend::url() const
{
return d->url;
}
QUrl Backend::helpUrl() const
{
return QUrl();
}
bool Backend::isEnabled() const
{
return d->enabled && requirementsFullfilled();
......@@ -168,17 +158,6 @@ Backend* Backend::getBackend(const QString& name)
return nullptr;
}
QWidget* Backend::settingsWidget(QWidget* parent) const
{
Q_UNUSED(parent)
return nullptr;
}
KConfigSkeleton* Backend::config() const
{
return nullptr;
}
QStringList Backend::extensions() const
{
QList<Extension*> extensions = findChildren<Extension*>(QRegularExpression(QLatin1String(".*Extension")));
......@@ -193,12 +172,6 @@ Extension* Backend::extension(const QString& name) const
return findChild<Extension*>(name);
}
bool Backend::requirementsFullfilled(QString* const reason) const
{
Q_UNUSED(reason);
return true;
}
bool Backend::checkExecutable(const QString& name, const QString& path, QString* reason)
{
if (path.isEmpty())
......
......@@ -83,6 +83,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* Destructor. Doesn't anything.
*/
~Backend() override;
public:
/**
......@@ -103,7 +104,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* @return @c false some requirements are missing. e.g. the maxima executable can not be found
* @see Capability
*/
virtual bool requirementsFullfilled(QString* const reason = nullptr) const;
virtual bool requirementsFullfilled(QString* const reason = nullptr) const = 0;
/**
* Returns a unique string to identify this backend.
......@@ -116,7 +117,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* Returns the recommended version of the backend supported by Cantor
* @return the recommended version of the backend
*/
virtual QString version() const;
virtual QString version() const = 0;
//Stuff extracted from the .desktop file
/**
......@@ -148,7 +149,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* "http://docs.kde.org/stable/en/kdeedu/kalgebra/");
* @return Url of the help
*/
virtual QUrl helpUrl() const;
virtual QUrl helpUrl() const = 0;
/**
* Returns if the backend should be enabled (shown in the Backend dialog)
* @return @c true, if the enabled flag is set to true, and the requirements are fulfilled
......@@ -172,13 +173,13 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* Returns a Widget for configuring this backend
* @return Widget for usage in the Settings dialog
*/
virtual QWidget* settingsWidget(QWidget* parent) const;
virtual QWidget* settingsWidget(QWidget* parent) const = 0;
/**
* Returns a KConfig object, containing all the settings,
* the backend might need
* @return a KConfigSkeleton object, for configuring this backend
*/
virtual KConfigSkeleton* config() const;
virtual KConfigSkeleton* config() const = 0;
/**
* Returns a list of the names of all the Extensions supported by this backend
* @return a list of the names of all the Extensions supported by this backend
......@@ -190,7 +191,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* if the Backend doesn't have an extension with this name.
* @return Pointer to the Extension object with the given name
*/
Extension * extension(const QString& name) const;
Extension* extension(const QString& name) const;
/**
* Returns a list of the names of all the installed and enabled backends
......@@ -215,6 +216,7 @@ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient
* In case the requrements are not fullfilled, the reason is written to @c reason.
*/
static bool checkExecutable(const QString& name, const QString& path, QString* reason);
private:
BackendPrivate* d;
};
......
Supports Markdown
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