From 5d1154c24e2475ed2b7ac248de27ab7b501a1e5e Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 16 Feb 2013 19:09:57 +0100 Subject: - hooks for CreateHardLink - createprocess hook will now reroute the cwd (fixes SUM, may break other tools?) - profile code moved to separate file - executables can now be linked to toolbar - category filters are now represented as a tree - csv export of mod list - ModInfoDialog is now "window modal" instead of "application modal" - nexus dialog now updates the mod-id field while browsing - right-click in nexus browser allows to open in external browser - ini viewer is no longer modal - bugfix: another attempt to fix processing of invalid header lines in fomod xmls (bom now handled) - bugfix: integrated fomod installer will no longer overwrite detected mod name by the one from the xml - bugfix: "hide file" from conflicted files list now updates that list - bugfix: conflicted files list no longer offers to hide files in BSAs - bugfix: pressing delete on the mod list with multiplie files selected offered to delete the wrong files - regression: mod name guessing with the old regular expression was less likely to lead to an empty mod name. Now both are tried --- src/executableslist.cpp | 366 +++++++++++++++++++++++++----------------------- 1 file changed, 191 insertions(+), 175 deletions(-) (limited to 'src/executableslist.cpp') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index ed66d8f4..036671f0 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -17,178 +17,194 @@ You should have received a copy of the GNU General Public License along with Mod Organizer. If not, see . */ -#include "executableslist.h" -#include -#include -#include -#include "utility.h" -#include - - -QDataStream &operator<<(QDataStream &out, const Executable &obj) -{ - out << obj.m_Title << obj.m_BinaryInfo.absoluteFilePath() << obj.m_Arguments << obj.m_CloseMO - << obj.m_SteamAppID << obj.m_WorkingDirectory << obj.m_Custom; - return out; -} - -QDataStream &operator>>(QDataStream &in, Executable &obj) -{ - QString binaryTemp; - int closeStyleTemp; - in >> obj.m_Title >> binaryTemp >> obj.m_Arguments >> closeStyleTemp - >> obj.m_SteamAppID >> obj.m_WorkingDirectory >> obj.m_Custom; - obj.m_CloseMO = (CloseMOStyle)closeStyleTemp; - obj.m_BinaryInfo.setFile(binaryTemp); - return in; -} - - -void registerExecutable() -{ - qRegisterMetaType("Executable"); - qRegisterMetaTypeStreamOperators("Executable"); -} - - -ExecutablesList::ExecutablesList() -{ -} - -ExecutablesList::~ExecutablesList() -{ -} - -void ExecutablesList::init() -{ - std::vector executables = GameInfo::instance().getExecutables(); - for (std::vector::const_iterator iter = executables.begin(); iter != executables.end(); ++iter) { - ExecutableInfo test = *iter; - addExecutableInternal(ToQString(iter->title), - QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())).append("/").append(ToQString(iter->binary)), - ToQString(iter->arguments), ToQString(iter->workingDirectory), - iter->closeMO, ToQString(iter->steamAppID)); - } -} - - -void ExecutablesList::getExecutables(std::vector::iterator &begin, std::vector::iterator &end) -{ - begin = m_Executables.begin(); - end = m_Executables.end(); -} - - -void ExecutablesList::getExecutables(std::vector::const_iterator &begin, - std::vector::const_iterator &end) const -{ - begin = m_Executables.begin(); - end = m_Executables.end(); -} - - -const Executable &ExecutablesList::find(const QString &title) const -{ - for (std::vector::const_iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Title == title) { - return *iter; - } - } - throw std::runtime_error("invalid name"); -} - - -Executable *ExecutablesList::findExe(const QString &title) -{ - for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Title == title) { - return &*iter; - } - } - return NULL; -} - - -bool ExecutablesList::titleExists(const QString &title) const -{ - auto test = [&] (const Executable &exe) { return exe.m_Title == title; }; - return std::find_if(m_Executables.begin(), m_Executables.end(), test) != m_Executables.end(); -} - - -void ExecutablesList::addExecutable(const Executable &executable) -{ - Executable *existingExe = findExe(executable.m_Title); - if (existingExe != NULL) { - *existingExe = executable; - } else { - m_Executables.push_back(executable); - } -} - - -void ExecutablesList::addExecutable(const QString &title, const QString &executableName, const QString &arguments, - const QString &workingDirectory, CloseMOStyle closeMO, const QString &steamAppID) -{ - QFileInfo file(executableName); - Executable *existingExe = findExe(title); - if (existingExe != NULL) { - existingExe->m_Title = title; - existingExe->m_CloseMO = closeMO; - existingExe->m_BinaryInfo = file; - existingExe->m_Arguments = arguments; - existingExe->m_WorkingDirectory = workingDirectory; - existingExe->m_SteamAppID = steamAppID; - existingExe->m_Custom = true; - } else { - Executable newExe; - newExe.m_Title = title; - newExe.m_CloseMO = closeMO; - newExe.m_BinaryInfo = file; - newExe.m_Arguments = arguments; - newExe.m_WorkingDirectory = workingDirectory; - newExe.m_SteamAppID = steamAppID; - newExe.m_Custom = true; - m_Executables.push_back(newExe); - } -} - -/*void ExecutablesList::remove(const QString &executableName) -{ - for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Custom && (iter->m_BinaryInfo.absoluteFilePath() == executableName)) { - m_Executables.erase(iter); - break; - } - } -}*/ - - -void ExecutablesList::remove(const QString &title) -{ - for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { - if (iter->m_Custom && (iter->m_Title == title)) { - m_Executables.erase(iter); - break; - } - } -} - - -void ExecutablesList::addExecutableInternal(const QString &title, const QString &executableName, - const QString &arguments, const QString &workingDirectory, - CloseMOStyle closeMO, const QString &steamAppID) -{ - QFileInfo file(executableName); - if (file.exists()) { - Executable newExe; - newExe.m_CloseMO = closeMO; - newExe.m_BinaryInfo = file; - newExe.m_Title = title; - newExe.m_Arguments = arguments; - newExe.m_WorkingDirectory = workingDirectory; - newExe.m_SteamAppID = steamAppID; - newExe.m_Custom = false; - m_Executables.push_back(newExe); - } -} +#include "executableslist.h" +#include +#include +#include +#include "utility.h" +#include + + +QDataStream &operator<<(QDataStream &out, const Executable &obj) +{ + out << obj.m_Title << obj.m_BinaryInfo.absoluteFilePath() << obj.m_Arguments << obj.m_CloseMO + << obj.m_SteamAppID << obj.m_WorkingDirectory << obj.m_Custom << obj.m_Toolbar; + return out; +} + +QDataStream &operator>>(QDataStream &in, Executable &obj) +{ + QString binaryTemp; + int closeStyleTemp; + in >> obj.m_Title >> binaryTemp >> obj.m_Arguments >> closeStyleTemp + >> obj.m_SteamAppID >> obj.m_WorkingDirectory >> obj.m_Custom >> obj.m_Toolbar; + + obj.m_CloseMO = (CloseMOStyle)closeStyleTemp; + obj.m_BinaryInfo.setFile(binaryTemp); + return in; +} + + +void registerExecutable() +{ + qRegisterMetaType("Executable"); + qRegisterMetaTypeStreamOperators("Executable"); +} + + +ExecutablesList::ExecutablesList() +{ +} + +ExecutablesList::~ExecutablesList() +{ +} + +void ExecutablesList::init() +{ + std::vector executables = GameInfo::instance().getExecutables(); + for (std::vector::const_iterator iter = executables.begin(); iter != executables.end(); ++iter) { + ExecutableInfo test = *iter; + addExecutableInternal(ToQString(iter->title), + QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())).append("/").append(ToQString(iter->binary)), + ToQString(iter->arguments), ToQString(iter->workingDirectory), + iter->closeMO, ToQString(iter->steamAppID)); + } +} + + +void ExecutablesList::getExecutables(std::vector::iterator &begin, std::vector::iterator &end) +{ + begin = m_Executables.begin(); + end = m_Executables.end(); +} + + +void ExecutablesList::getExecutables(std::vector::const_iterator &begin, + std::vector::const_iterator &end) const +{ + begin = m_Executables.begin(); + end = m_Executables.end(); +} + + +const Executable &ExecutablesList::find(const QString &title) const +{ + for (std::vector::const_iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { + if (iter->m_Title == title) { + return *iter; + } + } + throw std::runtime_error("invalid name"); +} + + +Executable &ExecutablesList::find(const QString &title) +{ + for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { + if (iter->m_Title == title) { + return *iter; + } + } + throw std::runtime_error("invalid name"); +} + + +Executable *ExecutablesList::findExe(const QString &title) +{ + for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { + if (iter->m_Title == title) { + return &*iter; + } + } + return NULL; +} + + +bool ExecutablesList::titleExists(const QString &title) const +{ + auto test = [&] (const Executable &exe) { return exe.m_Title == title; }; + return std::find_if(m_Executables.begin(), m_Executables.end(), test) != m_Executables.end(); +} + + +void ExecutablesList::addExecutable(const Executable &executable) +{ + Executable *existingExe = findExe(executable.m_Title); + if (existingExe != NULL) { + *existingExe = executable; + } else { + m_Executables.push_back(executable); + } +} + + +void ExecutablesList::addExecutable(const QString &title, const QString &executableName, const QString &arguments, + const QString &workingDirectory, CloseMOStyle closeMO, const QString &steamAppID, + bool custom, bool toolbar) +{ + QFileInfo file(executableName); + Executable *existingExe = findExe(title); + if (existingExe != NULL) { + existingExe->m_Title = title; + existingExe->m_CloseMO = closeMO; + existingExe->m_BinaryInfo = file; + existingExe->m_Arguments = arguments; + existingExe->m_WorkingDirectory = workingDirectory; + existingExe->m_SteamAppID = steamAppID; + existingExe->m_Custom = custom; + existingExe->m_Toolbar = toolbar; + } else { + Executable newExe; + newExe.m_Title = title; + newExe.m_CloseMO = closeMO; + newExe.m_BinaryInfo = file; + newExe.m_Arguments = arguments; + newExe.m_WorkingDirectory = workingDirectory; + newExe.m_SteamAppID = steamAppID; + newExe.m_Custom = true; + newExe.m_Toolbar = toolbar; + m_Executables.push_back(newExe); + } +} + +/*void ExecutablesList::remove(const QString &executableName) +{ + for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { + if (iter->m_Custom && (iter->m_BinaryInfo.absoluteFilePath() == executableName)) { + m_Executables.erase(iter); + break; + } + } +}*/ + + +void ExecutablesList::remove(const QString &title) +{ + for (std::vector::iterator iter = m_Executables.begin(); iter != m_Executables.end(); ++iter) { + if (iter->m_Custom && (iter->m_Title == title)) { + m_Executables.erase(iter); + break; + } + } +} + + +void ExecutablesList::addExecutableInternal(const QString &title, const QString &executableName, + const QString &arguments, const QString &workingDirectory, + CloseMOStyle closeMO, const QString &steamAppID) +{ + QFileInfo file(executableName); + if (file.exists()) { + Executable newExe; + newExe.m_CloseMO = closeMO; + newExe.m_BinaryInfo = file; + newExe.m_Title = title; + newExe.m_Arguments = arguments; + newExe.m_WorkingDirectory = workingDirectory; + newExe.m_SteamAppID = steamAppID; + newExe.m_Custom = false; + newExe.m_Toolbar = false; + m_Executables.push_back(newExe); + } +} -- cgit v1.3.1