diff options
author | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 09:54:37 (GMT) |
---|---|---|
committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-01-20 09:54:37 (GMT) |
commit | abb8248355783ad77b0a8099e8acd36a46dda7cc (patch) | |
tree | 06fc7283cd30026a09fd8b99ee00449577cf644d /Swift | |
parent | 97d03baffbf399c98238f9583c2718b5e7ab4b0e (diff) | |
download | swift-abb8248355783ad77b0a8099e8acd36a46dda7cc.zip swift-abb8248355783ad77b0a8099e8acd36a46dda7cc.tar.bz2 |
Updating ListWidget row description when configuration changes.
Change-Id: I537696127f27858a370b363904459ea7764e8d6a
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 23 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 1 |
2 files changed, 15 insertions, 9 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index bd71c37..6fa5406 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -210,11 +210,6 @@ void QtHighlightEditor::onDeleteButtonClicked() void QtHighlightEditor::onCurrentRowChanged(int currentRow) { - //ui_.ruleWidget->save(); - //ui_.ruleWidget->setActiveIndex(index); -// - //ui_.ruleWidget->setEnabled(index.isValid()); - ui_.deleteButton->setEnabled(currentRow != -1); ui_.moveUpButton->setEnabled(currentRow != -1 && currentRow != 0); ui_.moveDownButton->setEnabled(currentRow != -1 && currentRow != (ui_.listWidget->count()-1)); @@ -226,15 +221,15 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow) } if (currentRow != -1) { - ruleToDialog(highlightManager_->getRule(currentRow)); + HighlightRule rule = highlightManager_->getRule(currentRow); + ruleToDialog(rule); + ui_.ruleDescription->setText(P2QSTRING(formatNaturalDescription(rule))); } /* grey the dialog if we have nothing selected */ enableDialog(currentRow != -1); previousRow_ = currentRow; - - updateRuleDescription(); } void QtHighlightEditor::onApplyButtonClick() @@ -256,7 +251,10 @@ void QtHighlightEditor::onOkButtonClick() void QtHighlightEditor::updateRuleDescription() { - ui_.ruleDescription->setText(P2QSTRING(formatNaturalDescription(ruleFromDialog()))); + HighlightRule rule = ruleFromDialog(); + const std::string description = formatNaturalDescription(rule); + ui_.ruleDescription->setText(P2QSTRING(description)); + ui_.listWidget->item(getSelectedRow())->setText(P2QSTRING(description)); } void QtHighlightEditor::enableDialog(bool state) @@ -323,6 +321,13 @@ int QtHighlightEditor::getSelectedRow() const return -1; } +void QtHighlightEditor::setRowText(int row, const std::string &text) +{ + if (row>=0 && row<ui_.listWidget->count()) { + ui_.listWidget->item(row)->setText(P2QSTRING(text)); + } +} + HighlightRule QtHighlightEditor::ruleFromDialog() { HighlightRule rule; diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index 2c3a819..6cdb9d3 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -49,6 +49,7 @@ namespace Swift { void selectRow(int row); int getSelectedRow() const; + void setRowText(int row, const std::string &text); HighlightRule ruleFromDialog(); void ruleToDialog(const HighlightRule& rule); |