[education/rkward] rkward/dataeditor: Set QT_NO_CAST_FROM_ASCII in dataeditor folder
Thomas Friedrichsmeier
null at kde.org
Fri Apr 25 10:57:36 BST 2025
Git commit fa513d374b77e97a10015328665abe4d7a776f43 by Thomas Friedrichsmeier.
Committed on 25/04/2025 at 09:57.
Pushed by tfry into branch 'master'.
Set QT_NO_CAST_FROM_ASCII in dataeditor folder
M +1 -0 rkward/dataeditor/CMakeLists.txt
M +5 -5 rkward/dataeditor/rktextmatrix.cpp
M +33 -30 rkward/dataeditor/rkvareditmodel.cpp
M +1 -1 rkward/dataeditor/twintable.cpp
https://invent.kde.org/education/rkward/-/commit/fa513d374b77e97a10015328665abe4d7a776f43
diff --git a/rkward/dataeditor/CMakeLists.txt b/rkward/dataeditor/CMakeLists.txt
index 5bfa67966..b4998daf3 100644
--- a/rkward/dataeditor/CMakeLists.txt
+++ b/rkward/dataeditor/CMakeLists.txt
@@ -15,3 +15,4 @@ SET(dataeditor_STAT_SRCS
ADD_LIBRARY(dataeditor STATIC ${dataeditor_STAT_SRCS})
TARGET_LINK_LIBRARIES(dataeditor Qt6::Widgets KF6::WidgetsAddons KF6::Parts KF6::I18n)
+add_definitions(-DQT_NO_CAST_FROM_ASCII) # TODO remove, here, once enabled on top level
diff --git a/rkward/dataeditor/rktextmatrix.cpp b/rkward/dataeditor/rktextmatrix.cpp
index 84a17fa65..305587763 100644
--- a/rkward/dataeditor/rktextmatrix.cpp
+++ b/rkward/dataeditor/rktextmatrix.cpp
@@ -57,13 +57,13 @@ RKTextMatrix RKTextMatrix::matrixFromSeparatedValues (const QString& text, const
return ret;
}
-QString RKTextMatrix::toTabSeparatedValues () const {
- RK_TRACE (EDITOR);
+QString RKTextMatrix::toTabSeparatedValues() const {
+ RK_TRACE(EDITOR);
QString ret;
- for (int row = 0; row < rows.size (); ++row) {
- if (row) ret.append ('\n');
- ret.append (rows[row].join (QChar ('\t')));
+ for (int row = 0; row < rows.size(); ++row) {
+ if (row) ret.append(u'\n');
+ ret.append(rows[row].join(u'\t'));
}
return ret;
}
diff --git a/rkward/dataeditor/rkvareditmodel.cpp b/rkward/dataeditor/rkvareditmodel.cpp
index 9daca4309..0788c33da 100644
--- a/rkward/dataeditor/rkvareditmodel.cpp
+++ b/rkward/dataeditor/rkvareditmodel.cpp
@@ -836,22 +836,25 @@ RKVarEditDataFrameModel::~RKVarEditDataFrameModel () {
if (dataframe) stopListenForObject (dataframe);
}
-bool RKVarEditDataFrameModel::insertColumns (int column, int count, const QModelIndex& parent) {
- RK_TRACE (EDITOR);
+bool RKVarEditDataFrameModel::insertColumns(int column, int count, const QModelIndex& parent) {
+ RK_TRACE(EDITOR);
- if (parent.isValid ()) {
- RK_ASSERT (false);
+ if (parent.isValid()) {
+ RK_ASSERT(false);
return false;
}
- if (column > trueCols ()) column = trueCols ();
+ if (column > trueCols()) column = trueCols();
if (column < var_col_offset) column = var_col_offset;
for (int col = column; col < (column + count); ++col) {
- RObject *obj = dataframe->createPendingChild (dataframe->validizeName (QString ()), col-var_col_offset);
- RK_ASSERT (obj->isVariable ());
-// addObject (col, obj); // the object will be added via RKModificationTracker::addObject -> this::childAdded. That will also take care of calling beginInsertColumns()/endInsertColumns()
-
- RCommand* command = new RCommand(".rk.data.frame.insert.column (" + dataframe->getFullName() + ", \"" + obj->getShortName() + "\", " + QString::number(col+1-var_col_offset) + ")", RCommand::App | RCommand::Sync);
+ RObject* obj = dataframe->createPendingChild(dataframe->validizeName(QString()), col - var_col_offset);
+ RK_ASSERT(obj->isVariable());
+ // addObject (col, obj); // the object will be added via RKModificationTracker::addObject -> this::childAdded. That will also take care of calling
+ //beginInsertColumns()/endInsertColumns()
+
+ RCommand* command = new RCommand(u".rk.data.frame.insert.column ("_s + dataframe->getFullName() + u", \""_s + obj->getShortName() + u"\", "_s +
+ QString::number(col + 1 - var_col_offset) + u')',
+ RCommand::App | RCommand::Sync);
command->setUpdatesObject(dataframe);
RInterface::issueCommand(command);
}
@@ -880,22 +883,22 @@ bool RKVarEditDataFrameModel::removeColumns (int column, int count, const QModel
return true;
}
-void RKVarEditDataFrameModel::doInsertRowsInBackend (int row, int count) {
- RK_TRACE (EDITOR);
+void RKVarEditDataFrameModel::doInsertRowsInBackend(int row, int count) {
+ RK_TRACE(EDITOR);
// TODO: most of the time we're only adding one row at a time, still we should have a function to add multiple rows at once.
for (int i = row; i < row + count; ++i) {
- RCommand* command = new RCommand(".rk.data.frame.insert.row(" + dataframe->getFullName() + ", " + QString::number(i+1) + ')', RCommand::App | RCommand::Sync);
+ RCommand* command = new RCommand(u".rk.data.frame.insert.row("_s + dataframe->getFullName() + u", "_s + QString::number(i + 1) + u')', RCommand::App | RCommand::Sync);
command->setUpdatesObject(dataframe);
RInterface::issueCommand(command);
}
}
-void RKVarEditDataFrameModel::doRemoveRowsInBackend (int row, int count) {
- RK_TRACE (EDITOR);
+void RKVarEditDataFrameModel::doRemoveRowsInBackend(int row, int count) {
+ RK_TRACE(EDITOR);
for (int i = row + count - 1; i >= row; --i) {
- RCommand* command = new RCommand(".rk.data.frame.delete.row(" + dataframe->getFullName() + ", " + QString::number(i+1) + ')', RCommand::App | RCommand::Sync);
+ RCommand* command = new RCommand(u".rk.data.frame.delete.row("_s + dataframe->getFullName() + u", "_s + QString::number(i + 1) + u')', RCommand::App | RCommand::Sync);
command->setUpdatesObject(dataframe);
RInterface::issueCommand(command);
}
@@ -955,35 +958,35 @@ void RKVarEditDataFrameModel::doInsertColumns (int index, int count) {
insertColumns (index, count);
}
-void RKVarEditDataFrameModel::pushTable (RCommandChain *sync_chain) {
- RK_TRACE (EDITOR);
+void RKVarEditDataFrameModel::pushTable(RCommandChain* sync_chain) {
+ RK_TRACE(EDITOR);
// first push real data
- QString command = dataframe->getFullName ();
- command.append (" <- data.frame (");
+ QString command = dataframe->getFullName();
+ command.append(u" <- data.frame ("_s);
- RK_ASSERT (objects.size ());
+ RK_ASSERT(objects.size());
RKVariable* child = objects[0];
- QString na_vector = "=as.numeric (rep (NA, " + QString::number (child->getLength ()) + "))";
- for (int col=var_col_offset; col < objects.size (); ++col) {
- if (col > var_col_offset) command.append (", ");
- command.append (objects[col]->getShortName () + na_vector);
+ QString na_vector = u"=as.numeric (rep (NA, "_s + QString::number(child->getLength()) + u"))"_s;
+ for (int col = var_col_offset; col < objects.size(); ++col) {
+ if (col > var_col_offset) command.append(u", "_s);
+ command.append(objects[col]->getShortName() + na_vector);
}
- command.append (")");
+ command.append(u')');
// push all children
RCommand* rcommand = new RCommand(command, RCommand::Sync);
rcommand->setUpdatesObject(dataframe);
RInterface::issueCommand(rcommand, sync_chain);
- for (int col=0; col < objects.size (); ++col) {
- objects[col]->restore (sync_chain);
+ for (int col = 0; col < objects.size(); ++col) {
+ objects[col]->restore(sync_chain);
}
// now store the meta-data
- dataframe->writeMetaData (sync_chain);
+ dataframe->writeMetaData(sync_chain);
- RInterface::issueCommand (new RCommand (QString (), RCommand::Sync | RCommand::EmptyCommand | RCommand::ObjectListUpdate), sync_chain);
+ RInterface::issueCommand(new RCommand(QString(), RCommand::Sync | RCommand::EmptyCommand | RCommand::ObjectListUpdate), sync_chain);
}
void RKVarEditDataFrameModel::restoreObject (RObject* object, RCommandChain* chain) {
diff --git a/rkward/dataeditor/twintable.cpp b/rkward/dataeditor/twintable.cpp
index 4f569f2da..d6f035e83 100644
--- a/rkward/dataeditor/twintable.cpp
+++ b/rkward/dataeditor/twintable.cpp
@@ -224,7 +224,7 @@ void TwinTable::hasProblems() {
problems_note->addAction(a);
connect(a, &QAction::triggered, datamodel, [this, msg]() {
// NOTE: Not caching the problems in the lambda, as additional problem may yet be detected
- KMessageBox::detailedError(this, msg + "<br/>" + i18n("You may want to create an editable subset using Data->Subset data.frame."), datamodel->problems().join(QStringLiteral("\n")), i18n("Problem detected"));
+ KMessageBox::detailedError(this, msg + u"<br/>"_s + i18n("You may want to create an editable subset using Data->Subset data.frame."), datamodel->problems().join(u"\n"_s), i18n("Problem detected"));
});
}
problems_note->animatedShow();
More information about the rkward-tracker
mailing list