a3f32c1d13260612cac1297906c227db1fcbdb98
[quassel.git] / src / qtui / settingspages / bufferviewsettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef BUFFERVIEWSETTINGSPAGE_H
22 #define BUFFERVIEWSETTINGSPAGE_H
23
24 #include "settingspage.h"
25 #include "ui_bufferviewsettingspage.h"
26 #include "ui_buffervieweditdlg.h"
27
28 class BufferViewConfig;
29
30 class BufferViewSettingsPage : public SettingsPage {
31   Q_OBJECT
32
33 public:
34   BufferViewSettingsPage(QWidget *parent = 0);
35
36 public slots:
37   void save();
38   void load();
39   void reset();
40
41 private slots:
42   void coreConnectionStateChanged(bool state);
43
44   void addBufferView(BufferViewConfig *config);
45   void addBufferView(int bufferViewId);
46   void newBufferView(const QString &bufferViewName);
47   void updateBufferView();
48
49   void on_addBufferView_clicked();
50   void on_renameBufferView_clicked();
51   
52 private:
53   Ui::BufferViewSettingsPage ui;
54
55   // mappings for bufferViewId to position in the list and vice versa
56   QHash<int, int> _viewToListPos;
57   QHash<int, int> _listPosToView;
58
59   // list of bufferviews to create
60   QList<BufferViewConfig *> _newBufferViews;
61
62   // Hash of pointers to cloned bufferViewConfigs holding the changes
63   QHash<BufferViewConfig *, BufferViewConfig *> _changedBufferViews;
64
65   int listPos(BufferViewConfig *config);
66   int bufferViewId(int listPos);
67 };
68
69
70 /**************************************************************************
71  * BufferViewEditDlg
72  *************************************************************************/
73 class BufferViewEditDlg : public QDialog {
74   Q_OBJECT
75
76 public:
77   BufferViewEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
78
79   inline QString bufferViewName() const { return ui.bufferViewEdit->text(); }
80
81 private slots:
82   void on_bufferViewEdit_textChanged(const QString &);
83   
84 private:
85   Ui::BufferViewEditDlg ui;
86
87   QStringList existing;
88 };
89
90
91
92 #endif // BUFFERVIEWSETTINGSPAGE_H