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 <QVariantList>
24 #include <QTableWidgetItem>
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;
45 void defaults() override;
47 void clientConnected();
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 = "",
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);
65 /** Import local Highlight rules into the Core Highlight rules
67 * Iterates through all local highlight rules, converting each into core-side highlight rules.
72 * Event handler for core unspported Details button
74 void on_coreUnsupportedDetails_clicked();
77 Ui::CoreHighlightSettingsPage ui;
79 HighlightRuleManager::HighlightRuleList highlightList;
80 HighlightRuleManager::HighlightRuleList ignoredList;
92 void emptyHighlightTable();
93 void emptyIgnoredTable();
95 void setupRuleTable(QTableWidget *highlightTable) const;
98 * Get tooltip for the specified rule table column
100 * @param tableColumn Column to retrieve tooltip
101 * @return Translated tooltip for the specified column
103 QString getTableTooltip(column tableColumn) const;
106 * Setup tooltips and "What's this?" prompts for table entries
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
115 void setupTableTooltips(QWidget *enableWidget, QWidget *nameWidget, QWidget *regExWidget,
116 QWidget *csWidget, QWidget *senderWidget, QWidget *chanWidget) const;
119 * Setup tooltips and "What's this?" prompts for table entries
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
128 void setupTableTooltips(QTableWidgetItem *enableWidget, QTableWidgetItem *nameWidget,
129 QTableWidgetItem *regExWidget, QTableWidgetItem *csWidget,
130 QTableWidgetItem *senderWidget, QTableWidgetItem *chanWidget) const;
132 /** Update the UI to show core support for highlights
134 * Shows or hides the UI warnings around core-side highlights according to core connection and
135 * core feature support.
137 * @param state True if connected to core, otherwise false
139 void updateCoreSupportStatus(bool state);