1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef COREACCOUNTSETTINGSPAGE_H_
22 #define COREACCOUNTSETTINGSPAGE_H_
24 #include <QNetworkProxy>
25 #include <QSortFilterProxyModel>
27 #include "settingspage.h"
29 #include "coreaccount.h"
31 #include "ui_coreaccounteditdlg.h"
32 #include "ui_coreaccountsettingspage.h"
34 class CoreAccountModel;
35 class FilteredCoreAccountModel;
37 class CoreAccountSettingsPage : public SettingsPage
42 CoreAccountSettingsPage(QWidget *parent = 0);
44 inline bool hasDefaults() const { return false; }
45 inline bool isStandAlone() const { return _standalone; }
47 AccountId selectedAccount() const;
53 void setSelectedAccount(AccountId accId);
54 void setStandAlone(bool);
57 void connectToCore(AccountId accId);
60 void on_addAccountButton_clicked();
61 void on_editAccountButton_clicked();
62 void on_deleteAccountButton_clicked();
63 void on_accountView_doubleClicked(const QModelIndex &index);
65 void setWidgetStates();
66 void widgetHasChanged();
68 void rowsAboutToBeRemoved(const QModelIndex &index, int start, int end);
69 void rowsInserted(const QModelIndex &index, int start, int end);
72 Ui::CoreAccountSettingsPage ui;
74 CoreAccountModel *_model;
75 inline CoreAccountModel *model() const { return _model; }
76 FilteredCoreAccountModel *_filteredModel;
77 inline FilteredCoreAccountModel *filteredModel() const { return _filteredModel; }
79 AccountId _lastAccountId, _lastAutoConnectId;
82 void editAccount(const QModelIndex &);
84 bool testHasChanged();
86 inline QString settingsKey() const { return QString("CoreAccounts"); }
90 // ========================================
92 // ========================================
93 class CoreAccountEditDlg : public QDialog
98 CoreAccountEditDlg(const CoreAccount &account, QWidget *parent = 0);
100 CoreAccount account();
103 void on_hostName_textChanged(const QString &);
104 void on_accountName_textChanged(const QString &);
105 void on_user_textChanged(const QString &);
106 void on_radioButtonManualProxy_toggled(bool checked);
108 void setWidgetStates();
111 Ui::CoreAccountEditDlg ui;
112 CoreAccount _account;
113 enum ProxyType { NoProxy, SystemProxy, ManualProxy };
117 // ========================================
118 // FilteredCoreAccountModel
119 // ========================================
121 //! This filters out the internal account from the non-monolithic client's UI
122 class FilteredCoreAccountModel : public QSortFilterProxyModel
127 FilteredCoreAccountModel(CoreAccountModel *model, QObject *parent = 0);
130 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
133 AccountId _internalAccount;