summaryrefslogtreecommitdiff
path: root/src/installationmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/installationmanager.cpp')
-rw-r--r--src/installationmanager.cpp94
1 files changed, 48 insertions, 46 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index e7784771..a6f062de 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -499,9 +499,9 @@ bool InstallationManager::testOverwrite(const QString &modsDirectory, QString &m
QLineEdit::Normal, modName, &ok);
if (ok && !name.isEmpty()) {
modName = name;
- if (!ensureValidModName(modName)) {
- return false;
- }
+ if (!ensureValidModName(modName)) {
+ return false;
+ }
targetDirectory = QDir::fromNativeSeparators(modsDirectory.mid(0).append("\\").append(modName));
}
} else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_REPLACE) {
@@ -547,46 +547,46 @@ void InstallationManager::fixModName(QString &name)
{
// name = name.remove("^[ ]*").trimmed();
name = name.simplified();
- while (name.endsWith('.')) name.chop(1);
-
- name.replace(QRegExp("[<>:\"/\\|?*]"), "");
-
- static QString invalidNames[] = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
- "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" };
- for (int i = 0; i < sizeof(invalidNames) / sizeof(QString); ++i) {
- if (name == invalidNames[i]) {
- name = "";
- break;
- }
- }
+ while (name.endsWith('.')) name.chop(1);
+
+ name.replace(QRegExp("[<>:\"/\\|?*]"), "");
+
+ static QString invalidNames[] = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
+ "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" };
+ for (int i = 0; i < sizeof(invalidNames) / sizeof(QString); ++i) {
+ if (name == invalidNames[i]) {
+ name = "";
+ break;
+ }
+ }
}
-bool InstallationManager::ensureValidModName(QString &name)
-{
- fixModName(name);
-
- while (name.isEmpty()) {
- bool ok;
- name = QInputDialog::getText(m_ParentWidget, tr("Invalid name"),
- tr("The name you entered is invalid, please enter a different one."),
- QLineEdit::Normal, "", &ok);
- if (!ok) {
- return false;
- }
- fixModName(name);
- }
- return true;
-}
-
-
-bool InstallationManager::doInstall(const QString &modsDirectory, QString &modName, int modID,
+bool InstallationManager::ensureValidModName(QString &name)
+{
+ fixModName(name);
+
+ while (name.isEmpty()) {
+ bool ok;
+ name = QInputDialog::getText(m_ParentWidget, tr("Invalid name"),
+ tr("The name you entered is invalid, please enter a different one."),
+ QLineEdit::Normal, "", &ok);
+ if (!ok) {
+ return false;
+ }
+ fixModName(name);
+ }
+ return true;
+}
+
+
+bool InstallationManager::doInstall(const QString &modsDirectory, QString &modName, int modID,
const QString &version, const QString &newestVersion, int categoryID)
{
- if (!ensureValidModName(modName)) {
- return false;
- }
-
+ if (!ensureValidModName(modName)) {
+ return false;
+ }
+
// determine target directory
if (!testOverwrite(modsDirectory, modName)) {
return false;
@@ -679,7 +679,7 @@ bool EndsWith(LPCWSTR string, LPCWSTR subString)
bool InstallationManager::installFomodInternal(DirectoryTree *&baseNode, const QString &fomodPath, const QString &modsDirectory,
int modID, const QString &version, const QString &newestVersion, int categoryID,
- QString &modName, bool &manualRequest)
+ QString &modName, bool nameGuessed, bool &manualRequest)
{
qDebug("treating as fomod archive");
@@ -740,7 +740,7 @@ bool InstallationManager::installFomodInternal(DirectoryTree *&baseNode, const Q
bool success = false;
try {
- FomodInstallerDialog dialog(modName, fomodPath);
+ FomodInstallerDialog dialog(modName, nameGuessed, fomodPath);
FileData* const *data;
size_t size;
@@ -924,6 +924,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin
QString version = "";
QString newestVersion = "";
int categoryID = 0;
+ bool nameGuessed = false;
QString metaName = fileName.mid(0).append(".meta");
if (QFile(metaName).exists()) {
@@ -945,9 +946,9 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin
{ // guess the mod name and mod if from the file name if there was no meta information
QString guessedModName;
- int guessedModID = modID;
- NexusInterface::interpretNexusFileName(QFileInfo(fileName).baseName(), guessedModName, guessedModID, false);
- if ((modID == 0) && (guessedModID != -1)) {
+ int guessedModID = modID;
+ NexusInterface::interpretNexusFileName(QFileInfo(fileName).baseName(), guessedModName, guessedModID, false);
+ if ((modID == 0) && (guessedModID != -1)) {
modID = guessedModID;
} else if (modID != guessedModID) {
qDebug("passed mod id: %d, guessed id: %d", modID, guessedModID);
@@ -955,6 +956,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin
if (modName.isEmpty()) {
modName = guessedModName;
+ nameGuessed = true;
}
}
fixModName(modName);
@@ -1090,8 +1092,8 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin
if (xmlInstaller || nmmInstaller) {
if (!xmlInstaller || (nmmInstaller && !preferIntegrated)) {
- if (!ensureValidModName(modName) ||
- !testOverwrite(modsDirectory, modName)) {
+ if (!ensureValidModName(modName) ||
+ !testOverwrite(modsDirectory, modName)) {
return false;
}
@@ -1120,7 +1122,7 @@ bool InstallationManager::install(const QString &fileName, const QString &plugin
} else {
if (installFomodInternal(baseNode, fomodPath, modsDirectory,
modID, version, newestVersion, categoryID,
- modName, manualRequest)) {
+ modName, nameGuessed, manualRequest)) {
success = true;
}
}