Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [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 | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 11 | #include "addcontactpanel.h" |
| 12 | #include "ui_addcontactpanel.h" |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 13 | #include <QMessageBox> |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 14 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 15 | #ifndef Q_MOC_RUN |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 16 | #include <ndn-cpp-dev/security/validator.hpp> |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 17 | #include <boost/iostreams/stream.hpp> |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 18 | #include "endorse-collection.pb.h" |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 19 | #include "logging.h" |
| 20 | #endif |
| 21 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 22 | using namespace ndn; |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 23 | using namespace chronos; |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 24 | using namespace std; |
| 25 | |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 26 | INIT_LOGGER("AddContactPanel"); |
| 27 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 28 | AddContactPanel::AddContactPanel(shared_ptr<ContactManager> contactManager, |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 29 | QWidget *parent) |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 30 | : QDialog(parent) |
| 31 | , ui(new Ui::AddContactPanel) |
Yingdi Yu | 0b82a4e | 2013-10-18 11:29:25 -0700 | [diff] [blame] | 32 | , m_contactManager(contactManager) |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 33 | , m_warningDialog(new WarningDialog()) |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 34 | { |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 35 | ui->setupUi(this); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 36 | |
| 37 | qRegisterMetaType<ndn::Name>("NdnName"); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 38 | qRegisterMetaType<chronos::EndorseCertificate>("EndorseCertificate"); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 39 | qRegisterMetaType<ndn::Data>("NdnData"); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 40 | |
| 41 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 42 | this, SLOT(onCancelClicked())); |
| 43 | connect(ui->searchButton, SIGNAL(clicked()), |
| 44 | this, SLOT(onSearchClicked())); |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 45 | connect(ui->addButton, SIGNAL(clicked()), |
| 46 | this, SLOT(onAddClicked())); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 47 | connect(&*m_contactManager, SIGNAL(contactFetched(const chronos::EndorseCertificate&)), |
| 48 | this, SLOT(selfEndorseCertificateFetched(const chronos::EndorseCertificate&))); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 49 | connect(&*m_contactManager, SIGNAL(contactFetchFailed(const ndn::Name&)), |
| 50 | this, SLOT(selfEndorseCertificateFetchFailed(const ndn::Name&))); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 51 | connect(&*m_contactManager, SIGNAL(collectEndorseFetched(const ndn::Data&)), |
| 52 | this, SLOT(onCollectEndorseFetched(const ndn::Data&))); |
| 53 | connect(&*m_contactManager, SIGNAL(collectEndorseFetchFailed(const ndn::Name&)), |
| 54 | this, SLOT(onCollectEndorseFetchFailed(const ndn::Name&))); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 55 | connect(&*m_contactManager, SIGNAL(contactKeyFetched(const chronos::EndorseCertificate&)), |
| 56 | this, SLOT(onContactKeyFetched(const chronos::EndorseCertificate&))); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 57 | connect(&*m_contactManager, SIGNAL(contactKeyFetchFailed(const ndn::Name&)), |
| 58 | this, SLOT(onContactKeyFetchFailed(const ndn::Name&))); |
| 59 | |
| 60 | |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | AddContactPanel::~AddContactPanel() |
| 64 | { |
| 65 | delete ui; |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 66 | delete m_warningDialog; |
Yingdi Yu | a489875 | 2013-10-15 20:31:37 -0700 | [diff] [blame] | 67 | } |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 68 | |
| 69 | void |
| 70 | AddContactPanel::onCancelClicked() |
| 71 | { this->close(); } |
| 72 | |
| 73 | void |
| 74 | AddContactPanel::onSearchClicked() |
| 75 | { |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 76 | m_currentEndorseCertificateReady = false; |
| 77 | m_currentCollectEndorseReady = false; |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 78 | ui->infoView->clear(); |
| 79 | for(int i = ui->infoView->rowCount() - 1; i >= 0 ; i--) |
| 80 | ui->infoView->removeRow(i); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 81 | QString inputIdentity = ui->contactInput->text(); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 82 | m_searchIdentity = Name(inputIdentity.toStdString()); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 83 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 84 | if(Qt::Checked == ui->fetchBox->checkState()) |
| 85 | { |
| 86 | m_contactManager->fetchSelfEndorseCertificate(m_searchIdentity); |
| 87 | m_contactManager->fetchCollectEndorse(m_searchIdentity); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | if(isCorrectName(m_searchIdentity)) |
| 92 | m_contactManager->fetchKey(m_searchIdentity); |
| 93 | else |
| 94 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 95 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Wrong key certificate name!")); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | bool |
| 101 | AddContactPanel::isCorrectName(const Name& name) |
| 102 | { |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 103 | if(name.get(-1).toEscapedString() != "ID-CERT") |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 104 | return false; |
| 105 | |
| 106 | int keyIndex = -1; |
| 107 | for(int i = 0; i < name.size(); i++) |
| 108 | { |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 109 | if(name.get(i).toEscapedString() == "KEY") |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 110 | { |
| 111 | keyIndex = i; |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if(keyIndex < 0) |
| 117 | return false; |
| 118 | else |
| 119 | return true; |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | void |
| 123 | AddContactPanel::onAddClicked() |
| 124 | { |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 125 | ContactItem contactItem(*m_currentEndorseCertificate); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 126 | try{ |
| 127 | m_contactManager->getContactStorage()->addContact(contactItem); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 128 | }catch(ContactStorage::Error& e){ |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 129 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what())); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 130 | _LOG_ERROR("Exception: " << e.what()); |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 131 | return; |
| 132 | } |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 133 | emit newContactAdded(); |
| 134 | this->close(); |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 137 | void |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 138 | AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate) |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 139 | { |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 140 | |
| 141 | m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate); |
| 142 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 143 | m_currentEndorseCertificateReady = true; |
| 144 | |
| 145 | if(m_currentCollectEndorseReady == true) |
| 146 | displayContactInfo(); |
Yingdi Yu | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | void |
| 150 | AddContactPanel::selfEndorseCertificateFetchFailed(const Name& identity) |
| 151 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 152 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact profile")); |
Yingdi Yu | aa8d769 | 2013-10-18 17:05:02 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 155 | void |
| 156 | AddContactPanel::onContactKeyFetched(const EndorseCertificate& endorseCertificate) |
| 157 | { |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 158 | m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 159 | |
Alexander Afanasyev | 4f04c55 | 2013-11-07 15:30:05 -0800 | [diff] [blame] | 160 | m_currentCollectEndorseReady = false; |
Yingdi Yu | e9ea5c9 | 2013-11-06 18:42:34 -0800 | [diff] [blame] | 161 | |
| 162 | displayContactInfo(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | void |
| 166 | AddContactPanel::onContactKeyFetchFailed(const Name& identity) |
| 167 | { |
Yingdi Yu | eb98f7d | 2013-11-10 01:34:57 -0800 | [diff] [blame] | 168 | QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact ksk certificate")); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | void |
| 172 | AddContactPanel::onCollectEndorseFetched(const Data& data) |
| 173 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 174 | m_currentCollectEndorse = make_shared<Data>(data); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 175 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 176 | m_currentCollectEndorseReady = true; |
| 177 | |
| 178 | if(m_currentEndorseCertificateReady == true) |
| 179 | displayContactInfo(); |
| 180 | } |
| 181 | |
| 182 | void |
| 183 | AddContactPanel::onCollectEndorseFetchFailed(const Name& identity) |
| 184 | { |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 185 | m_currentCollectEndorse = shared_ptr<Data>(); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 186 | |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 187 | m_currentCollectEndorseReady = true; |
| 188 | |
| 189 | if(m_currentEndorseCertificateReady == true) |
| 190 | displayContactInfo(); |
| 191 | } |
| 192 | |
| 193 | void |
| 194 | AddContactPanel::displayContactInfo() |
| 195 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 196 | // _LOG_TRACE("displayContactInfo"); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 197 | const Profile& profile = m_currentEndorseCertificate->getProfile(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 198 | |
| 199 | map<string, int> endorseCount; |
| 200 | |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 201 | if(!static_cast<bool>(m_currentCollectEndorse)) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 202 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 203 | Chronos::EndorseCollection endorseCollection; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 204 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 205 | boost::iostreams::stream |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 206 | <boost::iostreams::array_source> is (reinterpret_cast<const char*>(m_currentCollectEndorse->getContent().value()), |
| 207 | m_currentCollectEndorse->getContent().value_size()); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 208 | |
| 209 | endorseCollection.ParseFromIstream(&is); |
| 210 | |
| 211 | for(int i = 0; i < endorseCollection.endorsement_size(); i ++) |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 212 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 213 | try{ |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 214 | Data data; |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 215 | data.wireDecode(Block(reinterpret_cast<const uint8_t*>(endorseCollection.endorsement(i).blob().c_str()), |
| 216 | endorseCollection.endorsement(i).blob().size())); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 217 | EndorseCertificate endorseCert(data); |
| 218 | |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 219 | Name signerName = endorseCert.getSigner().getPrefix(-1); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 220 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 221 | shared_ptr<ContactItem> contact = m_contactManager->getContact(signerName); |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 222 | if(!static_cast<bool>(contact)) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 223 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 224 | |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 225 | if(!contact->isIntroducer() || !contact->canBeTrustedFor(m_currentEndorseCertificate->getProfile().getIdentityName())) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 226 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 227 | |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 228 | if(!Validator::verifySignature(data, data.getSignature(), contact->getSelfEndorseCertificate().getPublicKeyInfo())) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 229 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 230 | |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 231 | const Profile& tmpProfile = endorseCert.getProfile(); |
| 232 | if(!(profile == tmpProfile)) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 233 | continue; |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 234 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 235 | const vector<string>& endorseList = endorseCert.getEndorseList(); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 236 | vector<string>::const_iterator it = endorseList.begin(); |
| 237 | for(; it != endorseList.end(); it++) |
Yingdi Yu | 6a5b9f6 | 2013-11-06 23:00:21 -0800 | [diff] [blame] | 238 | endorseCount[*it] += 1; |
Yingdi Yu | a1a688f | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 239 | }catch(std::runtime_error& e){ |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 240 | continue; |
| 241 | } |
| 242 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 243 | } |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 244 | |
| 245 | ui->infoView->setColumnCount(3); |
| 246 | Profile::const_iterator it = profile.begin(); |
| 247 | int rowCount = 0; |
| 248 | |
| 249 | QTableWidgetItem *typeHeader = new QTableWidgetItem(QString::fromUtf8("Type")); |
| 250 | ui->infoView->setHorizontalHeaderItem(0, typeHeader); |
| 251 | QTableWidgetItem *valueHeader = new QTableWidgetItem(QString::fromUtf8("Value")); |
| 252 | ui->infoView->setHorizontalHeaderItem(1, valueHeader); |
| 253 | QTableWidgetItem *endorseHeader = new QTableWidgetItem(QString::fromUtf8("Endorse")); |
| 254 | ui->infoView->setHorizontalHeaderItem(2, endorseHeader); |
| 255 | |
| 256 | for(; it != profile.end(); it++) |
| 257 | { |
| 258 | ui->infoView->insertRow(rowCount); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 259 | QTableWidgetItem *type = new QTableWidgetItem(QString::fromStdString(it->first)); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 260 | ui->infoView->setItem(rowCount, 0, type); |
| 261 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 262 | QTableWidgetItem *value = new QTableWidgetItem(QString::fromStdString(it->second)); |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 263 | ui->infoView->setItem(rowCount, 1, value); |
| 264 | |
| 265 | map<string, int>::iterator map_it = endorseCount.find(it->first); |
| 266 | QTableWidgetItem *endorse = NULL; |
| 267 | if(map_it == endorseCount.end()) |
| 268 | endorse = new QTableWidgetItem(QString::number(0)); |
| 269 | else |
| 270 | endorse = new QTableWidgetItem(QString::number(map_it->second)); |
| 271 | ui->infoView->setItem(rowCount, 2, endorse); |
| 272 | |
| 273 | rowCount++; |
| 274 | } |
| 275 | } |
| 276 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 277 | |
Yingdi Yu | d59b593 | 2013-10-16 13:16:49 -0700 | [diff] [blame] | 278 | #if WAF |
| 279 | #include "addcontactpanel.moc" |
| 280 | #include "addcontactpanel.cpp.moc" |
| 281 | #endif |