2014-07-03 22:21:21 +00:00
|
|
|
#include "FindModal.h"
|
|
|
|
#include "SocketCommand.h"
|
|
|
|
#include "WebPage.h"
|
|
|
|
#include "WebPageManager.h"
|
|
|
|
#include "ErrorMessage.h"
|
|
|
|
|
|
|
|
FindModal::FindModal(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
2014-07-16 02:55:24 +00:00
|
|
|
m_modalId = 0;
|
2014-07-03 22:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FindModal::start() {
|
2014-07-16 02:55:24 +00:00
|
|
|
m_modalId = arguments()[0].toInt();
|
|
|
|
if (page()->modalCount() < m_modalId) {
|
|
|
|
connect(page(), SIGNAL(modalReady(int)), SLOT(handleModalReady(int)));
|
2014-07-03 22:21:21 +00:00
|
|
|
} else {
|
2014-07-16 02:55:24 +00:00
|
|
|
handleModalReady(m_modalId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindModal::handleModalReady(int modalId) {
|
|
|
|
if (modalId == m_modalId) {
|
|
|
|
sender()->disconnect(SIGNAL(modalReady(int)), this, SLOT(handleModalReady(int)));
|
|
|
|
if (page()->modalMessage(m_modalId).isNull()) {
|
2014-07-03 22:21:21 +00:00
|
|
|
finish(false, new ErrorMessage("ModalNotFound", ""));
|
|
|
|
} else {
|
2014-07-16 02:55:24 +00:00
|
|
|
finish(true, page()->modalMessage(m_modalId));
|
2014-07-03 22:21:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|