e552a0b5cc6c00abf34b2bb69bdeee38c87ba7bc
[quassel.git] / src / qtui / settingspages / coreaccountsettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2009 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 COREACCOUNTSETTINGSPAGE_H_
22 #define COREACCOUNTSETTINGSPAGE_H_
23
24 #include "settingspage.h"
25
26 #include "coreaccount.h"
27
28 #include "ui_coreaccounteditdlg.h"
29 #include "ui_coreaccountsettingspage.h"
30
31 class CoreAccountModel;
32
33 class CoreAccountSettingsPage : public SettingsPage {
34   Q_OBJECT
35
36   public:
37     CoreAccountSettingsPage(QWidget *parent = 0);
38
39     virtual inline bool hasDefaults() const { return false; }
40
41   public slots:
42     void save();
43     void load();
44
45   private slots:
46     void on_addAccountButton_clicked();
47     void on_editAccountButton_clicked();
48     void on_deleteAccountButton_clicked();
49
50     void setWidgetStates();
51
52     void rowsAboutToBeRemoved(const QModelIndex &index, int start, int end);
53     void rowsInserted(const QModelIndex &index, int start, int end);
54
55   private:
56     Ui::CoreAccountSettingsPage ui;
57
58     CoreAccountModel *_model;
59     inline CoreAccountModel *model() const { return _model; }
60
61     AccountId _lastAccountId, _lastAutoConnectId;
62
63     virtual QVariant loadAutoWidgetValue(const QString &widgetName);
64     virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
65
66     void widgetHasChanged();
67     bool testHasChanged();
68
69     inline QString settingsKey() const { return QString("CoreAccounts"); }
70 };
71
72 // ========================================
73 //  CoreAccountEditDlg
74 // ========================================
75 class CoreAccountEditDlg : public QDialog {
76   Q_OBJECT
77
78 public:
79   CoreAccountEditDlg(const CoreAccount &account, QWidget *parent = 0);
80
81   CoreAccount account();
82
83 private slots:
84   void on_hostName_textChanged(const QString &);
85   void on_accountName_textChanged(const QString &);
86   void on_user_textChanged(const QString &);
87
88   void setWidgetStates();
89
90 private:
91   Ui::CoreAccountEditDlg ui;
92   CoreAccount _account;
93 };
94
95 #endif