402c823dbd9e132d260fea51fcc8d6d3710f28d0
[quassel.git] / src / qtui / settingspages / bufferviewsettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 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 "settingspage.h"
24 #include "ui_bufferviewsettingspage.h"
25 #include "ui_buffervieweditdlg.h"
26
27 #include <QItemSelection>
28
29 class BufferViewConfig;
30
31 class BufferViewSettingsPage : public SettingsPage
32 {
33     Q_OBJECT
34
35 public:
36     BufferViewSettingsPage(QWidget *parent = 0);
37     ~BufferViewSettingsPage();
38
39 public slots:
40     void save() final override;
41     void load() final override;
42     void reset();
43
44 private slots:
45     void coreConnectionStateChanged(bool state);
46
47     void addBufferView(BufferViewConfig *config);
48     void addBufferView(int bufferViewId);
49     void bufferViewDeleted();
50     void newBufferView(const QString &bufferViewName);
51     void updateBufferView();
52
53     void enableStatusBuffers(int networkIdx);
54
55     void on_addBufferView_clicked();
56     void on_renameBufferView_clicked();
57     void on_deleteBufferView_clicked();
58     void bufferViewSelectionChanged(const QItemSelection &current, const QItemSelection &previous);
59
60     void widgetHasChanged();
61
62 private:
63     Ui::BufferViewSettingsPage ui;
64     bool _ignoreWidgetChanges;
65     bool _useBufferViewHint;
66     int _bufferViewHint;
67
68     // list of bufferviews to create
69     QList<BufferViewConfig *> _newBufferViews;
70
71     // list of buferViews to delete
72     QList<int> _deleteBufferViews;
73
74     // Hash of pointers to cloned bufferViewConfigs holding the changes
75     QHash<BufferViewConfig *, BufferViewConfig *> _changedBufferViews;
76
77     int listPos(BufferViewConfig *config);
78     BufferViewConfig *bufferView(int listPos);
79     bool selectBufferViewById(int bufferViewId);
80     BufferViewConfig *cloneConfig(BufferViewConfig *config);
81     BufferViewConfig *configForDisplay(BufferViewConfig *config);
82
83     void loadConfig(BufferViewConfig *config);
84     void saveConfig(BufferViewConfig *config);
85     bool testHasChanged();
86 };
87
88
89 /**************************************************************************
90  * BufferViewEditDlg
91  *************************************************************************/
92 class BufferViewEditDlg : public QDialog
93 {
94     Q_OBJECT
95
96 public:
97     BufferViewEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
98
99     inline QString bufferViewName() const { return ui.bufferViewEdit->text(); }
100
101 private slots:
102     void on_bufferViewEdit_textChanged(const QString &);
103
104 private:
105     Ui::BufferViewEditDlg ui;
106
107     QStringList existing;
108 };