1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
23 #include <QTableWidgetItem>
24 #include <QVariantList>
26 #include "highlightrulemanager.h"
27 #include "settingspage.h"
29 #include "ui_corehighlightsettingspage.h"
31 class CoreHighlightSettingsPage : public SettingsPage
36 explicit CoreHighlightSettingsPage(QWidget* parent = nullptr);
38 bool hasDefaults() const override;
40 bool isSelectable() const override;
43 void save() final override;
44 void load() final override;
45 void defaults() final override;
47 void clientConnected();
50 void coreConnectionStateChanged(bool state);
51 void widgetHasChanged();
52 void addNewHighlightRow(bool enable = true,
54 const QString& name = tr("highlight rule"),
57 const QString& sender = "",
58 const QString& chanName = "",
60 void addNewIgnoredRow(bool enable = true,
62 const QString& name = tr("highlight rule"),
65 const QString& sender = "",
66 const QString& chanName = "",
68 void removeSelectedHighlightRows();
69 void removeSelectedIgnoredRows();
70 void highlightNicksChanged(int index);
71 void selectHighlightRow(QTableWidgetItem* item);
72 void selectIgnoredRow(QTableWidgetItem* item);
73 void highlightTableChanged(QTableWidgetItem* item);
74 void ignoredTableChanged(QTableWidgetItem* item);
76 /** Import local Highlight rules into the Core Highlight rules
78 * Iterates through all local highlight rules, converting each into core-side highlight rules.
83 * Event handler for core unspported Details button
85 void on_coreUnsupportedDetails_clicked();
88 Ui::CoreHighlightSettingsPage ui;
90 HighlightRuleManager::HighlightRuleList highlightList;
91 HighlightRuleManager::HighlightRuleList ignoredList;
104 void emptyHighlightTable();
105 void emptyIgnoredTable();
107 void setupRuleTable(QTableWidget* highlightTable) const;
110 * Get tooltip for the specified rule table column
112 * @param tableColumn Column to retrieve tooltip
113 * @return Translated tooltip for the specified column
115 QString getTableTooltip(column tableColumn) const;
118 * Setup tooltips and "What's this?" prompts for table entries
120 * @param enableWidget Enabled checkbox
121 * @param nameWidget Rule name
122 * @param regExWidget RegEx enabled
123 * @param csWidget Case-sensitive
124 * @param senderWidget Sender name
125 * @param chanWidget Channel name
127 void setupTableTooltips(
128 QWidget* enableWidget, QWidget* nameWidget, QWidget* regExWidget, QWidget* csWidget, QWidget* senderWidget, QWidget* chanWidget) const;
131 * Setup tooltips and "What's this?" prompts for table entries
133 * @param enableWidget Enabled checkbox
134 * @param nameWidget Rule name
135 * @param regExWidget RegEx enabled
136 * @param csWidget Case-sensitive
137 * @param senderWidget Sender name
138 * @param chanWidget Channel name
140 void setupTableTooltips(QTableWidgetItem* enableWidget,
141 QTableWidgetItem* nameWidget,
142 QTableWidgetItem* regExWidget,
143 QTableWidgetItem* csWidget,
144 QTableWidgetItem* senderWidget,
145 QTableWidgetItem* chanWidget) const;
147 /** Update the UI to show core support for highlights
149 * Shows or hides the UI warnings around core-side highlights according to core connection and
150 * core feature support.
152 * @param state True if connected to core, otherwise false
154 void updateCoreSupportStatus(bool state);