blob: f47287f325cd0353c9ac134419e3fb2e299102e4 [file] [log] [blame]
Yingdi Yu348f5ea2014-03-01 14:47:25 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
11#ifndef CONTACT_PANEL_H
12#define CONTACT_PANEL_H
13
14#include <QDialog>
15#include <QStringListModel>
16#include <QSqlTableModel>
17
18#include "set-alias-dialog.h"
19#include "endorse-combobox-delegate.h"
20
21#ifndef Q_MOC_RUN
22#endif
23
Yingdi Yu348f5ea2014-03-01 14:47:25 -080024namespace Ui {
25class ContactPanel;
26}
27
28class ContactPanel : public QDialog
29{
30 Q_OBJECT
31
32public:
Yingdi Yufa0b6a02014-04-30 14:26:42 -070033 explicit
Yingdi Yu348f5ea2014-03-01 14:47:25 -080034 ContactPanel(QWidget *parent = 0);
35
36 virtual
37 ~ContactPanel();
38
39private:
40 void
41 resetPanel();
42
43signals:
44 void
45 waitForContactList();
46
47 void
48 waitForContactInfo(const QString& identity);
49
50 void
51 removeContact(const QString& identity);
52
53 void
54 updateAlias(const QString& identity, const QString& alias);
55
56 void
57 updateIsIntroducer(const QString& identity, bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070058
Yingdi Yu348f5ea2014-03-01 14:47:25 -080059 void
60 updateEndorseCertificate(const QString& identity);
61
62 void
63 warning(const QString& msg);
64
65public slots:
66 void
67 onCloseDBModule();
68
69 void
70 onIdentityUpdated(const QString& identity);
71
72 void
73 onContactAliasListReady(const QStringList& aliasList);
74
75 void
76 onContactIdListReady(const QStringList& idList);
77
78 void
Yingdi Yufa0b6a02014-04-30 14:26:42 -070079 onContactInfoReady(const QString& identity,
80 const QString& name,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080081 const QString& institute,
82 bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070083
Yingdi Yu348f5ea2014-03-01 14:47:25 -080084private slots:
85 void
86 onSelectionChanged(const QItemSelection &selected,
87 const QItemSelection &deselected);
88
89 void
90 onContextMenuRequested(const QPoint& pos);
91
92 void
93 onSetAliasDialogRequested();
94
95 void
96 onContactDeletionRequested();
97
98 void
99 onIsIntroducerChanged(int state);
100
101 void
102 onAddScopeClicked();
103
104 void
105 onDeleteScopeClicked();
106
107 void
108 onSaveScopeClicked();
109
110 void
111 onEndorseButtonClicked();
112
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700113 void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800114 onAliasChanged(const QString& identity, const QString& alias);
115
116private:
117 Ui::ContactPanel* ui;
118
119 // Dialogs.
120 SetAliasDialog* m_setAliasDialog;
121
122 // Models.
123 QStringListModel* m_contactListModel;
124 QSqlTableModel* m_trustScopeModel;
125 QSqlTableModel* m_endorseDataModel;
126
127 // Delegates.
128 EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
129
130 // Actions.
131 QAction* m_menuAlias;
132 QAction* m_menuDelete;
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700133
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800134 // Internal data structure.
135 QStringList m_contactAliasList;
136 QStringList m_contactIdList;
137 QString m_currentSelectedContact;
138};
139
140#endif // CONTACT_PANEL_H