diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-22 13:59:38 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-22 13:59:38 +0300 |
commit | bd7207d8bf82c58c60399c05c29c2312a8c0f258 (patch) | |
tree | bd8674bdf03e23d6797ab9e69ece4523307607ff /client-qt/udm-client-qt/downloads_model.cpp | |
parent | acfde068698184249e50e0781a22bb38ba87cf3f (diff) |
protocol:
added download state field to "download"
added module defined download state names to "module_info"
few fields description
server:
added download state to downloader api structures
setting download states in outgoing downloads
client-qt:
basic implementation of download state in downloads table (withoud module defined states)
fixed downloads table model update (working)
Diffstat (limited to 'client-qt/udm-client-qt/downloads_model.cpp')
-rw-r--r-- | client-qt/udm-client-qt/downloads_model.cpp | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/client-qt/udm-client-qt/downloads_model.cpp b/client-qt/udm-client-qt/downloads_model.cpp index 1883a6c..f5d8817 100644 --- a/client-qt/udm-client-qt/downloads_model.cpp +++ b/client-qt/udm-client-qt/downloads_model.cpp @@ -57,15 +57,36 @@ QVariant downloads_model::data(const QModelIndex &index, int role) const break; // case 3: - return (qint64)((double)downloads[index.row()].downloaded() / (double)downloads[index.row()].size()) * 100.0; + if(downloads[index.row()].size()) + return (qint64)((double)downloads[index.row()].downloaded() / (double)downloads[index.row()].size()) * 100.0; + else + return QVariant(); break; - case 4: + case 4: //TODO: + { + switch(downloads[index.row()].state()) + { + case 0: + return tr("Stopped"); + break; + case 1: + return tr("Stopped"); + break; + //TODO: handle module defined states + default: + return QVariant(); + break; + } + return QVariant(); + } + break; + case 5: return downloads[index.row()].module_name().c_str(); break; - case 5: //TODO: + case 6: //TODO: return QVariant(); break; - case 6: //TODO: + case 7: //TODO: return QVariant(); break; @@ -99,12 +120,15 @@ QVariant downloads_model::headerData(int section, Qt::Orientation orientation, i return QString(tr("Progress")); break; case 4: - return QString(tr("Module name")); + return QString(tr("State")); break; case 5: - return QString(tr("Down Speed")); + return QString(tr("Module name")); break; case 6: + return QString(tr("Down Speed")); + break; + case 7: return QString(tr("ETA")); break; } @@ -134,9 +158,18 @@ bool downloads_model::removeRows(int position, int rows, const QModelIndex &/*in return true; } +QModelIndex downloads_model::index ( int row, int column, const QModelIndex & /*parent */) const +{ + return createIndex(row, column); +} +QModelIndex downloads_model::parent ( const QModelIndex & /*index*/) const +{ + return QModelIndex(); +} + void downloads_model::refresh() { - QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(downloads.size()-1, 5); + QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(downloads.size() - 1, 6); emit dataChanged(topLeft, bottomRight); } |