Provide some new accessors for Chat{View|Scene}
[quassel.git] / src / qtui / coreconfigwizard.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 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 _CORECONFIGWIZARD_H_
22 #define _CORECONFIGWIZARD_H_
23
24 #include <QHash>
25 #include <QWizard>
26 #include <QVariantMap>
27
28 #include "ui_coreconfigwizardintropage.h"
29 #include "ui_coreconfigwizardadminuserpage.h"
30 #include "ui_coreconfigwizardstorageselectionpage.h"
31 #include "ui_coreconfigwizardsyncpage.h"
32
33 class CoreConnection;
34
35 namespace CoreConfigWizardPages {
36   class SyncPage;
37   class SyncRelayPage;
38 };
39
40 class CoreConfigWizard : public QWizard {
41   Q_OBJECT
42
43   public:
44     enum {
45       IntroPage,
46       AdminUserPage,
47       StorageSelectionPage,
48       SyncPage,
49       SyncRelayPage,
50       StorageDetailsPage,
51       ConclusionPage
52     };
53
54     CoreConfigWizard(CoreConnection *connection, const QList<QVariant> &backends, QWidget *parent = 0);
55     QHash<QString, QVariant> backends() const;
56
57     inline CoreConnection *coreConnection() const { return _connection; }
58
59   signals:
60     void setupCore(const QVariant &setupData);
61     void loginToCore(const QString &user, const QString &password, bool rememberPassword);
62
63   public slots:
64     void loginSuccess();
65     void syncFinished();
66
67   private slots:
68     void prepareCoreSetup(const QString &backend, const QVariantMap &connectionProperties);
69     void coreSetupSuccess();
70     void coreSetupFailed(const QString &);
71     void startOver();
72
73   private:
74     QHash<QString, QVariant> _backends;
75     CoreConfigWizardPages::SyncPage *syncPage;
76     CoreConfigWizardPages::SyncRelayPage *syncRelayPage;
77
78     CoreConnection *_connection;
79 };
80
81 namespace CoreConfigWizardPages {
82
83   class IntroPage : public QWizardPage {
84     Q_OBJECT
85
86     public:
87       IntroPage(QWidget *parent = 0);
88       int nextId() const;
89     private:
90       Ui::CoreConfigWizardIntroPage ui;
91   };
92
93   class AdminUserPage : public QWizardPage {
94     Q_OBJECT
95
96     public:
97       AdminUserPage(QWidget *parent = 0);
98       int nextId() const;
99       bool isComplete() const;
100     private:
101       Ui::CoreConfigWizardAdminUserPage ui;
102   };
103
104   class StorageSelectionPage : public QWizardPage {
105     Q_OBJECT
106
107     public:
108       StorageSelectionPage(const QHash<QString, QVariant> &backends, QWidget *parent = 0);
109       int nextId() const;
110       QString selectedBackend() const;
111       QVariantMap connectionProperties() const;
112
113     private slots:
114       void on_backendList_currentIndexChanged();
115     private:
116       Ui::CoreConfigWizardStorageSelectionPage ui;
117       QGroupBox *_connectionBox;
118       QHash<QString, QVariant> _backends;
119   };
120
121   class SyncPage : public QWizardPage {
122     Q_OBJECT
123
124     public:
125       SyncPage(QWidget *parent = 0);
126       void initializePage();
127       int nextId() const;
128       bool isComplete() const;
129
130     public slots:
131       void setStatus(const QString &status);
132       void setError(bool);
133       void setComplete(bool);
134
135     signals:
136       void setupCore(const QString &backend, const QVariantMap &);
137
138     private:
139       Ui::CoreConfigWizardSyncPage ui;
140       bool complete;
141       bool hasError;
142   };
143
144   class SyncRelayPage : public QWizardPage {
145     Q_OBJECT
146
147     public:
148       SyncRelayPage(QWidget *parent = 0);
149       int nextId() const;
150       enum Mode { Success, Error };
151
152     public slots:
153       void setMode(Mode);
154
155     signals:
156       void startOver() const;
157
158     private:
159       Mode mode;
160   };
161
162 }
163
164 #endif