summaryrefslogtreecommitdiff
path: root/src/downloadlistwidget.cpp
diff options
context:
space:
mode:
authorKrzysztof Starecki <krzysztof.starecki@gmail.com>2018-12-30 22:13:15 +0100
committerKrzysztof Starecki <krzysztof.starecki@gmail.com>2018-12-30 22:13:15 +0100
commitc11ff7e2db09514304cef35a650aa3fbef27dd16 (patch)
tree52a514445448ca847016e795da66ef7d099d313b /src/downloadlistwidget.cpp
parentcfb941082e27925279535cade18d2b3c912c8930 (diff)
Add icon for incomplete download info, add download progress delegate
Diffstat (limited to 'src/downloadlistwidget.cpp')
-rw-r--r--src/downloadlistwidget.cpp26
1 files changed, 26 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
*/
+#include "downloadlist.h"
#include "downloadlistwidget.h"
#include <QPainter>
#include <QMouseEvent>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
+#include <QApplication>
+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)