Fixed Bug #20 (Handle Numeric Reply 433 ERR_NICKNAMEINUSE properly)
[quassel.git] / gui / identities.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 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 _IDENTITIES_H_
22 #define _IDENTITIES_H_
23
24 #include <QtGui>
25 #include <QtCore>
26
27 #include "global.h"
28 #include "ui_identitiesdlg.h"
29 #include "ui_identitieseditdlg.h"
30 #include "ui_nickeditdlg.h"
31
32 class IdentitiesDlg : public QDialog {
33   Q_OBJECT
34
35   public:
36     IdentitiesDlg(QWidget *parent, QString selectedId = QString());
37
38     VarMap getIdentities() { return identities; }
39     QMap<QString, QString> getNameMapping() { return nameMapping; }
40
41   public slots:
42     virtual void accept();
43
44   private slots:
45     void autoAwayChecked();
46     void identityChanged(QString);
47     void nickSelectionChanged();
48
49     void addNick();
50     void editNick();
51     void delNick();
52     void upNick();
53     void downNick();
54
55     void editIdentities();
56
57     void globalDataUpdated(QString);
58
59   private:
60     Ui::IdentitiesDlg ui;
61     VarMap identities;
62     QMap<QString, QString> nameMapping;
63     QString lastIdentity;
64
65     QString checkValidity();
66     VarMap createDefaultIdentity();
67     QString getCurIdentity();
68     void updateWidgets();
69     void updateIdentity(QString);
70 };
71
72 class NickEditDlg : public QDialog {
73   Q_OBJECT
74
75   public:
76     NickEditDlg(QWidget *parent, QString nick = QString());
77
78     QString getNick();
79
80   private slots:
81     void textChanged(QString);
82
83   private:
84     Ui::NickEditDlg ui;
85
86 };
87
88 class IdentitiesEditDlg : public QDialog {
89   Q_OBJECT
90
91   public:
92     IdentitiesEditDlg(QWidget *parent, VarMap identities, QMap<QString, QString> mapping, VarMap templ, QString selected = QString());
93
94     VarMap getIdentities() { return identities; }
95     QMap<QString, QString> getMapping() { return mapping; }
96     QString getSelectedIdentity() { return ui.identList->currentItem()->text(); }
97
98     //virtual void accept();
99
100   private slots:
101     void selectionChanged();
102
103     void addIdentity();
104     void duplicateIdentity();
105     void renameIdentity();
106     void deleteIdentity();
107
108   private:
109     Ui::IdentitiesEditDlg ui;
110
111     VarMap identities;
112     VarMap identTemplate;
113     QMap<QString, QString> mapping;
114
115     void sortList();
116 };
117
118 class RenameIdentityDlg : public QDialog {
119   Q_OBJECT
120
121   public:
122     RenameIdentityDlg(QWidget *parent, QList<QString> reserved, QString name = QString());
123
124     QString getName();
125
126   private slots:
127     void textChanged(QString);
128
129   private:
130     Ui::NickEditDlg ui;
131     QList<QString> reserved;
132 };
133
134 #endif