summaryrefslogtreecommitdiff
path: root/client-qt/udm-client-qt/udm_main.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2015-08-21 04:05:55 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2015-08-21 04:05:55 +0300
commitc8029a36924fdad89b2455746bfd771da723287f (patch)
treeecf981983d178176bd2e9619c7040c743c34d67d /client-qt/udm-client-qt/udm_main.cpp
parentc83c19a7d93ee77617c6e47bf0700346545b4611 (diff)
client-qt:
correct network thread termination downloads model skeleton filters model skeleton empty download info tabwindow main window layout initial server data requests (settings, modules, downloads) protocol: renamed most of ui_* messages to download_ui* as it more precise reworked ui related proto part added download related messages (should be sufficient for now) some work on event subscription part bit of work on module related messages added more top level messages (most of defined messages may be used now)
Diffstat (limited to 'client-qt/udm-client-qt/udm_main.cpp')
-rw-r--r--client-qt/udm-client-qt/udm_main.cpp89
1 files changed, 88 insertions, 1 deletions
diff --git a/client-qt/udm-client-qt/udm_main.cpp b/client-qt/udm-client-qt/udm_main.cpp
index 0089a45..17744aa 100644
--- a/client-qt/udm-client-qt/udm_main.cpp
+++ b/client-qt/udm-client-qt/udm_main.cpp
@@ -25,14 +25,25 @@
#include <QMessageBox>
#include <QStatusBar>
#include <QLabel>
+#include <QTableView>
+#include <QTreeView>
+#include <QTabWidget>
+#include <QHeaderView>
+#include <QSplitter>
+#include <QStackedLayout>
#include "connect_widget.h"
#include "client_session.h"
+#include "downloads_model.h"
+#include "filters_model.h"
udm_main::udm_main(QWidget *parent)
: QMainWindow(parent)
{
+ io_service_ = nullptr;
+ thread_client_session = nullptr;
+ //session = nullptr;
auto menu_main = this->menuBar()->addMenu(tr("Main"));
auto action_connect = menu_main->addAction(tr("Connect"));
connect(action_connect, SIGNAL(triggered()), this, SLOT(show_connect_widget()));
@@ -41,10 +52,55 @@ udm_main::udm_main(QWidget *parent)
lbl_state = new QLabel;
lbl_state->setText(tr("State") + ": " + tr("Offline"));
this->statusBar()->addPermanentWidget(lbl_state);
+
+ tbl_downloads = new QTableView;
+ tbl_downloads->setShowGrid(false);
+ mdl_downloads = new downloads_model;
+ tbl_downloads->setModel(mdl_downloads);
+ tbl_downloads->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tbl_downloads->setSortingEnabled(true);
+ tbl_downloads->horizontalHeader()->setHighlightSections(false);
+ tbl_downloads->horizontalHeader()->setMovable(true);
+ tbl_downloads->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
+ tbl_downloads->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+
+ tree_filters = new QTreeView;
+ mdl_filters = new filters_model;
+ tree_filters->setModel(mdl_filters);
+ tree_filters->header()->hide();
+ tree_filters->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ tree_filters->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tree_filters->setIndentation(10);
+
+ spl_hor = new QSplitter(Qt::Horizontal);
+ spl_hor->addWidget(tree_filters);
+ spl_hor->addWidget(tbl_downloads);
+
+ spl_hor->setStretchFactor(0, 2);
+ spl_hor->setStretchFactor(1, 10);
+
+ tabs_info = new QTabWidget;
+
+
+
+
+ spl_vert = new QSplitter(Qt::Vertical);
+ spl_vert->addWidget(spl_hor);
+ spl_vert->addWidget(tabs_info);
+
+ spl_vert->setStretchFactor(0, 3);
+ spl_vert->setStretchFactor(1, 1);
+ setCentralWidget(spl_vert);
+
}
udm_main::~udm_main()
{
+ if(thread_client_session)
+ {
+ thread_client_session->quit();
+ delete thread_client_session;
+ }
//TODO: clear all remaining data
}
@@ -59,15 +115,30 @@ void udm_main::show_connect_widget()
void udm_main::client_pre_connect_init()
{
+ if(thread_client_session)
+ {
+ delete thread_client_session;
+ thread_client_session = nullptr;
+ }
thread_client_session = new QThread(this);
+ if(io_service_)
+ {
+ delete io_service_;
+ io_service_ = nullptr;
+ }
io_service_ = new boost::asio::io_service;
+/* if(session) //crashing
+ {
+ delete session;
+ session = nullptr;
+ } */
session = new client_session(0, io_service_); //parent must be 0 here
connect(session, SIGNAL(server_message_received(server_msg)), this, SLOT(server_message_received(server_msg)));
connect(session, SIGNAL(client_connected(bool,QString)), this, SLOT(client_connected(bool,QString)));
}
void udm_main::client_connect_finalize()
{
- //connect(session, SIGNAL(terminate_thread()), thread_client_session, SLOT(terminate()));
+ connect(session, SIGNAL(terminate_thread()), thread_client_session, SLOT(quit()));
session->moveToThread(thread_client_session);
thread_client_session->start();
}
@@ -99,6 +170,22 @@ void udm_main::server_message_received(server_msg msg)
auth_token = msg.auth_reply().auth_token().c_str();
//TODO: update client status
lbl_state->setText(tr("State") + ": " + tr("Connected") + ", " + tr("Authenticated"));
+ //request modules and settings here
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_CORE_SETTINGS_REQUEST);
+ session->send_message(msg);
+ }
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_MODULES_REQUEST);
+ session->send_message(msg);
+ }
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_DOWNLOADS_LIST_REQUEST);
+ session->send_message(msg);
+ }
}
else
{