[rkward] /: Do away with the index column in optionsets, entirely.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Sun Nov 1 17:18:35 UTC 2015


Git commit 17252b97bbf9b30b9eb534cb07bc603cfef22cfc by Thomas Friedrichsmeier.
Committed on 01/11/2015 at 17:17.
Pushed by tfry into branch 'master'.

Do away with the index column in optionsets, entirely.

M  +1    -0    ChangeLog
M  +2    -5    rkward/misc/rkaccordiontable.cpp
M  +3    -4    rkward/plugin/rkoptionset.cpp
M  +0    -2    rkward/plugin/rkoptionset.h
M  +2    -6    rkward/plugin/rkstandardcomponent.cpp

http://commits.kde.org/rkward/17252b97bbf9b30b9eb534cb07bc603cfef22cfc

diff --git a/ChangeLog b/ChangeLog
index f1690f5..52ddb97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Complete rework of <optionset> UI for better usability
 - Try harder to honor system locale settings
 - Remove obsolete "Export tabular data" plugin (superceded by "Export Table / CSV")
 - Some usability refinements to "Import CVS" plugin
diff --git a/rkward/misc/rkaccordiontable.cpp b/rkward/misc/rkaccordiontable.cpp
index 0188df2..97ad47d 100644
--- a/rkward/misc/rkaccordiontable.cpp
+++ b/rkward/misc/rkaccordiontable.cpp
@@ -41,8 +41,6 @@ class RKAccordionDummyModel : public QAbstractProxyModel {
 public:
 	RKAccordionDummyModel (QObject *parent) : QAbstractProxyModel (parent) {
 		add_trailing_columns = 1;
-#warning TODO: make configurable
-		strip_leading_columns = 1;
 		add_trailing_rows = 1;
 	};
 
@@ -54,11 +52,11 @@ public:
 	}
 
 	inline int mapColumnFromSource (int column) const {
-		return qMax (0, column - strip_leading_columns);
+		return qMax (0, column);
 	}
 
 	inline int mapColumnToSource (int column) const {
-		return qMin (sourceModel ()->columnCount () - 1, column + strip_leading_columns);
+		return qMin (sourceModel ()->columnCount () - 1, column);
 	}
 
 	inline bool isTrailingColumn (int column) const {
@@ -166,7 +164,6 @@ public:
 	static const quint32 real_item_id = 0xFFFFFFFF;
 	static const quint32 trailing_item_id = 0xFFFFFFFE;
 	int add_trailing_columns;
-	int strip_leading_columns;
 	int add_trailing_rows;
 public slots:
 	void r_rowsInserted (const QModelIndex& parent, int start, int end) {
diff --git a/rkward/plugin/rkoptionset.cpp b/rkward/plugin/rkoptionset.cpp
index b3a2b3d..4e90dab 100644
--- a/rkward/plugin/rkoptionset.cpp
+++ b/rkward/plugin/rkoptionset.cpp
@@ -45,7 +45,6 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
 	updating = false;
 	last_known_status = Processing;
 	n_invalid_rows = n_unfinished_rows = 0;
-	display_show_index = false;
 
 	min_rows = xml->getIntAttribute (element, "min_rows", 0, DL_INFO);
 	min_rows_if_any = xml->getIntAttribute (element, "min_rows_if_any", 1, DL_INFO);
@@ -53,6 +52,7 @@ 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);
@@ -96,7 +96,7 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
 	// create columns
 	XMLChildList options = xml->getChildElements (element, "optioncolumn", DL_WARNING);
 
-	QStringList visible_column_labels ("#");	// Optionally hidden first row for index
+	QStringList visible_column_labels;
 	for (int i = 0; i < options.size (); ++i) {
 		const QDomElement &e = options.at (i);
 		QString id = xml->getStringAttribute (e, "id", QString (), DL_ERROR);
@@ -815,8 +815,7 @@ QVariant RKOptionSetDisplayModel::data (const QModelIndex& index, int role) cons
 	int column = index.column ();
 
 	if (role == Qt::DisplayRole) {
-		if (column == 0) return QVariant (QString::number (row + 1));
-		RKComponentPropertyStringList *p = set->visible_columns.value (column - 1);
+		RKComponentPropertyStringList *p = set->visible_columns.value (column);
 		if (p) {
 			return QVariant (p->valueAt (row));
 		} else {
diff --git a/rkward/plugin/rkoptionset.h b/rkward/plugin/rkoptionset.h
index 00120ed..c102e49 100644
--- a/rkward/plugin/rkoptionset.h
+++ b/rkward/plugin/rkoptionset.h
@@ -41,7 +41,6 @@ public:
 	RKOptionSet (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKOptionSet ();
 	int type () { return ComponentOptionSet; };
-	void setDisplayShowIndex (bool show_index) { display_show_index = show_index; };
 	bool isValid ();
 	/** reimplemented from RKComponent */
 	ComponentStatus recursiveStatus ();
@@ -111,7 +110,6 @@ friend class RKOptionSetDisplayModel;
 	QHash<QString, PropertyValueMap> former_row_states;
 
 	RKComponent *contents_container;
-	bool display_show_index;
 	ComponentStatus last_known_status;
 
 	RKOptionSetDisplayModel* model;
diff --git a/rkward/plugin/rkstandardcomponent.cpp b/rkward/plugin/rkstandardcomponent.cpp
index 22fca99..337f312 100644
--- a/rkward/plugin/rkstandardcomponent.cpp
+++ b/rkward/plugin/rkstandardcomponent.cpp
@@ -674,12 +674,8 @@ void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xm
 		} else if (e.tagName () == QLatin1String ("optionset")) {
 			widget = new RKOptionSet (e, component (), parent_widget);
 		} else if (e.tagName () == QLatin1String ("optiondisplay")) {
-			RKComponent *set = component ()->parentComponent ();
-			if (set->type () == RKComponentBase::ComponentOptionSet) {
-				static_cast<RKOptionSet *> (set)->setDisplayShowIndex (xml.getBoolAttribute (e, "index", false, DL_INFO));
-			} else {
-				xml.displayError (&e, QString ("optiondisplay element is not allowed outside of an optionset"), DL_ERROR);
-			}
+			// TODO: Remove after grace period. Last release to support optiondisplay: 0.6.3
+			xml.displayError (&e, QString ("<optiondisplay> element is obsolete. Ignoring."), DL_WARNING);
 /*		} else if (e.tagName () == QLatin1String ("scriptable")) {
  * TODO: We used to have some purely experimental code, here, to support fully custom elements (scripted via Kross->Forms). We will want 
  * to have something like that, eventually. After porting to KF5, Qt5, and thus dropping legacy support, the natural way to add this will



More information about the rkward-tracker mailing list