Debian Codegraph @

src/network/login.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2009 by The qGo Project *
3 * *
4 * This file is part of qGo. *
5 * *
6 * qGo is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, see <http://www.gnu.org/licenses/> *
18 * or write to the Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
21 #ifndef LOGIN_H
22 #define LOGIN_H
23
24 #include <QDialog>
25 #include <QAbstractTableModel>
26 #include <QAction>
27 #include <QMenu>
28 #include <QStyledItemDelegate>
29 #include "ui_login.h"
30 #include "defines.h"
31 #include "networkconnection.h"
32
33 class NetworkConnection;
34 class QMessageBox;
35
36 class CredentialTableModel : public QAbstractTableModel
37 {
38 Q_OBJECT
39 public:
40 CredentialTableModel(QObject * parent = 0);
41 ~CredentialTableModel();
42 int rowCount(const QModelIndex & parent = QModelIndex()) const;
43 int columnCount(const QModelIndex & parent = QModelIndex()) const;
44 QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
45 QVariant data(const QModelIndex & index, int role) const;
46 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
47 Qt::ItemFlags flags(const QModelIndex & index) const;
48 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
49 bool removeRows(int row, int count, const QModelIndex &parent);
50
51 void addCredential(ConnectionCredentials cred);
52 void loadCredentials(void);
53 void saveCredentials(void);
54 public:
55 QList <ConnectionCredentials> credentials;
56 bool editable;
57 };
58
59 class ComboBoxDelegate : public QStyledItemDelegate
60 {
61 Q_OBJECT
62 public:
63 ComboBoxDelegate(QObject *parent = 0);
64
65 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
66 const QModelIndex &index) const;
67
68 void setEditorData(QWidget *editor, const QModelIndex &index) const;
69 void setModelData(QWidget *editor, QAbstractItemModel *model,
70 const QModelIndex &index) const;
71
72 void updateEditorGeometry(QWidget *editor,
73 const QStyleOptionViewItem &option, const QModelIndex &index) const;
74 };
75
76 class NewCredentialsAction : public QAction
77 {
78 Q_OBJECT
79 public:
80 NewCredentialsAction(const QString &text, ConnectionCredentials c, QObject * parent = 0) : QAction(text,parent), cred(c) {};
81 ConnectionCredentials cred;
82 };
83
84 class LoginDialog : public QDialog, Ui::LoginDialog
85 {
86 Q_OBJECT
87 public:
88 LoginDialog(QWidget *parent = 0);
89 ~LoginDialog();
90 private:
91 void slot_cancel(void);
92 void slot_connect(QModelIndex);
93 void slot_newCredential(QAction *action);
94 void slot_deleteCredential(void);
95 void slot_receiveConnectionState(ConnectionState newState);
96 void slot_showPopup(const QPoint & iPoint);
97 void slot_toggleEditable(void);
98
99 ConnectionType serverStringToConnectionType(const QString & s);
100 NetworkConnection * newConnection(ConnectionCredentials cred);
101 Ui::LoginDialog ui;
102 NetworkConnection * connection;
103 CredentialTableModel * credModel;
104 QMenu * newCredMenu;
105 QModelIndex popup_item;
106 };
107
108 #endif