summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-01-04 16:05:39 +0100
committerTannin <devnull@localhost>2014-01-04 16:05:39 +0100
commit0ea7d99b9f2a2119abce2454ae4ed13fcf065895 (patch)
tree9d0262f7f6d06196c22873de6d58751ab6b4a130 /src
parente45b747c82832d227b9ee3ae9dcb214c4c7f67b5 (diff)
parent6cffbd4f274106ac09d3729e104bf526141d7d79 (diff)
Merge
Diffstat (limited to 'src')
-rw-r--r--src/downloadlist.cpp19
-rw-r--r--src/downloadlistsortproxy.cpp22
-rw-r--r--src/downloadlistwidget.cpp179
-rw-r--r--src/downloadlistwidget.h3
-rw-r--r--src/downloadlistwidgetcompact.cpp148
-rw-r--r--src/downloadlistwidgetcompact.h2
-rw-r--r--src/downloadmanager.cpp49
-rw-r--r--src/downloadmanager.h25
-rw-r--r--src/logbuffer.cpp15
-rw-r--r--src/logbuffer.h2
-rw-r--r--src/mainwindow.cpp12
-rw-r--r--src/messagedialog.cpp1
-rw-r--r--src/mo_icon.icobin298605 -> 96367 bytes
-rw-r--r--src/settings.cpp9
-rw-r--r--src/settings.h7
-rw-r--r--src/settingsdialog.cpp6
-rw-r--r--src/settingsdialog.h2
-rw-r--r--src/settingsdialog.ui44
-rw-r--r--src/splash.pngbin260807 -> 230138 bytes
19 files changed, 368 insertions, 177 deletions
diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp
index fe021a27..d280cdb6 100644
--- a/src/downloadlist.cpp
+++ b/src/downloadlist.cpp
@@ -34,9 +34,10 @@ DownloadList::DownloadList(DownloadManager *manager, QObject *parent)
int DownloadList::rowCount(const QModelIndex&) const
{
- return m_Manager->numTotalDownloads();
+ return m_Manager->numTotalDownloads() + m_Manager->numPendingDownloads();
}
+
int DownloadList::columnCount(const QModelIndex&) const
{
return 3;
@@ -75,14 +76,18 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) {
return index.row();
} else if (role == Qt::ToolTipRole) {
- QString text = m_Manager->getFileName(index.row()) + "\n";
- if (m_Manager->isInfoIncomplete(index.row())) {
- text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve.");
+ if (index.row() < m_Manager->numTotalDownloads()) {
+ QString text = m_Manager->getFileName(index.row()) + "\n";
+ if (m_Manager->isInfoIncomplete(index.row())) {
+ text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve.");
+ } else {
+ NexusInfo info = m_Manager->getNexusInfo(index.row());
+ text += QString("%1 (ID %2) %3").arg(info.m_ModName).arg(m_Manager->getModID(index.row())).arg(info.m_Version);
+ }
+ return text;
} else {
- NexusInfo info = m_Manager->getNexusInfo(index.row());
- text += QString("%1 (ID %2) %3").arg(info.m_ModName).arg(m_Manager->getModID(index.row())).arg(info.m_Version);
+ return tr("pending download");
}
- return text;
} else {
return QVariant();
}
diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp
index fc743574..7abe8579 100644
--- a/src/downloadlistsortproxy.cpp
+++ b/src/downloadlistsortproxy.cpp
@@ -37,13 +37,16 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left,
{
int leftIndex = sourceModel()->data(left).toInt();
int rightIndex = sourceModel()->data(right).toInt();
-
- if (left.column() == DownloadList::COL_NAME) {
- return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0;
- } 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);
+ if (leftIndex < m_Manager->numTotalDownloads()) {
+ if (left.column() == DownloadList::COL_NAME) {
+ return m_Manager->getFileName(leftIndex).compare(m_Manager->getFileName(rightIndex), Qt::CaseInsensitive) < 0;
+ } 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;
+ }
} else {
return leftIndex < rightIndex;
}
@@ -54,6 +57,9 @@ bool DownloadListSortProxy::filterAcceptsRow(int source_row, const QModelIndex&)
{
if (m_CurrentFilter.length() == 0) {
return true;
+ } else if (source_row < m_Manager->numTotalDownloads()) {
+ return m_Manager->getFileName(source_row).contains(m_CurrentFilter, Qt::CaseInsensitive);
+ } else {
+ return false;
}
- return m_Manager->getFileName(source_row).contains(m_CurrentFilter, Qt::CaseInsensitive);
}
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp
index b4d40799..68dd2adf 100644
--- a/src/downloadlistwidget.cpp
+++ b/src/downloadlistwidget.cpp
@@ -82,80 +82,100 @@ void DownloadListWidgetDelegate::drawCache(QPainter *painter, const QStyleOption
}
-void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+void DownloadListWidgetDelegate::paintPendingDownload(int downloadIndex) const
{
- try {
- auto iter = m_Cache.find(index.row());
- if (iter != m_Cache.end()) {
- drawCache(painter, option, *iter);
- return;
- }
-
- m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2), option.rect.height()));
+ std::pair<int, int> nexusids = m_Manager->getPendingDownload(downloadIndex);
+ m_NameLabel->setText(tr("< mod %1 file %2 >").arg(nexusids.first).arg(nexusids.second));
+ m_SizeLabel->setText("???");
+ m_InstallLabel->setVisible(true);
+ m_InstallLabel->setText(tr("Pending"));
+ m_Progress->setVisible(false);
+}
- int downloadIndex = index.data().toInt();
- QString name = m_Manager->getFileName(downloadIndex);
- if (name.length() > 53) {
- name.truncate(50);
- 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;
- m_InstallLabel->setVisible(true);
- m_Progress->setVisible(false);
+void DownloadListWidgetDelegate::paintRegularDownload(int downloadIndex) const
+{
+ QString name = m_Manager->getFileName(downloadIndex);
+ if (name.length() > 53) {
+ name.truncate(50);
+ 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;
+ m_InstallLabel->setVisible(true);
+ m_Progress->setVisible(false);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0));
#else
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0, QApplication::UnicodeUTF8));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Paused - Double Click to resume", 0, QApplication::UnicodeUTF8));
#endif
- labelPalette.setColor(QPalette::WindowText, Qt::darkRed);
- m_InstallLabel->setPalette(labelPalette);
- } else if (state == DownloadManager::STATE_FETCHINGMODINFO) {
- m_InstallLabel->setText(tr("Fetching Info 1"));
- m_Progress->setVisible(false);
- } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) {
- m_InstallLabel->setText(tr("Fetching Info 2"));
- m_Progress->setVisible(false);
- } else if (state >= DownloadManager::STATE_READY) {
- QPalette labelPalette;
- m_InstallLabel->setVisible(true);
- m_Progress->setVisible(false);
- if (state == DownloadManager::STATE_INSTALLED) {
- // the tr-macro doesn't work here, maybe because the translation is actually associated with DownloadListWidget instead
- // of DownloadListWidgetDelegate?
+ labelPalette.setColor(QPalette::WindowText, Qt::darkRed);
+ m_InstallLabel->setPalette(labelPalette);
+ } else if (state == DownloadManager::STATE_FETCHINGMODINFO) {
+ m_InstallLabel->setText(tr("Fetching Info 1"));
+ m_Progress->setVisible(false);
+ } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) {
+ m_InstallLabel->setText(tr("Fetching Info 2"));
+ m_Progress->setVisible(false);
+ } else if (state >= DownloadManager::STATE_READY) {
+ QPalette labelPalette;
+ m_InstallLabel->setVisible(true);
+ m_Progress->setVisible(false);
+ if (state == DownloadManager::STATE_INSTALLED) {
+ // the tr-macro doesn't work here, maybe because the translation is actually associated with DownloadListWidget instead
+ // of DownloadListWidgetDelegate?
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0));
#else
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0, QApplication::UnicodeUTF8));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Installed - Double Click to re-install", 0, QApplication::UnicodeUTF8));
#endif
- labelPalette.setColor(QPalette::WindowText, Qt::darkGray);
- } else if (state == DownloadManager::STATE_UNINSTALLED) {
+ labelPalette.setColor(QPalette::WindowText, Qt::darkGray);
+ } else if (state == DownloadManager::STATE_UNINSTALLED) {
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0));
#else
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0, QApplication::UnicodeUTF8));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Uninstalled - Double Click to re-install", 0, QApplication::UnicodeUTF8));
#endif
- labelPalette.setColor(QPalette::WindowText, Qt::lightGray);
- } else {
+ labelPalette.setColor(QPalette::WindowText, Qt::lightGray);
+ } else {
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0));
#else
- m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0, QApplication::UnicodeUTF8));
+ m_InstallLabel->setText(QApplication::translate("DownloadListWidget", "Done - Double Click to install", 0, QApplication::UnicodeUTF8));
#endif
- labelPalette.setColor(QPalette::WindowText, Qt::darkGreen);
- }
- m_InstallLabel->setPalette(labelPalette);
- if (m_Manager->isInfoIncomplete(downloadIndex)) {
- m_NameLabel->setText("<img src=\":/MO/gui/warning_16\" /> " + m_NameLabel->text());
- }
+ labelPalette.setColor(QPalette::WindowText, Qt::darkGreen);
+ }
+ m_InstallLabel->setPalette(labelPalette);
+ if (m_Manager->isInfoIncomplete(downloadIndex)) {
+ m_NameLabel->setText("<img src=\":/MO/gui/warning_16\" /> " + m_NameLabel->text());
+ }
+ } else {
+ m_InstallLabel->setVisible(false);
+ m_Progress->setVisible(true);
+ m_Progress->setValue(m_Manager->getProgress(downloadIndex));
+ }
+}
+
+void DownloadListWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ try {
+ auto iter = m_Cache.find(index.row());
+ if (iter != m_Cache.end()) {
+ drawCache(painter, option, *iter);
+ return;
+ }
+
+ m_ItemWidget->resize(QSize(m_View->columnWidth(0) + m_View->columnWidth(1) + m_View->columnWidth(2), option.rect.height()));
+
+ int downloadIndex = index.data().toInt();
+
+ if (downloadIndex >= m_Manager->numTotalDownloads()) {
+ paintPendingDownload(downloadIndex - m_Manager->numTotalDownloads());
} else {
- m_InstallLabel->setVisible(false);
- m_Progress->setVisible(true);
- m_Progress->setValue(m_Manager->getProgress(downloadIndex));
+ paintRegularDownload(downloadIndex);
}
#pragma message("caching disabled because changes in the list (including resorting) doesn't work correctly")
@@ -280,29 +300,32 @@ bool DownloadListWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::RightButton) {
QMenu menu(m_View);
+ bool hidden = false;
m_ContextRow = qobject_cast<QSortFilterProxyModel*>(model)->mapToSource(index).row();
- DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow);
- bool hidden = m_Manager->isHidden(m_ContextRow);
- if (state >= DownloadManager::STATE_READY) {
- menu.addAction(tr("Install"), this, SLOT(issueInstall()));
- if (m_Manager->isInfoIncomplete(m_ContextRow)) {
- menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
+ if (m_ContextRow < m_Manager->numTotalDownloads()) {
+ DownloadManager::DownloadState state = m_Manager->getState(m_ContextRow);
+ hidden = m_Manager->isHidden(m_ContextRow);
+ if (state >= DownloadManager::STATE_READY) {
+ menu.addAction(tr("Install"), this, SLOT(issueInstall()));
+ if (m_Manager->isInfoIncomplete(m_ContextRow)) {
+ menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
+ }
+ menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
+ if (hidden) {
+ menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
+ } else {
+ menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
+ }
+ } else if (state == DownloadManager::STATE_DOWNLOADING){
+ menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
+ menu.addAction(tr("Pause"), this, SLOT(issuePause()));
+ } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) {
+ menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
+ menu.addAction(tr("Resume"), this, SLOT(issueResume()));
}
- menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
- if (hidden) {
- menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
- } else {
- menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
- }
- } else if (state == DownloadManager::STATE_DOWNLOADING){
- menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
- menu.addAction(tr("Pause"), this, SLOT(issuePause()));
- } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) {
- menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
- menu.addAction(tr("Resume"), this, SLOT(issueResume()));
- }
- menu.addSeparator();
+ menu.addSeparator();
+ }
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
diff --git a/src/downloadlistwidget.h b/src/downloadlistwidget.h
index f5bfdbaa..80c4430a 100644
--- a/src/downloadlistwidget.h
+++ b/src/downloadlistwidget.h
@@ -60,6 +60,9 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ void paintPendingDownload(int downloadIndex) const;
+ void paintRegularDownload(int downloadIndex) const;
+
signals:
void installDownload(int index);
diff --git a/src/downloadlistwidgetcompact.cpp b/src/downloadlistwidgetcompact.cpp
index d2a71dd5..e2fbcd24 100644
--- a/src/downloadlistwidgetcompact.cpp
+++ b/src/downloadlistwidgetcompact.cpp
@@ -82,6 +82,66 @@ void DownloadListWidgetCompactDelegate::drawCache(QPainter *painter, const QStyl
}
+void DownloadListWidgetCompactDelegate::paintPendingDownload(int downloadIndex) const
+{
+ std::pair<int, int> nexusids = m_Manager->getPendingDownload(downloadIndex);
+ m_NameLabel->setText(tr("< mod %1 file %2 >").arg(nexusids.first).arg(nexusids.second));
+ if (m_SizeLabel != NULL) {
+ m_SizeLabel->setText("???");
+ }
+ m_DoneLabel->setVisible(true);
+ m_DoneLabel->setText(tr("Pending"));
+ m_Progress->setVisible(false);
+}
+
+
+void DownloadListWidgetCompactDelegate::paintRegularDownload(int downloadIndex) const
+{
+ QString name = m_Manager->getFileName(downloadIndex);
+ if (name.length() > 53) {
+ name.truncate(50);
+ 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);
+ m_DoneLabel->setText(tr("Paused"));
+ m_DoneLabel->setForegroundRole(QPalette::Link);
+ } else if (state == DownloadManager::STATE_FETCHINGMODINFO) {
+ m_DoneLabel->setText(tr("Fetching Info 1"));
+ } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) {
+ m_DoneLabel->setText(tr("Fetching Info 2"));
+ } else if (state >= DownloadManager::STATE_READY) {
+ m_DoneLabel->setVisible(true);
+ m_Progress->setVisible(false);
+ if (state == DownloadManager::STATE_INSTALLED) {
+ m_DoneLabel->setText(tr("Installed"));
+ m_DoneLabel->setForegroundRole(QPalette::Mid);
+ } else if (state == DownloadManager::STATE_UNINSTALLED) {
+ m_DoneLabel->setText(tr("Uninstalled"));
+ m_DoneLabel->setForegroundRole(QPalette::Dark);
+ } else {
+ m_DoneLabel->setText(tr("Done"));
+ m_DoneLabel->setForegroundRole(QPalette::WindowText);
+ }
+ if (m_Manager->isInfoIncomplete(downloadIndex)) {
+ m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text());
+ }
+ } else {
+ m_DoneLabel->setVisible(false);
+ m_Progress->setVisible(true);
+ m_Progress->setValue(m_Manager->getProgress(downloadIndex));
+ }
+}
+
void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
#pragma message("This is quite costy - room for optimization?")
@@ -100,49 +160,10 @@ void DownloadListWidgetCompactDelegate::paint(QPainter *painter, const QStyleOpt
}
int downloadIndex = index.data().toInt();
-
- QString name = m_Manager->getFileName(downloadIndex);
- if (name.length() > 53) {
- name.truncate(50);
- 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);
- m_DoneLabel->setText(tr("Paused"));
- m_DoneLabel->setForegroundRole(QPalette::Link);
- } else if (state == DownloadManager::STATE_FETCHINGMODINFO) {
- m_DoneLabel->setText(tr("Fetching Info 1"));
- } else if (state == DownloadManager::STATE_FETCHINGFILEINFO) {
- m_DoneLabel->setText(tr("Fetching Info 2"));
- } else if (state >= DownloadManager::STATE_READY) {
- m_DoneLabel->setVisible(true);
- m_Progress->setVisible(false);
- if (state == DownloadManager::STATE_INSTALLED) {
- m_DoneLabel->setText(tr("Installed"));
- m_DoneLabel->setForegroundRole(QPalette::Mid);
- } else if (state == DownloadManager::STATE_UNINSTALLED) {
- m_DoneLabel->setText(tr("Uninstalled"));
- m_DoneLabel->setForegroundRole(QPalette::Dark);
- } else {
- m_DoneLabel->setText(tr("Done"));
- m_DoneLabel->setForegroundRole(QPalette::WindowText);
- }
- if (m_Manager->isInfoIncomplete(downloadIndex)) {
- m_NameLabel->setText("<img src=\":/MO/gui/warning_16\"/> " + m_NameLabel->text());
- }
+ if (downloadIndex >= m_Manager->numTotalDownloads()) {
+ paintPendingDownload(downloadIndex - m_Manager->numTotalDownloads());
} else {
- m_DoneLabel->setVisible(false);
- m_Progress->setVisible(true);
- m_Progress->setValue(m_Manager->getProgress(downloadIndex));
+ paintRegularDownload(downloadIndex);
}
#pragma message("caching disabled because changes in the list (including resorting) doesn't work correctly")
@@ -268,29 +289,32 @@ bool DownloadListWidgetCompactDelegate::editorEvent(QEvent *event, QAbstractItem
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::RightButton) {
QMenu menu;
+ bool hidden = false;
m_ContextIndex = qobject_cast<QSortFilterProxyModel*>(model)->mapToSource(index);
- DownloadManager::DownloadState state = m_Manager->getState(m_ContextIndex.row());
- bool hidden = m_Manager->isHidden(m_ContextIndex.row());
- if (state >= DownloadManager::STATE_READY) {
- menu.addAction(tr("Install"), this, SLOT(issueInstall()));
- if (m_Manager->isInfoIncomplete(m_ContextIndex.row())) {
- menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
- }
- menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
- if (hidden) {
- menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
- } else {
- menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
+ if (m_ContextIndex.row() < m_Manager->numTotalDownloads()) {
+ DownloadManager::DownloadState state = m_Manager->getState(m_ContextIndex.row());
+ hidden = m_Manager->isHidden(m_ContextIndex.row());
+ if (state >= DownloadManager::STATE_READY) {
+ menu.addAction(tr("Install"), this, SLOT(issueInstall()));
+ if (m_Manager->isInfoIncomplete(m_ContextIndex.row())) {
+ menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfo()));
+ }
+ menu.addAction(tr("Delete"), this, SLOT(issueDelete()));
+ if (hidden) {
+ menu.addAction(tr("Un-Hide"), this, SLOT(issueRestoreToView()));
+ } else {
+ menu.addAction(tr("Remove from View"), this, SLOT(issueRemoveFromView()));
+ }
+ } else if (state == DownloadManager::STATE_DOWNLOADING){
+ menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
+ menu.addAction(tr("Pause"), this, SLOT(issuePause()));
+ } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) {
+ menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
+ menu.addAction(tr("Resume"), this, SLOT(issueResume()));
}
- } else if (state == DownloadManager::STATE_DOWNLOADING){
- menu.addAction(tr("Cancel"), this, SLOT(issueCancel()));
- menu.addAction(tr("Pause"), this, SLOT(issuePause()));
- } else if ((state == DownloadManager::STATE_PAUSED) || (state == DownloadManager::STATE_ERROR)) {
- menu.addAction(tr("Remove"), this, SLOT(issueDelete()));
- menu.addAction(tr("Resume"), this, SLOT(issueResume()));
- }
- menu.addSeparator();
+ menu.addSeparator();
+ }
menu.addAction(tr("Delete Installed..."), this, SLOT(issueDeleteCompleted()));
menu.addAction(tr("Delete All..."), this, SLOT(issueDeleteAll()));
if (!hidden) {
diff --git a/src/downloadlistwidgetcompact.h b/src/downloadlistwidgetcompact.h
index 05d00b9d..4d7f40de 100644
--- a/src/downloadlistwidgetcompact.h
+++ b/src/downloadlistwidgetcompact.h
@@ -78,6 +78,8 @@ protected:
private:
void drawCache(QPainter *painter, const QStyleOptionViewItem &option, const QPixmap &cache) const;
+ void paintPendingDownload(int downloadIndex) const;
+ void paintRegularDownload(int downloadIndex) const;
private slots:
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 48484d24..61c5113c 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -323,6 +323,7 @@ bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs,
(QMessageBox::question(NULL, tr("Download again?"), tr("A file with the same name has already been downloaded. "
"Do you want to download it again? The new file will receive a different name."),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
+ removePending(modID, fileID);
delete newDownload;
return false;
}
@@ -331,11 +332,24 @@ bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs,
startDownload(reply, newDownload, false);
- emit update(-1);
+// emit update(-1);
return true;
}
+void DownloadManager::removePending(int modID, int fileID)
+{
+ emit aboutToUpdate();
+ for (auto iter = m_PendingDownloads.begin(); iter != m_PendingDownloads.end(); ++iter) {
+ if ((iter->first == modID) && (iter->second == fileID)) {
+ m_PendingDownloads.erase(iter);
+ break;
+ }
+ }
+ emit update(-1);
+}
+
+
void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownload, bool resume)
{
newDownload->m_Reply = reply;
@@ -365,11 +379,14 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl
if (!resume) {
newDownload->m_PreResumeSize = newDownload->m_Output.size();
+ removePending(newDownload->m_ModID, newDownload->m_FileID);
+
emit aboutToUpdate();
m_ActiveDownloads.append(newDownload);
emit update(-1);
+ emit downloadAdded();
}
}
@@ -379,14 +396,21 @@ void DownloadManager::addNXMDownload(const QString &url)
NXMUrl nxmInfo(url);
QString managedGame = ToQString(MOShared::GameInfo::instance().getGameShortName());
-
+ qDebug("add nxm download", qPrintable(url));
if (nxmInfo.game().compare(managedGame, Qt::CaseInsensitive) != 0) {
+ qDebug("download requested for wrong game (game: %s, url: %s)", qPrintable(managedGame), qPrintable(nxmInfo.game()));
QMessageBox::information(NULL, tr("Wrong Game"), tr("The download link is for a mod for \"%1\" but this instance of MO "
"has been set up for \"%2\".").arg(nxmInfo.game()).arg(managedGame), QMessageBox::Ok);
return;
}
- m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.getModId(), nxmInfo.getFileId(), this, QVariant()));
+ emit aboutToUpdate();
+
+ m_PendingDownloads.append(std::make_pair(nxmInfo.modId(), nxmInfo.fileId()));
+
+ emit update(-1);
+ emit downloadAdded();
+ m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.modId(), nxmInfo.fileId(), this, QVariant()));
}
@@ -628,6 +652,19 @@ int DownloadManager::numTotalDownloads() const
return m_ActiveDownloads.size();
}
+int DownloadManager::numPendingDownloads() const
+{
+ return m_PendingDownloads.size();
+}
+
+std::pair<int, int> DownloadManager::getPendingDownload(int index)
+{
+ if ((index < 0) || (index >= m_PendingDownloads.size())) {
+ throw MyException(tr("invalid index"));
+ }
+
+ return m_PendingDownloads.at(index);
+}
QString DownloadManager::getFilePath(int index) const
{
@@ -1025,8 +1062,8 @@ void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant userD
NexusInfo info;
QVariantMap result = resultData.toMap();
-
info.m_Name = result["name"].toString();
+ qDebug("file info received for %s", qPrintable(info.m_Name));
info.m_Version = result["version"].toString();
if (info.m_Version.isEmpty()) {
info.m_Version = info.m_NewestVersion;
@@ -1121,9 +1158,12 @@ void DownloadManager::nxmDownloadURLsAvailable(int modID, int fileID, QVariant u
m_RequestIDs.erase(idIter);
}
+ qDebug("download urls received (modid %d, fileid %d)", modID, fileID);
+
NexusInfo info = userData.value<NexusInfo>();
QVariantList resultList = resultData.toList();
if (resultList.length() == 0) {
+ removePending(modID, fileID);
emit showMessage(tr("No download server available. Please try again later."));
return;
}
@@ -1282,3 +1322,4 @@ void DownloadManager::directoryChanged(const QString&)
{
refreshList();
}
+
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 099e6084..62396666 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -206,6 +206,19 @@ public:
int numTotalDownloads() const;
/**
+ * @brief retrieve number of pending downloads (nexus downloads for which we don't know the name and url yet)
+ * @return number of pending downloads
+ */
+ int numPendingDownloads() const;
+
+ /**
+ * @brief retrieve the info of a pending download
+ * @param index index of the pending download (index in the range [0, numPendingDownloads()[)
+ * @return pair of modid, fileid
+ */
+ std::pair<int, int> getPendingDownload(int index);
+
+ /**
* @brief retrieve the full path to the download specified by index
*
* @param index the index to look up
@@ -357,6 +370,11 @@ signals:
*/
void downloadSpeed(const QString &serverName, int bytesPerSecond);
+ /**
+ * @brief emitted whenever a new download is added to the list
+ */
+ void downloadAdded();
+
public slots:
/**
@@ -440,6 +458,8 @@ private:
QDateTime matchDate(const QString &timeString);
+ void removePending(int modID, int fileID);
+
private:
static const int AUTOMATIC_RETRIES = 3;
@@ -447,6 +467,9 @@ private:
private:
NexusInterface *m_NexusInterface;
+
+ QVector<std::pair<int, int> > m_PendingDownloads;
+
QVector<DownloadInfo*> m_ActiveDownloads;
QString m_OutputDirectory;
@@ -465,4 +488,6 @@ private:
};
+
+
#endif // DOWNLOADMANAGER_H
diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp
index a3b6f1b5..f930cf10 100644
--- a/src/logbuffer.cpp
+++ b/src/logbuffer.cpp
@@ -112,13 +112,26 @@ void LogBuffer::log(QtMsgType type, const QMessageLogContext &context, const QSt
#else
+
+char LogBuffer::msgTypeID(QtMsgType type)
+{
+ switch (type) {
+ case QtDebugMsg: return 'D';
+ case QtWarningMsg: return 'W';
+ case QtCriticalMsg: return 'C';
+ case QtFatalMsg: return 'F';
+ }
+}
+
+#include <QDateTime>
+
void LogBuffer::log(QtMsgType type, const char *message)
{
QMutexLocker guard(&s_Mutex);
if (!s_Instance.isNull()) {
s_Instance->logMessage(type, message);
}
- fprintf(stdout, "%s\n", message);
+ fprintf(stdout, "[%c] %s: %s\n", msgTypeID(type), qPrintable(QTime::currentTime().toString()), message);
fflush(stdout);
}
diff --git a/src/logbuffer.h b/src/logbuffer.h
index de5e887f..68753996 100644
--- a/src/logbuffer.h
+++ b/src/logbuffer.h
@@ -60,6 +60,8 @@ private:
void write() const;
+ static char msgTypeID(QtMsgType type);
+
private:
static QScopedPointer<LogBuffer> s_Instance;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 77e4cb3b..1f1d5f95 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -231,9 +231,9 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget
ui->savegameList->installEventFilter(this);
ui->savegameList->setMouseTracking(true);
-
connect(&m_DownloadManager, SIGNAL(showMessage(QString)), this, SLOT(showMessage(QString)));
connect(&m_DownloadManager, SIGNAL(downloadSpeed(QString,int)), this, SLOT(downloadSpeed(QString,int)));
+ connect(&m_DownloadManager, SIGNAL(downloadAdded()), ui->downloadView, SLOT(scrollToBottom()));
connect(ui->savegameList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(saveSelectionChanged(QListWidgetItem*)));
@@ -781,6 +781,8 @@ void MainWindow::showEvent(QShowEvent *event)
ui->groupCombo->setCurrentIndex(grouping);
allowListResize();
+
+ m_Settings.registerAsNXMHandler(false);
}
@@ -4026,15 +4028,10 @@ void MainWindow::on_actionSettings_triggered()
NexusInterface::instance()->setNMMVersion(m_Settings.getNMMVersion());
}
+
void MainWindow::on_actionNexus_triggered()
{
- std::wstring nxmPath = ToWString(QApplication::applicationDirPath() + "/nxmhandler.exe");
- std::wstring executable = ToWString(QApplication::applicationFilePath());
- ::ShellExecuteW(NULL, L"open", nxmPath.c_str(),
- (std::wstring(L"reg ") + GameInfo::instance().getGameShortName() + L" \"" + executable + L"\"").c_str(), NULL, SW_SHOWNORMAL);
-
::ShellExecuteW(NULL, L"open", GameInfo::instance().getNexusPage(false).c_str(), NULL, NULL, SW_SHOWNORMAL);
- ui->tabWidget->setCurrentIndex(4);
}
@@ -4054,6 +4051,7 @@ void MainWindow::linkClicked(const QString &url)
void MainWindow::downloadRequestedNXM(const QString &url)
{
QString username, password;
+ qDebug("download requested: %s", qPrintable(url));
if (!m_LoginAttempted && !NexusInterface::instance()->getAccessManager()->loggedIn() &&
(m_Settings.getNexusLogin(username, password) ||
diff --git a/src/messagedialog.cpp b/src/messagedialog.cpp
index 4a1ef0d6..8cef1b7c 100644
--- a/src/messagedialog.cpp
+++ b/src/messagedialog.cpp
@@ -81,6 +81,7 @@ void MessageDialog::resizeEvent(QResizeEvent *event)
void MessageDialog::showMessage(const QString &text, QWidget *reference)
{
+ qDebug("%s", qPrintable(text));
if (reference != NULL) {
MessageDialog *dialog = new MessageDialog(text, reference);
dialog->show();
diff --git a/src/mo_icon.ico b/src/mo_icon.ico
index b1105bb2..59da6c2d 100644
--- a/src/mo_icon.ico
+++ b/src/mo_icon.ico
Binary files differ
diff --git a/src/settings.cpp b/src/settings.cpp
index 8086672a..895094f7 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -102,6 +102,15 @@ bool Settings::pluginBlacklisted(const QString &fileName) const
return m_PluginBlacklist.contains(fileName);
}
+void Settings::registerAsNXMHandler(bool force)
+{
+ std::wstring nxmPath = ToWString(QCoreApplication::applicationDirPath() + "/nxmhandler.exe");
+ std::wstring executable = ToWString(QCoreApplication::applicationFilePath());
+ std::wstring mode = force ? L"forcereg" : L"reg";
+ ::ShellExecuteW(NULL, L"open", nxmPath.c_str(),
+ (mode + L" " + GameInfo::instance().getGameShortName() + L" \"" + executable + L"\"").c_str(), NULL, SW_SHOWNORMAL);
+}
+
void Settings::registerPlugin(IPlugin *plugin)
{
m_Plugins.push_back(plugin);
diff --git a/src/settings.h b/src/settings.h
index abffc94b..81174440 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -256,6 +256,13 @@ public:
*/
std::vector<MOBase::IPlugin*> plugins() const { return m_Plugins; }
+ /**
+ * @brief register MO as the handler for nxm links
+ * @param force set to true to enforce the registration dialog to show up,
+ * even if the user said earlier not to
+ */
+ void registerAsNXMHandler(bool force);
+
private:
QString obfuscate(const QString &password) const;
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index c8908ddb..bf1f95dc 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -29,6 +29,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QShortcut>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
+#include "settings.h"
using namespace MOBase;
@@ -165,3 +166,8 @@ void SettingsDialog::deleteBlacklistItem()
{
ui->pluginBlacklist->takeItem(ui->pluginBlacklist->currentIndex().row());
}
+
+void SettingsDialog::on_associateButton_clicked()
+{
+ Settings::instance().registerAsNXMHandler(true);
+}
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
index 718574a0..0bd9fd23 100644
--- a/src/settingsdialog.h
+++ b/src/settingsdialog.h
@@ -75,6 +75,8 @@ private slots:
void deleteBlacklistItem();
+ void on_associateButton_clicked();
+
private:
Ui::SettingsDialog *ui;
};
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index 39d49a39..bda6726c 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -275,32 +275,29 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
- </property>
- <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item>
<widget class="QLineEdit" name="usernameEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item>
<widget class="QLineEdit" name="passwordEdit">
<property name="enabled">
<bool>false</bool>
@@ -342,13 +339,40 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QPushButton" name="associateButton">
+ <property name="text">
+ <string>Associate with &quot;Download with manager&quot; links</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8" stretch="0,0">
+ <property name="spacing">
+ <number>4</number>
+ </property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_16">
<property name="text">
- <string>Known Servers (Dynamically updated every download)</string>
+ <string>Known Servers (updated on download)</string>
</property>
</widget>
</item>
diff --git a/src/splash.png b/src/splash.png
index 0137bf72..3eec8bed 100644
--- a/src/splash.png
+++ b/src/splash.png
Binary files differ