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
diff --git a/disabled/send-invitation-request-dialog.hpp b/disabled/send-invitation-request-dialog.hpp
new file mode 100644
index 0000000..ea86676
--- /dev/null
+++ b/disabled/send-invitation-request-dialog.hpp
@@ -0,0 +1,55 @@
+#ifndef SENDINVITATIONREQUESTDIALOG_H
+#define SENDINVITATIONREQUESTDIALOG_H
+
+#include <QDialog>
+#include <QStringListModel>
+#include <QMessageBox>
+#include <QDebug>
+#include <QAbstractItemView>
+
+#ifndef Q_MOC_RUN
+#include "chatroom-discovery.hpp"
+#endif
+
+namespace Ui {
+class SendInvitationRequestDialog;
+}
+
+namespace chronos {
+
+class SendInvitationRequestDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit SendInvitationRequestDialog(QWidget *parent = 0);
+ ~SendInvitationRequestDialog();
+
+ void
+ setContacts(const std::vector<ndn::Name>& contacts);
+
+ void
+ setChatroomName(const QString chatroomName);
+
+public slots:
+ void
+ onSendButtonClicked();
+
+ void
+ onCancelButtonClicked();
+
+ void
+ onContactListViewClicked(QModelIndex modelIndex);
+
+ void
+ onContactListViewDoubleClicked(QModelIndex modelIndex);
+
+private:
+ Ui::SendInvitationRequestDialog *ui;
+ QString m_chatroomName;
+ QStringListModel *m_stringListModel;
+};
+
+} //namespace chronos
+
+#endif // SENDINVITATIONREQUESTDIALOG_H
diff --git a/disabled/send-invitation-request-dialog.ui b/disabled/send-invitation-request-dialog.ui
new file mode 100644
index 0000000..1108478
--- /dev/null
+++ b/disabled/send-invitation-request-dialog.ui
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SendInvitationRequestDialog</class>
+ <widget class="QDialog" name="SendInvitationRequestDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>441</width>
+ <height>308</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QLabel" name="introLabel">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>20</y>
+ <width>391</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string><html><head/><body><p>Choose your contact to send invitation request:</p></body></html></string>
+ </property>
+ </widget>
+ <widget class="QListView" name="contactsListView">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>50</y>
+ <width>351</width>
+ <height>192</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="sendButton">
+ <property name="geometry">
+ <rect>
+ <x>230</x>
+ <y>260</y>
+ <width>91</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Send</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>260</y>
+ <width>91</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>