From e91eebefbea450a447b44a81dcabcc6ac8000a48 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 24 Aug 2013 22:50:00 +0200 Subject: - download size is now displayed - multiple esps/mods can now be enabled/disabled at once using space - bugfix: fomod installer didn't compile because of changes to condition checking - bugfix: broken inverse virtual name resolution in case of non-default mod directory --- src/downloadlistwidget.cpp | 2 ++ src/downloadlistwidget.h | 1 + src/downloadlistwidget.ui | 65 +++++++++++++++++++++++++++++---------- src/downloadlistwidgetcompact.cpp | 7 +++++ src/downloadlistwidgetcompact.h | 1 + src/downloadlistwidgetcompact.ui | 64 +++++++++++++++++++++++++++++--------- src/downloadmanager.cpp | 10 ++++++ src/downloadmanager.h | 8 +++++ src/mainwindow.cpp | 2 +- src/mainwindow.ui | 59 +++++------------------------------ src/modinfo.cpp | 2 +- src/modlist.cpp | 20 ++++++++++++ src/pluginlist.cpp | 31 +++++++++++++++++-- 13 files changed, 184 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index 743fc159..3a7dac66 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -44,6 +44,7 @@ DownloadListWidgetDelegate::DownloadListWidgetDelegate(DownloadManager *manager, : QItemDelegate(parent), m_Manager(manager), m_ItemWidget(new DownloadListWidget), m_ContextRow(0), m_View(view) { m_NameLabel = m_ItemWidget->findChild("nameLabel"); + m_SizeLabel = m_ItemWidget->findChild("sizeLabel"); m_Progress = m_ItemWidget->findChild("downloadProgress"); m_InstallLabel = m_ItemWidget->findChild("installLabel"); @@ -100,6 +101,7 @@ void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionView name.append("..."); } m_NameLabel->setText(name); + m_SizeLabel->setText(QString::number(m_Manager->getFileSize(downloadIndex) / 1024)); DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) { QPalette labelPalette; diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h index 5379356f..c80200fb 100644 --- a/src/downloadlistwidget.h +++ b/src/downloadlistwidget.h @@ -101,6 +101,7 @@ private: DownloadManager *m_Manager; QLabel *m_NameLabel; + QLabel *m_SizeLabel; QProgressBar *m_Progress; QLabel *m_InstallLabel; int m_ContextRow; diff --git a/src/downloadlistwidget.ui b/src/downloadlistwidget.ui index 5f169215..01b2ee07 100644 --- a/src/downloadlistwidget.ui +++ b/src/downloadlistwidget.ui @@ -42,23 +42,54 @@ - - - - 1 - 0 - - - - - 323 - 16777215 - - - - Placeholder - - + + + + + + 1 + 0 + + + + + 323 + 16777215 + + + + Placeholder + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + + + + + KB + + + + diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp index 39e8010b..f3e395da 100644 --- a/src/downloadlistwidgetcompact.cpp +++ b/src/downloadlistwidgetcompact.cpp @@ -44,6 +44,7 @@ DownloadListWidgetCompactDelegate::DownloadListWidgetCompactDelegate(DownloadMan : QItemDelegate(parent), m_Manager(manager), m_ItemWidget(new DownloadListWidgetCompact), m_View(view) { m_NameLabel = m_ItemWidget->findChild("nameLabel"); + m_SizeLabel = m_ItemWidget->findChild("sizeLabel"); m_Progress = m_ItemWidget->findChild("downloadProgress"); m_DoneLabel = m_ItemWidget->findChild("doneLabel"); @@ -106,7 +107,13 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt name.append("..."); } m_NameLabel->setText(name); + DownloadManager::DownloadState state = m_Manager->getState(downloadIndex); + + if (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); diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h index 3ac36e8d..78f51840 100644 --- a/src/downloadlistwidgetcompact.h +++ b/src/downloadlistwidgetcompact.h @@ -100,6 +100,7 @@ private: DownloadManager *m_Manager; QLabel *m_NameLabel; + QLabel *m_SizeLabel; QProgressBar *m_Progress; QLabel *m_DoneLabel; diff --git a/src/downloadlistwidgetcompact.ui b/src/downloadlistwidgetcompact.ui index b905706c..bc960c8e 100644 --- a/src/downloadlistwidgetcompact.ui +++ b/src/downloadlistwidgetcompact.ui @@ -29,7 +29,7 @@ - + 1 0 @@ -48,6 +48,40 @@ + + + + ( + + + + + + + 0 + + + + + + + MB) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -60,24 +94,24 @@ - - - 0 - 118 - 0 - - + + + 0 + 118 + 0 + + - - - 0 - 118 - 0 - - + + + 0 + 118 + 0 + + diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 07048ada..ca6744aa 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -97,6 +97,7 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con info->m_DownloadID = s_NextDownloadID++; info->m_Output.setFileName(filePath); + info->m_TotalSize = QFileInfo(filePath).size(); info->m_ModID = metaFile.value("modID", 0).toInt(); info->m_FileID = metaFile.value("fileID", 0).toInt(); info->m_CurrentUrl = 0; @@ -596,6 +597,15 @@ QString DownloadManager::getFileName(int index) const return m_ActiveDownloads.at(index)->m_FileName; } +qint64 DownloadManager::getFileSize(int index) const +{ + if ((index < 0) || (index >= m_ActiveDownloads.size())) { + throw MyException(tr("invalid index")); + } + + return m_ActiveDownloads.at(index)->m_TotalSize; +} + int DownloadManager::getProgress(int index) const { diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 4d493085..b4cb2786 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -206,6 +206,14 @@ public: **/ QString getFileName(int index) const; + /** + * @brief retrieve the file size of the download specified by index + * + * @param index index of the file to look up + * @return size of the file (total size during download) + */ + qint64 getFileSize(int index) const; + /** * @brief retrieve the current progress of the download specified by index * diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c4842738..4c9d388a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -945,7 +945,7 @@ bool MainWindow::registerPlugin(QObject *plugin) QObject *proxiedPlugin = proxy->instantiate(pluginName); if (proxiedPlugin != NULL) { if (registerPlugin(proxiedPlugin)) { - qDebug("loaded plugin \"%s\"", pluginName.toUtf8().constData()); + qDebug("loaded plugin \"%s\"", QDir::toNativeSeparators(pluginName).toUtf8().constData()); } else { qWarning("plugin \"%s\" failed to load", pluginName.toUtf8().constData()); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 14f00336..eb587911 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -31,16 +31,7 @@ 4 - - 6 - - - 6 - - - 6 - - + 6 @@ -320,7 +311,7 @@ p, li { white-space: pre-wrap; } false - 10 + 20 true @@ -730,16 +721,7 @@ p, li { white-space: pre-wrap; } Archives - - 6 - - - 6 - - - 6 - - + 6 @@ -818,16 +800,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye Data - - 6 - - - 6 - - - 6 - - + 6 @@ -861,7 +834,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye true - 200 + 400 @@ -897,16 +870,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye Saves - - 6 - - - 6 - - - 6 - - + 6 @@ -935,16 +899,7 @@ p, li { white-space: pre-wrap; } Downloads - - 2 - - - 2 - - - 2 - - + 2 diff --git a/src/modinfo.cpp b/src/modinfo.cpp index f6043d97..5cae62be 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -759,7 +759,7 @@ std::vector ModInfoRegular::getIniTweaks() const if (numTweaks != 0) { qDebug("%d active ini tweaks in %s", - numTweaks, metaFileName.toUtf8().constData()); + numTweaks, QDir::toNativeSeparators(metaFileName).toUtf8().constData()); } for (int i = 0; i < numTweaks; ++i) { diff --git a/src/modlist.cpp b/src/modlist.cpp index 9c537300..a08162e7 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -801,6 +801,26 @@ bool ModList::eventFilter(QObject *obj, QEvent *event) removeRow(rows[0].data(Qt::UserRole + 1).toInt(), QModelIndex()); } return true; + } else if (keyEvent->key() == Qt::Key_Space) { + QItemSelectionModel *selectionModel = itemView->selectionModel(); + const QSortFilterProxyModel *proxyModel = qobject_cast(selectionModel->model()); + + QModelIndex minRow, maxRow; + foreach (QModelIndex idx, selectionModel->selectedRows()) { + if (proxyModel != NULL) { + idx = proxyModel->mapToSource(idx); + } + if (!minRow.isValid() || (idx.row() < minRow.row())) { + minRow = idx; + } + if (!maxRow.isValid() || (idx.row() > maxRow.row())) { + maxRow = idx; + } + int oldState = idx.data(Qt::CheckStateRole).toInt(); + setData(idx, oldState == Qt::Unchecked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); + } + emit dataChanged(minRow, maxRow); + return true; } } return QObject::eventFilter(obj, event); diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 61069c2f..dc2410ee 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -823,9 +823,15 @@ bool PluginList::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QAbstractItemView *itemView = qobject_cast(obj); + + if (itemView == NULL) { + return QObject::eventFilter(obj, event); + } + QKeyEvent *keyEvent = static_cast(event); - if ((itemView != NULL) && - (keyEvent->modifiers() == Qt::ControlModifier) && + + // ctrl+up and ctrl+down -> increase or decrease priority of selected plugins + if ((keyEvent->modifiers() == Qt::ControlModifier) && ((keyEvent->key() == Qt::Key_Up) || (keyEvent->key() == Qt::Key_Down))) { QItemSelectionModel *selectionModel = itemView->selectionModel(); const QSortFilterProxyModel *proxyModel = qobject_cast(selectionModel->model()); @@ -851,6 +857,27 @@ bool PluginList::eventFilter(QObject *obj, QEvent *event) } } refreshLoadOrder(); + return true; + } else if (keyEvent->key() == Qt::Key_Space) { + QItemSelectionModel *selectionModel = itemView->selectionModel(); + const QSortFilterProxyModel *proxyModel = qobject_cast(selectionModel->model()); + + QModelIndex minRow, maxRow; + foreach (QModelIndex idx, selectionModel->selectedRows()) { + if (proxyModel != NULL) { + idx = proxyModel->mapToSource(idx); + } + if (!minRow.isValid() || (idx.row() < minRow.row())) { + minRow = idx; + } + if (!maxRow.isValid() || (idx.row() > maxRow.row())) { + maxRow = idx; + } + int oldState = idx.data(Qt::CheckStateRole).toInt(); + setData(idx, oldState == Qt::Unchecked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); + } + emit dataChanged(minRow, maxRow); + return true; } } -- cgit v1.3.1