1 /***************************************************************************
2 * Copyright (C) 2009 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #ifndef COREACCOUNTSETTINGSPAGE_H_
22 #define COREACCOUNTSETTINGSPAGE_H_
24 #include <QSortFilterProxyModel>
26 #include "settingspage.h"
28 #include "coreaccount.h"
30 #include "ui_coreaccounteditdlg.h"
31 #include "ui_coreaccountsettingspage.h"
33 class CoreAccountModel;
34 class FilteredCoreAccountModel;
36 class CoreAccountSettingsPage : public SettingsPage {
40 CoreAccountSettingsPage(QWidget *parent = 0);
42 inline bool hasDefaults() const { return false; }
43 inline bool isStandAlone() const { return _standalone; }
45 AccountId selectedAccount() const;
51 void setSelectedAccount(AccountId accId);
52 void setStandAlone(bool);
55 void connectToCore(AccountId accId);
58 void on_addAccountButton_clicked();
59 void on_editAccountButton_clicked();
60 void on_deleteAccountButton_clicked();
61 void on_accountView_doubleClicked(const QModelIndex &index);
63 void setWidgetStates();
65 void rowsAboutToBeRemoved(const QModelIndex &index, int start, int end);
66 void rowsInserted(const QModelIndex &index, int start, int end);
69 Ui::CoreAccountSettingsPage ui;
71 CoreAccountModel *_model;
72 inline CoreAccountModel *model() const { return _model; }
73 FilteredCoreAccountModel *_filteredModel;
74 inline FilteredCoreAccountModel *filteredModel() const { return _filteredModel; }
76 AccountId _lastAccountId, _lastAutoConnectId;
79 virtual QVariant loadAutoWidgetValue(const QString &widgetName);
80 virtual void saveAutoWidgetValue(const QString &widgetName, const QVariant &value);
82 void editAccount(const QModelIndex &);
84 void widgetHasChanged();
85 bool testHasChanged();
87 inline QString settingsKey() const { return QString("CoreAccounts"); }
90 // ========================================
92 // ========================================
93 class CoreAccountEditDlg : public QDialog {
97 CoreAccountEditDlg(const CoreAccount &account, QWidget *parent = 0);
99 CoreAccount account();
102 void on_hostName_textChanged(const QString &);
103 void on_accountName_textChanged(const QString &);
104 void on_user_textChanged(const QString &);
106 void setWidgetStates();
109 Ui::CoreAccountEditDlg ui;
110 CoreAccount _account;
113 // ========================================
114 // FilteredCoreAccountModel
115 // ========================================
117 //! This filters out the internal account from the non-monolithic client's UI
118 class FilteredCoreAccountModel : public QSortFilterProxyModel {
122 FilteredCoreAccountModel(CoreAccountModel *model, QObject *parent = 0);
125 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
128 AccountId _internalAccount;