mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c57b172204 | ||
|
|
dfca8be71b | ||
|
|
08037bf876 | ||
|
|
500ab7f706 | ||
|
|
08309b71ba | ||
|
|
dce78b62b8 | ||
|
|
af6e1c3ab4 | ||
|
|
50325c8fc2 | ||
|
|
7a382eab75 | ||
|
|
8e6868bf88 | ||
|
|
a891146446 | ||
|
|
72f14df8a7 | ||
|
|
0fa7155eb8 | ||
|
|
c6c61ce792 | ||
|
|
ef801879ab | ||
|
|
1e6c5f7c25 | ||
|
|
49e1dd23b6 | ||
|
|
9c31cfa915 | ||
|
|
91dd38cb29 | ||
|
|
bf0db9c218 | ||
|
|
8fcf21e771 | ||
|
|
b46b2fe6f2 | ||
|
|
e91eebefbe | ||
|
|
2e605b275b | ||
|
|
87f4e2df26 | ||
|
|
9272013103 |
@@ -12,7 +12,9 @@ SUBDIRS = bsatk \
|
||||
plugins \
|
||||
proxydll \
|
||||
nxmhandler \
|
||||
BossDummy
|
||||
BossDummy \
|
||||
pythonRunner \
|
||||
esptk
|
||||
|
||||
hookdll.depends = shared
|
||||
organizer.depends = shared, uibase, plugins
|
||||
|
||||
@@ -65,11 +65,6 @@ ActivateModsDialog::~ActivateModsDialog()
|
||||
}
|
||||
|
||||
|
||||
void ActivateModsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::set<QString> ActivateModsDialog::getModsToActivate()
|
||||
{
|
||||
std::set<QString> result;
|
||||
|
||||
@@ -62,7 +62,6 @@ public:
|
||||
std::set<QString> getESPsToActivate();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::ActivateModsDialog *ui;
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "archivetree.h"
|
||||
#include <QDragMoveEvent>
|
||||
|
||||
ArchiveTree::ArchiveTree(QWidget *parent) :
|
||||
QTreeWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool ArchiveTree::testMovePossible(QTreeWidgetItem *source, QTreeWidgetItem *target)
|
||||
{
|
||||
if ((target == NULL) ||
|
||||
(source == NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((source == target) ||
|
||||
(source->parent() == target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ArchiveTree::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
QTreeWidgetItem *source = this->currentItem();
|
||||
if ((source == NULL) || (source->parent() == NULL)) {
|
||||
// can't change top level
|
||||
event->ignore();
|
||||
return;
|
||||
} else {
|
||||
QTreeWidget::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ArchiveTree::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
if (!testMovePossible(this->currentItem(), itemAt(event->pos()))) {
|
||||
event->ignore();
|
||||
} else {
|
||||
QTreeWidget::dragMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ArchiveTree::dropEvent(QDropEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
QTreeWidgetItem *target = itemAt(event->pos());
|
||||
|
||||
QList<QTreeWidgetItem*> sourceItems = this->selectedItems();
|
||||
for (QList<QTreeWidgetItem*>::iterator iter = sourceItems.begin();
|
||||
iter != sourceItems.end(); ++iter) {
|
||||
QTreeWidgetItem *source = *iter;
|
||||
if ((source->parent() != NULL) &&
|
||||
testMovePossible(source, target)) {
|
||||
source->parent()->removeChild(source);
|
||||
if (target->data(0, Qt::UserRole).toInt() != 0) {
|
||||
// target is a file
|
||||
if (target->parent() == NULL) {
|
||||
// this should really not happen, how should a
|
||||
// file get to the top level?
|
||||
return;
|
||||
}
|
||||
int index = target->parent()->indexOfChild(target);
|
||||
target->parent()->insertChild(index, source);
|
||||
emit changed();
|
||||
} else {
|
||||
// target is a directory
|
||||
target->insertChild(target->childCount(), source);
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ARCHIVETREE_H
|
||||
#define ARCHIVETREE_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
/**
|
||||
* @brief QT tree widget used to display the content of an archive in the manual installation dialog
|
||||
**/
|
||||
class ArchiveTree : public QTreeWidget
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit ArchiveTree(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void changed();
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dragMoveEvent(QDragMoveEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
bool testMovePossible(QTreeWidgetItem *source, QTreeWidgetItem *target);
|
||||
|
||||
};
|
||||
|
||||
#endif // ARCHIVETREE_H
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
static const int CATEGORY_SPECIAL_UPDATEAVAILABLE = 10002;
|
||||
static const int CATEGORY_SPECIAL_NOCATEGORY = 10003;
|
||||
static const int CATEGORY_SPECIAL_CONFLICT = 10004;
|
||||
static const int CATEGORY_SPECIAL_NOTENDORSED = 10005;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int
|
||||
if ((role == Qt::DisplayRole) &&
|
||||
(orientation == Qt::Horizontal)) {
|
||||
switch (section) {
|
||||
case 0: return tr("Name");
|
||||
case 1: return tr("Filetime");
|
||||
case COL_NAME: return tr("Name");
|
||||
case COL_FILETIME: return tr("Filetime");
|
||||
default: return tr("Done");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -34,6 +34,14 @@ class DownloadList : public QAbstractTableModel
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum EColumn {
|
||||
COL_NAME = 0,
|
||||
COL_FILETIME,
|
||||
COL_STATUS
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "downloadlistsortproxy.h"
|
||||
#include "downloadlist.h"
|
||||
|
||||
DownloadListSortProxy::DownloadListSortProxy(const DownloadManager *manager, QObject *parent)
|
||||
: QSortFilterProxyModel(parent), m_Manager(manager), m_CurrentFilter()
|
||||
@@ -30,18 +31,21 @@ void DownloadListSortProxy::updateFilter(const QString &filter)
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
bool DownloadListSortProxy::lessThan(const QModelIndex &left,
|
||||
const QModelIndex &right) const
|
||||
{
|
||||
int leftIndex = sourceModel()->data(left).toInt();
|
||||
int rightIndex = sourceModel()->data(right).toInt();
|
||||
|
||||
if (left.column() == 0) {
|
||||
if (left.column() == DownloadList::COL_NAME) {
|
||||
return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0;
|
||||
} else if (left.column() == 1) {
|
||||
return leftIndex < rightIndex;
|
||||
} else {
|
||||
} else if (left.column() == DownloadList::COL_FILETIME) {
|
||||
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 {
|
||||
return leftIndex < rightIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -148,7 +150,7 @@ void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionView
|
||||
}
|
||||
m_InstallLabel->setPalette(labelPalette);
|
||||
if (m_Manager->isInfoIncomplete(downloadIndex)) {
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/resources/dialog-warning_16.png\" /> " + m_NameLabel->text());
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/warning_16\" /> " + m_NameLabel->text());
|
||||
}
|
||||
} else {
|
||||
m_InstallLabel->setVisible(false);
|
||||
|
||||
@@ -101,6 +101,7 @@ private:
|
||||
DownloadManager *m_Manager;
|
||||
|
||||
QLabel *m_NameLabel;
|
||||
QLabel *m_SizeLabel;
|
||||
QProgressBar *m_Progress;
|
||||
QLabel *m_InstallLabel;
|
||||
int m_ContextRow;
|
||||
|
||||
+48
-17
@@ -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">
|
||||
|
||||
@@ -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 ((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);
|
||||
@@ -130,7 +137,7 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt
|
||||
m_DoneLabel->setForegroundRole(QPalette::WindowText);
|
||||
}
|
||||
if (m_Manager->isInfoIncomplete(downloadIndex)) {
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/resources/dialog-warning_16.png\"/> " + m_NameLabel->text());
|
||||
m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text());
|
||||
}
|
||||
} else {
|
||||
m_DoneLabel->setVisible(false);
|
||||
|
||||
@@ -100,6 +100,7 @@ private:
|
||||
DownloadManager *m_Manager;
|
||||
|
||||
QLabel *m_NameLabel;
|
||||
QLabel *m_SizeLabel;
|
||||
QProgressBar *m_Progress;
|
||||
QLabel *m_DoneLabel;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>315</width>
|
||||
<height>22</height>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
@@ -23,14 +23,23 @@
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
@@ -48,6 +57,19 @@
|
||||
</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">
|
||||
@@ -60,24 +82,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>
|
||||
|
||||
+88
-2
@@ -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;
|
||||
@@ -52,6 +53,7 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createNew(const Ne
|
||||
DownloadInfo *info = new DownloadInfo;
|
||||
info->m_DownloadID = s_NextDownloadID++;
|
||||
info->m_StartTime.start();
|
||||
info->m_PreResumeSize = 0LL;
|
||||
info->m_Progress = 0;
|
||||
info->m_ResumePos = 0;
|
||||
info->m_ModID = modID;
|
||||
@@ -96,6 +98,8 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con
|
||||
|
||||
info->m_DownloadID = s_NextDownloadID++;
|
||||
info->m_Output.setFileName(filePath);
|
||||
info->m_TotalSize = QFileInfo(filePath).size();
|
||||
info->m_PreResumeSize = info->m_TotalSize;
|
||||
info->m_ModID = metaFile.value("modID", 0).toInt();
|
||||
info->m_FileID = metaFile.value("fileID", 0).toInt();
|
||||
info->m_CurrentUrl = 0;
|
||||
@@ -162,12 +166,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)
|
||||
{
|
||||
@@ -252,6 +285,7 @@ bool DownloadManager::addDownload(const QStringList &URLs,
|
||||
return addDownload(m_NexusInterface->getAccessManager()->get(request), URLs, fileName, modID, fileID, nexusInfo);
|
||||
}
|
||||
|
||||
|
||||
bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs, const QString &fileName,
|
||||
int modID, int fileID, const NexusInfo &nexusInfo)
|
||||
{
|
||||
@@ -300,6 +334,8 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl
|
||||
mode |= QIODevice::Append;
|
||||
}
|
||||
|
||||
newDownload->m_StartTime.start();
|
||||
|
||||
if (!newDownload->m_Output.open(mode)) {
|
||||
reportError(tr("failed to download %1: could not open output file: %2")
|
||||
.arg(reply->url().toString()).arg(newDownload->m_Output.fileName()));
|
||||
@@ -312,6 +348,8 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl
|
||||
connect(newDownload->m_Reply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
|
||||
|
||||
if (!resume) {
|
||||
newDownload->m_PreResumeSize = newDownload->m_Output.size();
|
||||
|
||||
emit aboutToUpdate();
|
||||
|
||||
m_ActiveDownloads.append(newDownload);
|
||||
@@ -456,8 +494,18 @@ void DownloadManager::pauseDownload(int index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DownloadManager::resumeDownload(int index)
|
||||
{
|
||||
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
|
||||
reportError(tr("invalid index %1").arg(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));
|
||||
@@ -556,6 +604,29 @@ QString DownloadManager::getFileName(int index) const
|
||||
return m_ActiveDownloads.at(index)->m_FileName;
|
||||
}
|
||||
|
||||
QDateTime DownloadManager::getFileTime(int index) const
|
||||
{
|
||||
if ((index < 0) || (index >= m_ActiveDownloads.size())) {
|
||||
throw MyException(tr("invalid index"));
|
||||
}
|
||||
|
||||
DownloadInfo *info = m_ActiveDownloads.at(index);
|
||||
if (!info->m_Created.isValid()) {
|
||||
info->m_Created = QFileInfo(info->m_Output).created();
|
||||
}
|
||||
|
||||
return info->m_Created;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@@ -984,6 +1055,8 @@ void DownloadManager::nxmDownloadURLsAvailable(int modID, int fileID, QVariant u
|
||||
|
||||
std::sort(resultList.begin(), resultList.end(), boost::bind(&DownloadManager::ServerByPreference, m_PreferredServers, _1, _2));
|
||||
|
||||
info.m_DownloadMap = resultList;
|
||||
|
||||
QStringList URLs;
|
||||
|
||||
foreach (const QVariant &server, resultList) {
|
||||
@@ -1071,6 +1144,19 @@ void DownloadManager::downloadFinished()
|
||||
createMetaFile(info);
|
||||
emit update(index);
|
||||
} else {
|
||||
|
||||
QString url = info->m_Urls[info->m_CurrentUrl];
|
||||
foreach (const QVariant &server, info->m_NexusInfo.m_DownloadMap) {
|
||||
QVariantMap serverMap = server.toMap();
|
||||
if (serverMap["URI"].toString() == url) {
|
||||
int deltaTime = info->m_StartTime.secsTo(QTime::currentTime());
|
||||
if (deltaTime > 5) {
|
||||
emit downloadSpeed(serverMap["Name"].toString(), (info->m_TotalSize - info->m_PreResumeSize) / deltaTime);
|
||||
} // no division by zero please! Also, if the download is shorter than a few seconds, the result is way to inprecise
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setState(info, STATE_FETCHINGMODINFO); // need to set this state before changing the file name, otherwise .unfinished is appended
|
||||
|
||||
QString newName = getFileNameFromNetworkReply(reply);
|
||||
|
||||
+28
-1
@@ -45,6 +45,7 @@ struct NexusInfo {
|
||||
QString m_Version;
|
||||
QString m_NewestVersion;
|
||||
QString m_FileName;
|
||||
QVariantList m_DownloadMap;
|
||||
bool m_Set;
|
||||
};
|
||||
Q_DECLARE_METATYPE(NexusInfo)
|
||||
@@ -82,6 +83,7 @@ private:
|
||||
QFile m_Output;
|
||||
QNetworkReply *m_Reply;
|
||||
QTime m_StartTime;
|
||||
qint64 m_PreResumeSize;
|
||||
int m_Progress;
|
||||
int m_ModID;
|
||||
int m_FileID;
|
||||
@@ -90,6 +92,9 @@ private:
|
||||
QStringList m_Urls;
|
||||
qint64 m_ResumePos;
|
||||
qint64 m_TotalSize;
|
||||
|
||||
QDateTime m_Created; // used as a cache in DownloadManager::getFileTime, may not be valid elsewhere
|
||||
|
||||
int m_Tries;
|
||||
bool m_ReQueried;
|
||||
|
||||
@@ -206,6 +211,21 @@ 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 creation time of the download specified by index
|
||||
* @param index index of the file to look up
|
||||
* @return size of the file (total size during download)
|
||||
*/
|
||||
QDateTime getFileTime(int index) const;
|
||||
|
||||
/**
|
||||
* @brief retrieve the current progress of the download specified by index
|
||||
*
|
||||
@@ -288,6 +308,8 @@ public:
|
||||
*/
|
||||
int indexByName(const QString &fileName) const;
|
||||
|
||||
void pauseAll();
|
||||
|
||||
signals:
|
||||
|
||||
void aboutToUpdate();
|
||||
@@ -313,6 +335,11 @@ signals:
|
||||
*/
|
||||
void stateChanged(int row, DownloadManager::DownloadState state);
|
||||
|
||||
/**
|
||||
* @brief emitted whenever a download completes successfully, reporting the download speed for the server used
|
||||
*/
|
||||
void downloadSpeed(const QString &serverName, int bytesPerSecond);
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@@ -357,10 +384,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
|
||||
|
||||
@@ -172,16 +172,6 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa
|
||||
}
|
||||
}
|
||||
|
||||
/*void ExecutablesList::remove(const QString &executableName)
|
||||
{
|
||||
for (std::vector<Executable>::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) {
|
||||
if (iter->m_Custom && (iter->m_BinaryInfo.absoluteFilePath() == executableName)) {
|
||||
m_Executables.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void ExecutablesList::remove(const QString &title)
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "finddialog.h"
|
||||
#include "ui_finddialog.h"
|
||||
|
||||
FindDialog::FindDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FindDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
FindDialog::~FindDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FindDialog::on_nextBtn_clicked()
|
||||
{
|
||||
emit findNext();
|
||||
}
|
||||
|
||||
void FindDialog::on_patternEdit_textChanged(const QString &pattern)
|
||||
{
|
||||
emit patternChanged(pattern);
|
||||
}
|
||||
|
||||
void FindDialog::on_closeBtn_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Sebastian Herbord. All rights reserved.
|
||||
|
||||
This file is part of Mod Organizer.
|
||||
|
||||
Mod Organizer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mod Organizer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FINDDIALOG_H
|
||||
#define FINDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class FindDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find dialog used in the TextView dialog
|
||||
**/
|
||||
class FindDialog : public QDialog
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
*
|
||||
* @param parent parent widget
|
||||
**/
|
||||
explicit FindDialog(QWidget *parent = 0);
|
||||
|
||||
~FindDialog();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief emitted when the user wants to jump to the next location matching the pattern
|
||||
**/
|
||||
void findNext();
|
||||
|
||||
/**
|
||||
* @brief emitted when the user changes the pattern to search for
|
||||
*
|
||||
* @param pattern the new search pattern
|
||||
**/
|
||||
void patternChanged(const QString &pattern);
|
||||
|
||||
private slots:
|
||||
void on_nextBtn_clicked();
|
||||
|
||||
void on_patternEdit_textChanged(const QString &arg1);
|
||||
|
||||
void on_closeBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::FindDialog *ui;
|
||||
};
|
||||
|
||||
#endif // FINDDIALOG_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user