~ubuntu-branches/ubuntu/saucy/quassel/saucy-proposed

« back to all changes in this revision

Viewing changes to src/qtui/settingspages/coreaccountsettingspage.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-02-17 12:49:50 UTC
  • mto: This revision was merged to the branch mainline in revision 59.
  • Revision ID: james.westby@ubuntu.com-20100217124950-v9hajw5d2xa6fszn
Tags: upstream-0.6~beta1
ImportĀ upstreamĀ versionĀ 0.6~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <QSortFilterProxyModel>
 
25
 
 
26
#include "settingspage.h"
 
27
 
 
28
#include "coreaccount.h"
 
29
 
 
30
#include "ui_coreaccounteditdlg.h"
 
31
#include "ui_coreaccountsettingspage.h"
 
32
 
 
33
class CoreAccountModel;
 
34
class FilteredCoreAccountModel;
 
35
 
 
36
class CoreAccountSettingsPage : public SettingsPage {
 
37
  Q_OBJECT
 
38
 
 
39
  public:
 
40
    CoreAccountSettingsPage(QWidget *parent = 0);
 
41
 
 
42
    inline bool hasDefaults() const { return false; }
 
43
    inline bool isStandAlone() const { return _standalone; }
 
44
 
 
45
    AccountId selectedAccount() const;
 
46
 
 
47
  public slots:
 
48
    void save();
 
49
    void load();
 
50
 
 
51
    void setSelectedAccount(AccountId accId);
 
52
    void setStandAlone(bool);
 
53
 
 
54
signals:
 
55
    void connectToCore(AccountId accId);
 
56
 
 
57
  private slots:
 
58
    void on_addAccountButton_clicked();
 
59
    void on_editAccountButton_clicked();
 
60
    void on_deleteAccountButton_clicked();
 
61
    void on_accountView_doubleClicked(const QModelIndex &index);
 
62
 
 
63
    void setWidgetStates();
 
64
    void widgetHasChanged();
 
65
 
 
66
    void rowsAboutToBeRemoved(const QModelIndex &index, int start, int end);
 
67
    void rowsInserted(const QModelIndex &index, int start, int end);
 
68
 
 
69
  private:
 
70
    Ui::CoreAccountSettingsPage ui;
 
71
 
 
72
    CoreAccountModel *_model;
 
73
    inline CoreAccountModel *model() const { return _model; }
 
74
    FilteredCoreAccountModel *_filteredModel;
 
75
    inline FilteredCoreAccountModel *filteredModel() const { return _filteredModel; }
 
76
 
 
77
    AccountId _lastAccountId, _lastAutoConnectId;
 
78
    bool _standalone;
 
79
 
 
80
    void editAccount(const QModelIndex &);
 
81
 
 
82
    bool testHasChanged();
 
83
 
 
84
    inline QString settingsKey() const { return QString("CoreAccounts"); }
 
85
};
 
86
 
 
87
// ========================================
 
88
//  CoreAccountEditDlg
 
89
// ========================================
 
90
class CoreAccountEditDlg : public QDialog {
 
91
  Q_OBJECT
 
92
 
 
93
public:
 
94
  CoreAccountEditDlg(const CoreAccount &account, QWidget *parent = 0);
 
95
 
 
96
  CoreAccount account();
 
97
 
 
98
private slots:
 
99
  void on_hostName_textChanged(const QString &);
 
100
  void on_accountName_textChanged(const QString &);
 
101
  void on_user_textChanged(const QString &);
 
102
 
 
103
  void setWidgetStates();
 
104
 
 
105
private:
 
106
  Ui::CoreAccountEditDlg ui;
 
107
  CoreAccount _account;
 
108
};
 
109
 
 
110
// ========================================
 
111
//  FilteredCoreAccountModel
 
112
// ========================================
 
113
 
 
114
//! This filters out the internal account from the non-monolithic client's UI
 
115
class FilteredCoreAccountModel : public QSortFilterProxyModel {
 
116
  Q_OBJECT
 
117
 
 
118
public:
 
119
  FilteredCoreAccountModel(CoreAccountModel *model, QObject *parent = 0);
 
120
 
 
121
protected:
 
122
  virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
 
123
 
 
124
private:
 
125
  AccountId _internalAccount;
 
126
};
 
127
 
 
128
#endif