Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 1 | /* -*- 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 Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 24 | namespace Ui { |
| 25 | class ContactPanel; |
| 26 | } |
| 27 | |
| 28 | class ContactPanel : public QDialog |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | public: |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 33 | explicit |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 34 | ContactPanel(QWidget *parent = 0); |
| 35 | |
| 36 | virtual |
| 37 | ~ContactPanel(); |
| 38 | |
| 39 | private: |
| 40 | void |
| 41 | resetPanel(); |
| 42 | |
| 43 | signals: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 58 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 59 | void |
| 60 | updateEndorseCertificate(const QString& identity); |
| 61 | |
| 62 | void |
| 63 | warning(const QString& msg); |
| 64 | |
| 65 | public 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 79 | onContactInfoReady(const QString& identity, |
| 80 | const QString& name, |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 81 | const QString& institute, |
| 82 | bool isIntro); |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 83 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 84 | private 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 113 | void |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 114 | onAliasChanged(const QString& identity, const QString& alias); |
| 115 | |
| 116 | private: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame^] | 133 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 134 | // Internal data structure. |
| 135 | QStringList m_contactAliasList; |
| 136 | QStringList m_contactIdList; |
| 137 | QString m_currentSelectedContact; |
| 138 | }; |
| 139 | |
| 140 | #endif // CONTACT_PANEL_H |