client: Unify Local/Remote Highlights table order
[quassel.git] / src / qtui / settingspages / highlightsettingspage.cpp
index c932d9f..330eb6d 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2015 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include "highlightsettingspage.h"
 
+#include "client.h"
 #include "qtui.h"
 #include "uisettings.h"
 
 #include <QHeaderView>
 
 HighlightSettingsPage::HighlightSettingsPage(QWidget *parent)
-    : SettingsPage(tr("Interface"), tr("Highlight"), parent)
+    : SettingsPage(tr("Interface"), tr("Local Highlights"), parent)
 {
     ui.setupUi(this);
     ui.highlightTable->verticalHeader()->hide();
@@ -78,7 +79,7 @@ bool HighlightSettingsPage::hasDefaults() const
 
 void HighlightSettingsPage::defaults()
 {
-    ui.highlightCurrentNick->setChecked(true);
+    ui.highlightNoNick->setChecked(true);
     ui.nicksCaseSensitive->setChecked(false);
     emptyTable();
 
@@ -90,6 +91,13 @@ void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool en
 {
     ui.highlightTable->setRowCount(ui.highlightTable->rowCount()+1);
 
+    QTableWidgetItem *enableItem = new QTableWidgetItem("");
+    if (enable)
+        enableItem->setCheckState(Qt::Checked);
+    else
+        enableItem->setCheckState(Qt::Unchecked);
+    enableItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
+
     QTableWidgetItem *nameItem = new QTableWidgetItem(name);
 
     QTableWidgetItem *regexItem = new QTableWidgetItem("");
@@ -106,20 +114,13 @@ void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool en
         csItem->setCheckState(Qt::Unchecked);
     csItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
 
-    QTableWidgetItem *enableItem = new QTableWidgetItem("");
-    if (enable)
-        enableItem->setCheckState(Qt::Checked);
-    else
-        enableItem->setCheckState(Qt::Unchecked);
-    enableItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
-
     QTableWidgetItem *chanNameItem = new QTableWidgetItem(chanName);
 
     int lastRow = ui.highlightTable->rowCount()-1;
+    ui.highlightTable->setItem(lastRow, HighlightSettingsPage::EnableColumn, enableItem);
     ui.highlightTable->setItem(lastRow, HighlightSettingsPage::NameColumn, nameItem);
     ui.highlightTable->setItem(lastRow, HighlightSettingsPage::RegExColumn, regexItem);
     ui.highlightTable->setItem(lastRow, HighlightSettingsPage::CsColumn, csItem);
-    ui.highlightTable->setItem(lastRow, HighlightSettingsPage::EnableColumn, enableItem);
     ui.highlightTable->setItem(lastRow, HighlightSettingsPage::ChanColumn, chanNameItem);
 
     if (!self)
@@ -187,6 +188,9 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem *item)
 
     switch (item->column())
     {
+    case HighlightSettingsPage::EnableColumn:
+        highlightRule["Enable"] = (item->checkState() == Qt::Checked);
+        break;
     case HighlightSettingsPage::NameColumn:
         if (item->text() == "")
             item->setText(tr("this shouldn't be empty"));
@@ -198,9 +202,6 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem *item)
     case HighlightSettingsPage::CsColumn:
         highlightRule["CS"] = (item->checkState() == Qt::Checked);
         break;
-    case HighlightSettingsPage::EnableColumn:
-        highlightRule["Enable"] = (item->checkState() == Qt::Checked);
-        break;
     case HighlightSettingsPage::ChanColumn:
         if (!item->text().isEmpty() && item->text().trimmed().isEmpty())
             item->setText("");
@@ -252,9 +253,7 @@ void HighlightSettingsPage::save()
     NotificationSettings notificationSettings;
     notificationSettings.setHighlightList(highlightList);
 
-    NotificationSettings::HighlightNickType highlightNickType;
-    if (ui.highlightNoNick->isChecked())
-        highlightNickType = NotificationSettings::NoNick;
+    NotificationSettings::HighlightNickType highlightNickType = NotificationSettings::NoNick;
     if (ui.highlightCurrentNick->isChecked())
         highlightNickType = NotificationSettings::CurrentNick;
     if (ui.highlightAllNicks->isChecked())
@@ -279,18 +278,18 @@ bool HighlightSettingsPage::testHasChanged()
 {
     NotificationSettings notificationSettings;
 
-    NotificationSettings::HighlightNickType highlightNickType;
-    if (ui.highlightNoNick->isChecked())
-        highlightNickType = NotificationSettings::NoNick;
+    NotificationSettings::HighlightNickType highlightNickType = NotificationSettings::NoNick;
     if (ui.highlightCurrentNick->isChecked())
         highlightNickType = NotificationSettings::CurrentNick;
     if (ui.highlightAllNicks->isChecked())
         highlightNickType = NotificationSettings::AllNicks;
 
-    if (notificationSettings.highlightNick() != highlightNickType) return true;
-    if (notificationSettings.nicksCaseSensitive() != ui.nicksCaseSensitive->isChecked()) return true;
-
-    if (notificationSettings.highlightList() != highlightList) return true;
+    if (notificationSettings.highlightNick() != highlightNickType)
+        return true;
+    if (notificationSettings.nicksCaseSensitive() != ui.nicksCaseSensitive->isChecked())
+        return true;
+    if (notificationSettings.highlightList() != highlightList)
+        return true;
 
     return false;
 }