[rkward-cvs] SF.net SVN: rkward:[4431] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue Nov 13 14:42:38 UTC 2012
Revision: 4431
http://rkward.svn.sourceforge.net/rkward/?rev=4431&view=rev
Author: tfry
Date: 2012-11-13 14:42:38 +0000 (Tue, 13 Nov 2012)
Log Message:
-----------
Fix some more optionset bugs and give better status feedback
Modified Paths:
--------------
trunk/rkward/rkward/plugin/rkoptionset.cpp
trunk/rkward/rkward/plugin/rkoptionset.h
trunk/rkward/rkward/plugins/testing/optionset.xml
Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp 2012-11-13 10:03:20 UTC (rev 4430)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp 2012-11-13 14:42:38 UTC (rev 4431)
@@ -166,7 +166,6 @@
}
n_invalid_rows = n_unfinished_rows = 0;
- updateVisuals ();
}
RKOptionSet::~RKOptionSet () {
@@ -280,21 +279,25 @@
}
void RKOptionSet::setRowState (int row, bool finished, bool valid) {
+ bool changed = false;
RK_ASSERT (row < rows.size ());
if (rows[row].finished != finished) {
rows[row].finished = finished;
finished ? --n_unfinished_rows : ++n_unfinished_rows;
+ changed = true;
}
if (rows[row].valid != valid) {
rows[row].valid = valid;
valid ? --n_invalid_rows : ++n_invalid_rows;
+ changed = true;
}
+ if (changed && model) model->dataChanged (model->index (row, 0), model->index (row, model->columnCount () - 1));
}
void RKOptionSet::changed () {
int row = active_row;
- if (row > 0) {
+ if (row >= 0) {
ComponentStatus cs = contents_container->recursiveStatus ();
setRowState (row, cs != Processing, cs == Satisfied);
}
@@ -302,7 +305,7 @@
ComponentStatus s = recursiveStatus ();
if (s != last_known_status) {
last_known_status = s;
- updateVisuals ();
+ if (model) model->headerDataChanged (Qt::Horizontal, 0, model->columnCount () - 1);
}
RKComponent::changed ();
@@ -347,7 +350,10 @@
}
if (target == keycolumn) handleKeycolumnUpdate ();
- else if (model) model->dataChanged (model->index (ci.display_index, 0), model->index (ci.display_index, model->rowCount ()));
+ else {
+ if (model) model->dataChanged (model->index (ci.display_index, 0), model->index (ci.display_index, model->rowCount ()));
+ applyContentsFromExternalColumn (target, active_row);
+ }
}
void RKOptionSet::handleKeycolumnUpdate () {
@@ -370,6 +376,9 @@
return; // no change
}
+ // get state of current row (which may subsequently be moved or even deleted
+ storeRowSerialization (active_row);
+
// update all columns
QMap<RKComponentPropertyStringList *, ColumnInfo>::iterator it = column_map.begin ();
for (; it != column_map.end (); ++it) {
@@ -430,6 +439,7 @@
activate_row = qMin (nrows - 1, activate_row);
current_row->setIntValue (active_row = activate_row);
if (model) model->triggerReset ();
+ setContentsForRow (active_row);
changed ();
}
@@ -472,22 +482,6 @@
contents_container->enablednessProperty ()->setBoolValue (row >= 0);
}
-void RKOptionSet::updateVisuals () {
- RK_TRACE (PLUGIN);
-
- if (!display) return;
-
- QPalette palette = display->header ()->palette ();
- if (isInactive ()) {
- palette.setColor (QPalette::Window, QColor (200, 200, 200));
- } else if (!isSatisfied ()) {
- palette.setColor (QPalette::Window, QColor (255, 0, 0));
- } else {
- palette.setColor (QPalette::Window, QColor (255, 255, 255));
- }
- display->header ()->setPalette (palette);
-}
-
void RKOptionSet::storeRowSerialization (int row) {
RK_TRACE (PLUGIN);
@@ -591,6 +585,14 @@
} else {
RK_ASSERT (false);
}
+ } else if (role == Qt::BackgroundRole) {
+ const RKOptionSet::RowInfo &ri = set->rows[row];
+ if (!ri.finished) return Qt::yellow;
+ if (!ri.valid) return Qt::red;
+ } else if (role == Qt::ToolTipRole) {
+ const RKOptionSet::RowInfo &ri = set->rows[row];
+ if (!ri.finished) return i18n ("This row has not yet been processed.");
+ if (!ri.valid) return i18n ("This row contains invalid settings.");
}
return QVariant ();
@@ -602,10 +604,23 @@
}
QVariant RKOptionSetDisplayModel::headerData (int section, Qt::Orientation orientation, int role) const {
- if (role == Qt::DisplayRole) {
- if (orientation == Qt::Horizontal) {
- return (column_labels.value (section));
+ if (orientation == Qt::Horizontal) {
+ if (role == Qt::DisplayRole) return (column_labels.value (section));
+ if (role == Qt::BackgroundRole) {
+ if (set->n_unfinished_rows > 0) return Qt::yellow;
+ if (!set->isValid ()) return Qt::red;
}
+ if (role == Qt::ToolTipRole) {
+ if (set->n_unfinished_rows > 0) return i18n ("Please wait while settings are being processed");
+ if (!set->isValid ()) {
+ QStringList probs;
+ if (set->n_invalid_rows > set->n_unfinished_rows) probs.append (i18n ("One or more rows contain invalid settings."));
+ if ((set->rowCount () > 0) && (set->rowCount () < set->min_rows_if_any)) probs.append (i18n ("At least %1 rows have to be defined (if any)").arg (set->min_rows_if_any));
+ if (set->rowCount () < set->min_rows) probs.append (i18n ("At least %1 rows have to be defined").arg (set->min_rows));
+ if (set->rowCount () > set->max_rows) probs.append (i18n ("At most %1 rows may be defined").arg (set->max_rows));
+ return (QString ("<p>%1</p><ul><li>%2</li></ul>").arg (i18n ("This element is not valid for the following reason(s):")).arg (probs.join ("</li>\n<li>")));
+ }
+ }
}
return QVariant ();
}
Modified: trunk/rkward/rkward/plugin/rkoptionset.h
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.h 2012-11-13 10:03:20 UTC (rev 4430)
+++ trunk/rkward/rkward/plugin/rkoptionset.h 2012-11-13 14:42:38 UTC (rev 4431)
@@ -58,7 +58,6 @@
void currentRowChanged ();
private:
friend class RKOptionSetDisplayModel;
- void updateVisuals ();
int rowCount () const { return row_count->intValue (); };
void setRowState (int row, bool finished, bool valid);
void storeRowSerialization (int row);
Modified: trunk/rkward/rkward/plugins/testing/optionset.xml
===================================================================
--- trunk/rkward/rkward/plugins/testing/optionset.xml 2012-11-13 10:03:20 UTC (rev 4430)
+++ trunk/rkward/rkward/plugins/testing/optionset.xml 2012-11-13 14:42:38 UTC (rev 4431)
@@ -68,10 +68,10 @@
<input id="commentb" label="Comment B"/>
</frame>
</content>
- <option id="var" label="test" restorable="false"/>
- <option id="varname" label="Varname" restorable="false"/>
- <option id="ca" label="Comment A" connect="commenta.text" restorable="true"/>
- <option id="cb" connect="commentb.text" restorable="true" default="This is a default entry. Change it, if you like."/>
+ <option id="var" label="test" external="true"/>
+ <option id="varname" label="Varname" external="true"/>
+ <option id="ca" label="Comment A" connect="commenta.text"/>
+ <option id="cb" connect="commentb.text" default="This is a default entry. Change it, if you like."/>
</optionset>
</row>
</tab>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list