1 /***************************************************************************
2 * Copyright (C) 2005-2019 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 ***************************************************************************/
21 #ifndef IGNORELISTSETTINGSPAGE_H
22 #define IGNORELISTSETTINGSPAGE_H
24 #include <QButtonGroup>
25 #include <QStyledItemDelegate>
27 #include "clientignorelistmanager.h"
28 #include "ignorelistmodel.h"
29 #include "settingspage.h"
31 #include "ui_ignorelisteditdlg.h"
32 #include "ui_ignorelistsettingspage.h"
36 class QAbstractItemModel;
38 // the delegate is used to draw the checkbox in column 0
39 class IgnoreListDelegate : public QStyledItemDelegate
44 IgnoreListDelegate(QWidget* parent = nullptr)
45 : QStyledItemDelegate(parent)
47 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
48 bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
51 class IgnoreListEditDlg : public QDialog
56 IgnoreListEditDlg(const IgnoreListManager::IgnoreListItem& item, QWidget* parent = nullptr, bool enabled = false);
57 inline IgnoreListManager::IgnoreListItem ignoreListItem() { return _ignoreListItem; }
58 void enableOkButton(bool state);
61 void widgetHasChanged();
62 void aboutToAccept() { _ignoreListItem = _clonedIgnoreListItem; }
65 IgnoreListManager::IgnoreListItem _ignoreListItem;
66 IgnoreListManager::IgnoreListItem _clonedIgnoreListItem;
68 Ui::IgnoreListEditDlg ui;
69 QButtonGroup _typeButtonGroup;
70 QButtonGroup _strictnessButtonGroup;
71 QButtonGroup _scopeButtonGroup;
74 class IgnoreListSettingsPage : public SettingsPage
79 IgnoreListSettingsPage(QWidget* parent = nullptr);
80 ~IgnoreListSettingsPage() override;
81 inline bool hasDefaults() const override { return false; }
82 inline bool needsCoreConnection() const override { return true; }
83 void editIgnoreRule(const QString& ignoreRule);
88 void defaults() override;
89 void newIgnoreRule(const QString& rule = {});
92 void enableDialog(bool);
93 void deleteSelectedIgnoreRule();
94 void editSelectedIgnoreRule();
95 void selectionChanged(const QItemSelection& selection, const QItemSelection&);
98 IgnoreListDelegate* _delegate;
99 Ui::IgnoreListSettingsPage ui;
100 IgnoreListModel _ignoreListModel;
103 #endif // IGNORELISTSETTINGSPAGE_H