From c11ff7e2db09514304cef35a650aa3fbef27dd16 Mon Sep 17 00:00:00 2001 From: Krzysztof Starecki Date: Sun, 30 Dec 2018 22:13:15 +0100 Subject: Add icon for incomplete download info, add download progress delegate --- src/downloadlistwidget.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/downloadlistwidget.cpp') diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 9cf8e097..6a85c317 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -17,13 +17,39 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ +#include "downloadlist.h" #include "downloadlistwidget.h" #include #include #include #include #include +#include +void DownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QModelIndex sourceIndex = m_SortProxy->mapToSource(index); + if (sourceIndex.column() == DownloadList::COL_STATUS && sourceIndex.row() < m_Manager->numTotalDownloads() + && m_Manager->getState(sourceIndex.row()) == DownloadManager::STATE_DOWNLOADING) { + bool pendingDownload = sourceIndex.row() >= m_Manager->numTotalDownloads(); + QStyleOptionProgressBar progressBarOption; + progressBarOption.state = QStyle::State_Enabled; + progressBarOption.direction = QApplication::layoutDirection(); + progressBarOption.rect = option.rect; + progressBarOption.fontMetrics = QApplication::fontMetrics(); + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.textAlignment = Qt::AlignCenter; + progressBarOption.textVisible = true; + progressBarOption.progress = m_Manager->getProgress(sourceIndex.row()).first; + progressBarOption.text = m_Manager->getProgress(sourceIndex.row()).second; + + QApplication::style()->drawControl(QStyle::CE_ProgressBar, + &progressBarOption, painter); + } else { + QStyledItemDelegate::paint(painter, option, index); + } +} DownloadListWidget::DownloadListWidget(QWidget *parent) : QTreeView(parent) -- cgit v1.3.1