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 ***************************************************************************/
21 #ifndef IGNORELISTSETTINGSPAGE_H
22 #define IGNORELISTSETTINGSPAGE_H
24 #include <QStyledItemDelegate>
25 #include <QButtonGroup>
27 #include "settingspage.h"
28 #include "ui_ignorelistsettingspage.h"
29 #include "ui_ignorelisteditdlg.h"
30 #include "ignorelistmodel.h"
31 #include "clientignorelistmanager.h"
35 class QAbstractItemModel;
37 // the delegate is used to draw the checkbox in column 0
38 class IgnoreListDelegate : public QStyledItemDelegate
43 IgnoreListDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
44 void paint(QPainter *painter, const QStyleOptionViewItem &option,
45 const QModelIndex &index) const;
46 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
47 const QModelIndex &index);
51 class IgnoreListEditDlg : public QDialog
56 IgnoreListEditDlg(const IgnoreListManager::IgnoreListItem &item, QWidget *parent = 0, 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;
75 class IgnoreListSettingsPage : public SettingsPage
80 IgnoreListSettingsPage(QWidget *parent = 0);
81 ~IgnoreListSettingsPage();
82 virtual inline bool hasDefaults() const { return false; }
83 virtual inline bool needsCoreConnection() const { return true; }
84 void editIgnoreRule(const QString &ignoreRule);
90 void newIgnoreRule(QString rule = QString());
93 void enableDialog(bool);
94 void deleteSelectedIgnoreRule();
95 void editSelectedIgnoreRule();
96 void selectionChanged(const QItemSelection &selection, const QItemSelection &);
99 IgnoreListDelegate *_delegate;
100 Ui::IgnoreListSettingsPage ui;
101 IgnoreListModel _ignoreListModel;
105 #endif //IGNORELISTSETTINGSPAGE_H