File indexing completed on 2023-10-01 07:35:55
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com> 0004 SPDX-FileCopyrightText: 2019 Alexander Semke <alexander.semke@web.de> 0005 */ 0006 0007 #include "rbackend.h" 0008 #include "rsession.h" 0009 #include "rextensions.h" 0010 #include "settings.h" 0011 #include "rsettingswidget.h" 0012 0013 #include <KPluginFactory> 0014 0015 RBackend::RBackend(QObject* parent,const QList<QVariant>& args) : Cantor::Backend(parent, args) 0016 { 0017 new RScriptExtension(this); 0018 new RPlotExtension(this); 0019 new RVariableManagementExtension(this); 0020 } 0021 0022 RBackend::~RBackend() 0023 { 0024 qDebug()<<"Destroying RBackend"; 0025 } 0026 0027 QString RBackend::id() const 0028 { 0029 return QLatin1String("r"); 0030 } 0031 0032 QString RBackend::version() const 0033 { 0034 return QLatin1String("Undefined"); 0035 } 0036 0037 Cantor::Session* RBackend::createSession() 0038 { 0039 qDebug()<<"Spawning a new R session"; 0040 0041 return new RSession(this); 0042 } 0043 0044 Cantor::Backend::Capabilities RBackend::capabilities() const 0045 { 0046 qDebug()<<"Requesting capabilities of RSession"; 0047 Cantor::Backend::Capabilities cap= 0048 SyntaxHighlighting| 0049 Completion | 0050 InteractiveMode; 0051 0052 if (RServerSettings::variableManagement()) 0053 cap |= VariableManagement; 0054 0055 return cap; 0056 } 0057 0058 bool RBackend::requirementsFullfilled(QString* const reason) const 0059 { 0060 #ifdef Q_OS_WIN 0061 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_rserver.exe")); 0062 #else 0063 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_rserver")); 0064 #endif 0065 return Cantor::Backend::checkExecutable(QLatin1String("Cantor RServer"), path, reason); 0066 } 0067 0068 QWidget* RBackend::settingsWidget(QWidget* parent) const 0069 { 0070 return new RSettingsWidget(parent, id()); 0071 } 0072 0073 KConfigSkeleton* RBackend::config() const 0074 { 0075 return RServerSettings::self(); 0076 } 0077 0078 QUrl RBackend::helpUrl() const 0079 { 0080 return QUrl(i18nc("the url to the documentation of R, please check if there is a translated version and use the correct url", 0081 "https://cran.r-project.org/manuals.html")); 0082 } 0083 0084 QString RBackend::defaultHelp() const 0085 { 0086 //description of R's help system taken from https://www.r-project.org/help.html 0087 //@tranlators: don't tranlate R's keywords here ("help", etc.) which are put inside <i></i> 0088 return i18n("<h1>R' Help System: <i>help()</i> and <i>?</i>:</h1><br>" 0089 "The <i>help()</i> function and <i>?</i> help operator in R provide access to the documentation pages for R functions, data sets, and other objects, both for packages in the standard R distribution and for contributed packages.<br><br>" 0090 "To access documentation for the standard <i>lm</i> (linear model) function, for example, enter the command <b><i>help(lm)</i></b> or <i>help(\"lm\")</i>, or <i>?lm</i> or <i>?\"lm\"</i> (i.e., the quotes are optional).<br><br>" 0091 "To access help for a function in a package that’s not currently loaded, specify in addition the name of the package: For example, to obtain documentation for the <i>rlm()</i> (robust linear model) function in the MASS package, <i>help(rlm, package=\"MASS\")</i>.<br><br>" 0092 "Standard names in R consist of upper- and lower-case letters, numerals (0-9), underscores (_), and periods (.), and must begin with a letter or a period. To obtain help for an object with a non-standard name (such as the help operator <i>?</i>), the name must be quoted: for example, <i>help('?')</i> or <i>?\"?\"</i>.<br><br>" 0093 "You may also use the <i>help()</i> function to access information about a package in your library — for example, <i>help(package=\"MASS\")</i> — which displays an index of available help pages for the package along with some other information.<br><br>" 0094 "Help pages for functions usually include a section with executable examples illustrating how the functions work. You can execute these examples in the current R session via the <i>example()</i> command: e.g., <i>example(lm)</i>."); 0095 } 0096 0097 QString RBackend::description() const 0098 { 0099 return i18n("<b>R</b> is a language and environment for statistical computing and graphics, similar to the S language and environment. <br/>"\ 0100 "It provides a wide variety of statistical (linear and nonlinear modelling, "\ 0101 "classical statistical tests, time-series analysis, classification, clustering, ...) "\ 0102 "and graphical techniques, and is highly extensible. The S language is often the "\ 0103 "vehicle of choice for research in statistical methodology, "\ 0104 "and R provides an Open Source route to participation in that activity."); 0105 } 0106 0107 K_PLUGIN_FACTORY_WITH_JSON(rbackend, "rbackend.json", registerPlugin<RBackend>();) 0108 #include "rbackend.moc"