summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp23
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
2 files changed, 17 insertions, 8 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
index 7bb7736..5d3cf2a 100644
--- a/Swift/QtUI/QtHighlightEditor.cpp
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -170,14 +170,9 @@ std::string formatShortDescription(const HighlightRule &rule)
void QtHighlightEditor::show()
{
- ui_.listWidget->clear();
-
highlightManager_->loadSettings();
- foreach(const HighlightRule &rule, highlightManager_->getRules()) {
- QListWidgetItem *item = new QListWidgetItem();
- item->setText(P2QSTRING(formatShortDescription(rule)));
- ui_.listWidget->addItem(item);
- }
+
+ populateList();
if (ui_.listWidget->count()) {
selectRow(0);
@@ -227,6 +222,7 @@ void QtHighlightEditor::soundCustomSelect()
void QtHighlightEditor::onNewButtonClicked()
{
int row = getSelectedRow() + 1;
+ populateList();
HighlightRule newRule;
newRule.setMatchChat(true);
highlightManager_->insertRule(row, newRule);
@@ -271,6 +267,9 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow)
HighlightRule rule = highlightManager_->getRule(currentRow);
ruleToDialog(rule);
ui_.ruleDescription->setText(P2QSTRING(formatLongDescription(rule)));
+ if (ui_.listWidget->currentItem()) {
+ ui_.listWidget->currentItem()->setText(P2QSTRING(formatShortDescription(rule)));
+ }
}
/* grey the dialog if we have nothing selected */
@@ -379,6 +378,16 @@ void QtHighlightEditor::selectSoundFile()
ui_.soundFile->setText(path);
}
+void QtHighlightEditor::populateList()
+{
+ ui_.listWidget->clear();
+ foreach(const HighlightRule &rule, highlightManager_->getRules()) {
+ QListWidgetItem *item = new QListWidgetItem();
+ item->setText(P2QSTRING(formatShortDescription(rule)));
+ ui_.listWidget->addItem(item);
+ }
+}
+
void QtHighlightEditor::selectRow(int row)
{
for (int i = 0; i < ui_.listWidget->count(); ++i) {
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index 6d3d42d..52414a6 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -50,7 +50,7 @@ namespace Swift {
void selectSoundFile();
private:
-
+ void populateList();
void selectRow(int row);
int getSelectedRow() const;
HighlightRule ruleFromDialog();