[education/rkward] rkward/plugin: Set QT_NO_CAST_FROM_ASCII in plugin folder
Thomas Friedrichsmeier
null at kde.org
Fri Apr 25 20:22:19 BST 2025
Git commit cddab861faab32f825a8b2dc11f85bde47f5328e by Thomas Friedrichsmeier.
Committed on 25/04/2025 at 19:22.
Pushed by tfry into branch 'master'.
Set QT_NO_CAST_FROM_ASCII in plugin folder
M +1 -0 rkward/plugin/CMakeLists.txt
M +11 -11 rkward/plugin/rkabstractoptionselector.cpp
M +40 -39 rkward/plugin/rkcomponent.cpp
M +14 -14 rkward/plugin/rkcomponentmap.cpp
M +54 -53 rkward/plugin/rkcomponentmeta.cpp
M +33 -32 rkward/plugin/rkcomponentproperties.cpp
M +50 -50 rkward/plugin/rkformula.cpp
M +33 -33 rkward/plugin/rkmatrixinput.cpp
M +37 -37 rkward/plugin/rkoptionset.cpp
M +1 -1 rkward/plugin/rkpluginbrowser.cpp
M +45 -34 rkward/plugin/rkpreviewbox.cpp
M +10 -9 rkward/plugin/rkstandardcomponent.cpp
M +30 -28 rkward/plugin/rkstandardcomponentgui.cpp
M +7 -4 rkward/plugin/rkvarslot.cpp
https://invent.kde.org/education/rkward/-/commit/cddab861faab32f825a8b2dc11f85bde47f5328e
diff --git a/rkward/plugin/CMakeLists.txt b/rkward/plugin/CMakeLists.txt
index 7cf20427b..3f4ef355c 100644
--- a/rkward/plugin/CMakeLists.txt
+++ b/rkward/plugin/CMakeLists.txt
@@ -37,3 +37,4 @@ SET(plugin_STAT_SRCS
ADD_LIBRARY(plugin STATIC ${plugin_STAT_SRCS})
TARGET_LINK_LIBRARIES(plugin Qt6::Widgets KF6::TextEditor KF6::WindowSystem KF6::I18n)
+add_definitions(-DQT_NO_CAST_FROM_ASCII) # TODO remove, here, once enabled on top level
diff --git a/rkward/plugin/rkabstractoptionselector.cpp b/rkward/plugin/rkabstractoptionselector.cpp
index ffd3f1456..418809ea9 100644
--- a/rkward/plugin/rkabstractoptionselector.cpp
+++ b/rkward/plugin/rkabstractoptionselector.cpp
@@ -68,30 +68,30 @@ void RKAbstractOptionSelector::addOptionsAndInit (const QDomElement &element) {
number->setIntValue (selected); // will also take care of activating the correct item
}
-RKComponentBase* RKAbstractOptionSelector::lookupComponent (const QString &identifier, QString *remainder) {
- RK_TRACE (PLUGIN);
+RKComponentBase *RKAbstractOptionSelector::lookupComponent(const QString &identifier, QString *remainder) {
+ RK_TRACE(PLUGIN);
- if (identifier.isEmpty ()) return this;
+ if (identifier.isEmpty()) return this;
- QString name = identifier.section ('.', 0, 0);
- if (named_options.contains (name)) {
+ QString name = identifier.section(u'.', 0, 0);
+ if (named_options.contains(name)) {
Option *opt = named_options[name];
- QString mod = identifier.section ('.', 1);
+ QString mod = identifier.section(u'.', 1);
if (mod != QLatin1String("enabled")) {
- RK_DEBUG (PLUGIN, DL_DEBUG, "options do not have property '%s'", mod.toLatin1().data ());
+ RK_DEBUG(PLUGIN, DL_DEBUG, "options do not have property '%s'", mod.toLatin1().data());
return this;
}
- if (!(opt->enabledness_prop)) { // requested for the first time
- opt->enabledness_prop = new RKComponentPropertyBool (this, false);
- connect (opt->enabledness_prop, &RKComponentPropertyBase::valueChanged, this, &RKAbstractOptionSelector::ItemPropertyChanged);
+ if (!(opt->enabledness_prop)) { // requested for the first time
+ opt->enabledness_prop = new RKComponentPropertyBool(this, false);
+ connect(opt->enabledness_prop, &RKComponentPropertyBase::valueChanged, this, &RKAbstractOptionSelector::ItemPropertyChanged);
}
return (opt->enabledness_prop);
}
- return RKComponent::lookupComponent (identifier, remainder);
+ return RKComponent::lookupComponent(identifier, remainder);
}
void RKAbstractOptionSelector::propertyChanged (RKComponentPropertyBase *property) {
diff --git a/rkward/plugin/rkcomponent.cpp b/rkward/plugin/rkcomponent.cpp
index 8855e6586..e599e4807 100644
--- a/rkward/plugin/rkcomponent.cpp
+++ b/rkward/plugin/rkcomponent.cpp
@@ -14,19 +14,19 @@ SPDX-License-Identifier: GPL-2.0-or-later
//############### RKComponentBase #####################
-RKComponentBase* RKComponentBase::lookupComponent (const QString &identifier, QString *remainder) {
- RK_TRACE (PLUGIN);
- RK_ASSERT (remainder);
+RKComponentBase *RKComponentBase::lookupComponent(const QString &identifier, QString *remainder) {
+ RK_TRACE(PLUGIN);
+ RK_ASSERT(remainder);
- if (identifier.isEmpty ()) return this;
- RK_DEBUG (PLUGIN, DL_DEBUG, "looking up '%s'", identifier.toLatin1 ().data ());
+ if (identifier.isEmpty()) return this;
+ RK_DEBUG(PLUGIN, DL_DEBUG, "looking up '%s'", identifier.toLatin1().data());
- RKComponentBase *child = child_map.value (identifier.section ('.', 0, 0));
- if (!child) { // if we do not have such a child, return this (and set remainder)
+ RKComponentBase *child = child_map.value(identifier.section(u'.', 0, 0));
+ if (!child) { // if we do not have such a child, return this (and set remainder)
*remainder = identifier;
return this;
- } else { // else do recursive lookup
- return child->lookupComponent (identifier.section ('.', 1), remainder);
+ } else { // else do recursive lookup
+ return child->lookupComponent(identifier.section(u'.', 1), remainder);
}
}
@@ -54,21 +54,22 @@ void RKComponentBase::addChild (const QString &id, RKComponentBase *child) {
child_map.insert(id, child); // no overwriting even on duplicate ("#noid#") ids
}
-void RKComponentBase::fetchPropertyValuesRecursive (PropertyValueMap *list, bool include_top_level, const QString &prefix, bool include_inactive_elements) const {
- RK_TRACE (PLUGIN);
+void RKComponentBase::fetchPropertyValuesRecursive(PropertyValueMap *list, bool include_top_level, const QString &prefix,
+ bool include_inactive_elements) const {
+ RK_TRACE(PLUGIN);
- for (auto it = child_map.constBegin (); it != child_map.constEnd (); ++it) {
- if (it.key () == QLatin1String("#noid#")) continue;
- if (it.value ()->isInternal ()) continue;
+ for (auto it = child_map.constBegin(); it != child_map.constEnd(); ++it) {
+ if (it.key() == QLatin1String("#noid#")) continue;
+ if (it.value()->isInternal()) continue;
- if (it.value ()->isProperty ()) {
+ if (it.value()->isProperty()) {
if (include_top_level) {
- list->insert (prefix + it.key (), fetchStringValue (it.value ()));
+ list->insert(prefix + it.key(), fetchStringValue(it.value()));
}
} else {
- RK_ASSERT (it.value ()->isComponent ());
- if (static_cast<RKComponent *> (it.value ())->isInactive () && (!include_inactive_elements)) continue;
- it.value ()->fetchPropertyValuesRecursive (list, true, prefix + it.key () + '.');
+ RK_ASSERT(it.value()->isComponent());
+ if (static_cast<RKComponent *>(it.value())->isInactive() && (!include_inactive_elements)) continue;
+ it.value()->fetchPropertyValuesRecursive(list, true, prefix + it.key() + u'.');
}
}
}
@@ -92,27 +93,27 @@ void RKComponentBase::setPropertyValues (const PropertyValueMap *list, bool warn
}
}
-//static
-QString RKComponentBase::valueMapToString (const PropertyValueMap &map) {
- RK_TRACE (PLUGIN);
+// static
+QString RKComponentBase::valueMapToString(const PropertyValueMap &map) {
+ RK_TRACE(PLUGIN);
QString out;
- for (PropertyValueMap::const_iterator it = map.constBegin (); it != map.constEnd (); ++it) {
- if (!out.isEmpty ()) out.append ("\n");
- out.append (RKCommonFunctions::escape (it.key () + '=' + it.value ()));
+ for (PropertyValueMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) {
+ if (!out.isEmpty()) out.append(u'\n');
+ out.append(RKCommonFunctions::escape(it.key() + u'=' + it.value()));
}
return out;
}
-//static
-bool RKComponentBase::stringListToValueMap (const QStringList &strings, PropertyValueMap *map) {
- RK_TRACE (PLUGIN);
+// static
+bool RKComponentBase::stringListToValueMap(const QStringList &strings, PropertyValueMap *map) {
+ RK_TRACE(PLUGIN);
- for (int i = 0; i < strings.size (); ++i) {
- QString line = RKCommonFunctions::unescape (strings[i]);
- int sep = line.indexOf ('=');
+ for (int i = 0; i < strings.size(); ++i) {
+ QString line = RKCommonFunctions::unescape(strings[i]);
+ int sep = line.indexOf(u'=');
if (sep < 0) return false;
- map->insert (line.left (sep), line.mid (sep+1));
+ map->insert(line.left(sep), line.mid(sep + 1));
}
return true;
}
@@ -380,16 +381,16 @@ void RKComponent::changed () {
Q_EMIT componentChanged(this);
}
-RKStandardComponent *RKComponent::standardComponent (QString *id_adjust) const {
- RK_TRACE (PLUGIN);
+RKStandardComponent *RKComponent::standardComponent(QString *id_adjust) const {
+ RK_TRACE(PLUGIN);
- RKComponent *p = const_cast<RKComponent*> (this);
+ RKComponent *p = const_cast<RKComponent *>(this);
while (p) {
- if (p->type () == RKComponent::ComponentStandard) return static_cast<RKStandardComponent*> (p);
- if (id_adjust) id_adjust->prepend (p->getIdInParent () + '.');
- p = p->parentComponent ();
+ if (p->type() == RKComponent::ComponentStandard) return static_cast<RKStandardComponent *>(p);
+ if (id_adjust) id_adjust->prepend(p->getIdInParent() + u'.');
+ p = p->parentComponent();
}
- RK_ASSERT (false);
+ RK_ASSERT(false);
return nullptr;
}
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index 53d83f847..9b403458f 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -36,7 +36,7 @@ QString RKPluginMapFile::makeFileName (const QString &filename) const {
QString RKPluginMapFile::parseId (const QDomElement& e, XMLHelper &xml) {
RK_TRACE (PLUGIN);
- return (xml.getStringAttribute (e, QStringLiteral("namespace"), QStringLiteral("rkward"), DL_WARNING) + "::" + xml.getStringAttribute (e, QStringLiteral("id"), QString (), DL_INFO));
+ return (xml.getStringAttribute (e, QStringLiteral("namespace"), QStringLiteral("rkward"), DL_WARNING) + u"::"_s + xml.getStringAttribute (e, QStringLiteral("id"), QString (), DL_INFO));
}
RKComponentAboutData RKPluginMapFile::getAboutData () {
@@ -62,12 +62,12 @@ RKComponentGUIXML::~RKComponentGUIXML () {
toplevel_menu.clear ();
}
-void RKComponentGUIXML::clearGUIDescription () {
- RK_TRACE (PLUGIN);
+void RKComponentGUIXML::clearGUIDescription() {
+ RK_TRACE(PLUGIN);
- gui_xml.setContent (QStringLiteral ("<!DOCTYPE kpartgui>\n<kpartgui name=\"rkwardcomponents\" version=\"063\">\n<MenuBar>\n\n</MenuBar>\n</kpartgui>"));
- toplevel_menu.clear ();
- component_menus.clear ();
+ gui_xml.setContent(QStringLiteral("<!DOCTYPE kpartgui>\n<kpartgui name=\"rkwardcomponents\" version=\"063\">\n<MenuBar>\n\n</MenuBar>\n</kpartgui>"));
+ toplevel_menu.clear();
+ component_menus.clear();
}
bool compareMenuEntries (const RKComponentGUIXML::Entry *a, const RKComponentGUIXML::Entry *b) {
@@ -96,7 +96,7 @@ void RKComponentGUIXML::resolveComponentLabelsAndSortMenu (Menu *menu, const QSt
component_menus.insert (entry->id, menu_path);
}
} else {
- resolveComponentLabelsAndSortMenu (static_cast<Menu*> (entry), menu_path.isEmpty () ? entry->label : menu_path + '\t' + entry->label);
+ resolveComponentLabelsAndSortMenu(static_cast<Menu *>(entry), menu_path.isEmpty() ? entry->label : menu_path + u'\t' + entry->label);
}
}
std::sort(group->entries.begin(), group->entries.end(), compareMenuEntries);
@@ -504,12 +504,12 @@ bool RKComponentMap::invokeComponent (const QString &component_id, const QString
return false;
}
- QStringList problems = component->matchAgainstState (state);
- if (!problems.isEmpty ()) {
- _message = i18n ("Not all specified settings could be applied. Most likely this is because some R objects are no longer present in your current workspace.");
- RK_DEBUG (PLUGIN, DL_WARNING, "%s", qPrintable (problems.join ("\n"))); // TODO: make failures available to backend
+ QStringList problems = component->matchAgainstState(state);
+ if (!problems.isEmpty()) {
+ _message = i18n("Not all specified settings could be applied. Most likely this is because some R objects are no longer present in your current workspace.");
+ RK_DEBUG(PLUGIN, DL_WARNING, "%s", qPrintable(problems.join(u'\n'))); // TODO: make failures available to backend
if (message) *message = _message;
- else KMessageBox::informationList (component, _message, problems, i18n ("Not all settings applied"));
+ else KMessageBox::informationList(component, _message, problems, i18n("Not all settings applied"));
// TODO: Don't show again-box?
// not considered an error
}
@@ -570,8 +570,8 @@ RKPluginMapParseResult RKComponentMap::addPluginMap (const QString& plugin_map_f
return ret;
}
- QString prefix = QFileInfo (plugin_map_file_abs).absolutePath() + '/' + xml.getStringAttribute (document_element, QStringLiteral("base_prefix"), QString (), DL_INFO);
- QString cnamespace = xml.getStringAttribute (document_element, QStringLiteral("namespace"), QStringLiteral("rkward"), DL_INFO) + "::";
+ QString prefix = QFileInfo (plugin_map_file_abs).absolutePath() + u'/' + xml.getStringAttribute (document_element, QStringLiteral("base_prefix"), QString (), DL_INFO);
+ QString cnamespace = xml.getStringAttribute (document_element, QStringLiteral("namespace"), QStringLiteral("rkward"), DL_INFO) + u"::"_s;
RKPluginMapFile* pluginmap_file_desc = new RKPluginMapFile (QFileInfo (plugin_map_file).absoluteFilePath (), prefix, xml.messageCatalog ());
pluginmap_file_desc->id = RKPluginMapFile::parseId (document_element, xml);
diff --git a/rkward/plugin/rkcomponentmeta.cpp b/rkward/plugin/rkcomponentmeta.cpp
index 6c2fedabc..4200a54ab 100644
--- a/rkward/plugin/rkcomponentmeta.cpp
+++ b/rkward/plugin/rkcomponentmeta.cpp
@@ -15,6 +15,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../debug.h"
+using namespace Qt::Literals::StringLiterals;
+
static QLatin1String rkward_min_version_tag("rkward_min_version");
static QLatin1String rkward_max_version_tag("rkward_max_version");
static QLatin1String R_min_version_tag("R_min_version");
@@ -46,7 +48,7 @@ RKComponentAboutData::RKComponentAboutData (const QDomElement& e, XMLHelper &xml
RKComponentAuthor author;
author.name = xml.i18nStringAttribute (ae, QStringLiteral("name"), QString (), DL_INFO);
if (author.name.isEmpty ()) {
- author.name = xml.i18nStringAttribute (ae, QStringLiteral("given"), QString (), DL_WARNING) + ' ' + xml.i18nStringAttribute (ae, QStringLiteral("family"), QString (), DL_WARNING);
+ author.name = xml.i18nStringAttribute (ae, QStringLiteral("given"), QString (), DL_WARNING) + u' ' + xml.i18nStringAttribute (ae, QStringLiteral("family"), QString (), DL_WARNING);
}
if (author.name.isEmpty ()) xml.displayError (&ae, QStringLiteral("No author name specified"), DL_WARNING);
@@ -68,49 +70,49 @@ RKComponentAboutData::~RKComponentAboutData () {
RK_TRACE (PLUGIN);
}
-QString RKComponentAboutData::toHtml () const {
- RK_TRACE (PLUGIN);
-
- QString ret = "<p><b>" + name + "</b>";
- if (!version.isEmpty ()) ret.append (' ' + version);
- if (!releasedate.isEmpty ()) ret.append (" (" + releasedate + ')');
- if (!shortinfo.isEmpty ()) ret.append (":</p>\n<p>" + shortinfo);
- ret.append ("</p>\n");
- if (!url.isEmpty ()) ret.append ("URL: <a href=\"" + url + "\">" + url + "</a></p>\n<p>");
- if (!copyright.isEmpty ()) ret.append (i18n ("Copyright (c): %1", copyright) + "</p>\n<p>");
- if (!license.isEmpty ()) ret.append (i18n ("License: %1", license) + "</p>");
-
- if (!authors.isEmpty ()) {
- ret.append ("\n<p><b>" + i18n ("Authors:") + "</b></p>\n<p><ul>");
- for (int i = 0; i < authors.size (); ++i) {
+QString RKComponentAboutData::toHtml() const {
+ RK_TRACE(PLUGIN);
+
+ QString ret = u"<p><b>"_s + name + u"</b>"_s;
+ if (!version.isEmpty()) ret.append(u' ' + version);
+ if (!releasedate.isEmpty()) ret.append(u" ("_s + releasedate + u')');
+ if (!shortinfo.isEmpty()) ret.append(u":</p>\n<p>"_s + shortinfo);
+ ret.append(u"</p>\n"_s);
+ if (!url.isEmpty()) ret.append(u"URL: <a href=\""_s + url + u"\">"_s + url + u"</a></p>\n<p>"_s);
+ if (!copyright.isEmpty()) ret.append(i18n("Copyright (c): %1", copyright) + u"</p>\n<p>"_s);
+ if (!license.isEmpty()) ret.append(i18n("License: %1", license) + u"</p>"_s);
+
+ if (!authors.isEmpty()) {
+ ret.append(u"\n<p><b>"_s + i18n("Authors:") + u"</b></p>\n<p><ul>"_s);
+ for (int i = 0; i < authors.size(); ++i) {
RKComponentAuthor a = authors[i];
- ret.append ("<li>" + a.name);
- if (!a.email.isEmpty ()) ret.append (" (" + a.email + ')');
- if (!a.url.isEmpty ()) ret.append (" (" + a.url + ')');
- if (!a.roles.isEmpty ()) ret.append ("<br/><i>" + i18nc ("Author roles (contributor, etc.)", "Roles") + "</i>: " + a.roles);
+ ret.append(u"<li>"_s + a.name);
+ if (!a.email.isEmpty()) ret.append(u" ("_s + a.email + u')');
+ if (!a.url.isEmpty()) ret.append(u" ("_s + a.url + u')');
+ if (!a.roles.isEmpty()) ret.append(u"<br/><i>"_s + i18nc("Author roles (contributor, etc.)", "Roles") + u"</i>: "_s + a.roles);
}
- ret.append ("</ul></p>");
+ ret.append(u"</ul></p>"_s);
}
- if (!translator_names.isNull ()) {
- QStringList tns = translator_names.split (QLatin1Char(','), Qt::KeepEmptyParts);
- QStringList tes = translator_emails.split (QLatin1Char(','), Qt::KeepEmptyParts);
- ret.append ("\n<p><b>" + i18n ("Translators:") + "</b></p>\n<p><ul>");
- for (int i = 0; i < tns.size (); ++i) {
- QString tn = tns.value (i);
- QString te = tes.value (i);
- if (tn.isEmpty () && te.isEmpty ()) continue;
- ret.append ("<li>" + tn + " <" + te + "></li>\n");
+ if (!translator_names.isNull()) {
+ QStringList tns = translator_names.split(QLatin1Char(','), Qt::KeepEmptyParts);
+ QStringList tes = translator_emails.split(QLatin1Char(','), Qt::KeepEmptyParts);
+ ret.append(u"\n<p><b>"_s + i18n("Translators:") + u"</b></p>\n<p><ul>"_s);
+ for (int i = 0; i < tns.size(); ++i) {
+ QString tn = tns.value(i);
+ QString te = tes.value(i);
+ if (tn.isEmpty() && te.isEmpty()) continue;
+ ret.append(u"<li>"_s + tn + u" <"_s + te + u"></li>\n"_s);
}
- ret.append ("</ul></p>");
+ ret.append(u"</ul></p>"_s);
}
return ret;
}
-bool RKComponentDependency::isRKWardVersionCompatible (const QDomElement& e) {
- RK_TRACE (PLUGIN);
+bool RKComponentDependency::isRKWardVersionCompatible(const QDomElement& e) {
+ RK_TRACE(PLUGIN);
if (e.hasAttribute(rkward_min_version_tag)) {
if (RKSessionVars::compareRKWardVersion(e.attribute(rkward_min_version_tag)) > 0) return false;
@@ -119,12 +121,12 @@ bool RKComponentDependency::isRKWardVersionCompatible (const QDomElement& e) {
if (RKSessionVars::compareRKWardVersion(e.attribute(rkward_max_version_tag)) < 0) return false;
}
if (e.hasAttribute(platforms_tag)) {
- auto platforms = e.attribute(platforms_tag).split(':');
+ auto platforms = e.attribute(platforms_tag).split(u':');
#if defined(Q_OS_WIN)
if (platforms.contains(QLatin1String("windows"))) return true;
#elif defined(Q_OS_MACOS)
if (platforms.contains(QLatin1String("macos"))) return true;
-#elif defined(Q_OS_UNIX) // NOTE: order matters. Q_OS_UNIX is also defined on mac, but we do not want to count that as "unix", here.
+#elif defined(Q_OS_UNIX) // NOTE: order matters. Q_OS_UNIX is also defined on mac, but we do not want to count that as "unix", here.
if (platforms.contains(QLatin1String("unix"))) return true;
#else
static_assert(false, "Undefined platform");
@@ -192,31 +194,30 @@ QList <RKComponentDependency> RKComponentDependency::parseDependencies (const QD
return ret;
}
-QString RKComponentDependency::depsToHtml (const QList <RKComponentDependency>& deps) {
- RK_TRACE (PLUGIN);
+QString RKComponentDependency::depsToHtml(const QList<RKComponentDependency>& deps) {
+ RK_TRACE(PLUGIN);
QString ret;
- if (deps.isEmpty ()) return ret;
+ if (deps.isEmpty()) return ret;
- ret.append ("<ul>");
- for (int i = 0; i < deps.size (); ++i) {
- ret.append ("<li>");
- const RKComponentDependency &dep = deps[i];
+ ret.append(u"<ul>"_s);
+ for (int i = 0; i < deps.size(); ++i) {
+ ret.append(u"<li>"_s);
+ const RKComponentDependency& dep = deps[i];
if (dep.type == RBaseInstallation) {
- ret.append ("R");
+ ret.append(u"R"_s);
} else if (dep.type == RKWardVersion) {
- ret.append ("RKWard");
+ ret.append(u"RKWard"_s);
} else {
- if (dep.type == RKWardPluginmap) ret.append (i18n ("RKWard plugin map"));
- else ret.append (i18n ("R package"));
- ret.append (" \"" + dep.package + "\"");
- if (!dep.source_info.isEmpty ()) ret.append (" (" + dep.source_info + ')');
+ if (dep.type == RKWardPluginmap) ret.append(i18n("RKWard plugin map"));
+ else ret.append(i18n("R package"));
+ ret.append(u" \""_s + dep.package + u"\""_s);
+ if (!dep.source_info.isEmpty()) ret.append(u" ("_s + dep.source_info + u')');
}
- if (!dep.min_version.isNull()) ret.append(" >= " + dep.min_version.toString());
- if (!dep.max_version.isNull()) ret.append(" <= " + dep.max_version.toString());
- ret.append ("</li>");
+ if (!dep.min_version.isNull()) ret.append(u" >= "_s + dep.min_version.toString());
+ if (!dep.max_version.isNull()) ret.append(u" <= "_s + dep.max_version.toString());
+ ret.append(u"</li>"_s);
}
- ret.append ("</ul>");
+ ret.append(u"</ul>"_s);
return ret;
}
-
diff --git a/rkward/plugin/rkcomponentproperties.cpp b/rkward/plugin/rkcomponentproperties.cpp
index 7c2cac3ff..45994b192 100644
--- a/rkward/plugin/rkcomponentproperties.cpp
+++ b/rkward/plugin/rkcomponentproperties.cpp
@@ -209,15 +209,16 @@ RKComponentPropertyStringList::~RKComponentPropertyStringList () {
RK_TRACE (PLUGIN);
}
-// escapes only newlines, so we can join strings by newline. Does duplicate backslashes, so the string can safely be passed through RKCommonFunction::unescape().
-QString escapeNewlines (const QString &in) {
+// escapes only newlines, so we can join strings by newline. Does duplicate backslashes, so the string can safely be passed through
+// RKCommonFunction::unescape().
+QString escapeNewlines(const QString &in) {
QString out;
- for (int i = 0; i < in.size (); ++i) {
+ for (int i = 0; i < in.size(); ++i) {
QChar c = in[i];
- if (c == '\\') out.append ("\\\\");
- else if (c == '\n') out.append ("\\n");
- else out.append (c);
+ if (c == u'\\') out.append(u"\\\\"_s);
+ else if (c == u'\n') out.append(u"\\n"_s);
+ else out.append(c);
}
return out;
@@ -317,21 +318,21 @@ RKComponentPropertyBool::~RKComponentPropertyBool () {
RK_TRACE (PLUGIN);
}
-RKComponentBase* RKComponentPropertyBool::lookupComponent (const QString &identifier, QString *remainder) {
- RK_TRACE (PLUGIN);
+RKComponentBase *RKComponentPropertyBool::lookupComponent(const QString &identifier, QString *remainder) {
+ RK_TRACE(PLUGIN);
- RKComponentBase *dummy = RKComponentPropertyBase::lookupComponent (identifier, remainder);
+ RKComponentBase *dummy = RKComponentPropertyBase::lookupComponent(identifier, remainder);
if (dummy != this) return dummy;
- QString next = identifier.section ('.', 0, 0);
+ QString next = identifier.section(u'.', 0, 0);
if (next == QLatin1String("not")) {
- RKComponentPropertyBool *negated = new RKComponentPropertyBool (this, false, false, value_true, value_false);
- negated->setInverted (true);
- negated->setInternal (true);
- negated->connectToGovernor (this);
- *remainder = QString (); // reset
- addChild (QStringLiteral("not"), negated); // so subsequent lookups will not recreate the negated property
- return (negated->lookupComponent (identifier.section ('.', 1), remainder));
+ RKComponentPropertyBool *negated = new RKComponentPropertyBool(this, false, false, value_true, value_false);
+ negated->setInverted(true);
+ negated->setInternal(true);
+ negated->connectToGovernor(this);
+ *remainder = QString(); // reset
+ addChild(QStringLiteral("not"), negated); // so subsequent lookups will not recreate the negated property
+ return (negated->lookupComponent(identifier.section(u'.', 1), remainder));
}
return (this);
@@ -752,21 +753,21 @@ QDoubleValidator *RKComponentPropertyDouble::getValidator () {
return validator;
}
-void RKComponentPropertyDouble::internalSetValue (double new_value) {
- RK_TRACE (PLUGIN);
+void RKComponentPropertyDouble::internalSetValue(double new_value) {
+ RK_TRACE(PLUGIN);
current_value = new_value;
// what we want is AT LEAST *precision digits, more if required. I'm sure there's a nifty algorithm for that, but this hack does the trick:
- _value = QString::number (current_value, 'f', 9); // 9 is an arbitrary limit to counter floating point jitter
- int decimal = _value.indexOf ('.');
+ _value = QString::number(current_value, 'f', 9); // 9 is an arbitrary limit to counter floating point jitter
+ int decimal = _value.indexOf(u'.');
if (decimal >= 0) {
int min_digit = decimal + precision + 1;
- while ((min_digit < _value.length ()) && _value.endsWith ('0')) _value.chop (1);
+ while ((min_digit < _value.length()) && _value.endsWith(u'0')) _value.chop(1);
}
- if (_value.endsWith ('.')) _value.chop (1);
+ if (_value.endsWith(u'.')) _value.chop(1);
- is_valid = ((new_value >= validator->bottom ()) && (new_value <= validator->top ()));
+ is_valid = ((new_value >= validator->bottom()) && (new_value <= validator->top()));
if (!is_valid) current_value = default_value;
}
@@ -952,8 +953,8 @@ QString RKComponentPropertyRObjects::checkObjectProblems (RObject *object) const
}
}
- if (probs.isEmpty ()) return QString ();
- return (QStringLiteral ("<ul><li>") + probs.join (QStringLiteral("</li><li>")) + "</li></ul>");
+ if (probs.isEmpty()) return QString();
+ return (u"<ul><li>"_s + probs.join(u"</li><li>"_s) + u"</li></ul>"_s);
}
RObject *RKComponentPropertyRObjects::objectValue () {
@@ -1402,13 +1403,13 @@ QVariant RKComponentPropertySwitch::value (const QString& modifier) {
if (index < 0) index = standards.size (); // remainder-category
}
- // First try to return matching property
- RKComponentPropertyBase *p = value_props.value (index);
+ // First, try to return matching property
+ RKComponentPropertyBase *p = value_props.value(index);
if (p) {
- QString mod = value_prop_mods.value (index);
- if (!(mod.isEmpty () || modifier.isEmpty ())) mod.append (".");
- mod.append (modifier);
- return p->value (mod);
+ QString mod = value_prop_mods.value(index);
+ if (!(mod.isEmpty() || modifier.isEmpty())) mod.append(u"."_s);
+ mod.append(modifier);
+ return p->value(mod);
}
// If that fails, try to find a static default string
diff --git a/rkward/plugin/rkformula.cpp b/rkward/plugin/rkformula.cpp
index a0f59d2b9..aff2ce10b 100644
--- a/rkward/plugin/rkformula.cpp
+++ b/rkward/plugin/rkformula.cpp
@@ -141,86 +141,86 @@ void RKFormula::typeChange (int id) {
makeModelString ();
}
-void RKFormula::makeModelString () {
- RK_TRACE (PLUGIN);
+void RKFormula::makeModelString() {
+ RK_TRACE(PLUGIN);
// first find out, whether multiple containers are involved and construct table string
multitable = false;
model_ok = false;
QString table_string, model_string, labels_string;
- mangled_names.clear ();
- RObject *dep_var = dependent->objectValue ();
+ mangled_names.clear();
+ RObject *dep_var = dependent->objectValue();
RObject *container = nullptr;
if (dep_var) {
model_ok = true;
}
- RObject::ObjectList vlist = fixed_factors->objectList ();
- if (vlist.empty ()) {
+ RObject::ObjectList vlist = fixed_factors->objectList();
+ if (vlist.empty()) {
model_ok = false;
}
if (dep_var) {
- container = dep_var->parentObject ();
- } else if (!vlist.empty ()) {
- container = vlist.first ()->parentObject ();
+ container = dep_var->parentObject();
+ } else if (!vlist.empty()) {
+ container = vlist.first()->parentObject();
}
- for (RObject::ObjectList::const_iterator it = vlist.cbegin (); it != vlist.cend (); ++it) {
- if ((*it)->parentObject () != container) {
+ for (RObject::ObjectList::const_iterator it = vlist.cbegin(); it != vlist.cend(); ++it) {
+ if ((*it)->parentObject() != container) {
multitable = true;
break;
}
}
if (multitable) {
- table_string = QLatin1String("data.frame (");
- if (dep_var) table_string.append (mangleName (dep_var) + '=' + dep_var->getFullName ());
- for (RObject::ObjectList::const_iterator it = vlist.cbegin (); it != vlist.cend (); ++it) {
- table_string.append (", " + mangleName ((*it)) + '=' + (*it)->getFullName ());
+ table_string = u"data.frame ("_s;
+ if (dep_var) table_string.append(mangleName(dep_var) + u'=' + dep_var->getFullName());
+ for (RObject::ObjectList::const_iterator it = vlist.cbegin(); it != vlist.cend(); ++it) {
+ table_string.append(u", "_s + mangleName((*it)) + u'=' + (*it)->getFullName());
}
- table_string.append (")");
+ table_string.append(u")"_s);
} else {
- if (container) table_string = container->getFullName ();
+ if (container) table_string = container->getFullName();
}
-
+
// construct model string
- model_string = mangleName (dep_var) + " ~ ";
+ model_string = mangleName(dep_var) + u" ~ "_s;
if (model_type == FullModel) {
- for (RObject::ObjectList::const_iterator it = vlist.cbegin (); it != vlist.cend (); ++it) {
- if (it != vlist.cbegin ()) model_string.append (" * ");
- model_string.append (mangleName (*it));
+ for (RObject::ObjectList::const_iterator it = vlist.cbegin(); it != vlist.cend(); ++it) {
+ if (it != vlist.cbegin()) model_string.append(u" * "_s);
+ model_string.append(mangleName(*it));
}
} else if (model_type == MainEffects) {
- for (RObject::ObjectList::const_iterator it = vlist.cbegin (); it != vlist.cend (); ++it) {
- if (it != vlist.cbegin ()) model_string.append (" + ");
- model_string.append (mangleName (*it));
+ for (RObject::ObjectList::const_iterator it = vlist.cbegin(); it != vlist.cend(); ++it) {
+ if (it != vlist.cbegin()) model_string.append(u" + "_s);
+ model_string.append(mangleName(*it));
}
- } else if (model_type == Custom) {
- if (interaction_map.empty ()) model_ok = false;
- for (InteractionMap::Iterator it = interaction_map.begin (); it != interaction_map.end (); ++it) {
- if (it != interaction_map.begin ()) {
- model_string.append (" + ");
+ } else if (model_type == Custom) {
+ if (interaction_map.empty()) model_ok = false;
+ for (InteractionMap::Iterator it = interaction_map.begin(); it != interaction_map.end(); ++it) {
+ if (it != interaction_map.begin()) {
+ model_string.append(u" + "_s);
}
- for (int i=0; i <= it.value ().level; ++i) {
+ for (int i = 0; i <= it.value().level; ++i) {
if (i) {
- model_string.append (":");
+ model_string.append(u":"_s);
}
- model_string.append (mangleName (it.value ().vars[i]));
+ model_string.append(mangleName(it.value().vars[i]));
}
}
}
// labels
- labels_string = QLatin1String("list (");
+ labels_string = u"list ("_s;
MangledNames::const_iterator it;
- for (it = mangled_names.cbegin (); it != mangled_names.cend (); ++it) {
- if (it != mangled_names.cbegin ()) {
- labels_string.append (", ");
+ for (it = mangled_names.cbegin(); it != mangled_names.cend(); ++it) {
+ if (it != mangled_names.cbegin()) {
+ labels_string.append(u", "_s);
}
- labels_string.append (it.key () + "=\"" + it.value ()->getDescription () + "\"");
+ labels_string.append(it.key() + u"=\""_s + it.value()->getDescription() + u'"');
}
- labels_string.append (")");
+ labels_string.append(u')');
- table->setValue (table_string);
- model->setValue (model_string);
- labels->setValue (labels_string);
- changed ();
+ table->setValue(table_string);
+ model->setValue(model_string);
+ labels->setValue(labels_string);
+ changed();
}
QString RKFormula::mangleName (RObject *var) {
@@ -287,7 +287,7 @@ void RKFormula::addButtonClicked () {
for (int j=0; j <= interactions[i].level; ++j) {
RK_DEBUG (PLUGIN, DL_DEBUG, "inserting interaction %d, level %d", i, j);
if (j) {
- dummy.append (" X ");
+ dummy.append(u" X "_s);
}
dummy.append (interactions[i].vars[j]->getShortName ());
}
@@ -398,13 +398,13 @@ bool RKFormula::isValid () {
return (model_ok);
}
-QStringList RKFormula::getUiLabelPair () const {
- RK_TRACE (PLUGIN);
+QStringList RKFormula::getUiLabelPair() const {
+ RK_TRACE(PLUGIN);
- QStringList ret (label_string);
- QString m = stripAccelerators (type_selector->checkedButton ()->text ());
- if (model_type == Custom) m.append (' ' + model->value ().toString ());
- ret.append (m);
+ QStringList ret(label_string);
+ QString m = stripAccelerators(type_selector->checkedButton()->text());
+ if (model_type == Custom) m.append(u' ' + model->value().toString());
+ ret.append(m);
return ret;
}
diff --git a/rkward/plugin/rkmatrixinput.cpp b/rkward/plugin/rkmatrixinput.cpp
index 6f914559b..ac052fa7c 100644
--- a/rkward/plugin/rkmatrixinput.cpp
+++ b/rkward/plugin/rkmatrixinput.cpp
@@ -76,10 +76,10 @@ RKMatrixInput::RKMatrixInput (const QDomElement& element, RKComponent* parent_co
model = new RKMatrixInputModel (this);
QString headers = xml->getStringAttribute (element, QStringLiteral("horiz_headers"), QString (), DL_INFO);
- if (!headers.isEmpty ()) model->horiz_header = headers.split (';');
+ if (!headers.isEmpty()) model->horiz_header = headers.split(u';');
else if (!headers.isNull ()) display->horizontalHeader ()->hide (); // attribute explicitly set to ""
headers = xml->getStringAttribute (element, QStringLiteral("vert_headers"), QString (), DL_INFO);
- if (!headers.isEmpty ()) model->vert_header = headers.split (';');
+ if (!headers.isEmpty()) model->vert_header = headers.split(u';');
else if (!headers.isNull ()) display->verticalHeader ()->hide ();
updateAll ();
display->setModel (model);
@@ -110,33 +110,33 @@ RKMatrixInput::~RKMatrixInput () {
RK_TRACE (PLUGIN);
}
-QVariant RKMatrixInput::value (const QString& modifier) {
- if (modifier.isEmpty () || (modifier == QLatin1String("cbind"))) {
+QVariant RKMatrixInput::value(const QString& modifier) {
+ if (modifier.isEmpty() || (modifier == QLatin1String("cbind"))) {
QStringList ret;
- for (int i = 0; i < column_count->intValue (); ++i) {
- ret.append ("\tc (" + makeColumnString (i, QStringLiteral(", ")) + ')');
+ for (int i = 0; i < column_count->intValue(); ++i) {
+ ret.append(u"\tc ("_s + makeColumnString(i, u", "_s) + u')');
}
- return QString ("cbind (\n" + ret.join (QStringLiteral(",\n")) + "\n)");
- } else if (modifier.startsWith (QLatin1String ("row."))) {
+ return QString(u"cbind (\n"_s + ret.join(u",\n"_s) + u"\n)"_s);
+ } else if (modifier.startsWith(QLatin1String("row."))) {
bool ok;
int row = QStringView(modifier).mid(4).toInt(&ok);
if ((row >= 0) && ok) {
- return (rowStrings (row));
+ return (rowStrings(row));
}
}
bool ok;
- int col = modifier.toInt (&ok);
+ int col = modifier.toInt(&ok);
if ((col >= 0) && ok) {
QStringList l;
- if (col < columns.size ()) l = columns[col].storage;
- while (l.size () < row_count->intValue ()) {
- l.append (QString ());
+ if (col < columns.size()) l = columns[col].storage;
+ while (l.size() < row_count->intValue()) {
+ l.append(QString());
}
- if (l.size () > row_count->intValue ()) l = l.mid (0, row_count->intValue ());
+ if (l.size() > row_count->intValue()) l = l.mid(0, row_count->intValue());
return l;
}
- return (QString ("Modifier '" + modifier + "' not recognized\n"));
+ return (QString(u"Modifier '"_s + modifier + u"' not recognized\n"_s));
}
bool RKMatrixInput::expandStorageForColumn (int column) {
@@ -180,13 +180,13 @@ void RKMatrixInput::setCellValue (int row, int column, const QString& value) {
Q_EMIT model->dataChanged(model->index(row, column), model->index(row, column));
}
-void RKMatrixInput::setColumnValue (int column, const QString& value) {
- RK_TRACE (PLUGIN);
+void RKMatrixInput::setColumnValue(int column, const QString& value) {
+ RK_TRACE(PLUGIN);
- if (!expandStorageForColumn (column)) return;
- columns[column].storage = value.split ('\t', Qt::KeepEmptyParts);
- updateColumn (column);
- Q_EMIT model->dataChanged (model->index(0, column), model->index(row_count->intValue() + trailing_rows, column));
+ if (!expandStorageForColumn(column)) return;
+ columns[column].storage = value.split(u'\t', Qt::KeepEmptyParts);
+ updateColumn(column);
+ Q_EMIT model->dataChanged(model->index(0, column), model->index(row_count->intValue() + trailing_rows, column));
}
void RKMatrixInput::updateColumn (int column) {
@@ -207,9 +207,9 @@ void RKMatrixInput::updateColumn (int column) {
updateAll ();
}
-QString pasteableValue (const QString &in, bool string) {
- if (string) return (RObject::rQuote (in));
- else if (in.isEmpty ()) return ("NA");
+QString pasteableValue(const QString &in, bool string) {
+ if (string) return (RObject::rQuote(in));
+ else if (in.isEmpty()) return (u"NA"_s);
else return in;
}
@@ -284,9 +284,9 @@ void RKMatrixInput::updateAll () {
tsv.append (col.cached_tab_joined_string);
}
for (; i < max_col; ++i) {
- tsv.append (QString (max_row, '\t'));
+ tsv.append(QString(max_row, u'\t'));
}
- tsv_data->setValue (tsv.join (QStringLiteral("\n")));
+ tsv_data->setValue(tsv.join(u'\n'));
updating_tsv_data = false;
@@ -327,19 +327,19 @@ void RKMatrixInput::dimensionPropertyChanged (RKComponentPropertyBase *property)
Q_EMIT model->layoutChanged();
}
-void RKMatrixInput::tsvPropertyChanged () {
+void RKMatrixInput::tsvPropertyChanged() {
if (updating_tsv_data) return;
updating_tsv_data = true;
- RK_TRACE (PLUGIN);
+ RK_TRACE(PLUGIN);
- columns.clear ();
- QStringList coldata = fetchStringValue (tsv_data).split ('\n', Qt::KeepEmptyParts);
- for (int i = 0; i < coldata.size (); ++i) {
- setColumnValue (i, coldata[i]);
+ columns.clear();
+ QStringList coldata = fetchStringValue(tsv_data).split(u'\n', Qt::KeepEmptyParts);
+ for (int i = 0; i < coldata.size(); ++i) {
+ setColumnValue(i, coldata[i]);
}
updating_tsv_data = false;
- updateAll ();
+ updateAll();
}
bool RKMatrixInput::isValueValid (const QString& value) const {
diff --git a/rkward/plugin/rkoptionset.cpp b/rkward/plugin/rkoptionset.cpp
index a94753acf..bcec83edd 100644
--- a/rkward/plugin/rkoptionset.cpp
+++ b/rkward/plugin/rkoptionset.cpp
@@ -24,7 +24,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../debug.h"
-#define KEYCOLUMN_UNINITIALIZED_VALUE QString ("___#!RK!___Keycol_uninitialized")
+#define KEYCOLUMN_UNINITIALIZED_VALUE QStringLiteral("___#!RK!___Keycol_uninitialized")
RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
@@ -91,9 +91,9 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
QString governor = xml->getStringAttribute (e, QStringLiteral("connect"), QString (), DL_INFO);
bool external = xml->getBoolAttribute (e, QStringLiteral("external"), false, DL_INFO);
- while (child_map.contains (id)) {
- RK_DEBUG (PLUGIN, DL_ERROR, "optionset already contains a property named %s. Renaming to _%s", qPrintable (id), qPrintable (id));
- id = '_' + id;
+ while (child_map.contains(id)) {
+ RK_DEBUG(PLUGIN, DL_ERROR, "optionset already contains a property named %s. Renaming to _%s", qPrintable(id), qPrintable(id));
+ id = u'_' + id;
}
ColumnInfo col_inf;
@@ -131,7 +131,7 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
keycolumn = nullptr;
} else {
updating = true;
- keycolumn->setValue (KEYCOLUMN_UNINITIALIZED_VALUE);
+ keycolumn->setValue(KEYCOLUMN_UNINITIALIZED_VALUE);
updating = false;
}
}
@@ -180,68 +180,68 @@ void RKOptionSet::fetchDefaults () {
contents_container->enablednessProperty ()->setBoolValue (rowCount () > 0); // no current row; Do this *after* fetching default values, however. Otherwise most values will *not* be read, as the element is disabled
}
-QString serializeList (const QStringList &list) {
+QString serializeList(const QStringList &list) {
QString ret;
- for (int i = 0; i < list.size (); ++i) {
- if (i > 0) ret.append ('\t');
- ret.append (RKCommonFunctions::escape (list[i]));
+ for (int i = 0; i < list.size(); ++i) {
+ if (i > 0) ret.append(u'\t');
+ ret.append(RKCommonFunctions::escape(list[i]));
}
return ret;
}
-QStringList unserializeList (const QString &serial) {
- QStringList ret = serial.split ('\t', Qt::KeepEmptyParts);
- for (int i = 0; i < ret.size (); ++i) {
- ret[i] = RKCommonFunctions::unescape (ret[i]);
+QStringList unserializeList(const QString &serial) {
+ QStringList ret = serial.split(u'\t', Qt::KeepEmptyParts);
+ for (int i = 0; i < ret.size(); ++i) {
+ ret[i] = RKCommonFunctions::unescape(ret[i]);
}
return ret;
}
-QString serializeMap (const RKComponent::PropertyValueMap &map) {
+QString serializeMap(const RKComponent::PropertyValueMap &map) {
QString ret;
RKComponent::PropertyValueMap::const_iterator it;
- for (it = map.constBegin (); it != map.constEnd (); ++it) {
- if (!ret.isEmpty ()) ret.append ('\t');
- ret.append (RKCommonFunctions::escape (it.key () + '=' + it.value ()));
+ for (it = map.constBegin(); it != map.constEnd(); ++it) {
+ if (!ret.isEmpty()) ret.append(u'\t');
+ ret.append(RKCommonFunctions::escape(it.key() + u'=' + it.value()));
}
return ret;
}
-RKComponent::PropertyValueMap unserializeMap (const QString &serial) {
+RKComponent::PropertyValueMap unserializeMap(const QString &serial) {
RKComponent::PropertyValueMap ret;
- QStringList l = serial.split ('\t', Qt::KeepEmptyParts);
- for (int i = 0; i < l.size (); ++i) {
+ QStringList l = serial.split(u'\t', Qt::KeepEmptyParts);
+ for (int i = 0; i < l.size(); ++i) {
QString &line = l[i];
- int sep = line.indexOf ('=');
- ret.insert (RKCommonFunctions::unescape (line.left (sep)), RKCommonFunctions::unescape (line.mid (sep+1)));
+ int sep = line.indexOf(u'=');
+ ret.insert(RKCommonFunctions::unescape(line.left(sep)), RKCommonFunctions::unescape(line.mid(sep + 1)));
}
return ret;
}
-void RKOptionSet::fetchPropertyValuesRecursive (PropertyValueMap *list, bool include_top_level, const QString &prefix, bool include_inactive_elements) const {
- RK_TRACE (PLUGIN);
- RK_ASSERT (include_top_level);
- RK_ASSERT (!include_inactive_elements);
+void RKOptionSet::fetchPropertyValuesRecursive(PropertyValueMap *list, bool include_top_level, const QString &prefix, bool include_inactive_elements) const {
+ RK_TRACE(PLUGIN);
+ RK_ASSERT(include_top_level);
+ RK_ASSERT(!include_inactive_elements);
QString serialization;
if (keycolumn) {
- serialization.append ("keys=" + serializeList (old_keys));
+ serialization.append(u"keys="_s + serializeList(old_keys));
}
- for (int r = 0; r < rows.size (); ++r) {
- if (!serialization.isEmpty ()) serialization.append ("\n");
+ for (int r = 0; r < rows.size(); ++r) {
+ if (!serialization.isEmpty()) serialization.append(u'\n');
if (r == active_row) {
- PropertyValueMap map; // current row may have changes which have not yet been stored to the state map
- contents_container->fetchPropertyValuesRecursive (&map);
- serialization.append ("_row=" + serializeMap (map));
+ PropertyValueMap map; // current row may have changes which have not yet been stored to the state map
+ contents_container->fetchPropertyValuesRecursive(&map);
+ serialization.append(u"_row="_s + serializeMap(map));
} else {
- serialization.append ("_row=" + serializeMap (rows[r].full_row_map));
+ serialization.append(u"_row="_s + serializeMap(rows[r].full_row_map));
}
}
- list->insert (prefix + "serialized", serialization);
+ list->insert(prefix + u"serialized"_s, serialization);
}
void RKOptionSet::serializationPropertyChanged (RKComponentPropertyBase* property) {
@@ -269,11 +269,11 @@ void RKOptionSet::serializationPropertyChanged (RKComponentPropertyBase* propert
QList<RowInfo> new_rows;
int row = 0;
- QStringList items = fetchStringValue (property).split ('\n');
+ QStringList items = fetchStringValue (property).split(u'\n');
bool keys_missing = (keycolumn != nullptr);
- for (int i = 0; i < items.size (); ++i) {
+ for (int i = 0; i < items.size(); ++i) {
const QString &item = items[i];
- int sep = item.indexOf ('=');
+ int sep = item.indexOf(u'=');
if (sep < 0) {
RK_DEBUG (PLUGIN, DL_WARNING, "Bad format while trying to de-serialize optionset, line %d", i);
continue;
diff --git a/rkward/plugin/rkpluginbrowser.cpp b/rkward/plugin/rkpluginbrowser.cpp
index 165f479e0..39814f3e1 100644
--- a/rkward/plugin/rkpluginbrowser.cpp
+++ b/rkward/plugin/rkpluginbrowser.cpp
@@ -48,7 +48,7 @@ RKPluginBrowser::RKPluginBrowser (const QDomElement &element, RKComponent *paren
selector = new GetFileNameWidget (this, mode, only_local, label_string, i18n ("Select"), xml->getStringAttribute (element, QStringLiteral("initial"), QString (), DL_INFO));
QString filter = xml->getStringAttribute (element, QStringLiteral("filter"), QString (), DL_INFO);
if (!filter.isEmpty ()) {
- filter.append ("\n*|All files (*)");
+ filter.append(u"\n*|All files (*)"_s);
selector->setFilter (filter);
}
connect (selector, &GetFileNameWidget::locationChanged, this, &RKPluginBrowser::textChangedFromUi);
diff --git a/rkward/plugin/rkpreviewbox.cpp b/rkward/plugin/rkpreviewbox.cpp
index 998de9529..5667264ac 100644
--- a/rkward/plugin/rkpreviewbox.cpp
+++ b/rkward/plugin/rkpreviewbox.cpp
@@ -59,21 +59,21 @@ RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_comp
box_layout->addWidget(manager->inlineStatusWidget());
// prepare placement
- placement_command = QLatin1String(".rk.with.window.hints ({");
- placement_end = QLatin1String("\n}, ");
- if (placement == AttachedPreview) placement_end.append ("\"attached\"");
- else if (placement == DetachedPreview) placement_end.append ("\"detached\"");
- else placement_end.append ("\"\"");
- placement_end.append (", " + idprop + ", style=\"preview\")");
+ placement_command = u".rk.with.window.hints ({"_s;
+ placement_end = u"\n}, "_s;
+ if (placement == AttachedPreview) placement_end.append(u"\"attached\""_s);
+ else if (placement == DetachedPreview) placement_end.append(u"\"detached\""_s);
+ else placement_end.append(u"\"\""_s);
+ placement_end.append(u", "_s + idprop + u", style=\"preview\")"_s);
if (placement == DockedPreview) {
RKStandardComponent *uicomp = topmostStandardComponent ();
if (uicomp) {
uicomp->addDockedPreview(state, toggle_preview_box->title(), manager);
if (preview_mode == OutputPreview) {
- RInterface::issueCommand ("local ({\n"
+ RInterface::issueCommand(QStringLiteral("local ({\n"
"outfile <- tempfile (fileext='.html')\n"
- "rk.assign.preview.data(" + idprop + ", list (filename=outfile, on.delete=function (id) {\n"
+ "rk.assign.preview.data(") + idprop + QStringLiteral(", list (filename=outfile, on.delete=function (id) {\n"
" oldfile <- rk.get.output.html.file()\n"
" rk.flush.output(outfile, ask=FALSE)\n"
" unlink(outfile)\n"
@@ -81,10 +81,10 @@ RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_comp
"}))\n"
"oldfile <- rk.set.output.html.file (outfile, style='preview') # for initialization\n"
"rk.set.output.html.file (oldfile)\n"
- "})\n" + placement_command + "rk.show.html(rk.get.preview.data (" + idprop + ")$filename)" + placement_end, RCommand::Plugin | RCommand::Sync);
+ "})\n") + placement_command + u"rk.show.html(rk.get.preview.data ("_s + idprop + u")$filename)"_s + placement_end, RCommand::Plugin | RCommand::Sync);
} else {
// For all others, create an empty data.frame as dummy. Even for custom docked previews it has the effect of initializing the preview area with _something_.
- RInterface::issueCommand ("local ({\nrk.assign.preview.data(" + idprop + ", data.frame ())\n})\n" + placement_command + "rk.edit(rkward::.rk.variables$.rk.preview.data[[" + idprop + "]])" + placement_end, RCommand::Plugin | RCommand::Sync);
+ RInterface::issueCommand(u"local ({\nrk.assign.preview.data("_s + idprop + u", data.frame ())\n})\n"_s + placement_command + u"rk.edit(rkward::.rk.variables$.rk.preview.data[["_s + idprop + u"]])"_s + placement_end, RCommand::Plugin | RCommand::Sync);
}
// A bit of a hack: For now, in wizards, docked previews are always active, and control boxes are meaningless.
@@ -168,56 +168,67 @@ void RKPreviewBox::tryPreview () {
}
}
-void RKPreviewBox::tryPreviewNow () {
- RK_TRACE (PLUGIN);
+void RKPreviewBox::tryPreviewNow() {
+ RK_TRACE(PLUGIN);
if (!code_property) return;
- ComponentStatus s = parentComponent ()->recursiveStatus ();
+ ComponentStatus s = parentComponent()->recursiveStatus();
if (s != Satisfied) {
- manager->setNoPreviewAvailable ();
- if (s == Processing) tryPreview ();
+ manager->setNoPreviewAvailable();
+ if (s == Processing) tryPreview();
return;
}
- if (!manager->needsCommand ()) return; // if the last plot is not done, yet, wait before starting the next.
+ if (!manager->needsCommand()) return; // if the last plot is not done, yet, wait before starting the next.
preview_active = true;
RCommand *command;
if (preview_mode == PlotPreview) {
- RInterface::issueCommand (placement_command + ".rk.startPreviewDevice (" + idprop + ')' + placement_end, RCommand::Plugin | RCommand::Sync, QString ());
+ RInterface::issueCommand(placement_command + u".rk.startPreviewDevice ("_s + idprop + u')' + placement_end, RCommand::Plugin | RCommand::Sync, QString());
// creating window generates warnings, sometimes. Don't make those part of the warnings shown for the preview -> separate command for the actual plot.
- command = new RCommand ("local({\n" + code_property->preview () + "})\n", RCommand::Plugin | RCommand::Sync);
+ command = new RCommand(u"local({\n"_s + code_property->preview() + u"})\n"_s, RCommand::Plugin | RCommand::Sync);
} else if (preview_mode == DataPreview) {
- command = new RCommand ("local({try({\n" + code_property->preview () + "\n})\nif(!exists(\"preview_data\",inherits=FALSE)) preview_data <- data.frame ('ERROR')\nrk.assign.preview.data(" + idprop + ", preview_data)\n})\n" + placement_command + "rk.edit(rkward::.rk.variables$.rk.preview.data[[" + idprop + "]])" + placement_end, RCommand::Plugin | RCommand::Sync);
+ command =
+ new RCommand(u"local({try({\n"_s + code_property->preview() +
+ u"\n})\nif(!exists(\"preview_data\",inherits=FALSE)) preview_data <- data.frame ('ERROR')\nrk.assign.preview.data("_s + idprop +
+ u", preview_data)\n})\n"_s + placement_command + u"rk.edit(rkward::.rk.variables$.rk.preview.data[["_s + idprop + u"]])"_s + placement_end,
+ RCommand::Plugin | RCommand::Sync);
} else if (preview_mode == OutputPreview) {
- command = new RCommand (placement_command + "local({\n"
- " oldfile <- rk.set.output.html.file(rk.get.preview.data (" + idprop + ")$filename, style='preview')\n"
- " rk.flush.output(ask=FALSE, style='preview')\n"
- " local({try({\n" + code_property->preview () + "\n})})\n" // nested local to make sure "oldfile" is not overwritten.
- " rk.set.output.html.file(oldfile)\n})\n"
- "rk.show.html(rk.get.preview.data (" + idprop + ")$filename)" + placement_end, RCommand::Plugin | RCommand::Sync);
+ command = new RCommand(placement_command +
+ u"local({\n"_s
+ u" oldfile <- rk.set.output.html.file(rk.get.preview.data ("_s +
+ idprop +
+ u")$filename, style='preview')\n"_s
+ u" rk.flush.output(ask=FALSE, style='preview')\n"_s
+ u" local({try({\n"_s +
+ code_property->preview() +
+ u"\n})})\n"_s // nested local to make sure "oldfile" is not overwritten.
+ u" rk.set.output.html.file(oldfile)\n})\n"_s
+ u"rk.show.html(rk.get.preview.data ("_s +
+ idprop + u")$filename)"_s + placement_end,
+ RCommand::Plugin | RCommand::Sync);
} else {
- command = new RCommand ("local({\n" + placement_command + code_property->preview () + placement_end + "})\n", RCommand::Plugin | RCommand::Sync);
+ command = new RCommand(u"local({\n"_s + placement_command + code_property->preview() + placement_end + u"})\n"_s, RCommand::Plugin | RCommand::Sync);
}
- manager->setCommand (command);
+ manager->setCommand(command);
}
-void RKPreviewBox::killPreview (bool cleanup) {
- RK_TRACE (PLUGIN);
+void RKPreviewBox::killPreview(bool cleanup) {
+ RK_TRACE(PLUGIN);
if (!(preview_active || cleanup)) return;
preview_active = false;
if (cleanup) {
QString command;
- if (preview_mode == PlotPreview) command = ".rk.killPreviewDevice (" + idprop + ")\n";
- command += "rk.discard.preview.data (" + idprop + ')';
- RInterface::issueCommand (command, RCommand::Plugin | RCommand::Sync);
+ if (preview_mode == PlotPreview) command = u".rk.killPreviewDevice ("_s + idprop + u")\n"_s;
+ command += u"rk.discard.preview.data ("_s + idprop + u')';
+ RInterface::issueCommand(command, RCommand::Plugin | RCommand::Sync);
}
if (placement != DockedPreview) {
- RKMDIWindow *window = RKWorkplace::mainWorkplace ()->getNamedWindow (manager->previewId ());
- if (window) window->deleteLater ();
+ RKMDIWindow *window = RKWorkplace::mainWorkplace()->getNamedWindow(manager->previewId());
+ if (window) window->deleteLater();
}
}
diff --git a/rkward/plugin/rkstandardcomponent.cpp b/rkward/plugin/rkstandardcomponent.cpp
index 69c1dd4f0..339e14487 100644
--- a/rkward/plugin/rkstandardcomponent.cpp
+++ b/rkward/plugin/rkstandardcomponent.cpp
@@ -92,7 +92,7 @@ RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget
// initialize the script backend with the code-template
QDomElement element = xml->getChildElement (doc_element, QStringLiteral("code"), DL_WARNING);
if (element.hasAttribute (QStringLiteral("file"))) {
- QString dummy = QFileInfo (filename).path() + '/' + xml->getStringAttribute (element, QStringLiteral("file"), QStringLiteral("code.js"), DL_WARNING);
+ QString dummy = QFileInfo (filename).path() + u'/' + xml->getStringAttribute (element, QStringLiteral("file"), QStringLiteral("code.js"), DL_WARNING);
backend = new QtScriptBackend (dummy, xml->messageCatalog ());
} else {
@@ -110,7 +110,7 @@ RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget
// check for existence of help file
element = xml->getChildElement(doc_element, QStringLiteral("help"), DL_WARNING);
- QString dummy = QFileInfo(filename).path() + '/' + xml->getStringAttribute(element, QStringLiteral("file"), QStringLiteral("::nosuchfile::"), DL_INFO);
+ QString dummy = QFileInfo(filename).path() + u'/' + xml->getStringAttribute(element, QStringLiteral("file"), QStringLiteral("::nosuchfile::"), DL_INFO);
have_help = QFileInfo::exists(dummy);
update_pending = false;
@@ -625,7 +625,7 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
} else if ((e.tagName () == QLatin1String ("varslot")) || (e.tagName () == QLatin1String ("valueslot"))) {
widget = new RKVarSlot (e, component (), parent_widget);
QString source = xml.getStringAttribute (e, QStringLiteral("source_property"), QString (), DL_INFO);
- if (source.isEmpty ()) source = xml.getStringAttribute (e, QStringLiteral("source"), QStringLiteral("#noid#"), DL_WARNING) + ".selected";
+ if (source.isEmpty ()) source = xml.getStringAttribute (e, QStringLiteral("source"), QStringLiteral("#noid#"), DL_WARNING) + u".selected"_s;
addConnection (id, QStringLiteral("source"), source, QString (), false, e);
} else if ((e.tagName () == QLatin1String ("valueselector")) || (e.tagName () == QLatin1String ("select"))) {
widget = new RKValueSelector (e, component (), parent_widget);
@@ -753,7 +753,7 @@ void RKComponentBuilder::parseLogic (const QDomElement &element, XMLHelper &xml,
} else if (mode == RKComponentPropertyConvert::Range) {
convert->setRange (xml.getDoubleAttribute (cel, QStringLiteral("min"), -FLT_MAX, DL_INFO), xml.getDoubleAttribute (cel, QStringLiteral("max"), FLT_MAX, DL_INFO));
}
- switch_convert_sources.insert (convert, xml.getStringAttribute (cel, QStringLiteral("sources"), QString (), DL_WARNING).split (';'));
+ switch_convert_sources.insert(convert, xml.getStringAttribute(cel, QStringLiteral("sources"), QString(), DL_WARNING).split(u';'));
convert->setRequireTrue (xml.getBoolAttribute (cel, QStringLiteral("require_true"), false, DL_INFO));
component ()->addChild (id, convert);
} else if (tagName == QLatin1String ("switch")) {
@@ -826,17 +826,18 @@ void RKComponentBuilder::parseLogic (const QDomElement &element, XMLHelper &xml,
}
}
-void RKComponentBuilder::addConnection (const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property, bool reconcile, const QDomElement &origin) {
- RK_TRACE (PLUGIN);
+void RKComponentBuilder::addConnection(const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property,
+ bool reconcile, const QDomElement &origin) {
+ RK_TRACE(PLUGIN);
RKComponentPropertyConnection conn;
conn.client_property = client_id;
- if (!client_property.isEmpty ()) conn.client_property += '.' + client_property;
+ if (!client_property.isEmpty()) conn.client_property += u'.' + client_property;
conn.governor_property = governor_id;
- if (!governor_property.isEmpty ()) conn.governor_property += '.' + governor_property;
+ if (!governor_property.isEmpty()) conn.governor_property += u'.' + governor_property;
conn.reconcile = reconcile;
conn.origin = origin;
- connection_list.append (conn);
+ connection_list.append(conn);
}
void RKComponentBuilder::makeConnections () {
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 7da089404..8093903e4 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -301,33 +301,34 @@ void RKStandardComponentGUI::showEvent (QShowEvent *e) {
}
}
-void RKStandardComponentGUI::ok () {
- RK_TRACE (PLUGIN);
+void RKStandardComponentGUI::ok() {
+ RK_TRACE(PLUGIN);
- RK_ASSERT (code_property->isValid ());
+ RK_ASSERT(code_property->isValid());
QString command = QStringLiteral("local({\n");
- command.append (code_property->preprocess ());
- command.append (code_property->calculate ());
- command.append (code_property->printout ());
- command.append ("})\n");
- RInterface::issueCommand (new RCommand (command, RCommand::Plugin | RCommand::CCOutput | RCommand::ObjectListUpdate), component->commandChain ());
+ command.append(code_property->preprocess());
+ command.append(code_property->calculate());
+ command.append(code_property->printout());
+ command.append(u"})\n"_s);
+ RInterface::issueCommand(new RCommand(command, RCommand::Plugin | RCommand::CCOutput | RCommand::ObjectListUpdate), component->commandChain());
// re-run link
// This should be run in a separate command, in case the above command bails out with an error. Even in that case, the re-run link should be printed.
- command.clear ();
- RKComponentHandle *handle = RKComponentMap::getComponentHandle (component->getId ());
- if (handle && handle->isAccessible ()) {
+ command.clear();
+ RKComponentHandle *handle = RKComponentMap::getComponentHandle(component->getId());
+ if (handle && handle->isAccessible()) {
RKComponent::PropertyValueMap map;
- component->serializeState (&map);
- command.append (".rk.rerun.plugin.link(plugin=\"" + component->getId () + "\", settings=\"" + RKCommonFunctions::escape (RKComponent::valueMapToString (map)) + "\", label=\"" + i18n ("Run again") + "\")\n");
+ component->serializeState(&map);
+ command.append(u".rk.rerun.plugin.link(plugin=\""_s + component->getId() + u"\", settings=\""_s +
+ RKCommonFunctions::escape(RKComponent::valueMapToString(map)) + u"\", label=\""_s + i18n("Run again") + u"\")\n"_s);
// NOTE: the serialized state is quote-escape *again* for passing to R.
}
// separator line
- command.append (".rk.make.hr()\n");
- RInterface::issueCommand (new RCommand (command, RCommand::Plugin | RCommand::ObjectListUpdate | RCommand::Silent), component->commandChain ());
+ command.append(u".rk.make.hr()\n"_s);
+ RInterface::issueCommand(new RCommand(command, RCommand::Plugin | RCommand::ObjectListUpdate | RCommand::Silent), component->commandChain());
- if (auto_close_box->isChecked ()) cancel ();
+ if (auto_close_box->isChecked()) cancel();
}
void RKStandardComponentGUI::cancel () {
@@ -406,11 +407,11 @@ void RKStandardComponentGUI::copyCode () {
code_display->copy ();
}
-void RKStandardComponentGUI::help () {
- RK_TRACE (PLUGIN);
+void RKStandardComponentGUI::help() {
+ RK_TRACE(PLUGIN);
- QString path = component->getId ().split (QStringLiteral("::")).join (QStringLiteral("/"));
- RKWorkplace::mainWorkplace ()->openHelpWindow (QUrl ("rkward://component/" + path));
+ QString path = component->getId().split(QStringLiteral("::")).join(QStringLiteral("/"));
+ RKWorkplace::mainWorkplace()->openHelpWindow(QUrl(u"rkward://component/"_s + path));
}
void RKStandardComponentGUI::closeEvent (QCloseEvent *e) {
@@ -439,18 +440,19 @@ void RKStandardComponentGUI::updateCode () {
code_update_timer->start (0);
}
-void RKStandardComponentGUI::updateCodeNow () {
- RK_TRACE (PLUGIN);
+void RKStandardComponentGUI::updateCodeNow() {
+ RK_TRACE(PLUGIN);
static bool was_valid = false;
- if (was_valid) code_display->saveScrollPosition ();
+ if (was_valid) code_display->saveScrollPosition();
- if (!code_property->isValid ()) {
- code_display->setText (i18n ("Processing. Please wait"));
- RK_DEBUG (PLUGIN, DL_DEBUG, "code not ready to be displayed: pre %d, cal %d, pri %d", !code_property->preprocess ().isNull (), !code_property->calculate ().isNull (), !code_property->printout ().isNull ());
+ if (!code_property->isValid()) {
+ code_display->setText(i18n("Processing. Please wait"));
+ RK_DEBUG(PLUGIN, DL_DEBUG, "code not ready to be displayed: pre %d, cal %d, pri %d", !code_property->preprocess().isNull(),
+ !code_property->calculate().isNull(), !code_property->printout().isNull());
was_valid = false;
} else {
- code_display->setText ("local({\n" + code_property->preprocess () + code_property->calculate () + code_property->printout () + "})\n");
- code_display->restoreScrollPosition ();
+ code_display->setText(u"local({\n"_s + code_property->preprocess() + code_property->calculate() + code_property->printout() + u"})\n"_s);
+ code_display->restoreScrollPosition();
was_valid = true;
}
}
diff --git a/rkward/plugin/rkvarslot.cpp b/rkward/plugin/rkvarslot.cpp
index 99787539d..dd5672e57 100644
--- a/rkward/plugin/rkvarslot.cpp
+++ b/rkward/plugin/rkvarslot.cpp
@@ -97,10 +97,13 @@ RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component,
if (mode == Varslot) {
// initialize filters
- static_cast<RKComponentPropertyRObjects*> (available)->setClassFilter (xml->getStringAttribute (element, QStringLiteral("classes"), QString (), DL_INFO).split (' ', Qt::SkipEmptyParts));
- static_cast<RKComponentPropertyRObjects*> (available)->setTypeFilter (xml->getStringAttribute (element, QStringLiteral("types"), QString (), DL_INFO).split (' ', Qt::SkipEmptyParts));
- static_cast<RKComponentPropertyRObjects*> (available)->setDimensionFilter (xml->getIntAttribute (element, QStringLiteral("num_dimensions"), 0, DL_INFO), xml->getIntAttribute (element, QStringLiteral("min_length"), 0, DL_INFO), xml->getIntAttribute (element, QStringLiteral("max_length"), INT_MAX, DL_INFO));
- static_cast<RKComponentPropertyRObjects*> (available)->setObjectProblemsAreErrors (false);
+ static_cast<RKComponentPropertyRObjects*>(available)->setClassFilter(xml->getStringAttribute(element, QStringLiteral("classes"), QString(), DL_INFO).split(u' ', Qt::SkipEmptyParts));
+ static_cast<RKComponentPropertyRObjects*>(available)->setTypeFilter(xml->getStringAttribute(element, QStringLiteral("types"), QString(), DL_INFO).split(u' ', Qt::SkipEmptyParts));
+ static_cast<RKComponentPropertyRObjects*>(available)->setDimensionFilter(
+ xml->getIntAttribute(element, QStringLiteral("num_dimensions"), 0, DL_INFO),
+ xml->getIntAttribute(element, QStringLiteral("min_length"), 0, DL_INFO),
+ xml->getIntAttribute(element, QStringLiteral("max_length"), INT_MAX, DL_INFO));
+ static_cast<RKComponentPropertyRObjects*>(available)->setObjectProblemsAreErrors(false);
}
available->setStripDuplicates (!xml->getBoolAttribute (element, QStringLiteral("allow_duplicates"), false, DL_INFO));
setRequired (xml->getBoolAttribute (element, QStringLiteral("required"), false, DL_INFO));
More information about the rkward-tracker
mailing list