Add chatroom discovery UI
Change-Id: I94ee73ce9b4bcc63e7ecbdbf2f4844b6b57615a3
diff --git a/disabled/send-invitation-request-dialog.cpp b/disabled/send-invitation-request-dialog.cpp
new file mode 100644
index 0000000..8cc0640
--- /dev/null
+++ b/disabled/send-invitation-request-dialog.cpp
@@ -0,0 +1,99 @@
+#include "send-invitation-request-dialog.hpp"
+#include "ui_send-invitation-request-dialog.h"
+
+using namespace chronos;
+
+SendInvitationRequestDialog::SendInvitationRequestDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::SendInvitationRequestDialog),
+ m_stringListModel(new QStringListModel)
+{
+ ui->setupUi(this);
+ ui->contactsListView->setEditTriggers(ui->contactsListView->NoEditTriggers);
+ ui->contactsListView->setModel(m_stringListModel);
+
+ connect(ui->sendButton, SIGNAL(clicked()),
+ this, SLOT(onSendButtonClicked()));
+ connect(ui->cancelButton, SIGNAL(clicked()),
+ this, SLOT(onCancelButtonClicked()));
+ connect(ui->contactsListView, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(onContactListViewClicked(QModelIndex)));
+ connect(ui->contactsListView,SIGNAL(doubleClicked(QModelIndex)),
+ this, SLOT(onContactListViewDoubleClicked(QModelIndex)));
+}
+
+SendInvitationRequestDialog::~SendInvitationRequestDialog()
+{
+ delete ui;
+}
+
+void
+SendInvitationRequestDialog::setContacts(const std::vector<ndn::Name>& contacts)
+{
+ QStringList contactsList;
+ for(int i = 0; i < contacts.size(); i++){
+ contactsList.append(QString::fromStdString(contacts[i].toUri()));
+ }
+ m_stringListModel->setStringList(contactsList);
+}
+
+void
+SendInvitationRequestDialog::onSendButtonClicked()
+{
+ if(ui->contactsListView->selectionModel()->selectedRows().size() == 0){
+ QMessageBox messageBox;
+ messageBox.addButton(QMessageBox::Ok);
+ messageBox.setIcon(QMessageBox::Information);
+ messageBox.setText("Please select a contact to send invitation request");
+ messageBox.exec();
+ }
+ else{
+ //send invitation request
+ int selectedRow = ui->contactsListView->selectionModel()->selectedRows()[0].row();
+ QString contactName = m_stringListModel->stringList()[selectedRow];
+ qDebug() << contactName;
+
+ QMessageBox messageBox;
+ messageBox.addButton(QMessageBox::Yes);
+ messageBox.addButton(QMessageBox::No);
+ messageBox.setIcon(QMessageBox::Question);
+ messageBox.setText("Send invitation request to "+ contactName +"?");
+
+ int selection = messageBox.exec();
+
+ if(selection == QMessageBox::Yes){
+ //send invitation request
+ //need to have another message box when successfully send
+ //emit sendInvitationRequest(m_chatroomName, contactName);
+ }
+ }
+}
+
+
+void
+SendInvitationRequestDialog::onCancelButtonClicked()
+{
+ //qDebug() << "cancel";
+ this->close();
+}
+
+void
+SendInvitationRequestDialog::onContactListViewClicked(QModelIndex modelIndex)
+{}
+
+void
+SendInvitationRequestDialog::onContactListViewDoubleClicked(QModelIndex modelIndex)
+{
+ onSendButtonClicked();
+}
+
+void
+SendInvitationRequestDialog::setChatroomName(const QString chatroomName)
+{
+ m_chatroomName = chatroomName;
+}
+
+
+#if WAF
+#include "send-invitation-request-dialog.moc"
+#endif