clang-tidy: Mark several settingspage methods as final
[quassel.git] / src / qtui / settingspages / corehighlightsettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include <QVariantList>
24 #include <QTableWidgetItem>
25
26 #include "highlightrulemanager.h"
27 #include "settingspage.h"
28
29 #include "ui_corehighlightsettingspage.h"
30
31 class CoreHighlightSettingsPage : public SettingsPage
32 {
33     Q_OBJECT
34
35 public:
36     explicit CoreHighlightSettingsPage(QWidget *parent = nullptr);
37
38     bool hasDefaults() const override;
39
40     bool isSelectable() const override;
41
42 public slots:
43     void save() final override;
44     void load() final override;
45     void defaults() final override;
46     void revert();
47     void clientConnected();
48
49 private slots:
50     void coreConnectionStateChanged(bool state);
51     void widgetHasChanged();
52     void addNewHighlightRow(bool enable = true, int id = -1, const QString &name = tr("highlight rule"), bool regex = false,
53                             bool cs = false, const QString &sender = "", const QString &chanName = "",
54                             bool self = false);
55     void addNewIgnoredRow(bool enable = true, int id = -1, const QString &name = tr("highlight rule"), bool regex = false,
56                           bool cs = false, const QString &sender = "", const QString &chanName = "", bool self = false);
57     void removeSelectedHighlightRows();
58     void removeSelectedIgnoredRows();
59     void highlightNicksChanged(int index);
60     void selectHighlightRow(QTableWidgetItem *item);
61     void selectIgnoredRow(QTableWidgetItem *item);
62     void highlightTableChanged(QTableWidgetItem *item);
63     void ignoredTableChanged(QTableWidgetItem *item);
64
65     /** Import local Highlight rules into the Core Highlight rules
66      *
67      * Iterates through all local highlight rules, converting each into core-side highlight rules.
68      */
69     void importRules();
70
71     /**
72      * Event handler for core unspported Details button
73      */
74     void on_coreUnsupportedDetails_clicked();
75
76 private:
77     Ui::CoreHighlightSettingsPage ui;
78
79     HighlightRuleManager::HighlightRuleList highlightList;
80     HighlightRuleManager::HighlightRuleList ignoredList;
81
82     enum column {
83         EnableColumn = 0,
84         NameColumn = 1,
85         RegExColumn = 2,
86         CsColumn = 3,
87         SenderColumn = 4,
88         ChanColumn = 5,
89         ColumnCount = 6
90     };
91
92     void emptyHighlightTable();
93     void emptyIgnoredTable();
94
95     void setupRuleTable(QTableWidget *highlightTable) const;
96
97     /**
98      * Get tooltip for the specified rule table column
99      *
100      * @param tableColumn Column to retrieve tooltip
101      * @return Translated tooltip for the specified column
102      */
103     QString getTableTooltip(column tableColumn) const;
104
105     /**
106      * Setup tooltips and "What's this?" prompts for table entries
107      *
108      * @param enableWidget  Enabled checkbox
109      * @param nameWidget    Rule name
110      * @param regExWidget   RegEx enabled
111      * @param csWidget      Case-sensitive
112      * @param senderWidget  Sender name
113      * @param chanWidget    Channel name
114      */
115     void setupTableTooltips(QWidget *enableWidget, QWidget *nameWidget, QWidget *regExWidget,
116                             QWidget *csWidget, QWidget *senderWidget, QWidget *chanWidget) const;
117
118     /**
119      * Setup tooltips and "What's this?" prompts for table entries
120      *
121      * @param enableWidget  Enabled checkbox
122      * @param nameWidget    Rule name
123      * @param regExWidget   RegEx enabled
124      * @param csWidget      Case-sensitive
125      * @param senderWidget  Sender name
126      * @param chanWidget    Channel name
127      */
128     void setupTableTooltips(QTableWidgetItem *enableWidget, QTableWidgetItem *nameWidget,
129                             QTableWidgetItem *regExWidget, QTableWidgetItem *csWidget,
130                             QTableWidgetItem *senderWidget, QTableWidgetItem *chanWidget) const;
131
132     /** Update the UI to show core support for highlights
133      *
134      * Shows or hides the UI warnings around core-side highlights according to core connection and
135      * core feature support.
136      *
137      * @param state  True if connected to core, otherwise false
138      */
139     void updateCoreSupportStatus(bool state);
140
141     int nextId();
142
143     bool _initialized;
144 };