From 8d6c715672023577dca5a6528ff49081dede1052 Mon Sep 17 00:00:00 2001 From: Silarn Date: Wed, 11 Apr 2018 17:46:59 -0500 Subject: Initial archive conflict parsing Squashed commit: Basic archive conflict parsing - pass 1 Merge fixes for archive parsing Basic archive conflict parsing - pass 1 Merge fixes for archive parsing Should fix conflict detection for archive files --- src/pluginlist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index b0f59e1e..04e39abf 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -140,8 +140,8 @@ void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MO for (auto plugin : plugins) { MOShared::FileEntry::Ptr file = directoryEntry.findFile(plugin.toStdWString()); if (file->getOrigin() != origin.getID()) { - const std::vector> alternatives = file->getAlternatives(); - if (std::find_if(alternatives.begin(), alternatives.end(), [&](const std::pair& element) { return element.first == origin.getID(); }) == alternatives.end()) + const std::vector>> alternatives = file->getAlternatives(); + if (std::find_if(alternatives.begin(), alternatives.end(), [&](const std::pair>& element) { return element.first == origin.getID(); }) == alternatives.end()) continue; } std::map::iterator iter = m_ESPsByName.find(plugin.toLower()); -- cgit v1.3.1 From d28ddcfbb52394a2a7ac793ad376ea8fd7b514fe Mon Sep 17 00:00:00 2001 From: Al Date: Mon, 24 Dec 2018 17:29:16 +0100 Subject: Added Active Plugins and Active Mods counters --- src/mainwindow.cpp | 12 ++++++++++++ src/mainwindow.h | 1 + src/mainwindow.ui | 22 +++++++++++++++++++++- src/organizercore.cpp | 4 ++++ src/pluginlist.cpp | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src/pluginlist.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bb136364..74374c2b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -458,6 +458,12 @@ MainWindow::MainWindow(QSettings &initSettings // set the name of the widget to the name of the action to allow styling ui->toolBar->widgetForAction(action)->setObjectName(action->objectName()); } + ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount()); + ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size()); + qDebug("Plugin enabledCount: %d", m_OrganizerCore.pluginList()->enabledCount()); + qDebug("Mods enabledCount: %d", (int)m_OrganizerCore.currentProfile()->getActiveMods().size()); + + } @@ -2186,6 +2192,11 @@ void MainWindow::directory_refreshed() statusBar()->hide(); } +void MainWindow::esplist_changed() +{ + ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount()); +} + void MainWindow::modorder_changed() { for (unsigned int i = 0; i < m_OrganizerCore.currentProfile()->numMods(); ++i) { @@ -2443,6 +2454,7 @@ void MainWindow::restoreBackup_clicked() void MainWindow::modlistChanged(const QModelIndex&, int) { m_OrganizerCore.currentProfile()->writeModlist(); + ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size()); } void MainWindow::modlistSelectionChanged(const QModelIndex ¤t, const QModelIndex&) diff --git a/src/mainwindow.h b/src/mainwindow.h index f66ea5e7..61113b8c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -162,6 +162,7 @@ public slots: void displayColumnSelection(const QPoint &pos); void modorder_changed(); + void esplist_changed(); void refresher_progress(int percent); void directory_refreshed(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7e94000d..067cd4d0 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -179,7 +179,7 @@ 2 - + @@ -224,6 +224,16 @@ p, li { white-space: pre-wrap; } + + + + Active: + + + + + + @@ -853,6 +863,16 @@ p, li { white-space: pre-wrap; } + + + + Active: + + + + + + diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d52ef40b..1f4e3434 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -560,6 +560,10 @@ void OrganizerCore::setUserInterface(IUserInterface *userInterface, SLOT(fileMoved(QString, QString, QString))); connect(&m_ModList, SIGNAL(modorder_changed()), widget, SLOT(modorder_changed())); + connect(&m_PluginList, SIGNAL(writePluginsList()), widget, + SLOT(esplist_changed())); + connect(&m_PluginList, SIGNAL(esplist_changed()), widget, + SLOT(esplist_changed())); connect(&m_DownloadManager, SIGNAL(showMessage(QString)), widget, SLOT(showMessage(QString))); } diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index b0f59e1e..fcb05979 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -846,6 +846,7 @@ void PluginList::generatePluginIndexes() m_ESPs[i].m_Index = QString("%1").arg(l - numESLs - numSkipped, 2, 16, QChar('0')).toUpper(); } } + emit esplist_changed(); } -- cgit v1.3.1 From 93a60177ee7c6b1a6d8d0d7b228ec46fc8e1f318 Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 28 Dec 2018 21:26:59 +0100 Subject: Changed "Loads BSA" flag to finds loaded archives in the entire virtual folder. --- src/pluginlist.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index fcb05979..8f336dae 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -181,15 +181,16 @@ void PluginList::refresh(const QString &profileName } QString filename = ToQString(current->getName()); - availablePlugins.append(filename.toLower()); - - if (m_ESPsByName.find(filename.toLower()) != m_ESPsByName.end()) { - continue; - } - QString extension = filename.right(3).toLower(); if ((extension == "esp") || (extension == "esm") || (extension == "esl")) { + + availablePlugins.append(filename.toLower()); + + if (m_ESPsByName.find(filename.toLower()) != m_ESPsByName.end()) { + continue; + } + bool forceEnabled = Settings::instance().forceEnableCoreFiles() && std::find(primaryPlugins.begin(), primaryPlugins.end(), filename.toLower()) != primaryPlugins.end(); @@ -202,10 +203,12 @@ void PluginList::refresh(const QString &profileName bool hasIni = baseDirectory.findFile(ToWString(iniPath)).get() != nullptr; std::set loadedArchives; - QString originPath = QString::fromWCharArray(origin.getPath().c_str()); - QDir dir(QDir::toNativeSeparators(originPath)); - for (QString filename : dir.entryList(QStringList() << QFileInfo(filename).baseName() + "*.bsa" << QFileInfo(filename).baseName() + "*.ba2")) { - loadedArchives.insert(filename); + for (FileEntry::Ptr archiveCandidate : files) { + QString candidateName = ToQString(archiveCandidate->getName()); + if (candidateName.contains(QRegExp(QFileInfo(filename).baseName() + "*.bsa", Qt::CaseInsensitive, QRegExp::Wildcard)) || + candidateName.contains(QRegExp(QFileInfo(filename).baseName() + "*.ba2", Qt::CaseInsensitive, QRegExp::Wildcard))) { + loadedArchives.insert(candidateName); + } } QString originName = ToQString(origin.getName()); -- cgit v1.3.1 From 299a769a83a883e68ecf47ee928113ed45b533b3 Mon Sep 17 00:00:00 2001 From: Al Date: Sat, 5 Jan 2019 18:44:15 +0100 Subject: Improve performance of refresh (regex and code distribution) --- src/mainwindow.cpp | 8 ++++---- src/pluginlist.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 633ceb5f..52cb894f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -463,8 +463,8 @@ MainWindow::MainWindow(QSettings &initSettings actionWidget->style()->polish(actionWidget); } - emit updatePluginCount(); - emit updateModCount(); + updatePluginCount(); + updateModCount(); } @@ -2223,7 +2223,7 @@ void MainWindow::directory_refreshed() void MainWindow::esplist_changed() { - emit updatePluginCount(); + updatePluginCount(); } void MainWindow::modorder_changed() @@ -2483,7 +2483,7 @@ void MainWindow::restoreBackup_clicked() void MainWindow::modlistChanged(const QModelIndex&, int) { m_OrganizerCore.currentProfile()->writeModlist(); - emit updateModCount(); + updateModCount(); } void MainWindow::modlistSelectionChanged(const QModelIndex ¤t, const QModelIndex&) diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 8f336dae..5171bf19 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -41,6 +41,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -174,6 +175,19 @@ void PluginList::refresh(const QString &profileName QStringList availablePlugins; + QRegExp bsaReg = QRegExp(); + QRegExp ba2Reg = QRegExp(); + bsaReg.setPatternSyntax(QRegExp::Wildcard); + bsaReg.setCaseSensitivity(Qt::CaseInsensitive); + ba2Reg.setPatternSyntax(QRegExp::Wildcard); + ba2Reg.setCaseSensitivity(Qt::CaseInsensitive); + + //TODO: try QRegularExpression when we move to Qt5.12 + /*QRegularExpression bsaReg = QRegularExpression(); + QRegularExpression ba2Reg = QRegularExpression(); + bsaReg.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + ba2Reg.setPatternOptions(QRegularExpression::CaseInsensitiveOption);*/ + std::vector files = baseDirectory.getFiles(); for (FileEntry::Ptr current : files) { if (current.get() == nullptr) { @@ -198,15 +212,23 @@ void PluginList::refresh(const QString &profileName try { FilesOrigin &origin = baseDirectory.getOriginByID(current->getOrigin(archive)); + //name without extension + QString baseName = QFileInfo(filename).baseName(); - QString iniPath = QFileInfo(filename).baseName() + ".ini"; + QString iniPath = baseName + ".ini"; bool hasIni = baseDirectory.findFile(ToWString(iniPath)).get() != nullptr; + bsaReg.setPattern(baseName + "*.bsa"); + ba2Reg.setPattern(baseName + "*.ba2"); + + + //bsaReg.setPattern(QRegularExpression::wildcardToRegularExpression(baseName + "*.bsa")); + //ba2Reg.setPattern(QRegularExpression::wildcardToRegularExpression(baseName + "*.ba2")); std::set loadedArchives; + QString candidateName; for (FileEntry::Ptr archiveCandidate : files) { - QString candidateName = ToQString(archiveCandidate->getName()); - if (candidateName.contains(QRegExp(QFileInfo(filename).baseName() + "*.bsa", Qt::CaseInsensitive, QRegExp::Wildcard)) || - candidateName.contains(QRegExp(QFileInfo(filename).baseName() + "*.ba2", Qt::CaseInsensitive, QRegExp::Wildcard))) { + candidateName = ToQString(archiveCandidate->getName()); + if (candidateName.contains(bsaReg) || candidateName.contains(ba2Reg)) { loadedArchives.insert(candidateName); } } -- cgit v1.3.1 From f2c145b2fc9d6ffce838398e06f7aa583d05887d Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Sat, 5 Jan 2019 16:34:10 -0600 Subject: Change qPrintable to qUtf8Printable to better support non-ASCII text --- src/bbcode.cpp | 2 +- src/directoryrefresher.cpp | 2 +- src/downloadmanager.cpp | 18 +++++++++--------- src/editexecutablesdialog.cpp | 2 +- src/icondelegate.cpp | 2 +- src/installationmanager.cpp | 8 ++++---- src/instancemanager.cpp | 2 +- src/logbuffer.cpp | 14 +++++++------- src/main.cpp | 24 ++++++++++++------------ src/mainwindow.cpp | 20 ++++++++++---------- src/messagedialog.cpp | 2 +- src/moapplication.cpp | 2 +- src/modinforegular.cpp | 2 +- src/modlist.cpp | 2 +- src/nexusinterface.cpp | 8 ++++---- src/nxmaccessmanager.cpp | 6 +++--- src/organizercore.cpp | 24 ++++++++++++------------ src/persistentcookiejar.cpp | 6 +++--- src/plugincontainer.cpp | 14 +++++++------- src/pluginlist.cpp | 12 ++++++------ src/profile.cpp | 18 +++++++++--------- src/profilesdialog.cpp | 2 +- src/selfupdater.cpp | 10 +++++----- src/settings.cpp | 4 ++-- src/usvfsconnector.cpp | 2 +- 25 files changed, 104 insertions(+), 104 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/bbcode.cpp b/src/bbcode.cpp index 56369538..84d7a7c0 100644 --- a/src/bbcode.cpp +++ b/src/bbcode.cpp @@ -88,7 +88,7 @@ public: return temp.replace(tagIter->second.first, QString("%2").arg(color, content)); } } else { - qWarning("don't know how to deal with tag %s", qPrintable(tagName)); + qWarning("don't know how to deal with tag %s", qUtf8Printable(tagName)); } } else { if (tagName == "*") { diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index 272b0596..cc745cc8 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -117,7 +117,7 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu origin.addFile(file->getIndex()); file->addOrigin(origin.getID(), file->getFileTime(), L""); } else { - qWarning("%s not found", qPrintable(fileInfo.fileName())); + qWarning("%s not found", qUtf8Printable(fileInfo.fileName())); } } } else { diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index b408f1a6..15831126 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -400,7 +400,7 @@ bool DownloadManager::addDownload(const QStringList &URLs, QString gameName, } QUrl preferredUrl = QUrl::fromEncoded(URLs.first().toLocal8Bit()); - qDebug("selected download url: %s", qPrintable(preferredUrl.toString())); + qDebug("selected download url: %s", qUtf8Printable(preferredUrl.toString())); QNetworkRequest request(preferredUrl); request.setHeader(QNetworkRequest::UserAgentHeader, m_NexusInterface->getAccessManager()->userAgent()); return addDownload(m_NexusInterface->getAccessManager()->get(request), URLs, fileName, gameName, modID, fileID, fileInfo); @@ -540,9 +540,9 @@ void DownloadManager::addNXMDownload(const QString &url) QStringList validGames; validGames.append(m_ManagedGame->gameShortName()); validGames.append(m_ManagedGame->validShortNames()); - qDebug("add nxm download: %s", qPrintable(url)); + qDebug("add nxm download: %s", qUtf8Printable(url)); if (!validGames.contains(nxmInfo.game(), Qt::CaseInsensitive)) { - qDebug("download requested for wrong game (game: %s, url: %s)", qPrintable(m_ManagedGame->gameShortName()), qPrintable(nxmInfo.game())); + qDebug("download requested for wrong game (game: %s, url: %s)", qUtf8Printable(m_ManagedGame->gameShortName()), qUtf8Printable(nxmInfo.game())); QMessageBox::information(nullptr, 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(m_ManagedGame->gameShortName()), QMessageBox::Ok); return; @@ -550,7 +550,7 @@ void DownloadManager::addNXMDownload(const QString &url) for (auto tuple : m_PendingDownloads) { if (std::get<0>(tuple).compare(nxmInfo.game(), Qt::CaseInsensitive) == 0, std::get<1>(tuple) == nxmInfo.modId() && std::get<2>(tuple) == nxmInfo.fileId()) { - qDebug("download requested is already started (mod id: %s, file id: %s)", qPrintable(QString(nxmInfo.modId())), qPrintable(QString(nxmInfo.fileId()))); + qDebug("download requested is already started (mod id: %s, file id: %s)", qUtf8Printable(QString(nxmInfo.modId())), qUtf8Printable(QString(nxmInfo.fileId()))); QMessageBox::information(nullptr, tr("Already Started"), tr("A download for this mod file has already been queued."), QMessageBox::Ok); return; } @@ -559,8 +559,8 @@ void DownloadManager::addNXMDownload(const QString &url) for (DownloadInfo *download : m_ActiveDownloads) { if (download->m_FileInfo->modID == nxmInfo.modId() && download->m_FileInfo->fileID == nxmInfo.fileId()) { if (download->m_State == STATE_DOWNLOADING || download->m_State == STATE_PAUSED || download->m_State == STATE_STARTED) { - qDebug("download requested is already started (mod: %s, file: %s)", qPrintable(QString(download->m_FileInfo->modID)), - qPrintable(download->m_FileInfo->fileName)); + qDebug("download requested is already started (mod: %s, file: %s)", qUtf8Printable(QString(download->m_FileInfo->modID)), + qUtf8Printable(download->m_FileInfo->fileName)); QMessageBox::information(nullptr, tr("Already Started"), tr("There is already a download started for this file (mod: %1, file: %2).") .arg(download->m_FileInfo->modName).arg(download->m_FileInfo->fileName), QMessageBox::Ok); @@ -814,7 +814,7 @@ void DownloadManager::resumeDownloadInt(int index) if (info->m_State == STATE_ERROR) { info->m_CurrentUrl = (info->m_CurrentUrl + 1) % info->m_Urls.count(); } - qDebug("request resume from url %s", qPrintable(info->currentURL())); + qDebug("request resume from url %s", qUtf8Printable(info->currentURL())); QNetworkRequest request(QUrl::fromEncoded(info->currentURL().toLocal8Bit())); request.setHeader(QNetworkRequest::UserAgentHeader, m_NexusInterface->getAccessManager()->userAgent()); if (info->m_State != STATE_ERROR) { @@ -1434,7 +1434,7 @@ QDateTime DownloadManager::matchDate(const QString &timeString) if (m_DateExpression.exactMatch(timeString)) { return QDateTime::fromMSecsSinceEpoch(m_DateExpression.cap(1).toLongLong()); } else { - qWarning("date not matched: %s", qPrintable(timeString)); + qWarning("date not matched: %s", qUtf8Printable(timeString)); return QDateTime::currentDateTime(); } } @@ -1783,7 +1783,7 @@ void DownloadManager::downloadError(QNetworkReply::NetworkError error) { if (error != QNetworkReply::OperationCanceledError) { QNetworkReply *reply = qobject_cast(sender()); - qWarning("%s (%d)", reply != nullptr ? qPrintable(reply->errorString()) + qWarning("%s (%d)", reply != nullptr ? qUtf8Printable(reply->errorString()) : "Download error occured", error); } diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index fde6b397..be2ee127 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -324,7 +324,7 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur QString customOverwrite = m_Profile->setting("custom_overwrites", selectedExecutable.m_Title).toString(); if (!customOverwrite.isEmpty()) { index = ui->newFilesModBox->findText(customOverwrite); - qDebug("find %s -> %d", qPrintable(customOverwrite), index); + qDebug("find %s -> %d", qUtf8Printable(customOverwrite), index); } ui->newFilesModCheckBox->setChecked(index != -1); diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index e502dc69..249dae6f 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -54,7 +54,7 @@ void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, if (!QPixmapCache::find(fullIconId, &icon)) { icon = QIcon(iconId).pixmap(iconWidth, iconWidth); if (icon.isNull()) { - qWarning("failed to load icon %s", qPrintable(iconId)); + qWarning("failed to load icon %s", qUtf8Printable(iconId)); } QPixmapCache::insert(fullIconId, icon); } diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 76b1e086..57c5e861 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -758,7 +758,7 @@ bool InstallationManager::install(const QString &fileName, if (fileInfo.dir() == QDir(m_DownloadsDirectory)) { m_CurrentFile = fileInfo.fileName(); } - qDebug("using mod name \"%s\" (id %d) -> %s", modName->toUtf8().constData(), modID, qPrintable(m_CurrentFile)); + qDebug("using mod name \"%s\" (id %d) -> %s", modName->toUtf8().constData(), modID, qUtf8Printable(m_CurrentFile)); //If there's an archive already open, close it. This happens with the bundle //installer when it uncompresses a split archive, then finds it has a real archive @@ -770,8 +770,8 @@ bool InstallationManager::install(const QString &fileName, new MethodCallback(this, &InstallationManager::queryPassword)); if (!archiveOpen) { qDebug("integrated archiver can't open %s: %s (%d)", - qPrintable(fileName), - qPrintable(getErrorString(m_ArchiveHandler->getLastError())), + qUtf8Printable(fileName), + qUtf8Printable(getErrorString(m_ArchiveHandler->getLastError())), m_ArchiveHandler->getLastError()); } ON_BLOCK_EXIT(std::bind(&InstallationManager::postInstallCleanup, this)); @@ -841,7 +841,7 @@ bool InstallationManager::install(const QString &fileName, } } catch (const IncompatibilityException &e) { qCritical("plugin \"%s\" incompatible: %s", - qPrintable(installer->name()), e.what()); + qUtf8Printable(installer->name()), e.what()); } // act upon the installation result. at this point the files have already been diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index 9066741d..a5a52d63 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -86,7 +86,7 @@ bool InstanceManager::deleteLocalInstance(const QString &instanceId) const if (!MOBase::shellDelete(QStringList(instancePath),true)) { - qWarning("Failed to shell-delete \"%s\" (errorcode %lu), trying regular delete", qPrintable(instancePath), ::GetLastError()); + qWarning("Failed to shell-delete \"%s\" (errorcode %lu), trying regular delete", qUtf8Printable(instancePath), ::GetLastError()); if (!MOBase::removeDir(instancePath)) { qWarning("regular delete failed too"); diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp index 522ce3c8..485e27db 100644 --- a/src/logbuffer.cpp +++ b/src/logbuffer.cpp @@ -127,7 +127,7 @@ void LogBuffer::log(QtMsgType type, const QMessageLogContext &context, { // QMutexLocker doesn't support timeout... if (!s_Mutex.tryLock(100)) { - fprintf(stderr, "failed to log: %s", qPrintable(message)); + fprintf(stderr, "failed to log: %s", qUtf8Printable(message)); return; } ON_BLOCK_EXIT([]() { s_Mutex.unlock(); }); @@ -137,17 +137,17 @@ void LogBuffer::log(QtMsgType type, const QMessageLogContext &context, } if (type == QtDebugMsg) { - fprintf(stdout, "%s [%c] %s\n", qPrintable(QTime::currentTime().toString()), - msgTypeID(type), qPrintable(message)); + fprintf(stdout, "%s [%c] %s\n", qUtf8Printable(QTime::currentTime().toString()), + msgTypeID(type), qUtf8Printable(message)); } else { if (context.line != 0) { fprintf(stdout, "%s [%c] (%s:%u) %s\n", - qPrintable(QTime::currentTime().toString()), msgTypeID(type), - context.file, context.line, qPrintable(message)); + qUtf8Printable(QTime::currentTime().toString()), msgTypeID(type), + context.file, context.line, qUtf8Printable(message)); } else { fprintf(stdout, "%s [%c] %s\n", - qPrintable(QTime::currentTime().toString()), msgTypeID(type), - qPrintable(message)); + qUtf8Printable(QTime::currentTime().toString()), msgTypeID(type), + qUtf8Printable(message)); } } fflush(stdout); diff --git a/src/main.cpp b/src/main.cpp index 4d2bb7ed..190a8f4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -262,7 +262,7 @@ QString determineProfile(QStringList &arguments, const QSettings &settings) qDebug("no configured profile"); selectedProfileName = "Default"; } else { - qDebug("configured profile: %s", qPrintable(selectedProfileName)); + qDebug("configured profile: %s", qUtf8Printable(selectedProfileName)); } return selectedProfileName; @@ -401,7 +401,7 @@ void setupPath() { static const int BUFSIZE = 4096; - qDebug("MO at: %s", qPrintable(QDir::toNativeSeparators( + qDebug("MO at: %s", qUtf8Printable(QDir::toNativeSeparators( QCoreApplication::applicationDirPath()))); QCoreApplication::setLibraryPaths(QStringList(QCoreApplication::applicationDirPath() + "/dlls") + QCoreApplication::libraryPaths()); @@ -429,18 +429,18 @@ static void preloadSsl() else { QString libeay32 = appPath + "\\libeay32.dll"; if (!QFile::exists(libeay32)) - qWarning("libeay32.dll not found: %s", qPrintable(libeay32)); + qWarning("libeay32.dll not found: %s", qUtf8Printable(libeay32)); else if (!LoadLibraryW(libeay32.toStdWString().c_str())) - qWarning("failed to load: %s, %d", qPrintable(libeay32), GetLastError()); + qWarning("failed to load: %s, %d", qUtf8Printable(libeay32), GetLastError()); } if (GetModuleHandleA("ssleay32.dll")) qWarning("ssleay32.dll already loaded?!"); else { QString ssleay32 = appPath + "\\ssleay32.dll"; if (!QFile::exists(ssleay32)) - qWarning("ssleay32.dll not found: %s", qPrintable(ssleay32)); + qWarning("ssleay32.dll not found: %s", qUtf8Printable(ssleay32)); else if (!LoadLibraryW(ssleay32.toStdWString().c_str())) - qWarning("failed to load: %s, %d", qPrintable(ssleay32), GetLastError()); + qWarning("failed to load: %s, %d", qUtf8Printable(ssleay32), GetLastError()); } } @@ -453,7 +453,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, const QString &splashPath) { - qDebug("Starting Mod Organizer version %s revision %s", qPrintable(getVersionDisplayString()), + qDebug("Starting Mod Organizer version %s revision %s", qUtf8Printable(getVersionDisplayString()), #if defined(HGID) HGID #elif defined(GITID) @@ -471,7 +471,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, #endif QString dataPath = application.property("dataPath").toString(); - qDebug("data path: %s", qPrintable(dataPath)); + qDebug("data path: %s", qUtf8Printable(dataPath)); if (!bootstrap()) { reportError("failed to set up data paths"); @@ -483,7 +483,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, QStringList arguments = application.arguments(); try { - qDebug("Working directory: %s", qPrintable(QDir::toNativeSeparators(QDir::currentPath()))); + qDebug("Working directory: %s", qUtf8Printable(QDir::toNativeSeparators(QDir::currentPath()))); QSettings settings(dataPath + "/" + QString::fromStdWString(AppConfig::iniFileName()), @@ -552,7 +552,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, } game->setGameVariant(settings.value("game_edition").toString()); - qDebug("managing game at %s", qPrintable(QDir::toNativeSeparators( + qDebug("managing game at %s", qUtf8Printable(QDir::toNativeSeparators( game->gameDirectory().absolutePath()))); organizer.updateExecutablesList(settings); @@ -578,12 +578,12 @@ int runApplication(MOApplication &application, SingleInstance &instance, } else if (OrganizerCore::isNxmLink(arguments.at(1))) { qDebug("starting download from command line: %s", - qPrintable(arguments.at(1))); + qUtf8Printable(arguments.at(1))); organizer.externalMessage(arguments.at(1)); } else { QString exeName = arguments.at(1); - qDebug("starting %s from command line", qPrintable(exeName)); + qDebug("starting %s from command line", qUtf8Printable(exeName)); arguments.removeFirst(); // remove application name (ModOrganizer.exe) arguments.removeFirst(); // remove binary name // pass the remaining parameters to the binary diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 83205ac4..ae37968c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1558,7 +1558,7 @@ void MainWindow::refreshSaveList() QDir savesDir = currentSavesDir(); savesDir.setNameFilters(filters); - qDebug("reading save games from %s", qPrintable(savesDir.absolutePath())); + qDebug("reading save games from %s", qUtf8Printable(savesDir.absolutePath())); QFileInfoList files = savesDir.entryInfoList(QDir::Files, QDir::Time); for (const QFileInfo &file : files) { @@ -1763,7 +1763,7 @@ void MainWindow::setupNetworkProxy(bool activate) query.setProtocolTag("http"); QList proxies = QNetworkProxyFactory::systemProxyForQuery(query); if ((proxies.size() > 0) && (proxies.at(0).type() != QNetworkProxy::NoProxy)) { - qDebug("Using proxy: %s", qPrintable(proxies.at(0).hostName())); + qDebug("Using proxy: %s", qUtf8Printable(proxies.at(0).hostName())); QNetworkProxy::setApplicationProxy(proxies[0]); } else { qDebug("Not using proxy"); @@ -2418,7 +2418,7 @@ void MainWindow::refreshFilters() while (currentID != 0) { categoriesUsed.insert(currentID); if (!cycleTest.insert(currentID).second) { - qWarning("cycle in categories: %s", qPrintable(SetJoin(cycleTest, ", "))); + qWarning("cycle in categories: %s", qUtf8Printable(SetJoin(cycleTest, ", "))); break; } currentID = m_CategoryFactory.getParentID(m_CategoryFactory.getCategoryIndex(currentID)); @@ -2732,7 +2732,7 @@ void MainWindow::unendorse_clicked() void MainWindow::loginFailed(const QString &error) { - qDebug("login failed: %s", qPrintable(error)); + qDebug("login failed: %s", qUtf8Printable(error)); statusBar()->hide(); } @@ -3711,7 +3711,7 @@ void MainWindow::addRemoveCategories_MenuHandler() { int maxRow = -1; for (const QPersistentModelIndex &idx : selected) { - qDebug("change categories on: %s", qPrintable(idx.data().toString())); + qDebug("change categories on: %s", qUtf8Printable(idx.data().toString())); QModelIndex modIdx = mapToModel(m_OrganizerCore.modList(), idx); if (modIdx.row() != m_ContextIdx.row()) { addRemoveCategoriesFromMenu(menu, modIdx.row(), m_ContextIdx.row()); @@ -3793,7 +3793,7 @@ void MainWindow::saveArchiveList() } } if (archiveFile.commitIfDifferent(m_ArchiveListHash)) { - qDebug("%s saved", qPrintable(QDir::toNativeSeparators(m_OrganizerCore.currentProfile()->getArchivesFileName()))); + qDebug("%s saved", qUtf8Printable(QDir::toNativeSeparators(m_OrganizerCore.currentProfile()->getArchivesFileName()))); } } else { qWarning("archive list not initialised"); @@ -4693,7 +4693,7 @@ void MainWindow::installTranslator(const QString &name) QString fileName = name + "_" + m_CurrentLanguage; if (!translator->load(fileName, qApp->applicationDirPath() + "/translations")) { if (m_CurrentLanguage.compare("en", Qt::CaseInsensitive)) { - qDebug("localization file %s not found", qPrintable(fileName)); + qDebug("localization file %s not found", qUtf8Printable(fileName)); } // we don't actually expect localization files for English } @@ -4718,7 +4718,7 @@ void MainWindow::languageChange(const QString &newLanguage) installTranslator(QFileInfo(fileName).baseName()); } ui->retranslateUi(this); - qDebug("loaded language %s", qPrintable(newLanguage)); + qDebug("loaded language %s", qUtf8Printable(newLanguage)); ui->profileBox->setItemText(0, QObject::tr("")); @@ -6134,7 +6134,7 @@ void MainWindow::dropLocalFile(const QUrl &url, const QString &outputDir, bool m { QFileInfo file(url.toLocalFile()); if (!file.exists()) { - qWarning("invalid source file %s", qPrintable(file.absoluteFilePath())); + qWarning("invalid source file %s", qUtf8Printable(file.absoluteFilePath())); return; } QString target = outputDir + "/" + file.fileName(); @@ -6167,7 +6167,7 @@ void MainWindow::dropLocalFile(const QUrl &url, const QString &outputDir, bool m success = shellCopy(file.absoluteFilePath(), target, true, this); } if (!success) { - qCritical("file operation failed: %s", qPrintable(windowsErrorString(::GetLastError()))); + qCritical("file operation failed: %s", qUtf8Printable(windowsErrorString(::GetLastError()))); } } diff --git a/src/messagedialog.cpp b/src/messagedialog.cpp index 90b0a9d3..6c6de3e7 100644 --- a/src/messagedialog.cpp +++ b/src/messagedialog.cpp @@ -81,7 +81,7 @@ void MessageDialog::resizeEvent(QResizeEvent *event) void MessageDialog::showMessage(const QString &text, QWidget *reference, bool bringToFront) { - qDebug("%s", qPrintable(text)); + qDebug("%s", qUtf8Printable(text)); if (reference != nullptr) { if (bringToFront || (qApp->activeWindow() != nullptr)) { MessageDialog *dialog = new MessageDialog(text, reference); diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 9ddd9e54..3a791827 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -137,7 +137,7 @@ void MOApplication::updateStyle(const QString &fileName) if (QFile::exists(fileName)) { setStyleSheet(QString("file:///%1").arg(fileName)); } else { - qWarning("invalid stylesheet: %s", qPrintable(fileName)); + qWarning("invalid stylesheet: %s", qUtf8Printable(fileName)); } } } diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 548e3178..45c3985b 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -302,7 +302,7 @@ bool ModInfoRegular::setName(const QString &name) } else { if (!shellRename(modDir.absoluteFilePath(m_Name), modDir.absoluteFilePath(name))) { qCritical("failed to rename mod %s (errorcode %d)", - qPrintable(name), ::GetLastError()); + qUtf8Printable(name), ::GetLastError()); return false; } } diff --git a/src/modlist.cpp b/src/modlist.cpp index 2cb74d50..c1954b39 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -960,7 +960,7 @@ bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &pa QString overwriteName = ModInfo::getByIndex(overwriteIndex)->name(); for (const QUrl &url : mimeData->urls()) { - qDebug("URL drop requested: %s", qPrintable(url.toLocalFile())); + qDebug("URL drop requested: %s", qUtf8Printable(url.toLocalFile())); if (!url.isLocalFile()) { qDebug("URL drop ignored: Not a local file."); continue; diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index e97e9800..c6f05405 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -226,7 +226,7 @@ void NexusInterface::interpretNexusFileName(const QString &fileName, QString &mo } else { modID = strtol(candidate.c_str(), nullptr, 10); } - qDebug("mod id guessed: %s -> %d", qPrintable(fileName), modID); + qDebug("mod id guessed: %s -> %d", qUtf8Printable(fileName), modID); } else if (std::regex_search(fileNameUTF8.constData(), result, simpleexp)) { qDebug("simple expression matched, using name only"); modName = QString::fromUtf8(result[1].str().c_str()); @@ -542,7 +542,7 @@ void NexusInterface::requestFinished(std::list::iterator iter) if (nexusError.length() == 0) { nexusError = tr("empty response"); } - qDebug("nexus error: %s", qPrintable(nexusError)); + qDebug("nexus error: %s", qUtf8Printable(nexusError)); emit nxmRequestFailed(iter->m_GameName, iter->m_ModID, iter->m_FileID, iter->m_UserData, iter->m_ID, nexusError); } else { bool ok; @@ -602,8 +602,8 @@ void NexusInterface::requestError(QNetworkReply::NetworkError) } qCritical("request (%s) error: %s (%d)", - qPrintable(reply->url().toString()), - qPrintable(reply->errorString()), + qUtf8Printable(reply->url().toString()), + qUtf8Printable(reply->errorString()), reply->error()); } diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 426c8b9c..912eab30 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -106,7 +106,7 @@ void NXMAccessManager::showCookies() const for (const QNetworkCookie &cookie : cookieJar()->cookiesForUrl(url)) { qDebug("%s - %s (expires: %s)", cookie.name().constData(), cookie.value().constData(), - qPrintable(cookie.expirationDate().toString())); + qUtf8Printable(cookie.expirationDate().toString())); } } @@ -164,7 +164,7 @@ void NXMAccessManager::retrieveCredentials() connect(reply, static_cast(&QNetworkReply::error), [=] (QNetworkReply::NetworkError) { - qDebug("failed to retrieve account credentials: %s", qPrintable(reply->errorString())); + qDebug("failed to retrieve account credentials: %s", qUtf8Printable(reply->errorString())); reply->deleteLater(); }); } @@ -235,7 +235,7 @@ QString NXMAccessManager::userAgent(const QString &subModule) const void NXMAccessManager::pageLogin() { - qDebug("logging %s in on Nexus", qPrintable(m_Username)); + qDebug("logging %s in on Nexus", qUtf8Printable(m_Username)); QString requestString = (Nexus_Management_URL + "/Sessions/?Login&uri=%1") .arg(QString(QUrl::toPercentEncoding(Nexus_Management_URL))); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 9ebe9f47..c4029a6d 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -47,7 +47,7 @@ #include #include -#include // for qPrintable, etc +#include // for qUtf8Printable, etc #include #include @@ -89,8 +89,8 @@ static bool isOnline() continue; } qDebug("interface %s seems to be up (address: %s)", - qPrintable(iter->humanReadableName()), - qPrintable(addresses[0].ip().toString())); + qUtf8Printable(iter->humanReadableName()), + qUtf8Printable(addresses[0].ip().toString())); connected = true; } } @@ -640,7 +640,7 @@ bool OrganizerCore::nexusLogin(bool retry) if ((!retry && m_Settings.getNexusLogin(username, password)) || (m_AskForNexusPW && queryLogin(username, password))) { // credentials stored or user entered them manually - qDebug("attempt login with username %s", qPrintable(username)); + qDebug("attempt login with username %s", qUtf8Printable(username)); accessManager->login(username, password); return true; } else { @@ -681,7 +681,7 @@ void OrganizerCore::startMOUpdate() void OrganizerCore::downloadRequestedNXM(const QString &url) { - qDebug("download requested: %s", qPrintable(url)); + qDebug("download requested: %s", qUtf8Printable(url)); if (nexusLogin()) { m_PendingDownloads.append(url); } else { @@ -1116,7 +1116,7 @@ QStringList OrganizerCore::findFiles( } } } else { - qWarning("directory %s not found", qPrintable(path)); + qWarning("directory %s not found", qUtf8Printable(path)); } return result; } @@ -1135,7 +1135,7 @@ QStringList OrganizerCore::getFileOrigins(const QString &fileName) const ToQString(m_DirectoryStructure->getOriginByID(i.first).getName())); } } else { - qDebug("%s not found", qPrintable(fileName)); + qDebug("%s not found", qUtf8Printable(fileName)); } return result; } @@ -1402,7 +1402,7 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary, } } else { qDebug("start of \"%s\" canceled by plugin", - qPrintable(binary.absoluteFilePath())); + qUtf8Printable(binary.absoluteFilePath())); return INVALID_HANDLE_VALUE; } } @@ -1781,7 +1781,7 @@ void OrganizerCore::updateModActiveState(int index, bool active) dir.entryList(QStringList() << "*.esm", QDir::Files)) { const FileEntry::Ptr file = m_DirectoryStructure->findFile(ToWString(esm)); if (file.get() == nullptr) { - qWarning("failed to activate %s", qPrintable(esm)); + qWarning("failed to activate %s", qUtf8Printable(esm)); continue; } @@ -1797,7 +1797,7 @@ void OrganizerCore::updateModActiveState(int index, bool active) dir.entryList(QStringList() << "*.esl", QDir::Files)) { const FileEntry::Ptr file = m_DirectoryStructure->findFile(ToWString(esl)); if (file.get() == nullptr) { - qWarning("failed to activate %s", qPrintable(esl)); + qWarning("failed to activate %s", qUtf8Printable(esl)); continue; } @@ -1813,7 +1813,7 @@ void OrganizerCore::updateModActiveState(int index, bool active) for (const QString &esp : esps) { const FileEntry::Ptr file = m_DirectoryStructure->findFile(ToWString(esp)); if (file.get() == nullptr) { - qWarning("failed to activate %s", qPrintable(esp)); + qWarning("failed to activate %s", qUtf8Printable(esp)); continue; } @@ -2140,7 +2140,7 @@ std::vector OrganizerCore::activeProblems() const // of a "log spam". But since this is a sevre error which will most likely make the // game crash/freeze/etc. and is very hard to diagnose, this "log spam" will make it // easier for the user to notice the warning. - qWarning("hook.dll found in game folder: %s", qPrintable(hookdll)); + qWarning("hook.dll found in game folder: %s", qUtf8Printable(hookdll)); problems.push_back(PROBLEM_MO1SCRIPTEXTENDERWORKAROUND); } return problems; diff --git a/src/persistentcookiejar.cpp b/src/persistentcookiejar.cpp index a6eb78fa..1ed463c6 100644 --- a/src/persistentcookiejar.cpp +++ b/src/persistentcookiejar.cpp @@ -11,7 +11,7 @@ PersistentCookieJar::PersistentCookieJar(const QString &fileName, QObject *paren } PersistentCookieJar::~PersistentCookieJar() { - qDebug("save %s", qPrintable(m_FileName)); + qDebug("save %s", qUtf8Printable(m_FileName)); save(); } @@ -40,14 +40,14 @@ void PersistentCookieJar::save() { QFile oldCookies(m_FileName); if (oldCookies.exists()) { if (!oldCookies.remove()) { - qCritical("failed to save cookies: failed to remove %s", qPrintable(m_FileName)); + qCritical("failed to save cookies: failed to remove %s", qUtf8Printable(m_FileName)); return; } } // if it doesn't exists that's fine } if (!file.copy(m_FileName)) { - qCritical("failed to save cookies: failed to write %s", qPrintable(m_FileName)); + qCritical("failed to save cookies: failed to write %s", qUtf8Printable(m_FileName)); } } diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 8935c472..46a95f0c 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -160,12 +160,12 @@ bool PluginContainer::registerPlugin(QObject *plugin, const QString &fileName) for (QObject *proxiedPlugin : matchingPlugins) { if (proxiedPlugin != nullptr) { if (registerPlugin(proxiedPlugin, pluginName)) { - qDebug("loaded plugin \"%s\"", qPrintable(QFileInfo(pluginName).fileName())); + qDebug("loaded plugin \"%s\"", qUtf8Printable(QFileInfo(pluginName).fileName())); } else { qWarning("plugin \"%s\" failed to load. If this plugin is for an older version of MO " "you have to update it or delete it if no update exists.", - qPrintable(pluginName)); + qUtf8Printable(pluginName)); } } } @@ -220,7 +220,7 @@ void PluginContainer::unloadPlugins() QPluginLoader *loader = m_PluginLoaders.back(); m_PluginLoaders.pop_back(); if ((loader != nullptr) && !loader->unload()) { - qDebug("failed to unload %s: %s", qPrintable(loader->fileName()), qPrintable(loader->errorString())); + qDebug("failed to unload %s: %s", qUtf8Printable(loader->fileName()), qUtf8Printable(loader->errorString())); } delete loader; } @@ -275,7 +275,7 @@ void PluginContainer::loadPlugins() while (iter.hasNext()) { iter.next(); if (m_Organizer->settings().pluginBlacklisted(iter.fileName())) { - qDebug("plugin \"%s\" blacklisted", qPrintable(iter.fileName())); + qDebug("plugin \"%s\" blacklisted", qUtf8Printable(iter.fileName())); continue; } loadCheck.write(iter.fileName().toUtf8()); @@ -287,14 +287,14 @@ void PluginContainer::loadPlugins() if (pluginLoader->instance() == nullptr) { m_FailedPlugins.push_back(pluginName); qCritical("failed to load plugin %s: %s", - qPrintable(pluginName), qPrintable(pluginLoader->errorString())); + qUtf8Printable(pluginName), qUtf8Printable(pluginLoader->errorString())); } else { if (registerPlugin(pluginLoader->instance(), pluginName)) { - qDebug("loaded plugin \"%s\"", qPrintable(QFileInfo(pluginName).fileName())); + qDebug("loaded plugin \"%s\"", qUtf8Printable(QFileInfo(pluginName).fileName())); m_PluginLoaders.push_back(pluginLoader.release()); } else { m_FailedPlugins.push_back(pluginName); - qWarning("plugin \"%s\" failed to load (may be outdated)", qPrintable(pluginName)); + qWarning("plugin \"%s\" failed to load (may be outdated)", qUtf8Printable(pluginName)); } } } diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 5171bf19..6f417331 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -182,7 +182,7 @@ void PluginList::refresh(const QString &profileName ba2Reg.setPatternSyntax(QRegExp::Wildcard); ba2Reg.setCaseSensitivity(Qt::CaseInsensitive); - //TODO: try QRegularExpression when we move to Qt5.12 + //TODO: try QRegularExpression when we move to Qt5.12 /*QRegularExpression bsaReg = QRegularExpression(); QRegularExpression ba2Reg = QRegularExpression(); bsaReg.setPatternOptions(QRegularExpression::CaseInsensitiveOption); @@ -435,7 +435,7 @@ void PluginList::addInformation(const QString &name, const QString &message) if (iter != m_ESPsByName.end()) { m_AdditionalInfo[name.toLower()].m_Messages.append(message); } else { - qWarning("failed to associate message for \"%s\"", qPrintable(name)); + qWarning("failed to associate message for \"%s\"", qUtf8Printable(name)); } } @@ -499,7 +499,7 @@ void PluginList::writeLockedOrder(const QString &fileName) const file->write(QString("%1|%2\r\n").arg(iter->first).arg(iter->second).toUtf8()); } file.commit(); - qDebug("%s saved", QDir::toNativeSeparators(fileName).toUtf8().constData()); + qDebug("%s saved", qUtf8Printable(QDir::toNativeSeparators(fileName))); } @@ -524,7 +524,7 @@ void PluginList::saveTo(const QString &lockedOrderFileName } } if (deleterFile.commitIfDifferent(m_LastSaveHash[deleterFileName])) { - qDebug("%s saved", qPrintable(QDir::toNativeSeparators(deleterFileName))); + qDebug("%s saved", qUtf8Printable(QDir::toNativeSeparators(deleterFileName))); } } else if (QFile::exists(deleterFileName)) { shellDelete(QStringList() << deleterFileName); @@ -712,7 +712,7 @@ void PluginList::setState(const QString &name, PluginStates state) { m_ESPs[iter->second].m_Enabled = (state == IPluginList::STATE_ACTIVE) || m_ESPs[iter->second].m_ForceEnabled; } else { - qWarning("plugin %s not found", qPrintable(name)); + qWarning("plugin %s not found", qUtf8Printable(name)); } } @@ -1386,7 +1386,7 @@ PluginList::ESPInfo::ESPInfo(const QString &name, bool enabled, m_Masters.insert(QString(iter->c_str())); } } catch (const std::exception &e) { - qCritical("failed to parse plugin file %s: %s", qPrintable(fullPath), e.what()); + qCritical("failed to parse plugin file %s: %s", qUtf8Printable(fullPath), e.what()); m_IsMaster = false; m_IsLight = false; m_IsLightFlagged = false; diff --git a/src/profile.cpp b/src/profile.cpp index 9da1a698..e8ead8e8 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -40,7 +40,7 @@ along with Mod Organizer. If not, see . #include #include // for QStringList #include // for qDebug, qWarning, etc -#include // for qPrintable +#include // for qUtf8Printable #include #include @@ -124,7 +124,7 @@ Profile::Profile(const QDir &directory, IPluginGame const *gamePlugin) findProfileSettings(); if (!QFile::exists(m_Directory.filePath("modlist.txt"))) { - qWarning("missing modlist.txt in %s", qPrintable(directory.path())); + qWarning("missing modlist.txt in %s", qUtf8Printable(directory.path())); touchFile(m_Directory.filePath("modlist.txt")); } @@ -252,7 +252,7 @@ void Profile::doWriteModlist() } if (file.commitIfDifferent(m_LastModlistHash)) { - qDebug("%s saved", QDir::toNativeSeparators(fileName).toUtf8().constData()); + qDebug("%s saved", qUtf8Printable(QDir::toNativeSeparators(fileName))); } } catch (const std::exception &e) { reportError(tr("failed to write mod list: %1").arg(e.what())); @@ -288,7 +288,7 @@ void Profile::createTweakedIniFile() if (error) { reportError(tr("failed to create tweaked ini: %1").arg(getCurrentErrorString().c_str())); } - qDebug("%s saved", qPrintable(QDir::toNativeSeparators(tweakedIni))); + qDebug("%s saved", qUtf8Printable(QDir::toNativeSeparators(tweakedIni))); } // static @@ -303,7 +303,7 @@ void Profile::renameModInAllProfiles(const QString& oldName, const QString& newN if (modList.exists()) renameModInList(modList, oldName, newName); else - qWarning("Profile has no modlist.txt : %s", qPrintable(profileIter.filePath())); + qWarning("Profile has no modlist.txt : %s", qUtf8Printable(profileIter.filePath())); } } @@ -361,7 +361,7 @@ void Profile::renameModInList(QFile &modList, const QString &oldName, const QStr if (renamed) qDebug("Renamed %d \"%s\" mod to \"%s\" in %s", - renamed, qPrintable(oldName), qPrintable(newName), qPrintable(modList.fileName())); + renamed, qUtf8Printable(oldName), qUtf8Printable(newName), qUtf8Printable(modList.fileName())); } void Profile::refreshModStatus() @@ -421,13 +421,13 @@ void Profile::refreshModStatus() } } else { qWarning("no mod state for \"%s\" (profile \"%s\")", - qPrintable(modName), m_Directory.path().toUtf8().constData()); + qUtf8Printable(modName), m_Directory.path().toUtf8().constData()); // need to rewrite the modlist to fix this modStatusModified = true; } } else { qDebug("mod \"%s\" (profile \"%s\") not found", - qPrintable(modName), m_Directory.path().toUtf8().constData()); + qUtf8Printable(modName), m_Directory.path().toUtf8().constData()); // need to rewrite the modlist to fix this modStatusModified = true; } @@ -775,7 +775,7 @@ bool Profile::localSettingsEnabled() const QStringList missingFiles; for (QString file : m_GamePlugin->iniFiles()) { if (!QFile::exists(m_Directory.filePath(file))) { - qWarning("missing %s in %s", qPrintable(file), qPrintable(m_Directory.path())); + qWarning("missing %s in %s", qUtf8Printable(file), qUtf8Printable(m_Directory.path())); missingFiles << file; } } diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index 17844357..f9ea655f 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -214,7 +214,7 @@ void ProfilesDialog::on_removeProfileButton_clicked() delete item; } if (!shellDelete(QStringList(profilePath))) { - qWarning("Failed to shell-delete \"%s\" (errorcode %lu), trying regular delete", qPrintable(profilePath), ::GetLastError()); + qWarning("Failed to shell-delete \"%s\" (errorcode %lu), trying regular delete", qUtf8Printable(profilePath), ::GetLastError()); if (!removeDir(profilePath)) { qWarning("regular delete failed too"); } diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index d26ca96c..cdcbc2f4 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -145,15 +145,15 @@ void SelfUpdater::testForUpdate() if (newestVer > this->m_MOVersion) { m_UpdateCandidate = newest; qDebug("update available: %s -> %s", - qPrintable(this->m_MOVersion.displayString()), - qPrintable(newestVer.displayString())); + qUtf8Printable(this->m_MOVersion.displayString()), + qUtf8Printable(newestVer.displayString())); emit updateAvailable(); } else if (newestVer < this->m_MOVersion) { // this could happen if the user switches from using prereleases to // stable builds. Should we downgrade? qDebug("this version is newer than the newest installed one: %s -> %s", - qPrintable(this->m_MOVersion.displayString()), - qPrintable(newestVer.displayString())); + qUtf8Printable(this->m_MOVersion.displayString()), + qUtf8Printable(newestVer.displayString())); } } }); @@ -224,7 +224,7 @@ void SelfUpdater::closeProgress() void SelfUpdater::openOutputFile(const QString &fileName) { QString outputPath = QDir::fromNativeSeparators(qApp->property("dataPath").toString()) + "/" + fileName; - qDebug("downloading to %s", qPrintable(outputPath)); + qDebug("downloading to %s", qUtf8Printable(outputPath)); m_UpdateFile.setFileName(outputPath); m_UpdateFile.open(QIODevice::WriteOnly); } diff --git a/src/settings.cpp b/src/settings.cpp index 8f768fd2..5cfe427b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -167,7 +167,7 @@ void Settings::registerPlugin(IPlugin *plugin) QVariant temp = m_Settings.value("Plugins/" + plugin->name() + "/" + setting.key, setting.defaultValue); if (!temp.convert(setting.defaultValue.type())) { qWarning("failed to interpret \"%s\" as correct type for \"%s\" in plugin \"%s\", using default", - qPrintable(temp.toString()), qPrintable(setting.key), qPrintable(plugin->name())); + qUtf8Printable(temp.toString()), qUtf8Printable(setting.key), qUtf8Printable(plugin->name())); temp = setting.defaultValue; } m_PluginSettings[plugin->name()][setting.key] = temp; @@ -574,7 +574,7 @@ void Settings::updateServers(const QList &servers) QVariantMap val = m_Settings.value(key).toMap(); QDate lastSeen = val["lastSeen"].toDate(); if (lastSeen.daysTo(now) > 30) { - qDebug("removing server %s since it hasn't been available for downloads in over a month", qPrintable(key)); + qDebug("removing server %s since it hasn't been available for downloads in over a month", qUtf8Printable(key)); m_Settings.remove(key); } } diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp index 9c81d0d9..ef7314c0 100644 --- a/src/usvfsconnector.cpp +++ b/src/usvfsconnector.cpp @@ -61,7 +61,7 @@ LogWorker::LogWorker() { m_LogFile.open(QIODevice::WriteOnly); qDebug("usvfs log messages are written to %s", - qPrintable(m_LogFile.fileName())); + qUtf8Printable(m_LogFile.fileName())); } LogWorker::~LogWorker() -- cgit v1.3.1 From cc7c3adcad973949ac976c3dc71bb8cf2677056c Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 11 Jan 2019 13:50:51 +0100 Subject: Fix or ignore a number of compiler warnings. --- src/aboutdialog.ui | 10 +++++----- src/overwriteinfodialog.cpp | 2 +- src/pluginlist.cpp | 2 +- src/selfupdater.cpp | 3 +-- src/settings.cpp | 2 +- src/shared/leaktrace.cpp | 13 ++++++++++++- src/spawn.cpp | 2 +- 7 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index ac7db1fc..86b95c83 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -161,7 +161,7 @@ - + QAbstractItemView::NoSelection @@ -202,7 +202,7 @@ - + QAbstractItemView::NoSelection @@ -231,9 +231,9 @@ Translators - + - + QAbstractItemView::NoSelection @@ -363,7 +363,7 @@ Other Supporters && Contributors - + diff --git a/src/overwriteinfodialog.cpp b/src/overwriteinfodialog.cpp index 1fe3f645..4d35a2c3 100644 --- a/src/overwriteinfodialog.cpp +++ b/src/overwriteinfodialog.cpp @@ -220,7 +220,7 @@ void OverwriteInfoDialog::openFile(const QModelIndex &index) QString fileName = m_FileSystemModel->filePath(index); HINSTANCE res = ::ShellExecuteW(nullptr, L"open", ToWString(fileName).c_str(), nullptr, nullptr, SW_SHOW); - if ((int)res <= 32) { + if ((INT_PTR)res <= 32) { qCritical("failed to invoke %s: %d", fileName.toUtf8().constData(), res); } } diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 6f417331..25f9c545 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -153,7 +153,7 @@ void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MO } } } - emit dataChanged(this->index(0, 0), this->index(m_ESPs.size() - 1, this->columnCount() - 1)); + emit dataChanged(this->index(0, 0), this->index(static_cast(m_ESPs.size()) - 1, this->columnCount() - 1)); } void PluginList::refresh(const QString &profileName diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index c913af6a..b5e7684c 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -338,9 +338,8 @@ void SelfUpdater::installUpdate() } else { reportError(tr("Failed to start %1: %2") .arg(m_UpdateFile.fileName()) - .arg((int)res)); + .arg((INT_PTR)res)); } - m_UpdateFile.remove(); } diff --git a/src/settings.cpp b/src/settings.cpp index f981f811..9267cccf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -142,7 +142,7 @@ void Settings::registerAsNXMHandler(bool force) } parameters += L" \"" + executable + L"\""; HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL); - if ((int)res <= 32) { + if ((INT_PTR)res <= 32) { QMessageBox::critical(nullptr, tr("Failed"), tr("Sorry, failed to start the helper application")); } diff --git a/src/shared/leaktrace.cpp b/src/shared/leaktrace.cpp index 1ff1fa9d..466162a4 100644 --- a/src/shared/leaktrace.cpp +++ b/src/shared/leaktrace.cpp @@ -1,3 +1,8 @@ +//disable warning messages 4302 , 4311 and 4312 +#pragma warning( disable : 4302 ) +#pragma warning( disable : 4311 ) +#pragma warning( disable : 4312 ) + #include "leaktrace.h" #include "stackdata.h" #include @@ -31,7 +36,7 @@ static struct __TraceData { for (auto iter = result.begin(); iter != result.end(); ++iter) { printf("-----------------------------------\n" "%d objects not freed, allocated at:\n%s", - iter->second.size(), iter->first.toString().c_str()); + static_cast(iter->second.size()), iter->first.toString().c_str()); printf("Addresses: "); for (int i = 0; i < (std::min)(5, static_cast(iter->second.size())); ++i) { @@ -55,3 +60,9 @@ void LeakTrace::TraceDealloc(void *ptr) { __trace.deregTrace(ptr); } + +//re-enable warning messages 4302 , 4311 and 4312 +#pragma warning( default : 4302 ) +#pragma warning( default : 4311 ) +#pragma warning( default : 4312 ) + diff --git a/src/spawn.cpp b/src/spawn.cpp index f8a7bb5f..e1de5c0f 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -94,7 +94,7 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, PROCESS_INFORMATION pi; BOOL success = FALSE; if (hooked) { - qDebug() << "Creating process hooked: <" << QString::fromWCharArray(commandLine, length) <<">"; + qDebug() << "Creating process hooked: <" << QString::fromWCharArray(commandLine, static_cast(length)) <<">"; success = ::CreateProcessHooked(nullptr, commandLine, nullptr, nullptr, // no special process or thread attributes -- cgit v1.3.1 From 11b2e0fe34e5029ab5ffc00d0cebc59bf286b7a8 Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 22 Jan 2019 13:25:31 +0100 Subject: Improved performance of pluginlist refresh by removing regex --- src/modinforegular.cpp | 3 ++- src/pluginlist.cpp | 24 +++--------------------- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 185f0495..0f1f93dc 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -631,7 +631,8 @@ QStringList ModInfoRegular::archives() const { QStringList result; QDir dir(this->absolutePath()); - for (const QString &archive : dir.entryList(QStringList({ "*.bsa", "*.ba2" }))) { + QStringList bsaList = dir.entryList(QStringList({ "*.bsa", "*.ba2" })); + for (const QString &archive : bsaList) { result.append(this->absolutePath() + "/" + archive); } return result; diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 25f9c545..ab8bb9f7 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -175,19 +175,6 @@ void PluginList::refresh(const QString &profileName QStringList availablePlugins; - QRegExp bsaReg = QRegExp(); - QRegExp ba2Reg = QRegExp(); - bsaReg.setPatternSyntax(QRegExp::Wildcard); - bsaReg.setCaseSensitivity(Qt::CaseInsensitive); - ba2Reg.setPatternSyntax(QRegExp::Wildcard); - ba2Reg.setCaseSensitivity(Qt::CaseInsensitive); - - //TODO: try QRegularExpression when we move to Qt5.12 - /*QRegularExpression bsaReg = QRegularExpression(); - QRegularExpression ba2Reg = QRegularExpression(); - bsaReg.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - ba2Reg.setPatternOptions(QRegularExpression::CaseInsensitiveOption);*/ - std::vector files = baseDirectory.getFiles(); for (FileEntry::Ptr current : files) { if (current.get() == nullptr) { @@ -217,18 +204,13 @@ void PluginList::refresh(const QString &profileName QString iniPath = baseName + ".ini"; bool hasIni = baseDirectory.findFile(ToWString(iniPath)).get() != nullptr; - - bsaReg.setPattern(baseName + "*.bsa"); - ba2Reg.setPattern(baseName + "*.ba2"); - - - //bsaReg.setPattern(QRegularExpression::wildcardToRegularExpression(baseName + "*.bsa")); - //ba2Reg.setPattern(QRegularExpression::wildcardToRegularExpression(baseName + "*.ba2")); std::set loadedArchives; QString candidateName; for (FileEntry::Ptr archiveCandidate : files) { candidateName = ToQString(archiveCandidate->getName()); - if (candidateName.contains(bsaReg) || candidateName.contains(ba2Reg)) { + if (candidateName.startsWith(baseName, Qt::CaseInsensitive) && + (candidateName.endsWith(".bsa", Qt::CaseInsensitive) || + candidateName.endsWith(".ba2", Qt::CaseInsensitive))) { loadedArchives.insert(candidateName); } } -- cgit v1.3.1 From 4b522f40e88e1350434aaa7d77fc60cb7ca36930 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 30 Jan 2019 20:32:48 -0600 Subject: Make logs more consistent in format and content --- src/categories.cpp | 12 ++++++------ src/directoryrefresher.cpp | 9 ++++++++- src/executableslist.cpp | 4 ++-- src/installationmanager.cpp | 2 +- src/loadmechanism.cpp | 4 ++-- src/mainwindow.cpp | 4 ++-- src/modinfo.cpp | 4 ++-- src/modinfodialog.cpp | 2 +- src/modlistsortproxy.cpp | 4 ++-- src/organizercore.cpp | 10 +++++----- src/overwriteinfodialog.cpp | 2 +- src/pluginlist.cpp | 6 +++--- src/profile.cpp | 22 +++++++++++----------- 13 files changed, 46 insertions(+), 39 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/categories.cpp b/src/categories.cpp index 4d89eff9..9e5fa9f7 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -72,7 +72,7 @@ void CategoryFactory::loadCategories() bool ok = false; int temp = iter->toInt(&ok); if (!ok) { - qCritical("invalid id %s", iter->constData()); + qCritical("invalid category id %s", iter->constData()); } nexusIDs.push_back(temp); } @@ -268,7 +268,7 @@ void CategoryFactory::loadDefaultCategories() int CategoryFactory::getParentID(unsigned int index) const { if (index >= m_Categories.size()) { - throw MyException(QObject::tr("invalid index %1").arg(index)); + throw MyException(QObject::tr("invalid category index: %1").arg(index)); } return m_Categories[index].m_ParentID; @@ -303,7 +303,7 @@ bool CategoryFactory::isDecendantOf(int id, int parentID) const bool CategoryFactory::hasChildren(unsigned int index) const { if (index >= m_Categories.size()) { - throw MyException(QObject::tr("invalid index %1").arg(index)); + throw MyException(QObject::tr("invalid category index: %1").arg(index)); } return m_Categories[index].m_HasChildren; @@ -313,7 +313,7 @@ bool CategoryFactory::hasChildren(unsigned int index) const QString CategoryFactory::getCategoryName(unsigned int index) const { if (index >= m_Categories.size()) { - throw MyException(QObject::tr("invalid index %1").arg(index)); + throw MyException(QObject::tr("invalid category index: %1").arg(index)); } return m_Categories[index].m_Name; @@ -323,7 +323,7 @@ QString CategoryFactory::getCategoryName(unsigned int index) const int CategoryFactory::getCategoryID(unsigned int index) const { if (index >= m_Categories.size()) { - throw MyException(QObject::tr("invalid index %1").arg(index)); + throw MyException(QObject::tr("invalid category index: %1").arg(index)); } return m_Categories[index].m_ID; @@ -334,7 +334,7 @@ int CategoryFactory::getCategoryIndex(int ID) const { std::map::const_iterator iter = m_IDMap.find(ID); if (iter == m_IDMap.end()) { - throw MyException(QObject::tr("invalid category id %1").arg(ID)); + throw MyException(QObject::tr("invalid category id: %1").arg(ID)); } return iter->second; } diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index c48b77d9..eded70b0 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -125,6 +125,10 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu // files to this mod FilesOrigin &origin = directoryStructure->createOrigin(ToWString(modName), directoryW, priority); for (const QString &filename : stealFiles) { + if (filename.isEmpty()) { + qWarning("Trying to find file with no name"); + continue; + } QFileInfo fileInfo(filename); FileEntry::Ptr file = directoryStructure->findFile(ToWString(fileInfo.fileName())); if (file.get() != nullptr) { @@ -135,7 +139,10 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu origin.addFile(file->getIndex()); file->addOrigin(origin.getID(), file->getFileTime(), L"", -1); } else { - qWarning("%s not found", qUtf8Printable(fileInfo.fileName())); + QString warnStr = fileInfo.absolutePath(); + if (warnStr.isEmpty()) + warnStr = filename; + qWarning("file not found: %1", qUtf8Printable(warnStr)); } } } else { diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 21cb6ed4..ae4ebdbf 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -75,7 +75,7 @@ const Executable &ExecutablesList::find(const QString &title) const return exe; } } - throw std::runtime_error(QString("invalid name %1").arg(title).toLocal8Bit().constData()); + throw std::runtime_error(QString("invalid executable name: %1").arg(title).toLocal8Bit().constData()); } @@ -86,7 +86,7 @@ Executable &ExecutablesList::find(const QString &title) return exe; } } - throw std::runtime_error(QString("invalid executable name %1").arg(title).toLocal8Bit().constData()); + throw std::runtime_error(QString("invalid executable name: %1").arg(title).toLocal8Bit().constData()); } diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 6719c84a..83128e4b 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -762,7 +762,7 @@ bool InstallationManager::install(const QString &fileName, if (fileInfo.dir() == QDir(m_DownloadsDirectory)) { m_CurrentFile = fileInfo.fileName(); } - qDebug("using mod name \"%s\" (id %d) -> %s", modName->toUtf8().constData(), modID, qUtf8Printable(m_CurrentFile)); + qDebug("using mod name \"%s\" (id %d) -> %s", qUtf8Printable(modName), modID, qUtf8Printable(m_CurrentFile)); //If there's an archive already open, close it. This happens with the bundle //installer when it uncompresses a split archive, then finds it has a real archive diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index ebbb5de3..8f0529ce 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -100,7 +100,7 @@ bool LoadMechanism::hashIdentical(const QString &fileNameLHS, const QString &fil { QFile fileLHS(fileNameLHS); if (!fileLHS.open(QIODevice::ReadOnly)) { - throw MyException(QObject::tr("%1 not found").arg(fileNameLHS)); + throw MyException(QObject::tr("file not found: %1").arg(qUtf8Printable(fileNameLHS))); } QByteArray dataLHS = fileLHS.readAll(); QByteArray hashLHS = QCryptographicHash::hash(dataLHS, QCryptographicHash::Md5); @@ -109,7 +109,7 @@ bool LoadMechanism::hashIdentical(const QString &fileNameLHS, const QString &fil QFile fileRHS(fileNameRHS); if (!fileRHS.open(QIODevice::ReadOnly)) { - throw MyException(QObject::tr("%1 not found").arg(fileNameRHS)); + throw MyException(QObject::tr("file not found: %1").arg(qUtf8Printable(fileNameRHS))); } QByteArray dataRHS = fileRHS.readAll(); QByteArray hashRHS = QCryptographicHash::hash(dataRHS, QCryptographicHash::Md5); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fccb5efe..8bcf7ba7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5186,7 +5186,7 @@ void MainWindow::previewDataFile() const FileEntry::Ptr file = m_OrganizerCore.directoryStructure()->searchFile(ToWString(fileName), nullptr); if (file.get() == nullptr) { - reportError(tr("file not found: %1").arg(fileName)); + reportError(tr("file not found: %1").arg(qUtf8Printable(fileName))); return; } @@ -6339,7 +6339,7 @@ void MainWindow::dropLocalFile(const QUrl &url, const QString &outputDir, bool m { QFileInfo file(url.toLocalFile()); if (!file.exists()) { - qWarning("invalid source file %s", qUtf8Printable(file.absoluteFilePath())); + qWarning("invalid source file: %s", qUtf8Printable(file.absoluteFilePath())); return; } QString target = outputDir + "/" + file.fileName(); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 1c6139f6..7ae41b02 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -110,7 +110,7 @@ QString ModInfo::getContentTypeName(int contentType) case CONTENT_INI: return tr("INI files"); case CONTENT_MODGROUP: return tr("ModGroup files"); - default: throw MyException(tr("invalid content type %1").arg(contentType)); + default: throw MyException(tr("invalid content type: %1").arg(contentType)); } } @@ -133,7 +133,7 @@ ModInfo::Ptr ModInfo::getByIndex(unsigned int index) QMutexLocker locker(&s_Mutex); if (index >= s_Collection.size() && index != ULONG_MAX) { - throw MyException(tr("invalid mod index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } if (index == ULONG_MAX) return s_Collection[ModInfo::getIndex("Overwrite")]; return s_Collection[index]; diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index d2e5e84f..04506374 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -1431,7 +1431,7 @@ void ModInfoDialog::previewDataFile() const FileEntry::Ptr file = m_OrganizerCore->directoryStructure()->searchFile(ToWString(fileName), nullptr); if (file.get() == nullptr) { - reportError(tr("file not found: %1").arg(fileName)); + reportError(tr("file not found: %1").arg(qUtf8Printable(fileName))); return; } diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 99f0efef..2d9ea4a5 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -474,13 +474,13 @@ bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) cons } if (row >= static_cast(m_Profile->numMods())) { - qWarning("invalid row idx %d", row); + qWarning("invalid row index: %d", row); return false; } QModelIndex idx = sourceModel()->index(row, 0, parent); if (!idx.isValid()) { - qDebug("invalid index"); + qDebug("invalid mod index"); return false; } if (sourceModel()->hasChildren(idx)) { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 10b6fd8b..4fa09ab6 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1010,7 +1010,7 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, emit modInstalled(modName); return modInfo.data(); } else { - reportError(tr("mod \"%1\" not found").arg(modName)); + reportError(tr("mod not found: %1").arg(qUtf8Printable(modName))); } } else if (m_InstallationManager.wasCancelled()) { QMessageBox::information(qApp->activeWindow(), tr("Installation cancelled"), @@ -1068,7 +1068,7 @@ void OrganizerCore::installDownload(int index) m_ModInstalled(modName); } else { - reportError(tr("mod \"%1\" not found").arg(modName)); + reportError(tr("mod not found: %1").arg(qUtf8Printable(modName))); } m_DownloadManager.markInstalled(index); @@ -1129,7 +1129,7 @@ QStringList OrganizerCore::findFiles( } } } else { - qWarning("directory %s not found", qUtf8Printable(path)); + qWarning("directory not found: %1", qUtf8Printable(path)); } return result; } @@ -1148,7 +1148,7 @@ QStringList OrganizerCore::getFileOrigins(const QString &fileName) const ToQString(m_DirectoryStructure->getOriginByID(i.first).getName())); } } else { - qDebug("%s not found", qUtf8Printable(fileName)); + qWarning("file not found: %1", qUtf8Printable(fileName)); } return result; } @@ -1294,7 +1294,7 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary, if (!binary.exists()) { reportError( - tr("Executable \"%1\" not found").arg(binary.absoluteFilePath())); + tr("Executable not found: %1").arg(qUtf8Printable(binary.absoluteFilePath()))); return INVALID_HANDLE_VALUE; } diff --git a/src/overwriteinfodialog.cpp b/src/overwriteinfodialog.cpp index 4d35a2c3..d1289c91 100644 --- a/src/overwriteinfodialog.cpp +++ b/src/overwriteinfodialog.cpp @@ -110,7 +110,7 @@ void OverwriteInfoDialog::setModInfo(ModInfo::Ptr modInfo) if (QDir(modInfo->absolutePath()).exists()) { m_FileSystemModel->setRootPath(modInfo->absolutePath()); } else { - throw MyException(tr("%1 not found").arg(modInfo->absolutePath())); + throw MyException(tr("mod not found: %1").arg(qUtf8Printable(modInfo->absolutePath()))); } } diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index b2fabbe0..56a5c91f 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -298,7 +298,7 @@ void PluginList::enableESP(const QString &name, bool enable) emit writePluginsList(); } else { - reportError(tr("esp not found: %1").arg(name)); + reportError(tr("Plugin not found: %1").arg(qUtf8Printable(name))); } } @@ -694,7 +694,7 @@ void PluginList::setState(const QString &name, PluginStates state) { m_ESPs[iter->second].m_Enabled = (state == IPluginList::STATE_ACTIVE) || m_ESPs[iter->second].m_ForceEnabled; } else { - qWarning("plugin %s not found", qUtf8Printable(name)); + qWarning("Plugin not found: %1", qUtf8Printable(name)); } } @@ -824,7 +824,7 @@ void PluginList::updateIndices() continue; } if (m_ESPs[i].m_Priority >= static_cast(m_ESPs.size())) { - qCritical("invalid priority %d", m_ESPs[i].m_Priority); + qCritical("invalid plugin priority: %d", m_ESPs[i].m_Priority); continue; } m_ESPsByName[m_ESPs[i].m_Name.toLower()] = i; diff --git a/src/profile.cpp b/src/profile.cpp index 629e043f..a5e3bc54 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -78,7 +78,7 @@ Profile::Profile(const QString &name, IPluginGame const *gamePlugin, bool useDef QDir profileBase(profilesDir); QString fixedName = name; if (!fixDirectoryName(fixedName)) { - throw MyException(tr("invalid profile name %1").arg(name)); + throw MyException(tr("invalid profile name: %1").arg(qUtf8Printable(name))); } if (!profileBase.exists() || !profileBase.mkdir(fixedName)) { @@ -416,19 +416,19 @@ void Profile::refreshModStatus() m_ModStatus[modIndex].m_Enabled = enabled; if (m_ModStatus[modIndex].m_Priority == -1) { if (static_cast(index) >= m_ModStatus.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } m_ModStatus[modIndex].m_Priority = index++; } } else { qWarning("no mod state for \"%s\" (profile \"%s\")", - qUtf8Printable(modName), m_Directory.path().toUtf8().constData()); + qUtf8Printable(modName), qUtf8Printable(m_Directory.path())); // need to rewrite the modlist to fix this modStatusModified = true; } } else { - qDebug("mod \"%s\" (profile \"%s\") not found", - qUtf8Printable(modName), m_Directory.path().toUtf8().constData()); + qDebug("mod not found: \"%s\" (profile \"%s\")", + qUtf8Printable(modName), qUtf8Printable(m_Directory.path())); // need to rewrite the modlist to fix this modStatusModified = true; } @@ -455,7 +455,7 @@ void Profile::refreshModStatus() m_ModStatus[i].m_Priority = numKnownMods - m_ModStatus[i].m_Priority - 1; } else { if (static_cast(index) >= m_ModStatus.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } if (modInfo->hasFlag(ModInfo::FLAG_FOREIGN)) { m_ModStatus[i].m_Priority = --topInsert; @@ -552,7 +552,7 @@ unsigned int Profile::modIndexByPriority(int priority) const void Profile::setModEnabled(unsigned int index, bool enabled) { if (index >= m_ModStatus.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } ModInfo::Ptr modInfo = ModInfo::getByIndex(index); @@ -573,7 +573,7 @@ void Profile::setModsEnabled(const QList &modsToEnable, const QLis QList dirtyMods; for (auto idx : modsToEnable) { if (idx >= m_ModStatus.size()) { - qCritical() << tr("invalid index %1").arg(idx); + qCritical() << tr("invalid mod index: %1").arg(idx); continue; } if (!m_ModStatus[idx].m_Enabled) { @@ -583,7 +583,7 @@ void Profile::setModsEnabled(const QList &modsToEnable, const QLis } for (auto idx : modsToDisable) { if (idx >= m_ModStatus.size()) { - qCritical() << tr("invalid index %1").arg(idx); + qCritical() << tr("invalid mod index: %1").arg(idx); continue; } if (ModInfo::getByIndex(idx)->alwaysEnabled()) { @@ -602,7 +602,7 @@ void Profile::setModsEnabled(const QList &modsToEnable, const QLis bool Profile::modEnabled(unsigned int index) const { if (index >= m_ModStatus.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } return m_ModStatus[index].m_Enabled; @@ -612,7 +612,7 @@ bool Profile::modEnabled(unsigned int index) const int Profile::getModPriority(unsigned int index) const { if (index >= m_ModStatus.size()) { - throw MyException(tr("invalid index %1").arg(index)); + throw MyException(tr("invalid mod index: %1").arg(index)); } return m_ModStatus[index].m_Priority; -- cgit v1.3.1 From 3444b9a46eaf6c923e0557517c54d59bd52e6e6c Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 31 Jan 2019 16:14:25 -0600 Subject: Fix some logs --- src/directoryrefresher.cpp | 2 +- src/pluginlist.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index eded70b0..c4d7bfc5 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -142,7 +142,7 @@ void DirectoryRefresher::addModFilesToStructure(DirectoryEntry *directoryStructu QString warnStr = fileInfo.absolutePath(); if (warnStr.isEmpty()) warnStr = filename; - qWarning("file not found: %1", qUtf8Printable(warnStr)); + qWarning("file not found: %s", qUtf8Printable(warnStr)); } } } else { diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 56a5c91f..ab955e4d 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -694,7 +694,7 @@ void PluginList::setState(const QString &name, PluginStates state) { m_ESPs[iter->second].m_Enabled = (state == IPluginList::STATE_ACTIVE) || m_ESPs[iter->second].m_ForceEnabled; } else { - qWarning("Plugin not found: %1", qUtf8Printable(name)); + qWarning("Plugin not found: %s", qUtf8Printable(name)); } } -- cgit v1.3.1 From 5eb686ac48cd29cc00aec546805ed2be005d944b Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 12 Feb 2019 18:54:56 +0100 Subject: Use case insensitive check for flagging primary prugins. Fixes some plugins not getting force enabled on TTW. --- src/pluginlist.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index ab955e4d..554cdc36 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -193,7 +193,8 @@ void PluginList::refresh(const QString &profileName } bool forceEnabled = Settings::instance().forceEnableCoreFiles() && - std::find(primaryPlugins.begin(), primaryPlugins.end(), filename.toLower()) != primaryPlugins.end(); + primaryPlugins.contains(filename, Qt::CaseInsensitive); + //(std::find(primaryPlugins.begin(), primaryPlugins.end(), filename.toLower()) != primaryPlugins.end()); bool archive = false; try { -- cgit v1.3.1 From c49fce871ae4f428c0181b0ea7dd396c85c735d2 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Sat, 9 Mar 2019 21:41:38 -0600 Subject: Allow selecting overwrite to trigger selected plugin highlight --- src/pluginlist.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 554cdc36..ec9bdac3 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -127,11 +127,10 @@ void PluginList::highlightPlugins(const QItemSelectionModel *selection, const MO esp.m_ModSelected = false; } for (QModelIndex idx : selection->selectedRows(ModList::COL_PRIORITY)) { - int modPriority = idx.data(Qt::UserRole).toInt(); - if (modPriority < 0 || modPriority == INT_MAX) + int modIndex = idx.data(Qt::UserRole + 1).toInt(); + if (modIndex == UINT_MAX) continue; - int modIndex = profile.modIndexByPriority(modPriority); ModInfo::Ptr selectedMod = ModInfo::getByIndex(modIndex); if (!selectedMod.isNull() && profile.modEnabled(modIndex)) { QDir dir(selectedMod->absolutePath()); -- cgit v1.3.1