summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client-qt/udm-client-qt/downloads_model.cpp9
-rw-r--r--client-qt/udm-client-qt/downloads_model.h2
-rw-r--r--client-qt/udm-client-qt/udm_main.cpp3
-rw-r--r--server/include/api_module_downloader.h4
4 files changed, 15 insertions, 3 deletions
diff --git a/client-qt/udm-client-qt/downloads_model.cpp b/client-qt/udm-client-qt/downloads_model.cpp
index 567b5e5..1883a6c 100644
--- a/client-qt/udm-client-qt/downloads_model.cpp
+++ b/client-qt/udm-client-qt/downloads_model.cpp
@@ -21,7 +21,7 @@
#include "downloads_model.h"
-downloads_model::downloads_model(std::vector<download> &downloads_, QObject */*parent*/) : downloads(downloads_)
+downloads_model::downloads_model(std::vector<download> &downloads_, QObject *parent) : QAbstractTableModel(parent), downloads(downloads_)
{
}
@@ -134,6 +134,13 @@ bool downloads_model::removeRows(int position, int rows, const QModelIndex &/*in
return true;
}
+void downloads_model::refresh()
+{
+ QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(downloads.size()-1, 5);
+ emit dataChanged(topLeft, bottomRight);
+}
+
+
void downloads_model::sort ( int /*column*/, Qt::SortOrder /*order*/)
{
//TODO:
diff --git a/client-qt/udm-client-qt/downloads_model.h b/client-qt/udm-client-qt/downloads_model.h
index fc7cfbc..08172d5 100644
--- a/client-qt/udm-client-qt/downloads_model.h
+++ b/client-qt/udm-client-qt/downloads_model.h
@@ -43,6 +43,8 @@ public:
signals:
public slots:
+ void refresh();
+
private:
std::vector<download> &downloads;
};
diff --git a/client-qt/udm-client-qt/udm_main.cpp b/client-qt/udm-client-qt/udm_main.cpp
index 7ad52ee..a7e0c18 100644
--- a/client-qt/udm-client-qt/udm_main.cpp
+++ b/client-qt/udm-client-qt/udm_main.cpp
@@ -58,6 +58,7 @@ udm_main::udm_main(QWidget *parent)
tbl_downloads = new QTableView;
tbl_downloads->setShowGrid(false);
+ tbl_downloads->setUpdatesEnabled(true);
mdl_downloads = new downloads_model(downloads);
tbl_downloads->setModel(mdl_downloads);
tbl_downloads->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -222,6 +223,7 @@ void udm_main::server_message_received(server_msg msg)
downloads.clear(); //TODO: something better
for(auto i : msg.downloads())
downloads.push_back(i.download());
+ mdl_downloads->refresh();
}
break;
case SERVER_MSG_TYPE::SERVER_DOWNLOAD_INFO_REPLY:
@@ -238,6 +240,7 @@ void udm_main::server_message_received(server_msg msg)
}
if(!found)
downloads.push_back(msg.download().download());
+ mdl_downloads->refresh();
}
break;
diff --git a/server/include/api_module_downloader.h b/server/include/api_module_downloader.h
index 9e42715..ba6cb6a 100644
--- a/server/include/api_module_downloader.h
+++ b/server/include/api_module_downloader.h
@@ -78,9 +78,9 @@ struct download_content_entry_s { //here is basic content entry description, thi
struct download_s {
- int id; //id generated via download_add or via session restore and it's unique for current session and current dowloader
+ int id = -1; //id generated via download_add or via session restore and it's unique for current session and current dowloader
std::string name;
- int64_t size, downloaded, download_speed; //download size and size of downloaded data, also download speed all vars in bytes
+ int64_t size = 0, downloaded = 0, download_speed = 0; //download size and size of downloaded data, also download speed all vars in bytes
std::map<int, std::string> info_map; //any additional info provided by downloader module can be stored here
std::list<download_content_entry_s> content; //download content can be set for download, structure described above
std::map<std::string, std::string> metadata; //client defined metadata map