cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / settingspages / corehighlightsettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2022 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 <QTableWidgetItem>
24 #include <QVariantList>
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 signals:
50     /**
51      * Signals the local highlight settings have been changed as part of cleaning up after
52      * importing the rules locally.
53      *
54      * @see CoreHighlightSettingsPage::importRules()
55      */
56     void localHighlightsChanged();
57
58 private slots:
59     void coreConnectionStateChanged(bool state);
60     void widgetHasChanged();
61     void addNewHighlightRow(bool enable = true,
62                             int id = -1,
63                             const QString& name = tr("highlight rule"),
64                             bool regex = false,
65                             bool cs = false,
66                             const QString& sender = "",
67                             const QString& chanName = "",
68                             bool self = false);
69     void addNewIgnoredRow(bool enable = true,
70                           int id = -1,
71                           const QString& name = tr("highlight rule"),
72                           bool regex = false,
73                           bool cs = false,
74                           const QString& sender = "",
75                           const QString& chanName = "",
76                           bool self = false);
77     void removeSelectedHighlightRows();
78     void removeSelectedIgnoredRows();
79     void highlightNicksChanged(int index);
80     void selectHighlightRow(QTableWidgetItem* item);
81     void selectIgnoredRow(QTableWidgetItem* item);
82     void highlightTableChanged(QTableWidgetItem* item);
83     void ignoredTableChanged(QTableWidgetItem* item);
84
85     /** Import local Highlight rules into the Core Highlight rules
86      *
87      * Iterates through all local highlight rules, converting each into core-side highlight rules.
88      */
89     void importRules();
90
91     /**
92      * Event handler for core unsupported Details button
93      */
94     void on_coreUnsupportedDetails_clicked();
95
96 private:
97     Ui::CoreHighlightSettingsPage ui;
98
99     HighlightRuleManager::HighlightRuleList highlightList;
100     HighlightRuleManager::HighlightRuleList ignoredList;
101
102     enum column
103     {
104         EnableColumn = 0,
105         NameColumn = 1,
106         RegExColumn = 2,
107         CsColumn = 3,
108         SenderColumn = 4,
109         ChanColumn = 5,
110         ColumnCount = 6
111     };
112
113     void emptyHighlightTable();
114     void emptyIgnoredTable();
115
116     void setupRuleTable(QTableWidget* highlightTable) const;
117
118     /**
119      * Get tooltip for the specified rule table column
120      *
121      * @param tableColumn Column to retrieve tooltip
122      * @return Translated tooltip for the specified column
123      */
124     QString getTableTooltip(column tableColumn) const;
125
126     /**
127      * Setup tooltips and "What's this?" prompts for table entries
128      *
129      * @param enableWidget  Enabled checkbox
130      * @param nameWidget    Rule name
131      * @param regExWidget   RegEx enabled
132      * @param csWidget      Case-sensitive
133      * @param senderWidget  Sender name
134      * @param chanWidget    Channel name
135      */
136     void setupTableTooltips(
137         QWidget* enableWidget, QWidget* nameWidget, QWidget* regExWidget, QWidget* csWidget, QWidget* senderWidget, QWidget* chanWidget) const;
138
139     /**
140      * Setup tooltips and "What's this?" prompts for table entries
141      *
142      * @param enableWidget  Enabled checkbox
143      * @param nameWidget    Rule name
144      * @param regExWidget   RegEx enabled
145      * @param csWidget      Case-sensitive
146      * @param senderWidget  Sender name
147      * @param chanWidget    Channel name
148      */
149     void setupTableTooltips(QTableWidgetItem* enableWidget,
150                             QTableWidgetItem* nameWidget,
151                             QTableWidgetItem* regExWidget,
152                             QTableWidgetItem* csWidget,
153                             QTableWidgetItem* senderWidget,
154                             QTableWidgetItem* chanWidget) const;
155
156     /** Update the UI to show core support for highlights
157      *
158      * Shows or hides the UI warnings around core-side highlights according to core connection and
159      * core feature support.
160      *
161      * @param state  True if connected to core, otherwise false
162      */
163     void updateCoreSupportStatus(bool state);
164
165     int nextId();
166
167     bool _initialized;
168 };