[education/rkward] rkward: Tell optionset to make use of available space.
Thomas Friedrichsmeier
null at kde.org
Thu Apr 7 22:06:34 BST 2022
Git commit 9dc80ede1d9ff41acf3983a43a55dedec733424a by Thomas Friedrichsmeier.
Committed on 07/04/2022 at 21:05.
Pushed by tfry into branch 'master'.
Tell optionset to make use of available space.
M +13 -10 rkward/plugin/rkoptionset.cpp
M +1 -3 rkward/plugin/rkoptionset.h
M +1 -3 rkward/plugins/data/recode_categorical.xml
https://invent.kde.org/education/rkward/commit/9dc80ede1d9ff41acf3983a43a55dedec733424a
diff --git a/rkward/plugin/rkoptionset.cpp b/rkward/plugin/rkoptionset.cpp
index 2496dada..73b7f7d0 100644
--- a/rkward/plugin/rkoptionset.cpp
+++ b/rkward/plugin/rkoptionset.cpp
@@ -1,6 +1,6 @@
/*
rkoptionset - This file is part of RKWard (https://rkward.kde.org). Created: Mon Oct 31 2011
-SPDX-FileCopyrightText: 2011-2014 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2011-2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -11,7 +11,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include <QTreeWidget>
#include <QHeaderView>
#include <QPushButton>
-#include <QStackedWidget>
#include <QLabel>
#include <QMimeData>
@@ -42,17 +41,15 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
// build UI framework
QVBoxLayout *layout = new QVBoxLayout (this);
layout->setContentsMargins (0, 0, 0, 0);
- switcher = new QStackedWidget (this);
- layout->addWidget (switcher);
accordion = new RKAccordionTable (this);
- switcher->addWidget (accordion);
+ layout->addWidget (accordion);
connect (accordion, static_cast<void (RKAccordionTable::*)(int)>(&RKAccordionTable::activated), this, &RKOptionSet::currentRowChanged);
connect (accordion, &RKAccordionTable::addRow, this, &RKOptionSet::addRow);
connect (accordion, &RKAccordionTable::removeRow, this, &RKOptionSet::removeRow);
updating_notice = new QLabel (i18n ("Updating status, please wait"), this);
- switcher->addWidget (updating_notice);
+ layout->addWidget (updating_notice);
update_timer.setInterval (0);
update_timer.setSingleShot (true);
connect (&update_timer, &QTimer::timeout, this, &RKOptionSet::slotUpdateUnfinishedRows);
@@ -165,6 +162,10 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
model->column_labels = visible_column_labels;
accordion->setShowAddRemoveButtons (!keycolumn);
accordion->setModel (model);
+ updating_notice->hide();
+ QSizePolicy pol(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ pol.setVerticalStretch(1); // For some reason, this apparently defaults to 0 - no stretch, unless absolutely necessary - for this widget, although I have no idea, why.
+ setSizePolicy(pol);
}
RKOptionSet::~RKOptionSet () {
@@ -342,14 +343,16 @@ void RKOptionSet::updateUnfinishedRows () {
RK_TRACE (PLUGIN);
if (!n_unfinished_rows) { // done
- if (switcher->currentWidget () != updating_notice) return;
+ if (!updating_notice->isVisible()) return;
current_row->setIntValue (return_to_row);
- switcher->setCurrentWidget (accordion);
+ accordion->show();
+ updating_notice->hide();
return;
}
- if (switcher->currentWidget () != updating_notice) {
- switcher->setCurrentWidget (updating_notice);
+ if (!updating_notice->isVisible()) {
+ updating_notice->show();
+ accordion->hide();
return_to_row = active_row;
}
for (int i = 0; i < rows.size (); ++i) {
diff --git a/rkward/plugin/rkoptionset.h b/rkward/plugin/rkoptionset.h
index cf242dff..013ba0d9 100644
--- a/rkward/plugin/rkoptionset.h
+++ b/rkward/plugin/rkoptionset.h
@@ -1,6 +1,6 @@
/*
rkoptionset - This file is part of the RKWard project. Created: Mon Oct 31 2011
-SPDX-FileCopyrightText: 2011-2012 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2011-2022 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -20,7 +20,6 @@ class RKAccordionTable;
class QTreeView;
class QPushButton;
class RKOptionSetDisplayModel;
-class QStackedWidget;
/** An RKOptionSet provides a group of options for an arbitrary number of "rows". E.g. different line colors for each of a group of variables.
*
@@ -104,7 +103,6 @@ friend class RKOptionSetDisplayModel;
RKOptionSetDisplayModel* model;
RKAccordionTable *accordion;
- QStackedWidget *switcher;
QWidget *updating_notice;
void updateUnfinishedRows ();
int return_to_row;
diff --git a/rkward/plugins/data/recode_categorical.xml b/rkward/plugins/data/recode_categorical.xml
index 923f6936..5381f902 100644
--- a/rkward/plugins/data/recode_categorical.xml
+++ b/rkward/plugins/data/recode_categorical.xml
@@ -42,7 +42,6 @@
<preview id="preview" label="Preview" mode="data"/>
</tab>
<tab label="Values" id="tab_values">
- <row>
<column>
<optionset id="set" min_rows="1" label="Recodings">
<logic>
@@ -97,14 +96,13 @@
</frame>
</content>
</optionset>
- </column>
- </row>
<radio id="other" label="Any other values"> <!-- TODO Should this be including original NAs? -->
<option value="copy" label="Copy" id="copy_others"/>
<option value="na" label="NA"/>
<option value="custom" label="Custom value:"/>
</radio>
<embed id="other_custom" component="rkward::multi_input"/>
+ </column>
</tab>
</tabbook></dialog>
</document>
More information about the rkward-tracker
mailing list