(no commit message)
[quassel.git] / gui / serverlist.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel 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) any later version.                                   *
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 _SERVERLIST_H_
22 #define _SERVERLIST_H_
23
24 #include <QtGui>
25 #include <QMap>
26 #include <QList>
27 #include <QVariant>
28
29 #include "ui_serverlistdlg.h"
30 #include "ui_identitiesdlg.h"
31 #include "ui_identitieseditdlg.h"
32 #include "ui_nickeditdlg.h"
33 #include "ui_networkeditdlg.h"
34
35 typedef QMap<QString, QVariant> VarMap;
36
37 class ServerListDlg : public QDialog {
38   Q_OBJECT
39
40   public:
41     ServerListDlg(QWidget *parent);
42     virtual ~ServerListDlg();
43
44     bool showOnStartup();
45
46   public slots:
47     void editIdentities();
48
49   private slots:
50     void updateButtons();
51     void on_showOnStartup_stateChanged(int);
52     void on_addButton_clicked();
53
54   private:
55     Ui::ServerListDlg ui;
56
57     void loadNetworks();
58     void storeNetworks();
59     void loadIdentities();
60     void storeIdentities();
61
62     VarMap networks;
63     VarMap identities;
64 };
65
66 class NetworkEditDlg : public QDialog {
67   Q_OBJECT
68
69   public:
70     NetworkEditDlg(QWidget *parent, VarMap network, VarMap identities);
71
72   private:
73     Ui::NetworkEditDlg ui;
74
75     VarMap network;
76     VarMap identities;
77
78     VarMap createDefaultNetwork();
79 };
80
81 class IdentitiesDlg : public QDialog {
82   Q_OBJECT
83
84   public:
85     IdentitiesDlg(QWidget *parent, VarMap identities);
86
87     VarMap getIdentities() { return identities; }
88     QMap<QString, QString> getNameMapping() { return nameMapping; }
89
90   public slots:
91     virtual void accept();
92
93   private slots:
94     void autoAwayChecked();
95     void identityChanged(QString);
96     void nickSelectionChanged();
97
98     void addNick();
99     void editNick();
100     void delNick();
101     void upNick();
102     void downNick();
103
104     void editIdentities();
105
106   private:
107     Ui::IdentitiesDlg ui;
108     VarMap identities;
109     QMap<QString, QString> nameMapping;
110     QString lastIdentity;
111
112     QString checkValidity();
113     VarMap createDefaultIdentity();
114     QString getCurIdentity();
115     void updateWidgets();
116     void updateIdentity(QString);
117 };
118
119 class NickEditDlg : public QDialog {
120   Q_OBJECT
121
122   public:
123     NickEditDlg(QWidget *parent, QString nick = QString());
124
125     QString getNick();
126
127   private slots:
128     void textChanged(QString);
129
130   private:
131     Ui::NickEditDlg ui;
132
133 };
134
135 class IdentitiesEditDlg : public QDialog {
136   Q_OBJECT
137
138   public:
139     IdentitiesEditDlg(QWidget *parent, VarMap identities, QMap<QString, QString> mapping, VarMap templ);
140
141     VarMap getIdentities() { return identities; }
142     QMap<QString, QString> getMapping() { return mapping; }
143
144   private slots:
145     void selectionChanged();
146
147     void addIdentity();
148     void duplicateIdentity();
149     void renameIdentity();
150     void deleteIdentity();
151
152   private:
153     Ui::IdentitiesEditDlg ui;
154
155     VarMap identities;
156     VarMap identTemplate;
157     QMap<QString, QString> mapping;
158
159     void sortList();
160 };
161
162 class RenameIdentityDlg : public QDialog {
163   Q_OBJECT
164
165   public:
166     RenameIdentityDlg(QWidget *parent, QList<QString> reserved, QString name = QString());
167
168     QString getName();
169
170   private slots:
171     void textChanged(QString);
172
173   private:
174     Ui::NickEditDlg ui;
175     QList<QString> reserved;
176 };
177  
178 #endif