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 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 11 | #ifndef CHRONOS_CONTACT_PANEL_HPP |
| 12 | #define CHRONOS_CONTACT_PANEL_HPP |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 13 | |
| 14 | #include <QDialog> |
| 15 | #include <QStringListModel> |
| 16 | #include <QSqlTableModel> |
| 17 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 18 | #include "set-alias-dialog.hpp" |
| 19 | #include "endorse-combobox-delegate.hpp" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 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 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 28 | namespace chronos { |
| 29 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 30 | class ContactPanel : public QDialog |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | |
| 34 | public: |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 35 | explicit |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 36 | ContactPanel(QWidget* parent = 0); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 37 | |
| 38 | virtual |
| 39 | ~ContactPanel(); |
| 40 | |
| 41 | private: |
| 42 | void |
| 43 | resetPanel(); |
| 44 | |
| 45 | signals: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 60 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 61 | void |
| 62 | updateEndorseCertificate(const QString& identity); |
| 63 | |
| 64 | void |
| 65 | warning(const QString& msg); |
| 66 | |
| 67 | public 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 81 | onContactInfoReady(const QString& identity, |
| 82 | const QString& name, |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 83 | const QString& institute, |
| 84 | bool isIntro); |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 85 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 86 | private slots: |
| 87 | void |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 88 | onSelectionChanged(const QItemSelection& selected, |
| 89 | const QItemSelection& deselected); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 90 | |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 115 | void |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 116 | onAliasChanged(const QString& identity, const QString& alias); |
| 117 | |
| 118 | private: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 135 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 136 | // Internal data structure. |
| 137 | QStringList m_contactAliasList; |
| 138 | QStringList m_contactIdList; |
| 139 | QString m_currentSelectedContact; |
| 140 | }; |
| 141 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 142 | } // namespace chronos |
| 143 | |
| 144 | #endif // CHRONOS_CONTACT_PANEL_HPP |