summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp23
-rw-r--r--Swift/QtUI/QtHighlightEditor.h1
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);