From 454ed688836c9de52039b84ea381ffd22890a6e8 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sun, 3 Jan 2016 20:58:58 +0300 Subject: client-qt: typo fix very basic implementation of download state changes handler --- client-qt/udm-client-qt/downloads_model.cpp | 3 +-- client-qt/udm-client-qt/udm_main.cpp | 21 ++++++++++++++++++--- server/udm-server.project | 21 ++++++++++++++------- udm.workspace | 10 ++++++---- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/client-qt/udm-client-qt/downloads_model.cpp b/client-qt/udm-client-qt/downloads_model.cpp index f5d8817..5789151 100644 --- a/client-qt/udm-client-qt/downloads_model.cpp +++ b/client-qt/udm-client-qt/downloads_model.cpp @@ -55,7 +55,6 @@ QVariant downloads_model::data(const QModelIndex &index, int role) const case 2: return (qint64)downloads[index.row()].downloaded(); break; - // case 3: if(downloads[index.row()].size()) return (qint64)((double)downloads[index.row()].downloaded() / (double)downloads[index.row()].size()) * 100.0; @@ -70,7 +69,7 @@ QVariant downloads_model::data(const QModelIndex &index, int role) const return tr("Stopped"); break; case 1: - return tr("Stopped"); + return tr("Started"); break; //TODO: handle module defined states default: diff --git a/client-qt/udm-client-qt/udm_main.cpp b/client-qt/udm-client-qt/udm_main.cpp index 48ff7c8..ab9b898 100644 --- a/client-qt/udm-client-qt/udm_main.cpp +++ b/client-qt/udm-client-qt/udm_main.cpp @@ -369,10 +369,26 @@ void udm_main::server_message_received(server_msg msg) switch(i.state()) { case SUBSCRIPTION_DOWNLOAD_STATE::SDS_STARTED: - //TODO: + for(auto d = downloads.begin(), end = downloads.end(); d != end; ++d) + { + if(d->id() == i.download_id()) + { + d->set_state(1); //TODO: use human readable enum for states ? + mdl_downloads->refresh(); //TODO: udapte only changed item + break; + } + } break; case SUBSCRIPTION_DOWNLOAD_STATE::SDS_STOPPED: - //TODO: + for(auto d = downloads.begin(), end = downloads.end(); d != end; ++d) + { + if(d->id() == i.download_id()) + { + d->set_state(0); //TODO: use human readable enum for states ? + mdl_downloads->refresh(); //TODO: udapte only changed item + break; + } + } break; case SUBSCRIPTION_DOWNLOAD_STATE::SDS_DELETED: { @@ -391,7 +407,6 @@ void udm_main::server_message_received(server_msg msg) BOOST_LOG_TRIVIAL(error)<<"error: deleted download which is not exist\n"< - + @@ -138,15 +147,13 @@ - + - - - + @@ -159,8 +166,8 @@ - - + + diff --git a/udm.workspace b/udm.workspace index f4ab096..a531e89 100644 --- a/udm.workspace +++ b/udm.workspace @@ -3,19 +3,21 @@ + + + + - + + - - - -- cgit v1.2.3