From eb97c46ed68a965d6ddf44fa6741fa929fd7d278 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 7 May 2016 00:03:38 +0200 Subject: cleanup --- src/CMakeLists.txt | 12 ++++- src/aboutdialog.cpp | 5 ++- src/aboutdialog.ui | 50 +++++++++++++++++++-- src/categories.cpp | 2 +- src/directoryrefresher.cpp | 2 +- src/downloadmanager.cpp | 47 +++++++++---------- src/editexecutablesdialog.cpp | 8 ++-- src/editexecutablesdialog.ui | 4 +- src/executableslist.h | 3 +- src/installationmanager.cpp | 3 +- src/logbuffer.cpp | 22 +++++---- src/main.cpp | 6 +-- src/mainwindow.cpp | 14 +++--- src/mainwindow.ui | 40 +++++++++++------ src/modflagicondelegate.cpp | 6 +-- src/modinfo.cpp | 6 +-- src/modinfodialog.cpp | 10 +++-- src/nexusinterface.cpp | 11 ++--- src/organizercore.cpp | 12 +++-- src/persistentcookiejar.cpp | 2 +- src/plugincontainer.cpp | 4 +- src/profile.cpp | 17 +++---- src/profile.h | 2 +- src/profilesdialog.cpp | 102 ++++++++++++++++++++---------------------- src/profilesdialog.ui | 4 +- src/shared/util.cpp | 8 +++- src/usvfsconnector.cpp | 9 +++- src/version.rc | 4 +- 28 files changed, 248 insertions(+), 167 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02c63ad2..a8b43c59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,14 +272,22 @@ INCLUDE_DIRECTORIES(${project_path}/uibase/src ${project_path}/archive/src ${project_path}/../usvfs/usvfs ${project_path}/game_gamebryo/src - ${project_path}/game_features/src) + ${project_path}/game_features/src + ${project_path}/githubpp/src) INCLUDE_DIRECTORIES(shared ${ZLIB_INCLUDE_DIRS}) LINK_DIRECTORIES(${lib_path} ${project_path}/../zlib/lib) -ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) +EXECUTE_PROCESS( + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +ADD_DEFINITIONS(-D_UNICODE -DUNICODE -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -DGITID="${GIT_COMMIT_HASH}") IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") SET(usvfs_name usvfs_x64) diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp index 3657a10d..ed57a217 100644 --- a/src/aboutdialog.cpp +++ b/src/aboutdialog.cpp @@ -54,10 +54,13 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent) addLicense("RRZE Icon Set", LICENSE_CCBY3); addLicense("Icons by Lorc, Delapouite and sbed available on http://game-icons.net", LICENSE_CCBY3); addLicense("Castle Core", LICENSE_APACHE2); + addLicense("LOOT", LICENSE_GPL3); ui->nameLabel->setText(QString("%1 %2").arg(ui->nameLabel->text()).arg(version)); -#ifdef HGID +#if defined(HGID) ui->revisionLabel->setText(ui->revisionLabel->text() + " " + HGID); +#elif defined(GITID) + ui->revisionLabel->setText(ui->revisionLabel->text() + " " + GITID); #else ui->revisionLabel->setText(ui->revisionLabel->text() + " unknown"); #endif diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index ea5d2141..8d560f2b 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -6,8 +6,8 @@ 0 0 - 508 - 335 + 746 + 369 @@ -18,13 +18,50 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + 0 + 0 + + + + + 250 + 250 + + + + + 250 + 250 + + - :/MO/gui/mo_icon.ico + :/MO/gui/splash + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -83,7 +120,7 @@ - Copyright 2011-2015 Sebastian Herbord + Copyright 2011-2016 Sebastian Herbord @@ -265,6 +302,11 @@ thosrtanner + + + ogrotten + + diff --git a/src/categories.cpp b/src/categories.cpp index 7539d3fd..50ba5271 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -188,7 +188,7 @@ int CategoryFactory::addCategory(const QString &name, const std::vector &ne void CategoryFactory::addCategory(int id, const QString &name, const std::vector &nexusIDs, int parentID) { - int index = m_Categories.size(); + int index = static_cast(m_Categories.size()); m_Categories.push_back(Category(index, id, name, nexusIDs, parentID)); for (int nexusID : nexusIDs) { m_NexusMap[nexusID] = index; diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index 4eac4103..0a8b82be 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -159,7 +159,7 @@ void DirectoryRefresher::refresh() } catch (const std::exception &e) { emit error(tr("failed to read mod (%1): %2").arg(iter->modName, e.what())); } - emit progress((i * 100) / m_Mods.size() + 1); + emit progress((i * 100) / static_cast(m_Mods.size()) + 1); } emit progress(100); diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 6b4628cc..b92e171e 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -88,7 +88,8 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con QString fileName = QFileInfo(filePath).fileName(); if (fileName.endsWith(UNFINISHED)) { - info->m_FileName = fileName.mid(0, fileName.length() - strlen(UNFINISHED)); + info->m_FileName = fileName.mid( + 0, fileName.length() - static_cast(strlen(UNFINISHED))); info->m_State = STATE_PAUSED; } else { info->m_FileName = fileName; @@ -471,7 +472,7 @@ void DownloadManager::addNXMDownload(const QString &url) void DownloadManager::removeFile(int index, bool deleteFile) { if (index >= m_ActiveDownloads.size()) { - throw MyException(tr("invalid index")); + throw MyException(tr("remove: invalid download index %1").arg(index)); } DownloadInfo *download = m_ActiveDownloads.at(index); @@ -538,7 +539,7 @@ void DownloadManager::refreshAlphabeticalTranslation() void DownloadManager::restoreDownload(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("restore: invalid download index: %1").arg(index)); } DownloadInfo *download = m_ActiveDownloads.at(index); @@ -571,7 +572,7 @@ void DownloadManager::removeDownload(int index, bool deleteFile) } } else { if (index >= m_ActiveDownloads.size()) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("remove: invalid download index %1").arg(index)); return; } @@ -589,7 +590,7 @@ void DownloadManager::removeDownload(int index, bool deleteFile) void DownloadManager::cancelDownload(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("cancel: invalid download index %1").arg(index)); return; } @@ -602,7 +603,7 @@ void DownloadManager::cancelDownload(int index) void DownloadManager::pauseDownload(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("pause: invalid download index %1").arg(index)); return; } @@ -622,7 +623,7 @@ void DownloadManager::pauseDownload(int index) void DownloadManager::resumeDownload(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("resume: invalid download index %1").arg(index)); return; } DownloadInfo *info = m_ActiveDownloads[index]; @@ -633,7 +634,7 @@ void DownloadManager::resumeDownload(int index) void DownloadManager::resumeDownloadInt(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("resume (int): invalid download index %1").arg(index)); return; } DownloadInfo *info = m_ActiveDownloads[index]; @@ -673,7 +674,7 @@ DownloadManager::DownloadInfo *DownloadManager::downloadInfoByID(unsigned int id void DownloadManager::queryInfo(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - reportError(tr("invalid index %1").arg(index)); + reportError(tr("query: invalid download index %1").arg(index)); return; } DownloadInfo *info = m_ActiveDownloads[index]; @@ -721,7 +722,7 @@ int DownloadManager::numPendingDownloads() const std::pair DownloadManager::getPendingDownload(int index) { if ((index < 0) || (index >= m_PendingDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("get pending: invalid download index %1").arg(index)); } return m_PendingDownloads.at(index); @@ -730,7 +731,7 @@ std::pair DownloadManager::getPendingDownload(int index) QString DownloadManager::getFilePath(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("get path: invalid download index %1").arg(index)); } return m_OutputDirectory + "/" + m_ActiveDownloads.at(index)->m_FileName; @@ -751,7 +752,7 @@ QString DownloadManager::getFileTypeString(int fileType) QString DownloadManager::getDisplayName(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("display name: invalid download index %1").arg(index)); } DownloadInfo *info = m_ActiveDownloads.at(index); @@ -768,7 +769,7 @@ QString DownloadManager::getDisplayName(int index) const QString DownloadManager::getFileName(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("file name: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_FileName; @@ -777,7 +778,7 @@ QString DownloadManager::getFileName(int index) const QDateTime DownloadManager::getFileTime(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("file time: invalid download index %1").arg(index)); } DownloadInfo *info = m_ActiveDownloads.at(index); @@ -791,7 +792,7 @@ QDateTime DownloadManager::getFileTime(int index) const qint64 DownloadManager::getFileSize(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("file size: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_TotalSize; @@ -801,7 +802,7 @@ qint64 DownloadManager::getFileSize(int index) const int DownloadManager::getProgress(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("progress: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_Progress; @@ -811,7 +812,7 @@ int DownloadManager::getProgress(int index) const DownloadManager::DownloadState DownloadManager::getState(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("state: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_State; @@ -821,7 +822,7 @@ DownloadManager::DownloadState DownloadManager::getState(int index) const bool DownloadManager::isInfoIncomplete(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("infocomplete: invalid download index %1").arg(index)); } DownloadInfo *info = m_ActiveDownloads.at(index); @@ -836,7 +837,7 @@ bool DownloadManager::isInfoIncomplete(int index) const int DownloadManager::getModID(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("mod id: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_FileInfo->modID; } @@ -844,7 +845,7 @@ int DownloadManager::getModID(int index) const bool DownloadManager::isHidden(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("ishidden: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_Hidden; } @@ -853,7 +854,7 @@ bool DownloadManager::isHidden(int index) const const ModRepositoryFileInfo *DownloadManager::getFileInfo(int index) const { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("file info: invalid download index %1").arg(index)); } return m_ActiveDownloads.at(index)->m_FileInfo; @@ -863,7 +864,7 @@ const ModRepositoryFileInfo *DownloadManager::getFileInfo(int index) const void DownloadManager::markInstalled(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("mark installed: invalid download index %1").arg(index)); } DownloadInfo *info = m_ActiveDownloads.at(index); @@ -878,7 +879,7 @@ void DownloadManager::markInstalled(int index) void DownloadManager::markUninstalled(int index) { if ((index < 0) || (index >= m_ActiveDownloads.size())) { - throw MyException(tr("invalid index")); + throw MyException(tr("mark uninstalled: invalid download index %1").arg(index)); } DownloadInfo *info = m_ActiveDownloads.at(index); diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 1b2d5a48..05a7603d 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -126,15 +126,17 @@ void EditExecutablesDialog::on_addButton_clicked() void EditExecutablesDialog::on_browseButton_clicked() { - QString binaryName = FileDialogMemory::getOpenFileName("editExecutableBinary", this, - tr("Select a binary"), QString(), tr("Executable (%1)").arg("*.exe *.bat *.jar")); + QString binaryName = FileDialogMemory::getOpenFileName( + "editExecutableBinary", this, tr("Select a binary"), QString(), + tr("Executable (%1)").arg("*.exe *.bat *.jar")); if (binaryName.endsWith(".jar", Qt::CaseInsensitive)) { QString binaryPath; { // try to find java automatically std::wstring binaryNameW = ToWString(binaryName); WCHAR buffer[MAX_PATH]; - if (::FindExecutableW(binaryNameW.c_str(), nullptr, buffer) > (HINSTANCE)32) { + if (::FindExecutableW(binaryNameW.c_str(), nullptr, buffer) + > reinterpret_cast(32)) { DWORD binaryType = 0UL; if (!::GetBinaryTypeW(binaryNameW.c_str(), &binaryType)) { qDebug("failed to determine binary type of \"%ls\": %lu", binaryNameW.c_str(), ::GetLastError()); diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index a2aad19a..2640bb15 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 384 - 446 + 426 + 460 diff --git a/src/executableslist.h b/src/executableslist.h index eb7d2d6f..0534c09e 100644 --- a/src/executableslist.h +++ b/src/executableslist.h @@ -133,7 +133,8 @@ public: const QString &steamAppID, Executable::Flags flags) { - updateExecutable(title, executableName, arguments, workingDirectory, steamAppID, Executable::AllFlags, flags); + updateExecutable(title, executableName, arguments, workingDirectory, + steamAppID, Executable::AllFlags, flags); } /** diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 8ab27124..bf5ee91a 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -346,7 +346,8 @@ DirectoryTree *InstallationManager::createFilesTree() // to uncheck all files in a directory while keeping the dir checked. Those directories are // currently not installed. DirectoryTree::Node *newNode = new DirectoryTree::Node; - newNode->setData(DirectoryTreeInformation(*componentIter, i)); + newNode->setData( + DirectoryTreeInformation(*componentIter, static_cast(i))); currentNode->addNode(newNode, false); currentNode = newNode; } else { diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp index 8207dcbb..522ce3c8 100644 --- a/src/logbuffer.cpp +++ b/src/logbuffer.cpp @@ -53,13 +53,15 @@ void LogBuffer::logMessage(QtMsgType type, const QString &message) if (type >= m_MinMsgType) { Message msg = {type, QTime::currentTime(), message}; if (m_NumMessages < m_Messages.size()) { - beginInsertRows(QModelIndex(), m_NumMessages, m_NumMessages + 1); + beginInsertRows(QModelIndex(), static_cast(m_NumMessages), + static_cast(m_NumMessages) + 1); } m_Messages.at(m_NumMessages % m_Messages.size()) = msg; if (m_NumMessages < m_Messages.size()) { endInsertRows(); } else { - emit dataChanged(createIndex(0, 0), createIndex(m_Messages.size(), 0)); + emit dataChanged(createIndex(0, 0), + createIndex(static_cast(m_Messages.size()), 0)); } ++m_NumMessages; if (type >= QtCriticalMsg) { @@ -84,9 +86,10 @@ void LogBuffer::write() const return; } - unsigned int i = (m_NumMessages > m_Messages.size()) - ? m_NumMessages - m_Messages.size() - : 0U; + unsigned int i + = (m_NumMessages > m_Messages.size()) + ? static_cast(m_NumMessages - m_Messages.size()) + : 0U; for (; i < m_NumMessages; ++i) { file.write(m_Messages.at(i % m_Messages.size()).toString().toUtf8()); file.write("\r\n"); @@ -165,7 +168,7 @@ int LogBuffer::rowCount(const QModelIndex &parent) const if (parent.isValid()) return 0; else - return std::min(m_NumMessages, m_Messages.size()); + return static_cast(std::min(m_NumMessages, m_Messages.size())); } int LogBuffer::columnCount(const QModelIndex &) const @@ -175,9 +178,10 @@ int LogBuffer::columnCount(const QModelIndex &) const QVariant LogBuffer::data(const QModelIndex &index, int role) const { - unsigned offset = m_NumMessages < m_Messages.size() - ? 0 - : m_NumMessages - m_Messages.size(); + unsigned int offset + = m_NumMessages < m_Messages.size() + ? 0 + : static_cast(m_NumMessages - m_Messages.size()); unsigned int msgIndex = (offset + index.row() + 1) % m_Messages.size(); switch (role) { case Qt::DisplayRole: { diff --git a/src/main.cpp b/src/main.cpp index eb3a7248..6db5a50e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,9 +161,9 @@ static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *except if (dbgDLL) { FuncMiniDumpWriteDump funcDump = (FuncMiniDumpWriteDump)::GetProcAddress(dbgDLL, "MiniDumpWriteDump"); if (funcDump) { - wchar_t exeNameBuffer[MAX_PATH]; - ::GetModuleFileNameW(nullptr, exeNameBuffer, MAX_PATH); - QString dumpName = QString::fromWCharArray(exeNameBuffer) + ".dmp"; + QString dataPath = qApp->property("dataPath").toString(); + QString exeName = QFileInfo(qApp->applicationFilePath()).fileName(); + QString dumpName = dataPath + "/" + exeName + ".dmp"; if (QMessageBox::question(nullptr, QObject::tr("Woops"), QObject::tr("ModOrganizer has crashed! " diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 24391999..e174a17c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -144,15 +144,10 @@ along with Mod Organizer. If not, see . #include #include -#include +#include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#else -#include -#endif #ifndef Q_MOC_RUN #include @@ -4198,7 +4193,12 @@ void MainWindow::on_bossButton_clicked() HANDLE stdOutWrite = INVALID_HANDLE_VALUE; HANDLE stdOutRead = INVALID_HANDLE_VALUE; createStdoutPipe(&stdOutRead, &stdOutWrite); - m_OrganizerCore.prepareVFS(); + try { + m_OrganizerCore.prepareVFS(); + } catch (const std::exception &e) { + QMessageBox::warning(qApp->activeWindow(), tr("Error"), e.what()); + return; + } HANDLE loot = startBinary(QFileInfo(qApp->applicationDirPath() + "/loot/lootcli.exe"), parameters.join(" "), diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7d23cde5..f504994a 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -45,7 +45,10 @@ Categories - + + + 0 + 3 @@ -92,25 +95,34 @@ - - - false + + + + 0 + 0 + + + + + 0 + 25 + - Click blank area to deselect + Clear + + + true - - - - - - false - - - false + + + + 0 + 0 + diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp index d66c3ac5..5c4167ad 100644 --- a/src/modflagicondelegate.cpp +++ b/src/modflagicondelegate.cpp @@ -58,7 +58,7 @@ size_t ModFlagIconDelegate::getNumIcons(const QModelIndex &index) const if (modIdx < ModInfo::getNumMods()) { ModInfo::Ptr info = ModInfo::getByIndex(modIdx); std::vector flags = info->getFlags(); - int count = flags.size(); + size_t count = flags.size(); if (std::find_first_of(flags.begin(), flags.end(), m_ConflictFlags, m_ConflictFlags + 4) == flags.end()) { ++count; } @@ -71,11 +71,11 @@ size_t ModFlagIconDelegate::getNumIcons(const QModelIndex &index) const QSize ModFlagIconDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &modelIndex) const { - int count = getNumIcons(modelIndex); + size_t count = getNumIcons(modelIndex); unsigned int index = modelIndex.data(Qt::UserRole + 1).toInt(); QSize result; if (index < ModInfo::getNumMods()) { - result = QSize(count * 40, 20); + result = QSize(static_cast(count) * 40, 20); } else { result = QSize(1, 20); } diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 5593b0f0..3c97ca85 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -112,7 +112,7 @@ void ModInfo::createFromOverwrite() unsigned int ModInfo::getNumMods() { QMutexLocker locker(&s_Mutex); - return s_Collection.size(); + return static_cast(s_Collection.size()); } @@ -121,7 +121,7 @@ ModInfo::Ptr ModInfo::getByIndex(unsigned int index) QMutexLocker locker(&s_Mutex); if (index >= s_Collection.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index %1").arg(index)); } return s_Collection[index]; } @@ -150,7 +150,7 @@ bool ModInfo::removeMod(unsigned int index) QMutexLocker locker(&s_Mutex); if (index >= s_Collection.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("remove: invalid mod index %1").arg(index)); } // update the indices first ModInfo::Ptr modInfo = s_Collection[index]; diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index feaac2d4..e1a2183c 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -351,14 +351,18 @@ void ModInfoDialog::refreshLists() void ModInfoDialog::addCategories(const CategoryFactory &factory, const std::set &enabledCategories, QTreeWidgetItem *root, int rootLevel) { - for (size_t i = 0; i < factory.numCategories(); ++i) { + for (int i = 0; i < static_cast(factory.numCategories()); ++i) { if (factory.getParentID(i) != rootLevel) { continue; } int categoryID = factory.getCategoryID(i); - QTreeWidgetItem *newItem = new QTreeWidgetItem(QStringList(factory.getCategoryName(i))); + QTreeWidgetItem *newItem + = new QTreeWidgetItem(QStringList(factory.getCategoryName(i))); newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable); - newItem->setCheckState(0, enabledCategories.find(categoryID) != enabledCategories.end() ? Qt::Checked : Qt::Unchecked); + newItem->setCheckState(0, enabledCategories.find(categoryID) + != enabledCategories.end() + ? Qt::Checked + : Qt::Unchecked); newItem->setData(0, Qt::UserRole, categoryID); if (factory.hasChildren(i)) { addCategories(factory, enabledCategories, newItem, categoryID); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index c689501f..4a44c067 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -206,11 +206,12 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo std::string candidate2 = result[2].str(); if (candidate2.length() != 0 && (candidate2.find_last_of("VvRr") == std::string::npos)) { // well, that second match might be an id too... - unsigned offset = strspn(candidate2.c_str(), "-_ "); + size_t offset = strspn(candidate2.c_str(), "-_ "); if (offset < candidate2.length() && query) { SelectionDialog selection(tr("Failed to guess mod id for \"%1\", please pick the correct one").arg(fileName)); QString r2Highlight(fileName); - r2Highlight.insert(result.position(2) + result.length(2), "* ").insert(result.position(2) + offset, " *"); + r2Highlight.insert(result.position(2) + result.length(2), "* ") + .insert(result.position(2) + static_cast(offset), " *"); QString r3Highlight(fileName); r3Highlight.insert(result.position(3) + result.length(3), "* ").insert(result.position(3), " *"); @@ -264,14 +265,14 @@ QString NexusInterface::getModURL(int modID) const return QString("%1/mods/%2").arg(getGameURL()).arg(modID); } -bool NexusInterface::isModURL(int modID, QString const &url) const +bool NexusInterface::isModURL(int modID, const QString &url) const { - if (url == getModURL(modID)) { + if (QUrl(url) == QUrl(getModURL(modID))) { return true; } //Try the alternate (old style) mod name QString alt = QString("%1/%2").arg(getOldModsURL()).arg(modID); - return alt == url; + return QUrl(alt) == QUrl(url); } int NexusInterface::requestDescription(int modID, QObject *receiver, QVariant userData, diff --git a/src/organizercore.cpp b/src/organizercore.cpp index f6196aa7..b1eaaef3 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1345,8 +1345,6 @@ void OrganizerCore::refreshESPList() // clear list try { m_PluginList.refresh(m_CurrentProfile->name(), *m_DirectoryStructure, - m_CurrentProfile->getPluginsFileName(), - m_CurrentProfile->getLoadOrderFileName(), m_CurrentProfile->getLockedOrderFileName()); } catch (const std::exception &e) { reportError(tr("Failed to refresh list of esps: %1").arg(e.what())); @@ -1621,7 +1619,7 @@ void OrganizerCore::loginSuccessful(bool necessary) if (necessary) { MessageDialog::showMessage(tr("login successful"), qApp->activeWindow()); } - foreach (QString url, m_PendingDownloads) { + for (QString url : m_PendingDownloads) { downloadRequestedNXM(url); } m_PendingDownloads.clear(); @@ -1765,9 +1763,7 @@ void OrganizerCore::savePluginList() m_PostRefreshTasks.append([&]() { this->savePluginList(); }); return; } - m_PluginList.saveTo(m_CurrentProfile->getPluginsFileName(), - m_CurrentProfile->getLoadOrderFileName(), - m_CurrentProfile->getLockedOrderFileName(), + m_PluginList.saveTo(m_CurrentProfile->getLockedOrderFileName(), m_CurrentProfile->getDeleterFileName(), m_Settings.hideUncheckedPlugins()); m_PluginList.saveLoadOrder(*m_DirectoryStructure); @@ -1825,6 +1821,7 @@ std::vector OrganizerCore::fileMapping() return result; } + std::vector OrganizerCore::fileMapping( const QString &dataPath, const QString &relPath, const DirectoryEntry *base, const DirectoryEntry *directoryEntry, int createDestination) @@ -1841,8 +1838,9 @@ std::vector OrganizerCore::fileMapping( QString originPath = QString::fromStdWString(base->getOriginByID(origin).getPath()); QString fileName = QString::fromStdWString(current->getName()); +// QString fileName = ToQString(current->getName()); QString source = originPath + relPath + fileName; - QString target = dataPath + relPath + fileName; + QString target = dataPath + relPath + fileName; if (source != target) { result.push_back({source, target, false, false}); } diff --git a/src/persistentcookiejar.cpp b/src/persistentcookiejar.cpp index 6ca0de39..44537491 100644 --- a/src/persistentcookiejar.cpp +++ b/src/persistentcookiejar.cpp @@ -26,7 +26,7 @@ void PersistentCookieJar::save() { QList cookies = allCookies(); data << static_cast(cookies.size()); - foreach (const QNetworkCookie &cookie, allCookies()) { + for (const QNetworkCookie &cookie : allCookies()) { data << cookie.toRawForm(); } diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index a594f703..c4976d2c 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -200,7 +200,7 @@ void PluginContainer::unloadPlugins() bf::for_each(m_Plugins, clearPlugins()); - foreach (const boost::signals2::connection &connection, m_DiagnosisConnections) { + for (const boost::signals2::connection &connection : m_DiagnosisConnections) { connection.disconnect(); } m_DiagnosisConnections.clear(); @@ -283,7 +283,7 @@ void PluginContainer::loadPlugins() m_PluginLoaders.push_back(pluginLoader.release()); } else { m_FailedPlugins.push_back(pluginName); - qWarning("plugin \"%s\" failed to load", qPrintable(pluginName)); + qWarning("plugin \"%s\" failed to load (may be outdated)", qPrintable(pluginName)); } } } diff --git a/src/profile.cpp b/src/profile.cpp index 8cc60cc0..d71b5a0f 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -163,7 +163,7 @@ void Profile::writeModlistNow() return; } - for (int i = m_ModStatus.size() - 1; i >= 0; --i) { + for (int i = static_cast(m_ModStatus.size()) - 1; i >= 0; --i) { // the priority order was inverted on load so it has to be inverted again unsigned int index = m_ModIndexByPriority[i]; if (index != UINT_MAX) { @@ -311,7 +311,7 @@ void Profile::refreshModStatus() // invert priority order to match that of the pluginlist. Also // give priorities to mods not referenced in the profile for (size_t i = 0; i < m_ModStatus.size(); ++i) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(i); + ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); if (modInfo->alwaysEnabled()) { m_ModStatus[i].m_Enabled = true; } @@ -340,7 +340,7 @@ void Profile::refreshModStatus() if (topInsert < 0) { int offset = topInsert * -1; for (size_t i = 0; i < m_ModStatus.size(); ++i) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(i); + ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); if (modInfo->getFixedPriority() == INT_MAX) { continue; } @@ -636,11 +636,12 @@ bool Profile::enableLocalSaves(bool enable) m_Directory.mkdir("saves"); } } else { - QMessageBox::StandardButton res = QMessageBox::question(QApplication::activeModalWidget(), tr("Delete savegames?"), - tr("Do you want to delete local savegames? (If you select \"No\", the save games " - "will show up again if you re-enable local savegames)"), - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, - QMessageBox::Cancel); + QMessageBox::StandardButton res = QMessageBox::question( + QApplication::activeModalWidget(), tr("Delete savegames?"), + tr("Do you want to delete local savegames? (If you select \"No\", the " + "save games will show up again if you re-enable local savegames)"), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, + QMessageBox::Cancel); if (res == QMessageBox::Yes) { shellDelete(QStringList(m_Directory.absoluteFilePath("saves"))); } else if (res == QMessageBox::No) { diff --git a/src/profile.h b/src/profile.h index ece23ef9..87dd91a5 100644 --- a/src/profile.h +++ b/src/profile.h @@ -174,7 +174,7 @@ public: /** * @return path to this profile **/ - QString absolutePath() const; + virtual QString absolutePath() const override; /** * @return path to this profile's save games diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index 1a47cf74..40f01f0e 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -66,17 +66,15 @@ ProfilesDialog::ProfilesDialog(const QString &profileName, MOBase::IPluginGame c profileIter.next(); QListWidgetItem *item = addItem(profileIter.filePath()); if (profileName == profileIter.fileName()) { - m_ProfilesList->setCurrentItem(item); + ui->profilesList->setCurrentItem(item); } } - QCheckBox *invalidationBox = findChild("invalidationBox"); - BSAInvalidation *invalidation = game->feature(); if (invalidation == nullptr) { - invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game.")); - invalidationBox->setEnabled(false); + ui->invalidationBox->setToolTip(tr("Archive invalidation isn't required for this game.")); + ui->invalidationBox->setEnabled(false); } } @@ -89,13 +87,13 @@ void ProfilesDialog::showEvent(QShowEvent *event) { TutorableDialog::showEvent(event); - if (m_ProfilesList->count() == 0) { - QPoint pos = m_ProfilesList->mapToGlobal(QPoint(0, 0)); - pos.rx() += m_ProfilesList->width() / 2; - pos.ry() += (m_ProfilesList->height() / 2) - 20; + if (ui->profilesList->count() == 0) { + QPoint pos = ui->profilesList->mapToGlobal(QPoint(0, 0)); + pos.rx() += ui->profilesList->width() / 2; + pos.ry() += (ui->profilesList->height() / 2) - 20; QWhatsThis::showText(pos, QObject::tr("Before you can use ModOrganizer, you need to create at least one profile. " - "ATTENTION: Run the game at least once before creating a profile!"), m_ProfilesList); + "ATTENTION: Run the game at least once before creating a profile!"), ui->profilesList); } } @@ -108,7 +106,7 @@ void ProfilesDialog::on_closeButton_clicked() QListWidgetItem *ProfilesDialog::addItem(const QString &name) { QDir profileDir(name); - QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), m_ProfilesList); + QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), ui->profilesList); try { newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(profileDir, m_Game)))); m_FailState = false; @@ -121,10 +119,9 @@ QListWidgetItem *ProfilesDialog::addItem(const QString &name) void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) { try { - QListWidget *profilesList = findChild("profilesList"); - QListWidgetItem *newItem = new QListWidgetItem(name, profilesList); + QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList); newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(new Profile(name, m_Game, useDefaultSettings)))); - profilesList->addItem(newItem); + ui->profilesList->addItem(newItem); m_FailState = false; } catch (const std::exception&) { m_FailState = true; @@ -135,10 +132,9 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) void ProfilesDialog::createProfile(const QString &name, const Profile &reference) { try { - QListWidget *profilesList = findChild("profilesList"); - QListWidgetItem *newItem = new QListWidgetItem(name, profilesList); + QListWidgetItem *newItem = new QListWidgetItem(name, ui->profilesList); newItem->setData(Qt::UserRole, QVariant::fromValue(Profile::Ptr(Profile::createPtrFrom(name, reference, m_Game)))); - profilesList->addItem(newItem); + ui->profilesList->addItem(newItem); m_FailState = false; } catch (const std::exception&) { m_FailState = true; @@ -164,20 +160,23 @@ void ProfilesDialog::on_addProfileButton_clicked() void ProfilesDialog::on_copyProfileButton_clicked() { bool okClicked; - QString name = QInputDialog::getText(this, tr("Name"), tr("Please enter a name for the new profile"), QLineEdit::Normal, QString(), &okClicked); + QString name = QInputDialog::getText( + this, tr("Name"), tr("Please enter a name for the new profile"), + QLineEdit::Normal, QString(), &okClicked); fixDirectoryName(name); if (okClicked) { if (name.size() > 0) { - QListWidget *profilesList = findChild("profilesList"); - try { - const Profile::Ptr currentProfile = profilesList->currentItem()->data(Qt::UserRole).value(); + const Profile::Ptr currentProfile = ui->profilesList->currentItem() + ->data(Qt::UserRole) + .value(); createProfile(name, *currentProfile); } catch (const std::exception &e) { reportError(tr("failed to copy profile: %1").arg(e.what())); } } else { - QMessageBox::warning(this, tr("Invalid name"), tr("Invalid profile name")); + QMessageBox::warning(this, tr("Invalid name"), + tr("Invalid profile name")); } } } @@ -188,13 +187,11 @@ void ProfilesDialog::on_removeProfileButton_clicked() QMessageBox::Yes | QMessageBox::No); if (confirmBox.exec() == QMessageBox::Yes) { - QListWidget *profilesList = findChild("profilesList"); - - Profile::Ptr currentProfile = profilesList->currentItem()->data(Qt::UserRole).value(); + Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value(); QString profilePath; if (currentProfile.get() == nullptr) { profilePath = Settings::instance().getProfileDirectory() - + "/" + profilesList->currentItem()->text(); + + "/" + ui->profilesList->currentItem()->text(); if (QMessageBox::question(this, tr("Profile broken"), tr("This profile you're about to delete seems to be broken or the path is invalid. " "I'm about to delete the following folder: \"%1\". Proceed?").arg(profilePath), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { @@ -205,7 +202,7 @@ void ProfilesDialog::on_removeProfileButton_clicked() // we have to get rid of the it before deleting the directory profilePath = currentProfile->absolutePath(); } - QListWidgetItem* item = profilesList->takeItem(profilesList->currentRow()); + QListWidgetItem* item = ui->profilesList->takeItem(ui->profilesList->currentRow()); if (item != nullptr) { delete item; } @@ -270,53 +267,50 @@ void ProfilesDialog::on_invalidationBox_stateChanged(int state) void ProfilesDialog::on_profilesList_currentItemChanged(QListWidgetItem *current, QListWidgetItem*) { - QCheckBox *invalidationBox = findChild("invalidationBox"); - QCheckBox *localSavesBox = findChild("localSavesBox"); - QPushButton *copyButton = findChild("copyProfileButton"); - QPushButton *removeButton = findChild("removeProfileButton"); - QPushButton *transferButton = findChild("transferButton"); - QPushButton *renameButton = findChild("renameButton"); - if (current != nullptr) { if (!current->data(Qt::UserRole).isValid()) return; const Profile::Ptr currentProfile = current->data(Qt::UserRole).value(); try { bool invalidationSupported = false; - invalidationBox->blockSignals(true); - invalidationBox->setChecked(currentProfile->invalidationActive(&invalidationSupported)); - invalidationBox->setEnabled(invalidationSupported); - invalidationBox->blockSignals(false); + ui->invalidationBox->blockSignals(true); + ui->invalidationBox->setChecked(currentProfile->invalidationActive(&invalidationSupported)); + ui->invalidationBox->setEnabled(invalidationSupported); + ui->invalidationBox->blockSignals(false); bool localSaves = currentProfile->localSavesEnabled(); - transferButton->setEnabled(localSaves); + ui->transferButton->setEnabled(localSaves); // prevent the stateChanged-event for the saves-box from triggering, otherwise it may think local saves // were disabled and delete the files/rename the dir - localSavesBox->blockSignals(true); - localSavesBox->setChecked(localSaves); - localSavesBox->blockSignals(false); + ui->localSavesBox->blockSignals(true); + ui->localSavesBox->setChecked(localSaves); + ui->localSavesBox->blockSignals(false); + + ui->copyProfileButton->setEnabled(true); + ui->removeProfileButton->setEnabled(true); + ui->renameButton->setEnabled(true); - copyButton->setEnabled(true); - removeButton->setEnabled(true); - renameButton->setEnabled(true); + ui->localIniFilesBox->blockSignals(true); + ui->localIniFilesBox->setChecked(currentProfile->localSettingsEnabled()); + ui->localIniFilesBox->blockSignals(false); } catch (const std::exception& E) { reportError(tr("failed to determine if invalidation is active: %1").arg(E.what())); - copyButton->setEnabled(false); - removeButton->setEnabled(false); - renameButton->setEnabled(false); - invalidationBox->setChecked(false); + ui->copyProfileButton->setEnabled(false); + ui->removeProfileButton->setEnabled(false); + ui->renameButton->setEnabled(false); + ui->invalidationBox->setChecked(false); } } else { - invalidationBox->setChecked(false); - copyButton->setEnabled(false); - removeButton->setEnabled(false); - renameButton->setEnabled(false); + ui->invalidationBox->setChecked(false); + ui->copyProfileButton->setEnabled(false); + ui->removeProfileButton->setEnabled(false); + ui->renameButton->setEnabled(false); } } void ProfilesDialog::on_localSavesBox_stateChanged(int state) { - Profile::Ptr currentProfile = m_ProfilesList->currentItem()->data(Qt::UserRole).value(); + Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value(); if (currentProfile->enableLocalSaves(state == Qt::Checked)) { ui->transferButton->setEnabled(state == Qt::Checked); diff --git a/src/profilesdialog.ui b/src/profilesdialog.ui index 0c952877..fe03f466 100644 --- a/src/profilesdialog.ui +++ b/src/profilesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 471 - 318 + 482 + 332 diff --git a/src/shared/util.cpp b/src/shared/util.cpp index 3692aae1..5491a9e6 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -81,12 +81,16 @@ std::wstring ToWString(const std::string &source, bool utf8) if (!utf8) { codepage = AreFileApisANSI() ? GetACP() : GetOEMCP(); } - int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), nullptr, 0); + int sizeRequired + = ::MultiByteToWideChar(codepage, 0, source.c_str(), + static_cast(source.length()), nullptr, 0); if (sizeRequired == 0) { throw windows_error("failed to convert string to wide character"); } result.resize(sizeRequired, L'\0'); - ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), &result[0], sizeRequired); + ::MultiByteToWideChar(codepage, 0, source.c_str(), + static_cast(source.length()), &result[0], + sizeRequired); } return result; diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp index db20a54f..bc818685 100644 --- a/src/usvfsconnector.cpp +++ b/src/usvfsconnector.cpp @@ -76,13 +76,16 @@ LogWorker::~LogWorker() void LogWorker::process() { + int noLogCycles = 0; while (!m_QuitRequested) { if (GetLogMessages(&m_Buffer[0], m_Buffer.size(), false)) { m_LogFile.write(m_Buffer.c_str()); m_LogFile.write("\n"); m_LogFile.flush(); + noLogCycles = 0; } else { - QThread::sleep(1); + QThread::msleep(std::min(40, noLogCycles) * 5); + ++noLogCycles; } } emit finished(); @@ -148,11 +151,13 @@ void UsvfsConnector::updateMapping(const MappingType &mapping) if (value % 10 == 0) { QCoreApplication::processEvents(); } + if (map.isDirectory) { VirtualLinkDirectoryStatic(map.source.toStdWString().c_str(), map.destination.toStdWString().c_str(), (map.createTarget ? LINKFLAG_CREATETARGET : 0) - | LINKFLAG_RECURSIVE); + | LINKFLAG_RECURSIVE + ); } else { VirtualLinkFile(map.source.toStdWString().c_str(), map.destination.toStdWString().c_str(), 0); diff --git a/src/version.rc b/src/version.rc index 028912d7..872c65d7 100644 --- a/src/version.rc +++ b/src/version.rc @@ -1,7 +1,7 @@ #include "Winver.h" -#define VER_FILEVERSION 2,0,4 -#define VER_FILEVERSION_STR "2,0,4alpha\0" +#define VER_FILEVERSION 2,0,5 +#define VER_FILEVERSION_STR "2.0.5beta\0" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION -- cgit v1.3.1