diff options
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); } |