From c1ac72f9fd5e8da003eee57552586fee93e937fb Mon Sep 17 00:00:00 2001 From: Richard Maudsley <richard.maudsley@isode.com> Date: Tue, 21 Jan 2014 10:23:31 +0000 Subject: GUI Tweaks. Change-Id: Ibe58d9c0fccc4f96854aa486415372f98a3eb167 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(); -- cgit v0.10.2-6-g49f6