Commit 7a7f1754 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Port away from deprecated QButtonGroup::buttonClicked(int). Move porting aids...

Port away from deprecated QButtonGroup::buttonClicked(int). Move porting aids to separate header file.
parent 33f24aca
Pipeline #176242 failed with stage
in 2 minutes and 22 seconds
......@@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rcontainerobject.h"
#include "robjectlist.h"
#include "../rbackend/rkrinterface.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "rkmodificationtracker.h"
......@@ -862,7 +862,7 @@ RKVariable::FormattingOptions RKVariable::parseFormattingOptionsString (const QS
formatting_options.precision_mode = FormattingOptions::PrecisionDefault;
formatting_options.precision = 0;
QStringList list = string.split ('#', RKCommonFunctions::SkipEmptyParts());
QStringList list = string.split ('#', RKCompatibility::SkipEmptyParts());
QString option, parameter;
for (QStringList::const_iterator it = list.constBegin (); it != list.constEnd (); ++it) {
option = (*it).section (':', 0, 0);
......
......@@ -20,6 +20,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../rbackend/rcommand.h"
#include "../misc/rkdialogbuttonbox.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../debug.h"
......@@ -35,7 +36,7 @@ RKReadLineDialog::RKReadLineDialog (QWidget *parent, const QString &caption, con
layout->addWidget (new QLabel (caption, this));
int screen_width = RKCommonFunctions::availableGeometry(this).width();
int screen_width = RKCompatibility::availableGeometry(this).width();
QString context = command->fullOutput ();
if (!context.isEmpty ()) {
......
......@@ -7,6 +7,7 @@ SET(misc_STAT_SRCS
xmlhelper.cpp
multistringselector.cpp
rkcommonfunctions.cpp
rkcompatibility.cpp
rkprogresscontrol.cpp
rksaveobjectchooser.cpp
rkdummypart.cpp
......
......@@ -11,12 +11,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <qregexp.h>
#include <QDir>
#include <QStandardPaths>
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# include <QDesktopWidget>
#else
# include <QScreen>
#endif
#include <QCoreApplication>
#include <QLabel>
#include <KLocalizedString>
......@@ -276,15 +271,4 @@ namespace RKCommonFunctions {
QObject::connect (ret, &QLabel::linkActivated, RKWorkplace::mainWorkplace (), &RKWorkplace::openAnyUrlString);
return ret;
}
QRect availableGeometry(QWidget* for_widget) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
auto screen = for_widget->screen();
if (screen) return screen->availableGeometry();
return QApplication::primaryScreen()->availableGeometry();
#else
return ::QApplication::desktop()->availableGeometry(for_widget);
#endif
}
} // namespace
......@@ -57,10 +57,6 @@ namespace RKCommonFunctions {
/** create a QLabel that has wordwarp enabled, *and* clickable links (opened inside RKWard), in a single line of code. */
QLabel* linkedWrappedLabel (const QString &text);
//// NOTE: Functions / constants below are porting aids, to be removed, eventually. ////
/** Small wrapper around QScreen::availableGeometry(), mostly to ease porting */
QRect availableGeometry(QWidget *for_widget);
/** Porting aid: Qt::SplitBehaviorFlags was added in Qt 5.14, deprecating the previous flags in QString. Remove, once we depend on Qt >= 5.14 */
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
inline Qt::SplitBehaviorFlags KeepEmptyParts() { return Qt::KeepEmptyParts; };
......
/*
rkcommonfunctions - This file is part of the RKWard project. Created: Sat May 14 2022
SPDX-FileCopyrightText: 2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier@kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "rkcompatibility.h"
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# include <QDesktopWidget>
#else
# include <QScreen>
#endif
namespace RKCompatibility {
QRect availableGeometry(QWidget* for_widget) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
auto screen = for_widget->screen();
if (screen) return screen->availableGeometry();
return QApplication::primaryScreen()->availableGeometry();
#else
return ::QApplication::desktop()->availableGeometry(for_widget);
#endif
}
};
/*
rkcommonfunctions - This file is part of the RKWard project. Created: Sat May 14 2022
SPDX-FileCopyrightText: 2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier@kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef RKCOMPATIBILTY_H
#define RKCOMPATIBILTY_H
#include <QRect>
#include <QString>
#include <QButtonGroup>
class QWidget;
/** Some helper functions / enums for the sole purpose of working around API changes while keeping compatibility across a wide range of Qt/KF versions.
By their very nature, these functions are not meant to stay, but should be removed, as soon as the incompatibility falls outside the range of supported versions.
@author Thomas Friedrichsmeier
*/
namespace RKCompatibility {
//// NOTE: Functions / constants below are porting aids, to be removed, eventually. ////
/** Small wrapper around QScreen::availableGeometry(), mostly to ease porting */
QRect availableGeometry(QWidget *for_widget);
/** Porting aid: Qt::SplitBehaviorFlags was added in Qt 5.14, deprecating the previous flags in QString. Remove, once we depend on Qt >= 5.14 */
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
inline Qt::SplitBehaviorFlags KeepEmptyParts() { return Qt::KeepEmptyParts; };
inline Qt::SplitBehaviorFlags SkipEmptyParts() { return Qt::SkipEmptyParts; };
#else
inline QString::SplitBehavior KeepEmptyParts() { return QString::KeepEmptyParts; };
inline QString::SplitBehavior SkipEmptyParts() { return QString::SkipEmptyParts; };
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
inline void(QButtonGroup::* groupButtonClicked())(int) { return static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked); };
#else
inline void(QButtonGroup::* groupButtonClicked())(int) { return static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked); };
#endif
};
#endif
......@@ -56,6 +56,7 @@ void RKPasteSpecialAction::doSpecialPaste() {
#include "rksaveobjectchooser.h"
#include "../rbackend/rkrinterface.h"
#include "../misc/rkprogresscontrol.h"
#include "../misc/rkcompatibility.h"
RKPasteSpecialDialog::RKPasteSpecialDialog(QWidget* parent, bool standalone) : QDialog(parent) {
RK_TRACE (MISC);
......@@ -93,7 +94,7 @@ RKPasteSpecialDialog::RKPasteSpecialDialog(QWidget* parent, bool standalone) : Q
dimensionality_group->addButton (rbutton, DimDataFrame);
rbutton->setChecked (true);
group_layout->addWidget (rbutton);
connect (dimensionality_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
connect (dimensionality_group, RKCompatibility::groupButtonClicked(), this, &RKPasteSpecialDialog::updateState);
rowlayout->addWidget (box);
const QMimeData* clipdata = QApplication::clipboard ()->mimeData ();
......@@ -123,7 +124,7 @@ RKPasteSpecialDialog::RKPasteSpecialDialog(QWidget* parent, bool standalone) : Q
separator_freefield = new QLineEdit (";", box);
h_layout->addWidget (separator_freefield);
group_layout->addLayout (h_layout);
connect (separator_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
connect (separator_group, RKCompatibility::groupButtonClicked(), this, &RKPasteSpecialDialog::updateState);
rowlayout->addWidget (box);
rowlayout = new QHBoxLayout;
......@@ -143,7 +144,7 @@ RKPasteSpecialDialog::RKPasteSpecialDialog(QWidget* parent, bool standalone) : Q
rbutton = new QRadioButton (i18n ("Quote all values"), box);
quoting_group->addButton (rbutton, QuoteAll);
group_layout->addWidget (rbutton);
connect (quoting_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKPasteSpecialDialog::updateState);
connect (quoting_group, RKCompatibility::groupButtonClicked(), this, &RKPasteSpecialDialog::updateState);
rowlayout->addWidget (box);
// Labels
......
......@@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../misc/xmlhelper.h"
#include "../misc/rkmessagecatalog.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../rbackend/rksessionvars.h"
#include <KLocalizedString>
......@@ -93,8 +93,8 @@ QString RKComponentAboutData::toHtml () const {
}
if (!translator_names.isNull ()) {
QStringList tns = translator_names.split (QLatin1Char(','), RKCommonFunctions::KeepEmptyParts());
QStringList tes = translator_emails.split (QLatin1Char(','), RKCommonFunctions::KeepEmptyParts());
QStringList tns = translator_names.split (QLatin1Char(','), RKCompatibility::KeepEmptyParts());
QStringList tes = translator_emails.split (QLatin1Char(','), RKCompatibility::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);
......
......@@ -84,6 +84,7 @@ the specialized properties (e.g. RKComponentPropertyInt::intValue () always retu
#include "rkcomponentproperties.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include <KLocalizedString>
......@@ -1004,13 +1005,13 @@ bool RKComponentPropertyRObjects::setValueList (const QStringList& values) {
bool RKComponentPropertyRObjects::setValue (const QString &value) {
RK_TRACE (PLUGIN);
return setValueList (value.split (sep, RKCommonFunctions::SkipEmptyParts()));
return setValueList (value.split (sep, RKCompatibility::SkipEmptyParts()));
}
bool RKComponentPropertyRObjects::isStringValid (const QString &value) {
RK_TRACE (PLUGIN);
QStringList slist = value.split (sep, RKCommonFunctions::SkipEmptyParts());
QStringList slist = value.split (sep, RKCompatibility::SkipEmptyParts());
for (QStringList::const_iterator it = slist.cbegin (); it != slist.cend (); ++it) {
RObject *obj = RObjectList::getObjectList ()->findObject (*it);
......
......@@ -22,6 +22,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../core/rcontainerobject.h"
#include "../misc/xmlhelper.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkcompatibility.h"
#include "../debug.h"
......@@ -65,7 +66,7 @@ RKFormula::RKFormula (const QDomElement &element, RKComponent *parent_component,
type_selector->addButton (button, (int) MainEffects);
vbox->addWidget (button = new QRadioButton (i18n ("Custom Model:"), this));
type_selector->addButton (button, (int) Custom);
connect (type_selector, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKFormula::typeChange);
connect (type_selector, RKCompatibility::groupButtonClicked(), this, &RKFormula::typeChange);
custom_model_widget = new QWidget (this);
QHBoxLayout *model_hbox = new QHBoxLayout (custom_model_widget);
......
......@@ -17,7 +17,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../misc/rktableview.h"
#include "../dataeditor/rktextmatrix.h"
#include "../misc/xmlhelper.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../debug.h"
......@@ -185,7 +185,7 @@ void RKMatrixInput::setColumnValue (int column, const QString& value) {
RK_TRACE (PLUGIN);
if (!expandStorageForColumn (column)) return;
columns[column].storage = value.split ('\t', RKCommonFunctions::KeepEmptyParts());
columns[column].storage = value.split ('\t', RKCompatibility::KeepEmptyParts());
updateColumn (column);
emit model->dataChanged (model->index(0, column), model->index(row_count->intValue() + trailing_rows, column));
}
......@@ -334,7 +334,7 @@ void RKMatrixInput::tsvPropertyChanged () {
RK_TRACE (PLUGIN);
columns.clear ();
QStringList coldata = fetchStringValue (tsv_data).split ('\n', RKCommonFunctions::KeepEmptyParts());
QStringList coldata = fetchStringValue (tsv_data).split ('\n', RKCompatibility::KeepEmptyParts());
for (int i = 0; i < coldata.size (); ++i) {
setColumnValue (i, coldata[i]);
}
......
......@@ -18,6 +18,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rkstandardcomponent.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../misc/rkaccordiontable.h"
#include "../misc/rkstandardicons.h"
#include "../misc/xmlhelper.h"
......@@ -190,7 +191,7 @@ QString serializeList (const QStringList &list) {
}
QStringList unserializeList (const QString &serial) {
QStringList ret = serial.split ('\t', RKCommonFunctions::KeepEmptyParts());
QStringList ret = serial.split ('\t', RKCompatibility::KeepEmptyParts());
for (int i = 0; i < ret.size (); ++i) {
ret[i] = RKCommonFunctions::unescape (ret[i]);
}
......@@ -210,7 +211,7 @@ QString serializeMap (const RKComponent::PropertyValueMap &map) {
RKComponent::PropertyValueMap unserializeMap (const QString &serial) {
RKComponent::PropertyValueMap ret;
QStringList l = serial.split ('\t', RKCommonFunctions::KeepEmptyParts());
QStringList l = serial.split ('\t', RKCompatibility::KeepEmptyParts());
for (int i = 0; i < l.size (); ++i) {
QString &line = l[i];
int sep = line.indexOf ('=');
......
......@@ -17,6 +17,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <KLocalizedString>
#include "../misc/xmlhelper.h"
#include "../misc/rkcompatibility.h"
#include "../debug.h"
RKRadio::RKRadio (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKAbstractOptionSelector (parent_component, parent_widget) {
......@@ -37,7 +38,7 @@ RKRadio::RKRadio (const QDomElement &element, RKComponent *parent_component, QWi
addOptionsAndInit (element);
vbox->addWidget (group_box);
connect (group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKRadio::itemSelected);
connect (group, RKCompatibility::groupButtonClicked(), this, &RKRadio::itemSelected);
}
RKRadio::~RKRadio(){
......
......@@ -23,6 +23,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rkcomponentmap.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkxmlguipreviewarea.h"
#include "../misc/rkstyle.h"
......@@ -75,7 +76,7 @@ public:
setSizes (sizes);
if (QSplitter::window ()->isVisible ()) {
QRect boundary = RKCommonFunctions::availableGeometry(this);
QRect boundary = RKCompatibility::availableGeometry(this);
int new_width = window->width ();
int new_height = window->height ();
int new_x = window->x ();
......
......@@ -24,7 +24,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../debug.h"
#include "../misc/xmlhelper.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
......@@ -99,8 +99,8 @@ RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component,
if (mode == Varslot) {
// initialize filters
static_cast<RKComponentPropertyRObjects*> (available)->setClassFilter (xml->getStringAttribute (element, "classes", QString (), DL_INFO).split (' ', RKCommonFunctions::SkipEmptyParts()));
static_cast<RKComponentPropertyRObjects*> (available)->setTypeFilter (xml->getStringAttribute (element, "types", QString (), DL_INFO).split (' ', RKCommonFunctions::SkipEmptyParts()));
static_cast<RKComponentPropertyRObjects*> (available)->setClassFilter (xml->getStringAttribute (element, "classes", QString (), DL_INFO).split (' ', RKCompatibility::SkipEmptyParts()));
static_cast<RKComponentPropertyRObjects*> (available)->setTypeFilter (xml->getStringAttribute (element, "types", QString (), DL_INFO).split (' ', RKCompatibility::SkipEmptyParts()));
static_cast<RKComponentPropertyRObjects*> (available)->setDimensionFilter (xml->getIntAttribute (element, "num_dimensions", 0, DL_INFO), xml->getIntAttribute (element, "min_length", 0, DL_INFO), xml->getIntAttribute (element, "max_length", INT_MAX, DL_INFO));
static_cast<RKComponentPropertyRObjects*> (available)->setObjectProblemsAreErrors (false);
}
......
......@@ -51,6 +51,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "settings/rksettingsmoduleconsole.h"
#include "settings/rkrecenturls.h"
#include "misc/rkcommonfunctions.h"
#include "misc/rkcompatibility.h"
#include "misc/rkstandardicons.h"
#include "misc/rkstandardactions.h"
#include "core/robjectlist.h"
......@@ -712,7 +713,7 @@ void RKConsole::userLoadHistory (const QUrl &_url) {
QFile file (filename);
if (!file.open (QIODevice::Text | QIODevice::ReadOnly)) return;
setCommandHistory (QString (file.readAll ()).split ('\n', RKCommonFunctions::SkipEmptyParts()), false);
setCommandHistory (QString (file.readAll ()).split ('\n', RKCompatibility::SkipEmptyParts()), false);
file.close ();
delete (tmpfile);
......@@ -896,7 +897,7 @@ void RKConsole::pipeCommandThroughConsoleLocal (const QString &command_string) {
}
}
if (RKSettingsModuleConsole::addPipedCommandsToHistory() != RKSettingsModuleConsole::DontAdd) {
QStringList lines = command_string.split ('\n', RKCommonFunctions::SkipEmptyParts());
QStringList lines = command_string.split ('\n', RKCompatibility::SkipEmptyParts());
if ((RKSettingsModuleConsole::addPipedCommandsToHistory() == RKSettingsModuleConsole::AlwaysAdd) || (lines.count () == 1)) {
for (int i = 0; i < lines.count (); ++i) {
commands_history.append (lines[i]);
......
......@@ -53,6 +53,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "core/renvironmentobject.h"
#include "misc/rkstandardicons.h"
#include "misc/rkcommonfunctions.h"
#include "misc/rkcompatibility.h"
#include "misc/rkxmlguisyncer.h"
#include "misc/rkdbusapi.h"
#include "misc/rkdialogbuttonbox.h"
......@@ -770,7 +771,7 @@ void RKWardMainWindow::readOptions () {
KConfigGroup cg = config->group ("General Options");
QSize size = cg.readEntry ("Geometry", QSize ());
if (size.isEmpty ()) {
size = RKCommonFunctions::availableGeometry(this).size();
size = RKCompatibility::availableGeometry(this).size();
}
resize (size);
......
......@@ -20,6 +20,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../misc/rkspinbox.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../misc/rkstyle.h"
#include "../debug.h"
......@@ -65,7 +66,7 @@ RKSettingsModuleDebug::RKSettingsModuleDebug (RKSettings *gui, QWidget *parent)
box_layout->addWidget (*it);
(*it)->setChecked (RK_Debug::RK_Debug_Flags & debug_flags_group->id (*it));
}
connect (debug_flags_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKSettingsModuleDebug::settingChanged);
connect (debug_flags_group, RKCompatibility::groupButtonClicked(), this, &RKSettingsModuleDebug::settingChanged);
main_vbox->addWidget (group);
......
......@@ -22,6 +22,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../misc/getfilenamewidget.h"
#include "../misc/rkspinbox.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/rkcompatibility.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkstyle.h"
......@@ -109,7 +110,7 @@ RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *pare
group_layout->addWidget (button);
workplace_save_chooser->addButton (button, DontSaveWorkplace);
if ((button = workplace_save_chooser->button (workplace_save_mode))) button->setChecked (true);
connect (workplace_save_chooser, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &RKSettingsModuleGeneral::change);
connect (workplace_save_chooser, RKCompatibility::groupButtonClicked(), this, &RKSettingsModuleGeneral::change);
main_vbox->addWidget (group_box);
main_vbox->addSpacing (2*RKStyle::spacingHint ());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment