diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadlist.cpp | 3 | ||||
| -rw-r--r-- | src/downloadlist.h | 3 | ||||
| -rw-r--r-- | src/downloadlistsortproxy.cpp | 2 | ||||
| -rw-r--r-- | src/downloadlistwidget.cpp | 24 | ||||
| -rw-r--r-- | src/downloadlistwidget.h | 2 | ||||
| -rw-r--r-- | src/downloadlistwidgetcompact.cpp | 45 | ||||
| -rw-r--r-- | src/downloadlistwidgetcompact.h | 3 | ||||
| -rw-r--r-- | src/downloadlistwidgetcompact.ui | 22 | ||||
| -rw-r--r-- | src/downloadmanager.cpp | 8 |
9 files changed, 102 insertions, 10 deletions
diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index f13cdef1..1e31973d 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -40,7 +40,7 @@ int DownloadList::rowCount(const QModelIndex&) const int DownloadList::columnCount(const QModelIndex&) const
{
- return 3;
+ return 4;
}
@@ -63,6 +63,7 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int switch (section) {
case COL_NAME: return tr("Name");
case COL_FILETIME: return tr("Filetime");
+ case COL_SIZE: return tr("Size");
default: return tr("Done");
}
} else {
diff --git a/src/downloadlist.h b/src/downloadlist.h index 2316dddc..e8833f0f 100644 --- a/src/downloadlist.h +++ b/src/downloadlist.h @@ -39,7 +39,8 @@ public: enum EColumn {
COL_NAME = 0,
COL_FILETIME,
- COL_STATUS
+ COL_STATUS,
+ COL_SIZE
};
public:
diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp index 2780f973..f791617a 100644 --- a/src/downloadlistsortproxy.cpp +++ b/src/downloadlistsortproxy.cpp @@ -47,6 +47,8 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left, return m_Manager->getFileTime(leftIndex) < m_Manager->getFileTime(rightIndex);
} else if (left.column() == DownloadList::COL_STATUS) {
return m_Manager->getState(leftIndex) < m_Manager->getState(rightIndex);
+ } else if(left.column() == DownloadList::COL_SIZE){
+ return m_Manager->getFileSize(leftIndex) < m_Manager->getFileSize(rightIndex);
} else {
return leftIndex < rightIndex;
}
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 0ef408fb..ad694107 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -82,7 +82,7 @@ void DownloadListWidgetDelegate::drawCache(QPainter *painter, const QStyleOption {
QRect rect = option.rect;
rect.setLeft(0);
- rect.setWidth(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2));
+ rect.setWidth(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3));
painter->drawPixmap(rect, cache);
}
@@ -193,7 +193,7 @@ void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionView return;
}
- m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2), option.rect.height()));
+ m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3), option.rect.height()));
int downloadIndex = index.data().toInt();
@@ -310,6 +310,15 @@ void DownloadListWidgetDelegate::issueDeleteCompleted() }
}
+void DownloadListWidgetDelegate::issueDeleteUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Delete Files?"),
+ tr("This will remove all uninstalled downloads from this list and from disk."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, true);
+ }
+}
+
void DownloadListWidgetDelegate::issueRemoveFromViewAll()
{
if (QMessageBox::question(nullptr, tr("Are you sure?"),
@@ -328,6 +337,15 @@ void DownloadListWidgetDelegate::issueRemoveFromViewCompleted() }
}
+void DownloadListWidgetDelegate::issueRemoveFromViewUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will remove all uninstalled downloads from this list (but NOT from disk)."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, false);
+ }
+}
+
bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index)
{
@@ -380,11 +398,13 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel * menu.addSeparator();
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
+ menu.addAction(tr("Delete Uninstalled..."), this, SLOT(issueDeleteUninstalled()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
menu.addSeparator();
menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide Uninstalled..."), this, SLOT(issueRemoveFromViewUninstalled()));
menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
}
if (hidden) {
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 4dcbea99..2dd73e73 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -99,8 +99,10 @@ private slots: void issueResume();
void issueDeleteAll();
void issueDeleteCompleted();
+ void issueDeleteUninstalled();
void issueRemoveFromViewAll();
void issueRemoveFromViewCompleted();
+ void issueRemoveFromViewUninstalled();
void issueQueryInfo();
void stateChanged(int row, DownloadManager::DownloadState);
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index 1d1805ef..34e31006 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -81,10 +81,27 @@ void DownloadListWidgetCompactDelegate::drawCache(QPainter *painter, const QStyl {
QRect rect = option.rect;
rect.setLeft(0);
- rect.setWidth(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2));
+ rect.setWidth(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3));
painter->drawPixmap(rect, cache);
}
+QString DownloadListWidgetCompactDelegate::sizeFormat(quint64 size) const
+{
+ qreal calc = size;
+ QStringList list;
+ list << "KB" << "MB" << "GB" << "TB";
+
+ QStringListIterator i(list);
+ QString unit("byte(s)");
+
+ while (calc >= 1024.0 && i.hasNext())
+ {
+ unit = i.next();
+ calc /= 1024.0;
+ }
+
+ return QString().setNum(calc, 'f', 2) + " " + unit;
+}
void DownloadListWidgetCompactDelegate::paintPendingDownload(int downloadIndex) const
{
@@ -110,8 +127,8 @@ void DownloadListWidgetCompactDelegate::paintRegularDownload(int downloadIndex) DownloadManager::DownloadState state = m_Manager->getState(downloadIndex);
- if ((m_SizeLabel != nullptr) && (state >= DownloadManager::STATE_READY)) {
- m_SizeLabel->setText(QString::number(m_Manager->getFileSize(downloadIndex) / 1048576));
+ if ((m_SizeLabel != nullptr)) {
+ m_SizeLabel->setText(sizeFormat(m_Manager->getFileSize(downloadIndex)));
}
if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR) || (state == DownloadManager::STATE_PAUSING)) {
@@ -153,7 +170,7 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt return;
}
- m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2), option.rect.height()));
+ m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2) + m_View->columnWidth(3), option.rect.height()));
if (index.row() % 2 == 1) {
m_ItemWidget->setBackgroundRole(QPalette::AlternateBase);
} else {
@@ -275,6 +292,15 @@ void DownloadListWidgetCompactDelegate::issueDeleteCompleted() }
}
+void DownloadListWidgetCompactDelegate::issueDeleteUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will remove all uninstalled downloads from this list and from disk."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, true);
+ }
+}
+
void DownloadListWidgetCompactDelegate::issueRemoveFromViewAll()
{
if (QMessageBox::question(nullptr, tr("Are you sure?"),
@@ -293,6 +319,15 @@ void DownloadListWidgetCompactDelegate::issueRemoveFromViewCompleted() }
}
+void DownloadListWidgetCompactDelegate::issueRemoveFromViewUninstalled()
+{
+ if (QMessageBox::question(nullptr, tr("Are you sure?"),
+ tr("This will permanently remove all uninstalled downloads from this list (but NOT from disk)."),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ emit removeDownload(-3, false);
+ }
+}
+
bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index)
@@ -342,10 +377,12 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem menu.addSeparator();
}
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
+ menu.addAction(tr("Delete Uninstalled..."), this, SLOT(issueDeleteUninstalled()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
menu.addSeparator();
menu.addAction(tr("Hide Installed..."), this, SLOT(issueRemoveFromViewCompleted()));
+ menu.addAction(tr("Hide Uninstalled..."), this, SLOT(issueRemoveFromViewUninstalled()));
menu.addAction(tr("Hide All..."), this, SLOT(issueRemoveFromViewAll()));
}
if (hidden) {
diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h index c25b7e99..b1b3c617 100644 --- a/src/downloadlistwidgetcompact.h +++ b/src/downloadlistwidgetcompact.h @@ -74,6 +74,7 @@ signals: protected:
+ QString sizeFormat(quint64 size) const;
bool editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index);
@@ -97,8 +98,10 @@ private slots: void issueResume();
void issueDeleteAll();
void issueDeleteCompleted();
+ void issueDeleteUninstalled();
void issueRemoveFromViewAll();
void issueRemoveFromViewCompleted();
+ void issueRemoveFromViewUninstalled();
void issueQueryInfo();
void stateChanged(int row, DownloadManager::DownloadState);
diff --git a/src/downloadlistwidgetcompact.ui b/src/downloadlistwidgetcompact.ui index b43f1fb3..a3cf3f02 100644 --- a/src/downloadlistwidgetcompact.ui +++ b/src/downloadlistwidgetcompact.ui @@ -19,7 +19,7 @@ <property name="autoFillBackground">
<bool>true</bool>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0">
<property name="spacing">
<number>2</number>
</property>
@@ -58,6 +58,26 @@ </widget>
</item>
<item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="sizeLabel">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 9e523bf9..385d2246 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -690,7 +690,13 @@ void DownloadManager::removeDownload(int index, bool deleteFile) emit aboutToUpdate();
if (index < 0) {
- DownloadState minState = index == -1 ? STATE_READY : STATE_INSTALLED;
+ DownloadState minState;
+ if (index == -3) {
+ minState = STATE_UNINSTALLED;
+ }
+ else
+ minState = index == -1 ? STATE_READY : STATE_INSTALLED;
+
index = 0;
for (QVector<DownloadInfo*>::iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end();) {
if ((*iter)->m_State >= minState) {
|
