[education/rkward/kf5] /: Port some foreach usage
Thomas Friedrichsmeier
null at kde.org
Wed Apr 10 16:12:08 BST 2024
Git commit 78f0c5429373ead2e06edf6d73fe904046e3c3c1 by Thomas Friedrichsmeier, on behalf of Carl Schwan.
Committed on 01/04/2024 at 11:45.
Pushed by tfry into branch 'kf5'.
Port some foreach usage
M +1 -1 CMakeLists.txt
M +1 -1 rkward/core/robject.cpp
M +1 -1 rkward/core/robjectlist.h
M +1 -1 rkward/dataeditor/rktextmatrix.h
M +1 -0 rkward/dataeditor/twintable.cpp
M +1 -1 rkward/dialogs/rkerrordialog.h
M +0 -1 rkward/misc/rkcommonfunctions.h
M +1 -1 rkward/misc/rkspinbox.h
M +2 -1 rkward/misc/rkxmlguisyncer.cpp
M +1 -1 rkward/plugin/CMakeLists.txt
M +8 -7 rkward/plugin/rkcomponentmap.cpp
M +1 -1 rkward/plugin/rkcomponentmap.h
M +3 -7 rkward/plugin/rkcomponentproperties.cpp
M +1 -1 rkward/plugin/rkvalueselector.cpp
M +1 -1 rkward/rbackend/rcommand.h
M +2 -2 rkward/rbackend/rkrbackendprotocol_shared.h
M +5 -5 rkward/rbackend/rkrinterface.h
M +10 -8 rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
M +1 -1 rkward/rkconsole.cpp
M +1 -1 rkward/settings/CMakeLists.txt
M +1 -1 rkward/settings/rksettingsmodule.h
M +3 -3 rkward/settings/rksettingsmodulecommandeditor.cpp
M +4 -2 rkward/settings/rksettingsmoduleoutput.cpp
M +7 -5 rkward/settings/rksettingsmoduleplugins.cpp
M +2 -2 rkward/settings/rksettingsmoduler.cpp
M +1 -1 rkward/windows/rkmdiwindow.cpp
M +3 -3 rkward/windows/rkmdiwindow.h
https://invent.kde.org/education/rkward/-/commit/78f0c5429373ead2e06edf6d73fe904046e3c3c1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b790c50ea..2e8012bbb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ ENDIF(FORCE_PRETTY_MAKEFILE)
ADD_DEFINITIONS(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
-remove_definitions(-DQT_NO_CAST_FROM_ASCII) # TODO remove to compley to KDECompilerSettings
+remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_FOREACH) # TODO remove to compley to KDECompilerSettings
#uncomment the line below to save ~250-350kB in object size
#ADD_DEFINITIONS(-DRKWARD_NO_TRACE)
diff --git a/rkward/core/robject.cpp b/rkward/core/robject.cpp
index 2b5a4f8f4..b55f5c5af 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -316,7 +316,7 @@ void RObject::fetchMoreIfNeeded (int levels) {
if (levels <= 0) return;
if (!isContainer ()) return;
const RObjectMap children = static_cast<RContainerObject*> (this)->childmap;
- foreach (RObject* child, children) {
+ for (RObject* child : children) {
child->fetchMoreIfNeeded (levels - 1);
}
}
diff --git a/rkward/core/robjectlist.h b/rkward/core/robjectlist.h
index 65bc6b9ff..5c6d68c10 100644
--- a/rkward/core/robjectlist.h
+++ b/rkward/core/robjectlist.h
@@ -54,7 +54,7 @@ public:
/** detach the given list of packages (if the packages are loaded, and safe to remove)
@returns a list of error messages (usually empty) */
- QStringList detachPackages (const QStringList &packages, RCommandChain *chain = 0, RKInlineProgressControl *control = 0);
+ QStringList detachPackages (const QStringList &packages, RCommandChain *chain = nullptr, RKInlineProgressControl *control = nullptr);
/** A pseudo object containing as children all loaded namespaces which do not belong to a package on the search path */
RKOrphanNamespacesObject* orphanNamespacesObject () const { return orphan_namespaces; };
QString getObjectDescription () const override;
diff --git a/rkward/dataeditor/rktextmatrix.h b/rkward/dataeditor/rktextmatrix.h
index 61d9def3a..4ce4462fc 100644
--- a/rkward/dataeditor/rktextmatrix.h
+++ b/rkward/dataeditor/rktextmatrix.h
@@ -21,7 +21,7 @@ public:
~RKTextMatrix ();
static RKTextMatrix matrixFromClipboard ();
- static RKTextMatrix matrixFromSeparatedValues (const QString& text, const QRegularExpression &tab = {"\t"}, const QChar& brk='\n');
+ static RKTextMatrix matrixFromSeparatedValues (const QString& text, const QRegularExpression &tab = QRegularExpression(QStringLiteral("\t")), const QChar& brk = QLatin1Char('\n'));
QString toTabSeparatedValues () const;
void copyToClipboard () const;
diff --git a/rkward/dataeditor/twintable.cpp b/rkward/dataeditor/twintable.cpp
index 5e2585dc4..f8de42c78 100644
--- a/rkward/dataeditor/twintable.cpp
+++ b/rkward/dataeditor/twintable.cpp
@@ -21,6 +21,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <QVBoxLayout>
#include <QHeaderView>
#include <QApplication>
+#include <QActionGroup>
#include "twintablemember.h"
#include "rkvareditmodel.h"
diff --git a/rkward/dialogs/rkerrordialog.h b/rkward/dialogs/rkerrordialog.h
index 968976aff..b5f8f558f 100644
--- a/rkward/dialogs/rkerrordialog.h
+++ b/rkward/dialogs/rkerrordialog.h
@@ -16,7 +16,7 @@ namespace RKErrorDialog {
/** Displays an error message with a button "Report bug" */
void reportableErrorMessage (QWidget *parent_widget, const QString &user_message, const QString &details, const QString &caption, const QString &message_code);
/** Open "Report bug" dialog */
- void reportBug (QWidget *parent_widget = 0, const QString &message_info=QString ());
+ void reportBug (QWidget *parent_widget = nullptr, const QString &message_info=QString ());
};
#endif
diff --git a/rkward/misc/rkcommonfunctions.h b/rkward/misc/rkcommonfunctions.h
index e5dd12578..7fd1b1244 100644
--- a/rkward/misc/rkcommonfunctions.h
+++ b/rkward/misc/rkcommonfunctions.h
@@ -11,7 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <QRect>
#include <QString>
-class QStringList;
class QDomNode;
class KXMLGUIClient;
class QWidget;
diff --git a/rkward/misc/rkspinbox.h b/rkward/misc/rkspinbox.h
index 1f4039532..455168884 100644
--- a/rkward/misc/rkspinbox.h
+++ b/rkward/misc/rkspinbox.h
@@ -22,7 +22,7 @@ class RKSpinBox : public QSpinBox {
Q_OBJECT
public:
/** constructor. Use on of setIntMode or setRealMode to initialize the Spinbox! */
- explicit RKSpinBox (QWidget *parent = 0);
+ explicit RKSpinBox (QWidget *parent = nullptr);
/** dtor */
~RKSpinBox ();
diff --git a/rkward/misc/rkxmlguisyncer.cpp b/rkward/misc/rkxmlguisyncer.cpp
index 3a7c1ed3d..c2401b673 100644
--- a/rkward/misc/rkxmlguisyncer.cpp
+++ b/rkward/misc/rkxmlguisyncer.cpp
@@ -50,7 +50,8 @@ void RKXMLGUISyncer::watchXMLGUIClientUIrc (KXMLGUIClient *client, bool recursiv
}
if (recursive) {
- foreach (KXMLGUIClient *child, client->childClients ()) {
+ const auto childs = client->childClients ();
+ for (KXMLGUIClient *child : childs) {
watchXMLGUIClientUIrc (child, true);
}
}
diff --git a/rkward/plugin/CMakeLists.txt b/rkward/plugin/CMakeLists.txt
index 8a627dd45..7cf20427b 100644
--- a/rkward/plugin/CMakeLists.txt
+++ b/rkward/plugin/CMakeLists.txt
@@ -36,4 +36,4 @@ SET(plugin_STAT_SRCS
)
ADD_LIBRARY(plugin STATIC ${plugin_STAT_SRCS})
-TARGET_LINK_LIBRARIES(plugin Qt6::Widgets KF6::TextEditor KF6::WindowSystem)
+TARGET_LINK_LIBRARIES(plugin Qt6::Widgets KF6::TextEditor KF6::WindowSystem KF6::I18n)
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index fc1770790..db1b6f258 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -330,12 +330,12 @@ void RKComponentGUIXML::clearOverrides () {
////////////////////////////// Bhttp://apps.sourceforge.net/mediawiki/rkward/nfs/project/r/rk/rkward/6/6d/RKWardApplicationDetached.pngEGIN RKComponentMap /////////////////////////////////////
// static members
-RKComponentMap *RKComponentMap::component_map = 0;
+RKComponentMap *RKComponentMap::component_map = nullptr;
void RKComponentMap::initialize () {
RK_TRACE (PLUGIN);
- RK_ASSERT (component_map == 0);
+ RK_ASSERT (component_map == nullptr);
component_map = new RKComponentMap ();
}
@@ -388,7 +388,7 @@ RKComponentGUIXML *RKComponentMap::getContext (const QString &id) {
if (context) return context;
RK_DEBUG (PLUGIN, DL_WARNING, "no such context %s", id.toLatin1 ().data ());
- return (0);
+ return nullptr;
}
RKComponentHandle* RKComponentMap::getComponentHandle (const QString &id) {
@@ -398,7 +398,7 @@ RKComponentHandle* RKComponentMap::getComponentHandle (const QString &id) {
if (handle) return handle;
RK_DEBUG (PLUGIN, DL_WARNING, "no such component %s", id.toLatin1 ().data ());
- return (0);
+ return nullptr;
}
RKComponentHandle* RKComponentMap::getComponentHandleLocal (const QString &id) {
@@ -466,7 +466,7 @@ bool RKComponentMap::invokeComponent (const QString &component_id, const QString
return false;
}
- RKStandardComponent *component = handle->invoke (0, 0);
+ RKStandardComponent *component = handle->invoke (nullptr, nullptr);
RK_ASSERT (component);
RKComponent::PropertyValueMap state;
@@ -542,7 +542,8 @@ void RKComponentMap::finalizeAll () {
finalize ();
setXMLGUIBuildDocument (gui_xml);
actionCollection ()->readSettings ();
- foreach (RKComponentGUIXML *ctx, getMap()->contexts) {
+ const auto contexts = getMap()->contexts;
+ for (RKComponentGUIXML *ctx : contexts) {
ctx->finalize ();
}
}
@@ -666,7 +667,7 @@ RKPluginMapParseResult RKComponentMap::addPluginMap (const QString& plugin_map_f
}
}
- foreach (const QString &id, depfailed_local_components) {
+ for (const QString &id : std::as_const(depfailed_local_components)) {
if (local_components.contains (id)) continue;
ret.addAndPrintError (DL_ERROR, i18n ("Component '%1' is not available in a version compatible with this version of RKWard", id));
}
diff --git a/rkward/plugin/rkcomponentmap.h b/rkward/plugin/rkcomponentmap.h
index d8fd85ddf..8c22e296a 100644
--- a/rkward/plugin/rkcomponentmap.h
+++ b/rkward/plugin/rkcomponentmap.h
@@ -235,7 +235,7 @@ public:
};
/** invokes the specified component as toplevel
@param message If a non-null pointer to QString is given, error messages are written into this string *instead* of being displayed */
- static bool invokeComponent (const QString &component_id, const QStringList &serialized_settings, ComponentInvocationMode submit_mode = ManualSubmit, QString *message=0, RCommandChain *in_chain = 0);
+ static bool invokeComponent (const QString &component_id, const QStringList &serialized_settings, ComponentInvocationMode submit_mode = ManualSubmit, QString *message = nullptr, RCommandChain *in_chain = nullptr);
/** @returns for rk.list.plugins(): Return a list of all currently registered component ids, their context, menu, and label (i.e. current four strings per component) */
QStringList listPlugins ();
void setPluginStatus (const QStringList &ids, const QStringList &contexts, const QStringList& visible);
diff --git a/rkward/plugin/rkcomponentproperties.cpp b/rkward/plugin/rkcomponentproperties.cpp
index 9f3b59a3c..cda17b800 100644
--- a/rkward/plugin/rkcomponentproperties.cpp
+++ b/rkward/plugin/rkcomponentproperties.cpp
@@ -887,12 +887,8 @@ bool RKComponentPropertyRObjects::setObjectValueSilent (RObject* object) {
RK_TRACE (PLUGIN);
problems.clear ();
-#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
- QSet<RObject*> unique(object_list.constBegin(), object_list.constEnd());
-#else
- QSet<RObject*> unique = object_list.toSet ();
-#endif
- foreach (RObject *obj, unique) {
+ const QSet<RObject*> unique(object_list.constBegin(), object_list.constEnd());
+ for (RObject *obj : unique) {
stopListenForObject (obj);
}
object_list.clear ();
@@ -910,7 +906,7 @@ void RKComponentPropertyRObjects::setObjectList (const RObject::ObjectList &newl
RK_TRACE (PLUGIN);
if (newlist != object_list) {
- setObjectValueSilent (0);
+ setObjectValueSilent (nullptr);
for (int i = 0; i < newlist.size (); ++i) {
addObjectValueSilent (newlist[i]);
}
diff --git a/rkward/plugin/rkvalueselector.cpp b/rkward/plugin/rkvalueselector.cpp
index 51a09d824..ddf8063b6 100644
--- a/rkward/plugin/rkvalueselector.cpp
+++ b/rkward/plugin/rkvalueselector.cpp
@@ -155,7 +155,7 @@ void RKValueSelector::selectionPropertyChanged () {
}
list_view->selectionModel ()->clearSelection ();
- foreach (const int row, selected_rows) {
+ for (const int row : std::as_const(selected_rows)) {
list_view->selectionModel ()->select (model->index (row), QItemSelectionModel::Select | QItemSelectionModel::Rows);
}
updating = false;
diff --git a/rkward/rbackend/rcommand.h b/rkward/rbackend/rcommand.h
index e7f0ce3c8..3aec00593 100644
--- a/rkward/rbackend/rcommand.h
+++ b/rkward/rbackend/rcommand.h
@@ -196,7 +196,7 @@ public:
template<typename T> void whenFinished(const QObject* receiver, const T func) {
QObject::connect(notifier(), &RCommandNotifier::commandFinished, receiver, func);
- };
+ }
private:
friend class RInterface;
friend class RCommandStack;
diff --git a/rkward/rbackend/rkrbackendprotocol_shared.h b/rkward/rbackend/rkrbackendprotocol_shared.h
index f452730fc..a4bd37075 100644
--- a/rkward/rbackend/rkrbackendprotocol_shared.h
+++ b/rkward/rbackend/rkrbackendprotocol_shared.h
@@ -54,13 +54,13 @@ public:
RCommandProxy *takeCommand () {
RCommandProxy* ret = command;
- command = 0;
+ command = nullptr;
return ret;
}
ROutputList *takeOutput () {
ROutputList* ret = output;
- output = 0;
+ output = nullptr;
return ret;
}
diff --git a/rkward/rbackend/rkrinterface.h b/rkward/rbackend/rkrinterface.h
index 1e5e777d8..17ff3bcf7 100644
--- a/rkward/rbackend/rkrinterface.h
+++ b/rkward/rbackend/rkrinterface.h
@@ -49,10 +49,10 @@ public:
RCommand *c = new RCommand(QString(), RCommand::EmptyCommand | RCommand::Sync);
c->whenFinished(receiver, func);
issueCommand(c, chain);
- };
+ }
/** opens a new command chain. Returns a pointer to the new chain. If you specify a parent, the new chain will be a sub-chain of that chain. */
- static RCommandChain *startChain(RCommandChain *parent=0);
+ static RCommandChain *startChain(RCommandChain *parent = nullptr);
/** closes the command chain. The chain (and even its parent, if it is already closed) may be deleted right afterwards! */
static void closeChain(RCommandChain *chain);
@@ -68,7 +68,7 @@ not be interrupted. */
void pauseProcessing (bool pause);
/** returns the command currently running in the thread. Be careful when using the returned pointer! */
- RCommand *runningCommand () const { return (all_current_commands.isEmpty () ? 0 : all_current_commands.last ()); };
+ RCommand *runningCommand () const { return (all_current_commands.isEmpty () ? nullptr : all_current_commands.last ()); };
enum RStatus {
Busy,
@@ -107,7 +107,7 @@ private:
QList<RCommand*> all_current_commands;
/** NOTE: processing R events while waiting for the next command may, conceivably, lead to new requests, which may also wait for sub-commands! Thus we keep a simple stack of requests. */
QList<RBackendRequest*> command_requests;
- RBackendRequest* currentCommandRequest () const { return (command_requests.isEmpty () ? 0 : command_requests.last ()); };
+ RBackendRequest* currentCommandRequest () const { return (command_requests.isEmpty () ? nullptr : command_requests.last ()); };
void tryNextCommand ();
void doNextCommand (RCommand *command);
RCommand *popPreviousCommand (int id);
@@ -141,7 +141,7 @@ friend class RCommand;
protected:
void handleRequest (RBackendRequest *request);
static RInterface *_instance;
- void _issueCommand(RCommand *command, RCommandChain *chain=0);
+ void _issueCommand(RCommand *command, RCommandChain *chain = nullptr);
/** constructor */
RInterface();
Q_SIGNALS:
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
index c1b64526d..26510d152 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
@@ -10,6 +10,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QDialog>
+#include <QMatrix4x4>
+#include <QFontMetricsF>
#include <KLocalizedString>
#include <sys/stat.h>
@@ -36,7 +38,7 @@ RKGraphicsDevice::RKGraphicsDevice (double width, double height, const QString &
RK_TRACE (GRAPHICS_DEVICE);
interaction_opcode = -1;
- dialog = 0;
+ dialog = nullptr;
id = 0;
recording_path = false;
current_mask = 0;
@@ -471,7 +473,7 @@ void RKGraphicsDevice::text(double x, double y, const QString& text, double rot,
QPainterPath sub;
QSizeF size = strSize(text, font);
sub.addText(-(hadj * size.width()), 0, font, text);
- QMatrix trans;
+ QMatrix4x4 trans;
trans.translate(x, y);
trans.rotate(-rot);
recorded_path.addPath(trans.map(sub));
@@ -622,7 +624,7 @@ void RKGraphicsDevice::confirmNewPage () {
RK_TRACE (GRAPHICS_DEVICE);
RK_ASSERT (interaction_opcode < 0);
- RK_ASSERT (dialog == 0);
+ RK_ASSERT (dialog == nullptr);
interaction_opcode = RKDNewPageConfirm;
QString msg = i18n ("<p>Press Enter to see next plot, or click 'Cancel' to abort.</p>");
@@ -687,7 +689,7 @@ bool RKGraphicsDevice::eventFilter (QObject *watched, QEvent *event) {
if (event->type () == QEvent::MouseButtonRelease) {
QMouseEvent *me = static_cast<QMouseEvent*> (event);
if (me->button () == Qt::LeftButton) {
- Q_EMIT locatorDone(true, me->x(), me->y());
+ Q_EMIT locatorDone(true, me->position().x(), me->position().y());
interaction_opcode = -1;
}
stopInteraction ();
@@ -699,11 +701,11 @@ bool RKGraphicsDevice::eventFilter (QObject *watched, QEvent *event) {
StoredEvent sev;
sev.event_code = event->type () == QEvent::MouseButtonPress ? RKDMouseDown : (event->type () == QEvent::MouseButtonRelease ? RKDMouseUp : RKDMouseMove);
- sev.x = me->x ();
- sev.y = me->y ();
+ sev.x = me->position().x ();
+ sev.y = me->position().y ();
sev.buttons = 0;
if (me->buttons () & Qt::LeftButton) sev.buttons |= RKDMouseLeftButton;
- if (me->buttons () & Qt::MidButton) sev.buttons |= RKDMouseMiddleButton;
+ if (me->buttons () & Qt::MiddleButton) sev.buttons |= RKDMouseMiddleButton;
if (me->buttons () & Qt::RightButton) sev.buttons |= RKDMouseRightButton;
// Mouse move event may be generated much faster than R can handle them. We simply lump them together
@@ -768,7 +770,7 @@ void RKGraphicsDevice::stopInteraction () {
if (dialog) {
dialog->deleteLater ();
- dialog = 0;
+ dialog = nullptr;
}
if (view) { // might already be destroyed
view->setCursor (Qt::ArrowCursor);
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 5e24bb925..7079cac13 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -381,7 +381,7 @@ bool RKConsole::eventFilter (QObject *o, QEvent *e) {
}
} else if (e->type () == QEvent::MouseButtonRelease){
QMouseEvent *m = (QMouseEvent *)e;
- if (m->button() == Qt::MidButton) {
+ if (m->button() == Qt::MiddleButton) {
QClipboard *cb = QApplication::clipboard ();
submitBatch (cb->text (QClipboard::Selection));
return (true);
diff --git a/rkward/settings/CMakeLists.txt b/rkward/settings/CMakeLists.txt
index 70240457e..07e061130 100644
--- a/rkward/settings/CMakeLists.txt
+++ b/rkward/settings/CMakeLists.txt
@@ -34,4 +34,4 @@ IF (WIN32 OR USE_BINARY_PACKAGES)
ENDIF (WIN32 OR USE_BINARY_PACKAGES)
ADD_LIBRARY(settings STATIC ${settings_STAT_SRCS})
-TARGET_LINK_LIBRARIES(settings Qt6::Widgets KF6::WidgetsAddons Qt6::Xml KF6::ConfigCore KF6::Parts KF6::TextEditor KF6::I18n)
+TARGET_LINK_LIBRARIES(settings Qt6::Widgets KF6::WidgetsAddons Qt6::Xml KF6::ConfigCore KF6::Parts KF6::TextEditor KF6::I18n KF6::KIOWidgets)
diff --git a/rkward/settings/rksettingsmodule.h b/rkward/settings/rksettingsmodule.h
index afa485d10..14864c65e 100644
--- a/rkward/settings/rksettingsmodule.h
+++ b/rkward/settings/rksettingsmodule.h
@@ -104,7 +104,7 @@ public:
RKConfigGroup(const char *name, std::initializer_list<RKConfigBase*> values) : RKConfigBase(name),
values(values) {};
template<typename T> RKConfigGroup(const char *name, size_t count, RKConfigValue<T>* _values) : RKConfigBase(name),
- values(count) { for (size_t i = 0; i < count; ++i) values[i] = (_values + i); };
+ values(count) { for (size_t i = 0; i < count; ++i) values[i] = (_values + i); }
~RKConfigGroup() {};
void loadConfig(KConfigGroup &cg) override {
KConfigGroup lcg = cg;
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index 86a8158fd..adc90727d 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -198,9 +198,9 @@ bool RKSettingsModuleCommandEditor::matchesScriptFileFilter (const QString &file
RK_TRACE (SETTINGS);
const QStringList exts = script_file_filter.get().split(' ');
- foreach (const QString& ext, exts) {
- QRegExp reg (ext, Qt::CaseInsensitive, QRegExp::Wildcard);
- if (reg.exactMatch (filename)) return true;
+ for (const QString& ext : exts) {
+ auto reg = QRegularExpression::fromWildcard(ext, Qt::CaseInsensitive);
+ if (reg.match (filename).hasMatch()) return true;
}
return false;
}
diff --git a/rkward/settings/rksettingsmoduleoutput.cpp b/rkward/settings/rksettingsmoduleoutput.cpp
index b951e462c..0d2e49c28 100644
--- a/rkward/settings/rksettingsmoduleoutput.cpp
+++ b/rkward/settings/rksettingsmoduleoutput.cpp
@@ -96,7 +96,7 @@ void RKCarbonCopySettings::applyChanges() {
cc_globally_enabled = cc_globally_enabled_box->isChecked ();
- foreach (RKCarbonCopySettings *sibling, instances) {
+ for (RKCarbonCopySettings *sibling : std::as_const(instances)) {
if (sibling != this) sibling->update ();
}
}
@@ -123,7 +123,9 @@ RKSettingsModuleOutput::RKSettingsModuleOutput (RKSettings *gui, QWidget *parent
auto auto_raise_box = auto_raise.makeCheckbox(i18n("raise window on new output"), this);
group_layout->addWidget (auto_raise_box);
auto_raise_box->setEnabled (auto_show);
- connect(auto_show_box, &QCheckBox::stateChanged, auto_raise_box, &QWidget::setEnabled);
+ connect(auto_show_box, &QCheckBox::stateChanged, auto_raise_box, [auto_raise_box](int state) {
+ auto_raise_box->setEnabled(state);
+ });
main_vbox->addWidget (group);
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 8f87d0766..126f05943 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -370,7 +370,7 @@ void RKSettingsModulePlugins::registerPluginMaps (const QStringList &maps, AddMo
RK_TRACE (SETTINGS);
QStringList added;
- foreach (const QString &map, maps) {
+ for (const QString &map : maps) {
if (map.isEmpty ()) continue;
if (known_plugin_maps.addMap(map, add_mode)) {
added.append(map);
@@ -400,12 +400,14 @@ QStringList RKSettingsModulePlugins::findPluginMapsRecursive (const QString &bas
RK_TRACE (SETTINGS);
QDir dir (basedir);
- QStringList maps = dir.entryList (QDir::Files).filter (QRegExp (".*\\.pluginmap$"));
+ const QStringList maps = dir.entryList (QDir::Files).filter (QRegularExpression (".*\\.pluginmap$"));
QStringList ret;
- foreach (const QString &map, maps) ret.append (dir.absoluteFilePath (map));
+ for (const QString &map : maps) {
+ ret.append (dir.absoluteFilePath (map));
+ }
QStringList subdirs = dir.entryList (QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
- foreach (const QString& subdir, subdirs) {
+ for (const QString& subdir : subdirs) {
ret.append (findPluginMapsRecursive (dir.absoluteFilePath (subdir)));
}
@@ -418,7 +420,7 @@ RKSettingsModulePluginsModel::RKSettingsModulePluginsModel (QObject* parent) : Q
RKSettingsModulePluginsModel::~RKSettingsModulePluginsModel() {
RK_TRACE (SETTINGS);
- foreach (const PluginMapMetaInfo &inf, plugin_map_dynamic_info) {
+ for (const PluginMapMetaInfo &inf : std::as_const(plugin_map_dynamic_info)) {
delete (inf.about);
}
}
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 3a5873937..ccb378bcc 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -253,7 +253,7 @@ QStringList RKSettingsModuleR::makeRRunTimeOptionCommands () {
if (!options_further.get().isEmpty ()) list.append (options_further.get() + '\n');
if (!options_addpaths.get().isEmpty ()) {
QString command = "rk.adjust.system.path (add=c(";
- foreach (const QString &p, options_addpaths.get()) {
+ for (const QString &p : options_addpaths.get()) {
command.append (RObject::rQuote (p));
}
list.append (command + "))\n");
@@ -395,7 +395,7 @@ QString RKSettingsModuleRPackages::userLibraryLocation () {
}
QStringList RKSettingsModuleRPackages::libraryLocations () {
- return (QStringList (userLibraryLocation ()) + expandLibLocs (liblocs + defaultliblocs));
+ return (QStringList (userLibraryLocation ()) + expandLibLocs (liblocs.get() + defaultliblocs));
}
QStringList RKSettingsModuleRPackages::addUserLibLocTo (const QStringList& liblocs) {
diff --git a/rkward/windows/rkmdiwindow.cpp b/rkward/windows/rkmdiwindow.cpp
index ced310347..a8d185f4a 100644
--- a/rkward/windows/rkmdiwindow.cpp
+++ b/rkward/windows/rkmdiwindow.cpp
@@ -300,7 +300,7 @@ void RKMDIWindow::slotActivateForFocusFollowsMouse () {
}
}
-void RKMDIWindow::enterEvent (QEvent *event) {
+void RKMDIWindow::enterEvent (QEnterEvent *event) {
RK_TRACE (APP);
if (!isActive ()) {
diff --git a/rkward/windows/rkmdiwindow.h b/rkward/windows/rkmdiwindow.h
index 51b632ccb..cd60cd40a 100644
--- a/rkward/windows/rkmdiwindow.h
+++ b/rkward/windows/rkmdiwindow.h
@@ -66,7 +66,7 @@ protected:
/** constructor
@param parent parent widget
@param type Type of window (see RKMDIWindow::Type).*/
- RKMDIWindow (QWidget *parent, int type, bool tool_window=false, const char *name=0);
+ RKMDIWindow (QWidget *parent, int type, bool tool_window=false, const char *name = nullptr);
virtual ~RKMDIWindow ();
public Q_SLOTS:
/** Reimplemented from QWidget::setCaption () to Q_EMIT the signal captionChanged () when the caption is changed. */
@@ -107,7 +107,7 @@ public:
/** Set a status message to be shown in a popup inside the window. The message persists until the given R command has finished, or until this function is called with an empty string.
This should be used, when the information shown is currently out-of-date (e.g. when refreshing a preview / loading a plot from history), _not_ when the window
is simply busy (e.g. when saving the current plot to history). */
- void setStatusMessage (const QString& message, RCommand* command=0);
+ void setStatusMessage (const QString& message, RCommand* command = nullptr);
/** Set a style hint for the window. So far the only interpreted style hint is "preview", and not all windows implement it. Base implements hiding of "active" indicator border for "preview"s. */
virtual void setWindowStyleHint (const QString& hint);
@@ -149,7 +149,7 @@ protected:
void removeUiBuddy(QObject* buddy);
/** reimplemented from QWidget to emulate focus-follows-mouse behavior */
- void enterEvent (QEvent *event) override;
+ void enterEvent (QEnterEvent *event) override;
/** @see globalContextProperty() */
void setGlobalContextProperty (const QString& property, const QString& value) { global_context_properties.insert (property, value); };
More information about the rkward-tracker
mailing list