Make Highlight table select newly added rule
authorsalnx <linuxstalker@gmail.com>
Tue, 9 Jun 2009 19:54:55 +0000 (23:54 +0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 22 May 2012 18:50:18 +0000 (20:50 +0200)
This also slightly improves usability if table contains many rows so user don't have to scroll down manually when adding rule.

Signed-off-by: Bas Pape <baspape@gmail.com>
src/qtui/settingspages/highlightsettingspage.cpp
src/qtui/settingspages/highlightsettingspage.h

index 4d169f2..82613af 100644 (file)
@@ -73,7 +73,7 @@ void HighlightSettingsPage::defaults() {
   widgetHasChanged();
 }
 
-void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool enable, QString chanName) {
+void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool enable, QString chanName, bool self) {
   ui.highlightTable->setRowCount(ui.highlightTable->rowCount()+1);
 
   QTableWidgetItem *nameItem = new QTableWidgetItem(name);
@@ -108,6 +108,9 @@ void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool en
   ui.highlightTable->setItem(lastRow, HighlightSettingsPage::EnableColumn, enableItem);
   ui.highlightTable->setItem(lastRow, HighlightSettingsPage::ChanColumn, chanNameItem);
 
+  if(!self)
+    ui.highlightTable->setCurrentItem(nameItem);
+
   QVariantMap highlightRule;
   highlightRule["Name"] = name;
   highlightRule["RegEx"] = regex;
@@ -199,7 +202,7 @@ void HighlightSettingsPage::load() {
     bool enable = highlightRule["Enable"].toBool();
     QString chanName = highlightRule["Chan"].toString();
 
-    addNewRow(name, regex, cs, enable, chanName);
+    addNewRow(name, regex, cs, enable, chanName, true);
   }
 
   switch(notificationSettings.highlightNick())
index 60996f1..d4fd3d3 100644 (file)
@@ -42,7 +42,7 @@ class HighlightSettingsPage : public SettingsPage {
 
   private slots:
     void widgetHasChanged();
-    void addNewRow(QString name = tr("highlight rule"), bool regex = false, bool cs = true, bool enable = true, QString chanName = "");
+    void addNewRow(QString name = tr("highlight rule"), bool regex = false, bool cs = true, bool enable = true, QString chanName = "", bool self = false);
     void removeSelectedRows();
     void selectRow(QTableWidgetItem *item);
     void tableChanged(QTableWidgetItem *item);