File indexing completed on 2024-04-28 11:20:34

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2010 Miha Čančula <miha.cancula@gmail.com>
0004     SPDX-FileCopyrightText: 2019 Alexander Semke <alexander.semke@web.de>
0005 */
0006 
0007 #include "octavebackend.h"
0008 #include "octaveextensions.h"
0009 #include "octavesession.h"
0010 #include "octavesettingswidget.h"
0011 #include "settings.h"
0012 
0013 #include <KPluginFactory>
0014 
0015 OctaveBackend::OctaveBackend(QObject* parent, const QList<QVariant>& args): Backend(parent, args)
0016 {
0017     new OctaveHistoryExtension(this);
0018     new OctaveScriptExtension(this);
0019     new OctavePlotExtension(this);
0020     new OctaveLinearAlgebraExtension(this);
0021     new OctaveVariableManagementExtension(this);
0022     new OctavePackagingExtension(this);
0023 }
0024 
0025 QString OctaveBackend::id() const
0026 {
0027     return QLatin1String("octave");
0028 }
0029 
0030 QString OctaveBackend::version() const
0031 {
0032     return QLatin1String("7.2");
0033 }
0034 
0035 Cantor::Backend::Capabilities OctaveBackend::capabilities() const
0036 {
0037     Cantor::Backend::Capabilities cap =
0038         SyntaxHighlighting |
0039         Completion         |
0040         SyntaxHelp         |
0041         IntegratedPlots    |
0042         VariableDimension;
0043 
0044     if (OctaveSettings::self()->variableManagement())
0045         cap |= VariableManagement;
0046     return cap;
0047 }
0048 
0049 Cantor::Session* OctaveBackend::createSession()
0050 {
0051     return new OctaveSession(this);
0052 }
0053 
0054 bool OctaveBackend::requirementsFullfilled(QString* const reason) const
0055 {
0056     const QString& path = OctaveSettings::path().toLocalFile();
0057     return Cantor::Backend::checkExecutable(QLatin1String("Octave"), path, reason);
0058 }
0059 
0060 QUrl OctaveBackend::helpUrl() const
0061 {
0062     return QUrl(i18nc("the url to the documentation of Octave, please check if there is a translated version and use the correct url",
0063             "https://octave.org/doc/interpreter/"));
0064 }
0065 
0066 QString OctaveBackend::description() const
0067 {
0068     return i18n("<b>GNU Octave</b> is a high-level language, primarily intended for numerical computations. <br/>"
0069                 "It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab.");
0070 }
0071 
0072 QWidget* OctaveBackend::settingsWidget(QWidget* parent) const
0073 {
0074     return new OctaveSettingsWidget(parent, id());
0075 }
0076 
0077 KConfigSkeleton* OctaveBackend::config() const
0078 {
0079     return OctaveSettings::self();
0080 }
0081 
0082 K_PLUGIN_FACTORY_WITH_JSON(octavebackend, "octavebackend.json", registerPlugin<OctaveBackend>();)
0083 #include "octavebackend.moc"