| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| /* |
| * Copyright (c) 2013, Regents of the University of California |
| * Yingdi Yu |
| * |
| * BSD license, See the LICENSE file for more information |
| * |
| * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| */ |
| |
| #include "invite-list-dialog.hpp" |
| #include "ui_invite-list-dialog.h" |
| |
| namespace chronochat { |
| |
| InviteListDialog::InviteListDialog(QWidget* parent) |
| :QDialog(parent) |
| , ui(new Ui::InviteListDialog) |
| , m_contactListModel(new QStringListModel) |
| { |
| ui->setupUi(this); |
| |
| ui->contactListView->setModel(m_contactListModel); |
| |
| connect(ui->inviteButton, SIGNAL(clicked()), |
| this, SLOT(onInviteClicked())); |
| connect(ui->cancelButton, SIGNAL(clicked()), |
| this, SLOT(onCancelClicked())); |
| } |
| |
| InviteListDialog::~InviteListDialog() |
| { |
| delete ui; |
| delete m_contactListModel; |
| } |
| |
| void |
| InviteListDialog::setInviteLabel(std::string label) |
| { |
| std::string msg("invite to chatroom:\n"); |
| msg += label; |
| ui->inviteLabel->setText(QString::fromStdString(msg)); |
| } |
| |
| void |
| InviteListDialog::onInviteClicked() |
| { |
| QModelIndexList selected = ui->contactListView->selectionModel()->selectedIndexes(); |
| QString alias = m_contactListModel->data(selected.first(), Qt::DisplayRole).toString(); |
| |
| // TODO:: could be optimized without using for loop. |
| for (int i = 0; i < m_contactAliasList.size(); i++) { |
| if (alias == m_contactAliasList[i]) { |
| emit sendInvitation(m_contactIdList[i]); |
| break; |
| } |
| } |
| |
| this->close(); |
| } |
| |
| void |
| InviteListDialog::onCancelClicked() |
| { |
| this->close(); |
| } |
| |
| void |
| InviteListDialog::onContactAliasListReady(const QStringList& aliasList) |
| { |
| m_contactAliasList = aliasList; |
| m_contactListModel->setStringList(m_contactAliasList); |
| } |
| |
| void |
| InviteListDialog::onContactIdListReady(const QStringList& idList) |
| { |
| m_contactIdList = idList; |
| } |
| |
| } // namespace chronochat |
| |
| #if WAF |
| #include "invite-list-dialog.moc" |
| // #include "invite-list-dialog.cpp.moc" |
| #endif |