mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
Add 'download meta information' support to download tab
This commit is contained in:
@@ -33,6 +33,11 @@ DownloadList::DownloadList(DownloadManager *manager, QObject *parent)
|
||||
connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate()));
|
||||
}
|
||||
|
||||
void DownloadList::setMetaDisplay(bool metaDisplay)
|
||||
{
|
||||
m_MetaDisplay = metaDisplay;
|
||||
}
|
||||
|
||||
|
||||
int DownloadList::rowCount(const QModelIndex&) const
|
||||
{
|
||||
@@ -86,7 +91,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
} else {
|
||||
switch (index.column()) {
|
||||
case COL_NAME: return m_Manager->getFileName(index.row());
|
||||
case COL_NAME: return m_MetaDisplay ? m_Manager->getDisplayName(index.row()) : m_Manager->getFileName(index.row());
|
||||
case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row()));
|
||||
case COL_STATUS:
|
||||
switch (m_Manager->getState(index.row())) {
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
**/
|
||||
explicit DownloadList(DownloadManager *manager, QObject *parent = 0);
|
||||
|
||||
void setMetaDisplay(bool metaDisplay);
|
||||
|
||||
/**
|
||||
* @brief retrieve the number of rows to display. Invoked by Qt
|
||||
*
|
||||
@@ -90,6 +92,7 @@ public slots:
|
||||
private:
|
||||
|
||||
DownloadManager *m_Manager;
|
||||
bool m_MetaDisplay;
|
||||
|
||||
QString sizeFormat(quint64 size) const;
|
||||
};
|
||||
|
||||
@@ -84,6 +84,16 @@ void DownloadListWidget::setManager(DownloadManager *manager)
|
||||
m_Manager = manager;
|
||||
}
|
||||
|
||||
void DownloadListWidget::setSourceModel(DownloadList *sourceModel)
|
||||
{
|
||||
m_SourceModel = sourceModel;
|
||||
}
|
||||
|
||||
void DownloadListWidget::setMetaDisplay(bool metaDisplay)
|
||||
{
|
||||
m_SourceModel->setMetaDisplay(metaDisplay);
|
||||
}
|
||||
|
||||
void DownloadListWidget::onDoubleClick(const QModelIndex &index)
|
||||
{
|
||||
QModelIndex sourceIndex = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(index);
|
||||
|
||||
@@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define DOWNLOADLISTWIDGET_H
|
||||
|
||||
#include "downloadmanager.h"
|
||||
#include "downloadlist.h"
|
||||
#include "downloadlistsortproxy.h"
|
||||
#include <QWidget>
|
||||
#include <QItemDelegate>
|
||||
@@ -58,6 +59,8 @@ public:
|
||||
~DownloadListWidget();
|
||||
|
||||
void setManager(DownloadManager *manager);
|
||||
void setSourceModel(DownloadList *sourceModel);
|
||||
void setMetaDisplay(bool metaDisplay);
|
||||
|
||||
signals:
|
||||
void installDownload(int index);
|
||||
@@ -95,6 +98,7 @@ private slots:
|
||||
|
||||
private:
|
||||
DownloadManager *m_Manager;
|
||||
DownloadList *m_SourceModel;
|
||||
int m_ContextRow;
|
||||
};
|
||||
|
||||
|
||||
+5
-2
@@ -5150,12 +5150,14 @@ void MainWindow::on_actionEndorseMO_triggered()
|
||||
|
||||
void MainWindow::initDownloadView()
|
||||
{
|
||||
DownloadList *sourceModel = new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView);
|
||||
DownloadListSortProxy *sortProxy = new DownloadListSortProxy(m_OrganizerCore.downloadManager(), ui->downloadView);
|
||||
sortProxy->setSourceModel(new DownloadList(m_OrganizerCore.downloadManager(), ui->downloadView));
|
||||
sortProxy->setSourceModel(sourceModel);
|
||||
connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), sortProxy, SLOT(updateFilter(QString)));
|
||||
connect(ui->downloadFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(downloadFilterChanged(QString)));
|
||||
|
||||
ui->downloadView->setModel(sortProxy);
|
||||
ui->downloadView->setSourceModel(sourceModel);
|
||||
ui->downloadView->setModel(sortProxy);
|
||||
ui->downloadView->setManager(m_OrganizerCore.downloadManager());
|
||||
ui->downloadView->setItemDelegate(new DownloadProgressDelegate(m_OrganizerCore.downloadManager(), sortProxy, ui->downloadView));
|
||||
ui->downloadView->setUniformRowHeights(true);
|
||||
@@ -5183,6 +5185,7 @@ void MainWindow::updateDownloadView()
|
||||
ui->downloadView->setProperty("downloadView", "compact");
|
||||
else
|
||||
ui->downloadView->setProperty("downloadView", "standard");
|
||||
ui->downloadView->setMetaDisplay(m_OrganizerCore.settings().metaDownloads());
|
||||
ui->downloadView->style()->unpolish(ui->downloadView);
|
||||
ui->downloadView->style()->polish(ui->downloadView);
|
||||
m_OrganizerCore.downloadManager()->refreshList();
|
||||
|
||||
+251
-251
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user