diff options
| author | Tannin <devnull@localhost> | 2014-01-04 15:57:14 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-01-04 15:57:14 +0100 |
| commit | 4dc3538a7d14dd0f1aaa2e6c172745b63e251c86 (patch) | |
| tree | 2242c92482306c5710b00dfb212cce11456e776d /src/downloadlistwidgetcompact.cpp | |
| parent | 14ac234daf1680b0685f6bea3e74aa09dfcf38ef (diff) | |
- nxmhandler will now ask before registering itself
- downloads from nexus are now displayed before file information is retrieved
- logging from the ui is now a bit more informative
- download list now scrolls to bottom automatically
Diffstat (limited to 'src/downloadlistwidgetcompact.cpp')
| -rw-r--r-- | src/downloadlistwidgetcompact.cpp | 148 |
1 files changed, 86 insertions, 62 deletions
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index d2a71dd5..e2fbcd24 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -82,6 +82,66 @@ void DownloadListWidgetCompactDelegate::drawCache(QPainter *painter, const QStyl } +void DownloadListWidgetCompactDelegate::paintPendingDownload(int downloadIndex) const +{ + std::pair<int, int> nexusids = m_Manager->getPendingDownload(downloadIndex); + m_NameLabel->setText(tr("< mod %1 file %2 >").arg(nexusids.first).arg(nexusids.second)); + if (m_SizeLabel != NULL) { + m_SizeLabel->setText("???"); + } + m_DoneLabel->setVisible(true); + m_DoneLabel->setText(tr("Pending")); + m_Progress->setVisible(false); +} + + +void DownloadListWidgetCompactDelegate::paintRegularDownload(int downloadIndex) const +{ + QString name = m_Manager->getFileName(downloadIndex); + if (name.length() > 53) { + name.truncate(50); + name.append("..."); + } + m_NameLabel->setText(name); + + DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); + + if ((m_SizeLabel != NULL) && (state >= DownloadManager::STATE_READY)) { + m_SizeLabel->setText(QString::number(m_Manager->getFileSize(downloadIndex) / 1048576)); + } + + if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) { + m_DoneLabel->setVisible(true); + m_Progress->setVisible(false); + m_DoneLabel->setText(tr("Paused")); + m_DoneLabel->setForegroundRole(QPalette::Link); + } else if (state == DownloadManager::STATE_FETCHINGMODINFO) { + m_DoneLabel->setText(tr("Fetching Info 1")); + } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) { + m_DoneLabel->setText(tr("Fetching Info 2")); + } else if (state >= DownloadManager::STATE_READY) { + m_DoneLabel->setVisible(true); + m_Progress->setVisible(false); + if (state == DownloadManager::STATE_INSTALLED) { + m_DoneLabel->setText(tr("Installed")); + m_DoneLabel->setForegroundRole(QPalette::Mid); + } else if (state == DownloadManager::STATE_UNINSTALLED) { + m_DoneLabel->setText(tr("Uninstalled")); + m_DoneLabel->setForegroundRole(QPalette::Dark); + } else { + m_DoneLabel->setText(tr("Done")); + m_DoneLabel->setForegroundRole(QPalette::WindowText); + } + if (m_Manager->isInfoIncomplete(downloadIndex)) { + m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text()); + } + } else { + m_DoneLabel->setVisible(false); + m_Progress->setVisible(true); + m_Progress->setValue(m_Manager->getProgress(downloadIndex)); + } +} + void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { #pragma message("This is quite costy - room for optimization?") @@ -100,49 +160,10 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt } int downloadIndex = index.data().toInt(); - - QString name = m_Manager->getFileName(downloadIndex); - if (name.length() > 53) { - name.truncate(50); - name.append("..."); - } - m_NameLabel->setText(name); - - DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); - - if ((m_SizeLabel != NULL) && (state >= DownloadManager::STATE_READY)) { - m_SizeLabel->setText(QString::number(m_Manager->getFileSize(downloadIndex) / 1048576)); - } - - if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) { - m_DoneLabel->setVisible(true); - m_Progress->setVisible(false); - m_DoneLabel->setText(tr("Paused")); - m_DoneLabel->setForegroundRole(QPalette::Link); - } else if (state == DownloadManager::STATE_FETCHINGMODINFO) { - m_DoneLabel->setText(tr("Fetching Info 1")); - } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) { - m_DoneLabel->setText(tr("Fetching Info 2")); - } else if (state >= DownloadManager::STATE_READY) { - m_DoneLabel->setVisible(true); - m_Progress->setVisible(false); - if (state == DownloadManager::STATE_INSTALLED) { - m_DoneLabel->setText(tr("Installed")); - m_DoneLabel->setForegroundRole(QPalette::Mid); - } else if (state == DownloadManager::STATE_UNINSTALLED) { - m_DoneLabel->setText(tr("Uninstalled")); - m_DoneLabel->setForegroundRole(QPalette::Dark); - } else { - m_DoneLabel->setText(tr("Done")); - m_DoneLabel->setForegroundRole(QPalette::WindowText); - } - if (m_Manager->isInfoIncomplete(downloadIndex)) { - m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text()); - } + if (downloadIndex >= m_Manager->numTotalDownloads()) { + paintPendingDownload(downloadIndex - m_Manager->numTotalDownloads()); } else { - m_DoneLabel->setVisible(false); - m_Progress->setVisible(true); - m_Progress->setValue(m_Manager->getProgress(downloadIndex)); + paintRegularDownload(downloadIndex); } #pragma message("caching disabled because changes in the list (including resorting) doesn't work correctly") @@ -268,29 +289,32 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() == Qt::RightButton) { QMenu menu; + bool hidden = false; m_ContextIndex = qobject_cast<QSortFilterProxyModel*>(model)->mapToSource(index); - DownloadManager::DownloadState state = m_Manager->getState(m_ContextIndex.row()); - bool hidden = m_Manager->isHidden(m_ContextIndex.row()); - if (state >= DownloadManager::STATE_READY) { - menu.addAction(tr("Install"), this, SLOT(issueInstall())); - if (m_Manager->isInfoIncomplete(m_ContextIndex.row())) { - menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo())); - } - menu.addAction(tr("Delete"), this, SLOT(issueDelete())); - if (hidden) { - menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView())); - } else { - menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView())); + if (m_ContextIndex.row() < m_Manager->numTotalDownloads()) { + DownloadManager::DownloadState state = m_Manager->getState(m_ContextIndex.row()); + hidden = m_Manager->isHidden(m_ContextIndex.row()); + if (state >= DownloadManager::STATE_READY) { + menu.addAction(tr("Install"), this, SLOT(issueInstall())); + if (m_Manager->isInfoIncomplete(m_ContextIndex.row())) { + menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo())); + } + menu.addAction(tr("Delete"), this, SLOT(issueDelete())); + if (hidden) { + menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView())); + } else { + menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView())); + } + } else if (state == DownloadManager::STATE_DOWNLOADING){ + menu.addAction(tr("Cancel"), this, SLOT(issueCancel())); + menu.addAction(tr("Pause"), this, SLOT(issuePause())); + } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) { + menu.addAction(tr("Remove"), this, SLOT(issueDelete())); + menu.addAction(tr("Resume"), this, SLOT(issueResume())); } - } else if (state == DownloadManager::STATE_DOWNLOADING){ - menu.addAction(tr("Cancel"), this, SLOT(issueCancel())); - menu.addAction(tr("Pause"), this, SLOT(issuePause())); - } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) { - menu.addAction(tr("Remove"), this, SLOT(issueDelete())); - menu.addAction(tr("Resume"), this, SLOT(issueResume())); - } - menu.addSeparator(); + menu.addSeparator(); + } menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted())); menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll())); if (!hidden) { |
