summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/downloadlistwidget.cpp2
-rw-r--r--src/downloadlistwidget.h1
-rw-r--r--src/downloadlistwidget.ui65
-rw-r--r--src/downloadlistwidgetcompact.cpp7
-rw-r--r--src/downloadlistwidgetcompact.h1
-rw-r--r--src/downloadlistwidgetcompact.ui64
-rw-r--r--src/downloadmanager.cpp54
-rw-r--r--src/downloadmanager.h11
-rw-r--r--src/mainwindow.cpp13
-rw-r--r--src/mainwindow.ui59
-rw-r--r--src/modinfo.cpp2
-rw-r--r--src/modlist.cpp20
-rw-r--r--src/pluginlist.cpp31
-rw-r--r--src/shared/directoryentry.cpp5
14 files changed, 240 insertions, 95 deletions
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<QLabel*>("nameLabel");
+ m_SizeLabel = m_ItemWidget->findChild<QLabel*>("sizeLabel");
m_Progress = m_ItemWidget->findChild<QProgressBar*>("downloadProgress");
m_InstallLabel = m_ItemWidget->findChild<QLabel*>("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 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QLabel" name="nameLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>323</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Placeholder</string>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="nameLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>323</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Placeholder</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="sizeLabel">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>KB</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
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<QLabel*>("nameLabel");
+ m_SizeLabel = m_ItemWidget->findChild<QLabel*>("sizeLabel");
m_Progress = m_ItemWidget->findChild<QProgressBar*>("downloadProgress");
m_DoneLabel = m_ItemWidget->findChild<QLabel*>("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 @@
<item>
<widget class="QLabel" name="nameLabel">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -49,6 +49,40 @@
</widget>
</item>
<item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>(</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sizeLabel">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>MB)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QLabel" name="doneLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@@ -60,24 +94,24 @@
<palette>
<active>
<colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>118</green>
- <blue>0</blue>
- </color>
- </brush>
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>118</green>
+ <blue>0</blue>
+ </color>
+ </brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>118</green>
- <blue>0</blue>
- </color>
- </brush>
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>118</green>
+ <blue>0</blue>
+ </color>
+ </brush>
</colorrole>
</inactive>
<disabled>
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 3a2d26eb..ca6744aa 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -33,6 +33,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <boost/bind.hpp>
#include <regex>
#include <QMessageBox>
+#include <QCoreApplication>
using QtJson::Json;
@@ -96,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;
@@ -162,12 +164,41 @@ bool DownloadManager::downloadsInProgress()
{
for (QVector<DownloadInfo*>::iterator iter = m_ActiveDownloads.begin(); iter != m_ActiveDownloads.end(); ++iter) {
if ((*iter)->m_State < STATE_READY) {
-// return true;
+ return true;
}
}
return false;
}
+void DownloadManager::pauseAll()
+{
+ // first loop: pause all downloads
+ for (int i = 0; i < m_ActiveDownloads.count(); ++i) {
+ if (m_ActiveDownloads[i]->m_State < STATE_READY) {
+ pauseDownload(i);
+ }
+ }
+
+ ::Sleep(100);
+
+ bool done = false;
+ // further loops: busy waiting for all downloads to complete. This could be neater...
+ while (!done) {
+ QCoreApplication::processEvents();
+ done = true;
+ foreach (DownloadInfo *info, m_ActiveDownloads) {
+ if ((info->m_State < STATE_CANCELED) ||
+ (info->m_State != STATE_FETCHINGFILEINFO) || (info->m_State != STATE_FETCHINGMODINFO)) {
+ done = false;
+ break;
+ }
+ }
+ if (!done) {
+ ::Sleep(100);
+ }
+ }
+}
+
void DownloadManager::setOutputDirectory(const QString &outputDirectory)
{
@@ -456,7 +487,6 @@ void DownloadManager::pauseDownload(int index)
}
}
-
void DownloadManager::resumeDownload(int index)
{
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
@@ -464,6 +494,17 @@ void DownloadManager::resumeDownload(int index)
return;
}
DownloadInfo *info = m_ActiveDownloads[index];
+ info->m_Tries = AUTOMATIC_RETRIES;
+ resumeDownloadInt(index);
+}
+
+void DownloadManager::resumeDownloadInt(int index)
+{
+ if ((index < 0) || (index >= m_ActiveDownloads.size())) {
+ reportError(tr("invalid index %1").arg(index));
+ return;
+ }
+ DownloadInfo *info = m_ActiveDownloads[index];
if (info->isPausedState()) {
if (info->m_State == STATE_ERROR) {
info->m_CurrentUrl = (info->m_CurrentUrl + 1) % info->m_Urls.count();
@@ -556,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 623dda7a..b4cb2786 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -207,6 +207,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
*
* @param index index of the file to look up
@@ -288,6 +296,7 @@ public:
*/
int indexByName(const QString &fileName) const;
+ void pauseAll();
signals:
void aboutToUpdate();
@@ -357,10 +366,10 @@ private slots:
private:
void createMetaFile(DownloadInfo *info);
-// QString getOutputPath(const QUrl &url, const QString &fileName) const;
QString getDownloadFileName(const QString &baseName) const;
void startDownload(QNetworkReply *reply, DownloadInfo *newDownload, bool resume);
+ void resumeDownloadInt(int index);
/**
* @brief start a download from a url
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a8f69090..4c9d388a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -712,12 +712,15 @@ void MainWindow::showEvent(QShowEvent *event)
void MainWindow::closeEvent(QCloseEvent* event)
{
- if (m_DownloadManager.downloadsInProgress() &&
- QMessageBox::question(this, tr("Downloads in progress"),
+ if (m_DownloadManager.downloadsInProgress()) {
+ if (QMessageBox::question(this, tr("Downloads in progress"),
tr("There are still downloads in progress, do you really want to quit?"),
QMessageBox::Yes | QMessageBox::Cancel) == QMessageBox::Cancel) {
- event->ignore();
- return;
+ event->ignore();
+ return;
+ } else {
+ m_DownloadManager.pauseAll();
+ }
}
setCursor(Qt::WaitCursor);
@@ -942,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 @@
<property name="spacing">
<number>4</number>
</property>
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="topMargin">
- <number>6</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>6</number>
</property>
<item>
@@ -320,7 +311,7 @@ p, li { white-space: pre-wrap; }
<bool>false</bool>
</property>
<attribute name="headerDefaultSectionSize">
- <number>10</number>
+ <number>20</number>
</attribute>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
@@ -730,16 +721,7 @@ p, li { white-space: pre-wrap; }
<string notr="true">Archives</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="topMargin">
- <number>6</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>6</number>
</property>
<item>
@@ -818,16 +800,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye
<string>Data</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="topMargin">
- <number>6</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>6</number>
</property>
<item>
@@ -861,7 +834,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye
<bool>true</bool>
</property>
<attribute name="headerDefaultSectionSize">
- <number>200</number>
+ <number>400</number>
</attribute>
<column>
<property name="text">
@@ -897,16 +870,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye
<string>Saves</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="topMargin">
- <number>6</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>6</number>
</property>
<item>
@@ -935,16 +899,7 @@ p, li { white-space: pre-wrap; }
<string>Downloads</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
- <property name="leftMargin">
- <number>2</number>
- </property>
- <property name="topMargin">
- <number>2</number>
- </property>
- <property name="rightMargin">
- <number>2</number>
- </property>
- <property name="bottomMargin">
+ <property name="margin">
<number>2</number>
</property>
<item>
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<QString> 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<const QSortFilterProxyModel*>(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<QAbstractItemView*>(obj);
+
+ if (itemView == NULL) {
+ return QObject::eventFilter(obj, event);
+ }
+
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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<const QSortFilterProxyModel*>(selectionModel->model());
@@ -852,6 +858,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<const QSortFilterProxyModel*>(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/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 7897b6aa..802c3696 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -54,6 +54,11 @@ public:
LEAK_TRACE;
}
+ ~OriginConnection()
+ {
+ LEAK_UNTRACE;
+ }
+
FilesOrigin& createOrigin(const std::wstring &originName, const std::wstring &directory, int priority,
boost::shared_ptr<FileRegister> fileRegister, boost::shared_ptr<OriginConnection> originConnection) {
int newID = createID();