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