@@ -1958,7 +1958,7 @@ void MainWindow::modorder_changed()
19581958 }
19591959 }
19601960 m_OrganizerCore.refreshBSAList ();
1961- m_OrganizerCore.currentProfile ()->modlistWriter (). write ();
1961+ m_OrganizerCore.currentProfile ()->writeModlist ();
19621962 m_ArchiveListWriter.write ();
19631963 m_OrganizerCore.directoryStructure ()->getFileRegister ()->sortOrigins ();
19641964
@@ -2019,71 +2019,9 @@ void MainWindow::installMod_clicked()
20192019 installMod ();
20202020}
20212021
2022- void MainWindow::renameModInList (QFile &modList, const QString &oldName, const QString &newName)
2023- {
2024- // TODO this code needs to be merged with ModList::readFrom
2025- if (!modList.open (QIODevice::ReadWrite)) {
2026- reportError (tr (" failed to open %1" ).arg (modList.fileName ()));
2027- return ;
2028- }
2029-
2030- QBuffer outBuffer;
2031- outBuffer.open (QIODevice::WriteOnly);
2032-
2033- while (!modList.atEnd ()) {
2034- QByteArray line = modList.readLine ();
2035-
2036- if (line.length () == 0 ) {
2037- // ignore empty lines
2038- qWarning (" mod list contained invalid data: empty line" );
2039- continue ;
2040- }
2041-
2042- char spec = line.at (0 );
2043- if (spec == ' #' ) {
2044- // don't touch comments
2045- outBuffer.write (line);
2046- continue ;
2047- }
2048-
2049- QString modName = QString::fromUtf8 (line).mid (1 ).trimmed ();
2050-
2051- if (modName.isEmpty ()) {
2052- // file broken?
2053- qWarning (" mod list contained invalid data: missing mod name" );
2054- continue ;
2055- }
2056-
2057- outBuffer.write (QByteArray (1 , spec));
2058- if (modName == oldName) {
2059- modName = newName;
2060- }
2061- outBuffer.write (modName.toUtf8 ().constData ());
2062- outBuffer.write (" \r\n " );
2063- }
2064-
2065- modList.resize (0 );
2066- modList.write (outBuffer.buffer ());
2067- modList.close ();
2068- }
2069-
2070-
20712022void MainWindow::modRenamed (const QString &oldName, const QString &newName)
20722023{
2073- // fix the profiles directly on disc
2074- for (int i = 0 ; i < ui->profileBox ->count (); ++i) {
2075- QString profileName = ui->profileBox ->itemText (i);
2076-
2077- // TODO this functionality should be in the Profile class
2078- QString modlistName = QString (" %1/%2/modlist.txt" )
2079- .arg (qApp->property (" dataPath" ).toString () + " /" + QString::fromStdWString (AppConfig::profilesPath ()))
2080- .arg (profileName);
2081-
2082- QFile modList (modlistName);
2083- if (modList.exists ()) {
2084- renameModInList (modList, oldName, newName);
2085- }
2086- }
2024+ Profile::renameModInAllProfiles (oldName, newName);
20872025
20882026 // immediately refresh the active profile because the data in memory is invalid
20892027 m_OrganizerCore.currentProfile ()->refreshModStatus ();
@@ -2264,7 +2202,7 @@ void MainWindow::restoreBackup_clicked()
22642202
22652203void MainWindow::modlistChanged (const QModelIndex&, int )
22662204{
2267- m_OrganizerCore.currentProfile ()->modlistWriter (). write ();
2205+ m_OrganizerCore.currentProfile ()->writeModlist ();
22682206}
22692207
22702208void MainWindow::modlistSelectionChanged (const QModelIndex ¤t, const QModelIndex&)
@@ -3307,7 +3245,7 @@ void MainWindow::fixMods_clicked(SaveGameInfo::MissingAssets const &missingAsset
33073245 }
33083246 }
33093247
3310- m_OrganizerCore.currentProfile ()->modlistWriter (). write ();
3248+ m_OrganizerCore.currentProfile ()->writeModlist ();
33113249 m_OrganizerCore.refreshLists ();
33123250
33133251 std::set<QString> espsToActivate = dialog.getESPsToActivate ();
@@ -3393,7 +3331,8 @@ void MainWindow::addWindowsLink(const ShortcutType mapping)
33933331 QString executable = QDir::toNativeSeparators (selectedExecutable.m_BinaryInfo .absoluteFilePath ());
33943332
33953333 std::wstring targetFile = ToWString (exeInfo.absoluteFilePath ());
3396- std::wstring parameter = ToWString (QString (" \" moshortcut://%1\" " ).arg (selectedExecutable.m_Title ));
3334+ std::wstring parameter = ToWString (
3335+ QString (" \" moshortcut://%1:%2\" " ).arg (InstanceManager::instance ().currentInstance (),selectedExecutable.m_Title ));
33973336 std::wstring description = ToWString (QString (" Run %1 with ModOrganizer" ).arg (selectedExecutable.m_Title ));
33983337 std::wstring iconFile = ToWString (executable);
33993338 std::wstring currentDirectory = ToWString (QDir::toNativeSeparators (qApp->applicationDirPath ()));
@@ -4678,7 +4617,7 @@ void MainWindow::on_restoreButton_clicked()
46784617
46794618void MainWindow::on_saveModsButton_clicked ()
46804619{
4681- m_OrganizerCore.currentProfile ()->modlistWriter (). writeImmediately (true );
4620+ m_OrganizerCore.currentProfile ()->writeModlistNow (true );
46824621 QDateTime now = QDateTime::currentDateTime ();
46834622 if (createBackup (m_OrganizerCore.currentProfile ()->getModlistFileName (), now)) {
46844623 MessageDialog::showMessage (tr (" Backup of modlist created" ), this );
0 commit comments