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 | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 11 | #ifndef CHRONOCHAT_CONTACT_PANEL_HPP |
| 12 | #define CHRONOCHAT_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> |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame^] | 17 | #include <QItemSelection> |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 18 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 19 | #include "set-alias-dialog.hpp" |
| 20 | #include "endorse-combobox-delegate.hpp" |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 21 | |
| 22 | #ifndef Q_MOC_RUN |
| 23 | #endif |
| 24 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 25 | namespace Ui { |
| 26 | class ContactPanel; |
| 27 | } |
| 28 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 29 | namespace chronochat { |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 30 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 31 | class ContactPanel : public QDialog |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | |
| 35 | public: |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 36 | explicit |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 37 | ContactPanel(QWidget* parent = 0); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 38 | |
| 39 | virtual |
| 40 | ~ContactPanel(); |
| 41 | |
| 42 | private: |
| 43 | void |
| 44 | resetPanel(); |
| 45 | |
| 46 | signals: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 61 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 62 | void |
| 63 | updateEndorseCertificate(const QString& identity); |
| 64 | |
| 65 | void |
| 66 | warning(const QString& msg); |
| 67 | |
| 68 | public 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 82 | onContactInfoReady(const QString& identity, |
| 83 | const QString& name, |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 84 | const QString& institute, |
| 85 | bool isIntro); |
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 86 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 87 | private slots: |
| 88 | void |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 89 | onSelectionChanged(const QItemSelection& selected, |
| 90 | const QItemSelection& deselected); |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 91 | |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 116 | void |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 117 | onAliasChanged(const QString& identity, const QString& alias); |
| 118 | |
| 119 | private: |
| 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 Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 136 | |
Yingdi Yu | 348f5ea | 2014-03-01 14:47:25 -0800 | [diff] [blame] | 137 | // Internal data structure. |
| 138 | QStringList m_contactAliasList; |
| 139 | QStringList m_contactIdList; |
| 140 | QString m_currentSelectedContact; |
| 141 | }; |
| 142 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 143 | } // namespace chronochat |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 144 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 145 | #endif // CHRONOCHAT_CONTACT_PANEL_HPP |