blob: d164391c00c482580f3b686efd954ec8670d3ee5 [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
Yingdi Yueb692ac2015-02-10 18:46:18 -080011#ifndef CHRONOCHAT_CONTACT_PANEL_HPP
12#define CHRONOCHAT_CONTACT_PANEL_HPP
Yingdi Yu348f5ea2014-03-01 14:47:25 -080013
14#include <QDialog>
15#include <QStringListModel>
16#include <QSqlTableModel>
17
Yingdi Yu0b0a7362014-08-05 16:31:30 -070018#include "set-alias-dialog.hpp"
19#include "endorse-combobox-delegate.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080020
21#ifndef Q_MOC_RUN
22#endif
23
Yingdi Yu348f5ea2014-03-01 14:47:25 -080024namespace Ui {
25class ContactPanel;
26}
27
Yingdi Yueb692ac2015-02-10 18:46:18 -080028namespace chronochat {
Yingdi Yu0b0a7362014-08-05 16:31:30 -070029
Yingdi Yu348f5ea2014-03-01 14:47:25 -080030class ContactPanel : public QDialog
31{
32 Q_OBJECT
33
34public:
Yingdi Yufa0b6a02014-04-30 14:26:42 -070035 explicit
Yingdi Yu0b0a7362014-08-05 16:31:30 -070036 ContactPanel(QWidget* parent = 0);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080037
38 virtual
39 ~ContactPanel();
40
41private:
42 void
43 resetPanel();
44
45signals:
46 void
47 waitForContactList();
48
49 void
50 waitForContactInfo(const QString& identity);
51
52 void
53 removeContact(const QString& identity);
54
55 void
56 updateAlias(const QString& identity, const QString& alias);
57
58 void
59 updateIsIntroducer(const QString& identity, bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070060
Yingdi Yu348f5ea2014-03-01 14:47:25 -080061 void
62 updateEndorseCertificate(const QString& identity);
63
64 void
65 warning(const QString& msg);
66
67public slots:
68 void
69 onCloseDBModule();
70
71 void
72 onIdentityUpdated(const QString& identity);
73
74 void
75 onContactAliasListReady(const QStringList& aliasList);
76
77 void
78 onContactIdListReady(const QStringList& idList);
79
80 void
Yingdi Yufa0b6a02014-04-30 14:26:42 -070081 onContactInfoReady(const QString& identity,
82 const QString& name,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080083 const QString& institute,
84 bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070085
Yingdi Yu348f5ea2014-03-01 14:47:25 -080086private slots:
87 void
Yingdi Yu0b0a7362014-08-05 16:31:30 -070088 onSelectionChanged(const QItemSelection& selected,
89 const QItemSelection& deselected);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080090
91 void
92 onContextMenuRequested(const QPoint& pos);
93
94 void
95 onSetAliasDialogRequested();
96
97 void
98 onContactDeletionRequested();
99
100 void
101 onIsIntroducerChanged(int state);
102
103 void
104 onAddScopeClicked();
105
106 void
107 onDeleteScopeClicked();
108
109 void
110 onSaveScopeClicked();
111
112 void
113 onEndorseButtonClicked();
114
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700115 void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800116 onAliasChanged(const QString& identity, const QString& alias);
117
118private:
119 Ui::ContactPanel* ui;
120
121 // Dialogs.
122 SetAliasDialog* m_setAliasDialog;
123
124 // Models.
125 QStringListModel* m_contactListModel;
126 QSqlTableModel* m_trustScopeModel;
127 QSqlTableModel* m_endorseDataModel;
128
129 // Delegates.
130 EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
131
132 // Actions.
133 QAction* m_menuAlias;
134 QAction* m_menuDelete;
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700135
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800136 // Internal data structure.
137 QStringList m_contactAliasList;
138 QStringList m_contactIdList;
139 QString m_currentSelectedContact;
140};
141
Yingdi Yueb692ac2015-02-10 18:46:18 -0800142} // namespace chronochat
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700143
Yingdi Yueb692ac2015-02-10 18:46:18 -0800144#endif // CHRONOCHAT_CONTACT_PANEL_HPP