blob: 7eec224277e9521d87b2eed7c46f79f0f8295f3a [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>
Varun Patil3d850902020-11-23 12:19:14 +053017#include <QItemSelection>
Yingdi Yu348f5ea2014-03-01 14:47:25 -080018
Yingdi Yu0b0a7362014-08-05 16:31:30 -070019#include "set-alias-dialog.hpp"
20#include "endorse-combobox-delegate.hpp"
Yingdi Yu348f5ea2014-03-01 14:47:25 -080021
22#ifndef Q_MOC_RUN
23#endif
24
Yingdi Yu348f5ea2014-03-01 14:47:25 -080025namespace Ui {
26class ContactPanel;
27}
28
Yingdi Yueb692ac2015-02-10 18:46:18 -080029namespace chronochat {
Yingdi Yu0b0a7362014-08-05 16:31:30 -070030
Yingdi Yu348f5ea2014-03-01 14:47:25 -080031class ContactPanel : public QDialog
32{
33 Q_OBJECT
34
35public:
Yingdi Yufa0b6a02014-04-30 14:26:42 -070036 explicit
Yingdi Yu0b0a7362014-08-05 16:31:30 -070037 ContactPanel(QWidget* parent = 0);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080038
39 virtual
40 ~ContactPanel();
41
42private:
43 void
44 resetPanel();
45
46signals:
47 void
48 waitForContactList();
49
50 void
51 waitForContactInfo(const QString& identity);
52
53 void
54 removeContact(const QString& identity);
55
56 void
57 updateAlias(const QString& identity, const QString& alias);
58
59 void
60 updateIsIntroducer(const QString& identity, bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070061
Yingdi Yu348f5ea2014-03-01 14:47:25 -080062 void
63 updateEndorseCertificate(const QString& identity);
64
65 void
66 warning(const QString& msg);
67
68public slots:
69 void
70 onCloseDBModule();
71
72 void
73 onIdentityUpdated(const QString& identity);
74
75 void
76 onContactAliasListReady(const QStringList& aliasList);
77
78 void
79 onContactIdListReady(const QStringList& idList);
80
81 void
Yingdi Yufa0b6a02014-04-30 14:26:42 -070082 onContactInfoReady(const QString& identity,
83 const QString& name,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080084 const QString& institute,
85 bool isIntro);
Yingdi Yufa0b6a02014-04-30 14:26:42 -070086
Yingdi Yu348f5ea2014-03-01 14:47:25 -080087private slots:
88 void
Yingdi Yu0b0a7362014-08-05 16:31:30 -070089 onSelectionChanged(const QItemSelection& selected,
90 const QItemSelection& deselected);
Yingdi Yu348f5ea2014-03-01 14:47:25 -080091
92 void
93 onContextMenuRequested(const QPoint& pos);
94
95 void
96 onSetAliasDialogRequested();
97
98 void
99 onContactDeletionRequested();
100
101 void
102 onIsIntroducerChanged(int state);
103
104 void
105 onAddScopeClicked();
106
107 void
108 onDeleteScopeClicked();
109
110 void
111 onSaveScopeClicked();
112
113 void
114 onEndorseButtonClicked();
115
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700116 void
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800117 onAliasChanged(const QString& identity, const QString& alias);
118
119private:
120 Ui::ContactPanel* ui;
121
122 // Dialogs.
123 SetAliasDialog* m_setAliasDialog;
124
125 // Models.
126 QStringListModel* m_contactListModel;
127 QSqlTableModel* m_trustScopeModel;
128 QSqlTableModel* m_endorseDataModel;
129
130 // Delegates.
131 EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
132
133 // Actions.
134 QAction* m_menuAlias;
135 QAction* m_menuDelete;
Yingdi Yufa0b6a02014-04-30 14:26:42 -0700136
Yingdi Yu348f5ea2014-03-01 14:47:25 -0800137 // Internal data structure.
138 QStringList m_contactAliasList;
139 QStringList m_contactIdList;
140 QString m_currentSelectedContact;
141};
142
Yingdi Yueb692ac2015-02-10 18:46:18 -0800143} // namespace chronochat
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700144
Yingdi Yueb692ac2015-02-10 18:46:18 -0800145#endif // CHRONOCHAT_CONTACT_PANEL_HPP