diff options
| author | Tannin <devnull@localhost> | 2014-01-13 19:32:54 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-01-13 19:32:54 +0100 |
| commit | a083a2d3b6506ab95d3b18ab0ffa7751750e0249 (patch) | |
| tree | 1bb333c8c8b1df4889f65dc383c25e37c6046289 | |
| parent | db09b806b9e765b5cb49a9a80f74a4440fff3027 (diff) | |
- implemented hook for NtQueryDirectoryFile
- saves list is now automatically updated on FS changes
- optimization: data tree widget is no longer filled completely at once but one directory at a time
- bugfix: pending downloads were not removed from list after a failed nxm request
- bugfix: there was still a nmm.nexusmods.com link
- bugfix: the text "alpha" in version strings wasn't interpreted correctly
| -rw-r--r-- | src/downloadmanager.cpp | 6 | ||||
| -rw-r--r-- | src/logbuffer.cpp | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 67 | ||||
| -rw-r--r-- | src/mainwindow.h | 5 | ||||
| -rw-r--r-- | src/modinfodialog.cpp | 2 | ||||
| -rw-r--r-- | src/organizer.pro | 10 | ||||
| -rw-r--r-- | src/shared/directoryentry.h | 2 |
7 files changed, 81 insertions, 13 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index f0f4ba2d..fdc825f1 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -429,7 +429,7 @@ void DownloadManager::addNXMDownload(const QString &url) emit update(-1); emit downloadAdded(); - m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.modId(), nxmInfo.fileId(), this, QVariant())); + m_RequestIDs.insert(m_NexusInterface->requestFileInfo(nxmInfo.modId(), nxmInfo.fileId(), this, nxmInfo.fileId())); } @@ -1201,7 +1201,7 @@ void DownloadManager::nxmDownloadURLsAvailable(int modID, int fileID, QVariant u } -void DownloadManager::nxmRequestFailed(int modID, QVariant, int requestID, const QString &errorString) +void DownloadManager::nxmRequestFailed(int modID, QVariant userData, int requestID, const QString &errorString) { std::set<int>::iterator idIter = m_RequestIDs.find(requestID); if (idIter == m_RequestIDs.end()) { @@ -1225,6 +1225,8 @@ void DownloadManager::nxmRequestFailed(int modID, QVariant, int requestID, const break; } } + + removePending(modID, userData.toInt()); emit showMessage(tr("Failed to request file info from nexus: %1").arg(errorString)); } diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp index f930cf10..6f3f640f 100644 --- a/src/logbuffer.cpp +++ b/src/logbuffer.cpp @@ -131,7 +131,7 @@ void LogBuffer::log(QtMsgType type, const char *message) if (!s_Instance.isNull()) { s_Instance->logMessage(type, message); } - fprintf(stdout, "[%c] %s: %s\n", msgTypeID(type), qPrintable(QTime::currentTime().toString()), message); + fprintf(stdout, "%s [%c] %s\n", qPrintable(QTime::currentTime().toString()), msgTypeID(type), message); fflush(stdout); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 80465fb9..139db3f0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -256,13 +256,16 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget connect(&m_PluginList, SIGNAL(saveTimer()), this, SLOT(savePluginList())); connect(ui->bsaList, SIGNAL(itemsMoved()), this, SLOT(bsaList_itemMoved())); - connect(ui->bsaWarning, SIGNAL(linkActivated(QString)), this, SLOT(linkClicked(QString))); + connect(ui->dataTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(expandDataTreeItem(QTreeWidgetItem*))); + connect(&m_DirectoryRefresher, SIGNAL(refreshed()), this, SLOT(directory_refreshed())); connect(&m_DirectoryRefresher, SIGNAL(progress(int)), this, SLOT(refresher_progress(int))); connect(&m_DirectoryRefresher, SIGNAL(error(QString)), this, SLOT(showError(QString))); + connect(&m_SavesWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(refreshSavesIfOpen())); + connect(&m_Settings, SIGNAL(languageChanged(QString)), this, SLOT(languageChange(QString))); connect(&m_Settings, SIGNAL(styleChanged(QString)), this, SIGNAL(styleChanged(QString))); @@ -1526,21 +1529,52 @@ void MainWindow::updateTo(QTreeWidgetItem *subTree, const std::wstring &director std::vector<DirectoryEntry*>::const_iterator current, end; directoryEntry.getSubDirectories(current, end); for (; current != end; ++current) { - QStringList columns(ToQString((*current)->getName())); + QString pathName = ToQString((*current)->getName()); + QStringList columns(pathName); columns.append(""); - QTreeWidgetItem *directoryChild = new QTreeWidgetItem(columns); - updateTo(directoryChild, temp.str(), **current, conflictsOnly); - if (directoryChild->childCount() != 0) { + if (!(*current)->isEmpty()) { + QTreeWidgetItem *directoryChild = new QTreeWidgetItem(columns); + QTreeWidgetItem *onDemandLoad = new QTreeWidgetItem(QStringList()); + onDemandLoad->setData(0, Qt::UserRole + 0, "__loaded_on_demand__"); + onDemandLoad->setData(0, Qt::UserRole + 1, ToQString(temp.str())); + onDemandLoad->setData(0, Qt::UserRole + 2, conflictsOnly); + directoryChild->addChild(onDemandLoad); subTree->addChild(directoryChild); - } else { - delete directoryChild; +/* updateTo(directoryChild, temp.str(), **current, conflictsOnly); + if (directoryChild->childCount() != 0) { + subTree->addChild(directoryChild); + } else { + delete directoryChild; + }*/ } } } + subTree->sortChildren(0, Qt::AscendingOrder); } +void MainWindow::expandDataTreeItem(QTreeWidgetItem *item) +{ + if ((item->childCount() == 1) && (item->child(0)->data(0, Qt::UserRole).toString() == "__loaded_on_demand__")) { + // read the data we need from the sub-item, then dispose of it + QTreeWidgetItem *onDemandDataItem = item->child(0); + std::wstring path = ToWString(onDemandDataItem->data(0, Qt::UserRole + 1).toString()); + bool conflictsOnly = onDemandDataItem->data(0, Qt::UserRole + 2).toBool(); + item->removeChild(onDemandDataItem); + + std::wstring virtualPath = (path + L"\\").substr(6) + ToWString(item->text(0)); + DirectoryEntry *dir = m_DirectoryStructure->findSubDirectoryRecursive(virtualPath); + if (dir != NULL) { + updateTo(item, path, *dir, conflictsOnly); + } else { + qWarning("failed to update view of %ls", path.c_str()); + } + + } +} + + bool MainWindow::refreshProfiles(bool selectProfile) { QComboBox* profileBox = findChild<QComboBox*>("profileBox"); @@ -1665,6 +1699,14 @@ void MainWindow::refreshDataTree() } +void MainWindow::refreshSavesIfOpen() +{ + if (ui->tabWidget->currentIndex() == 3) { + refreshSaveList(); + } +} + + void MainWindow::refreshSaveList() { ui->savegameList->clear(); @@ -1680,6 +1722,8 @@ void MainWindow::refreshSaveList() savesDir.setPath(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getDocumentsDir() + L"\\" + path))); } + m_SavesWatcher.addPath(savesDir.absolutePath()); + QStringList filters; filters << ToQString(GameInfo::instance().getSaveGameExtension()); savesDir.setNameFilters(filters); @@ -4399,7 +4443,12 @@ void MainWindow::previewDataFile() QString filePath = QDir::fromNativeSeparators(ToQString(origin.getPath())) + "/" + fileName; if (QFile::exists(filePath)) { // it's very possible the file doesn't exist, because it's inside an archive. we don't support that - preview.addVariant(ToQString(origin.getName()), m_PreviewGenerator.genPreview(filePath)); + QWidget *wid = m_PreviewGenerator.genPreview(filePath); + if (wid == NULL) { + reportError(tr("failed to generate preview for %1").arg(filePath)); + } else { + preview.addVariant(ToQString(origin.getName()), wid); + } } }; @@ -4409,6 +4458,8 @@ void MainWindow::previewDataFile() } if (preview.numVariants() > 0) { preview.exec(); + } else { + QMessageBox::information(this, tr("Sorry"), tr("Sorry, can't preview anything. This function currently does not support extracting from bsas.")); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 21c121fb..59bee7bb 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -370,6 +370,8 @@ private: PreviewGenerator m_PreviewGenerator; + QFileSystemWatcher m_SavesWatcher; + private slots: void showMessage(const QString &message); @@ -523,6 +525,9 @@ private slots: void ignoreUpdate(); void unignoreUpdate(); + void refreshSavesIfOpen(); + void expandDataTreeItem(QTreeWidgetItem *item); + private slots: // ui slots // actions void on_actionAdd_Profile_triggered(); diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 674e7165..7f221bdc 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -766,7 +766,7 @@ void ModInfoDialog::activateNexusTab() QLineEdit *modIDEdit = findChild<QLineEdit*>("modIDEdit"); int modID = modIDEdit->text().toInt(); if (modID != 0) { - QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(ToQString(GameInfo::instance().getNexusPage())).arg(modID); + QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(ToQString(GameInfo::instance().getNexusPage(false))).arg(modID); QLabel *visitNexusLabel = findChild<QLabel*>("visitNexusLabel"); visitNexusLabel->setText(tr("<a href=\"%1\">Visit on Nexus</a>").arg(nexusLink)); visitNexusLabel->setToolTip(nexusLink); diff --git a/src/organizer.pro b/src/organizer.pro index 07feb326..25384e69 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -80,7 +80,15 @@ SOURCES += \ ../esptk/subrecord.cpp \
noeditdelegate.cpp \
previewgenerator.cpp \
- previewdialog.cpp
+ previewdialog.cpp \
+ gl/gltexloaders.cpp \
+ gl/dds/dds_api.cpp \
+ gl/dds/Image.cpp \
+ gl/dds/DirectDrawSurface.cpp \
+ gl/dds/Stream.cpp \
+ gl/dds/BlockDXT.cpp \
+ gl/dds/ColorBlock.cpp
+
HEADERS += \
transfersavesdialog.h \
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h index ad5d179b..15af5e9e 100644 --- a/src/shared/directoryentry.h +++ b/src/shared/directoryentry.h @@ -205,6 +205,8 @@ public: void clear();
bool isPopulated() const { return m_Populated; }
+ bool isEmpty() const { return (m_Files.size() == 0) && (m_SubDirectories.size() == 0); }
+
const DirectoryEntry *getParent() const { return m_Parent; }
// add files to this directory (and subdirectories) from the specified origin. That origin may exist or not
|
