summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-05-24 18:51:03 +0200
committerTannin <devnull@localhost>2015-05-24 18:51:03 +0200
commit02cc97a58d7cda800b8c431dfeaa3242e5f0b69d (patch)
tree3a6daf855967f41e8ef189a1411dbf31b86da1cf /src
parentffd94e72b4ae137854e1ff3c96ff88eb48cea140 (diff)
- bugfix: bsa order wasn't correctly restored.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp35
-rw-r--r--src/organizercore.cpp18
-rw-r--r--src/organizercore.h2
3 files changed, 28 insertions, 27 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 44ccc642..e3c824e5 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1301,6 +1301,7 @@ static QStringList toStringList(InputIterator current, InputIterator end)
}
return result;
}
+
void MainWindow::updateBSAList(const QStringList &defaultArchives, const QStringList &activeArchives)
{
m_DefaultArchives = defaultArchives;
@@ -1311,33 +1312,31 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString
ui->bsaList->header()->setResizeMode(QHeaderView::ResizeToContents);
#endif
- std::vector<std::pair<UINT32, QTreeWidgetItem*> > items;
-
- std::vector<FileEntry::Ptr> files = m_OrganizerCore.directoryStructure()->getFiles();
- for (auto iter = files.begin(); iter != files.end(); ++iter) {
- FileEntry::Ptr current = *iter;
+ std::vector<std::pair<UINT32, QTreeWidgetItem*>> items;
- QString filename = ToQString(current->getName().c_str());
- QString extension = filename.right(3).toLower();
+ for (FileEntry::Ptr current : m_OrganizerCore.directoryStructure()->getFiles()) {
+ QFileInfo fileInfo(ToQString(current->getName().c_str()));
- if (extension == "bsa") {
- int index = activeArchives.indexOf(filename);
+ if (fileInfo.suffix().toLower() == "bsa") {
+ int index = activeArchives.indexOf(fileInfo.fileName());
if (index == -1) {
index = 0xFFFF;
}
- QString basename = filename.left(filename.indexOf("."));
- QStringList strings(filename);
- bool isArchive = false;
- int origin = current->getOrigin(isArchive);
- strings.append(ToQString(m_OrganizerCore.directoryStructure()->getOriginByID(origin).getName()));
- QTreeWidgetItem *newItem = new QTreeWidgetItem(strings);
+
+ QString basename = fileInfo.baseName();
+ int originId = current->getOrigin();
+ FilesOrigin &origin = m_OrganizerCore.directoryStructure()->getOriginByID(originId);
+
+ QTreeWidgetItem *newItem = new QTreeWidgetItem(QStringList()
+ << fileInfo.fileName()
+ << ToQString(origin.getName()));
newItem->setData(0, Qt::UserRole, index);
- newItem->setData(1, Qt::UserRole, origin);
+ newItem->setData(1, Qt::UserRole, originId);
newItem->setFlags(newItem->flags() & ~Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable);
newItem->setCheckState(0, (index != -1) ? Qt::Checked : Qt::Unchecked);
newItem->setData(0, Qt::UserRole, false);
if (m_OrganizerCore.settings().forceEnableCoreFiles()
- && defaultArchives.contains(filename)) {
+ && defaultArchives.contains(fileInfo.fileName())) {
newItem->setCheckState(0, Qt::Checked);
newItem->setDisabled(true);
newItem->setData(0, Qt::UserRole, true);
@@ -1356,7 +1355,7 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString
if (index < 0) index = 0;
- UINT32 sortValue = ((m_OrganizerCore.directoryStructure()->getOriginByID(origin).getPriority() & 0xFFFF) << 16) | (index & 0xFFFF);
+ UINT32 sortValue = ((origin.getPriority() & 0xFFFF) << 16) | (index & 0xFFFF);
items.push_back(std::make_pair(sortValue, newItem));
}
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index c065e587..a62c881d 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -528,7 +528,6 @@ void OrganizerCore::setCurrentProfile(const QString &profileName)
m_ModList.setProfile(newProfile);
connect(m_CurrentProfile, SIGNAL(modStatusChanged(uint)), this, SLOT(modStatusChanged(uint)));
-
refreshDirectoryStructure();
}
@@ -928,7 +927,7 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString &
prepareStart();
if (!binary.exists()) {
- reportError(tr("Executable \"%1\" not found").arg(binary.fileName()));
+ reportError(tr("Executable \"%1\" not found").arg(binary.absoluteFilePath()));
return INVALID_HANDLE_VALUE;
}
@@ -1223,7 +1222,9 @@ void OrganizerCore::updateModInDirectoryStructure(unsigned int index, ModInfo::P
if (m_UserInterface != nullptr) {
m_UserInterface->archivesWriter().write();
}
- m_DirectoryRefresher.setMods(m_CurrentProfile->getActiveMods(), enabledArchives());
+ std::vector<QString> archives = enabledArchives();
+ m_DirectoryRefresher.setMods(m_CurrentProfile->getActiveMods(),
+ std::set<QString>(archives.begin(), archives.end()));
// finally also add files from bsas to the directory structure
m_DirectoryRefresher.addModBSAToStructure(m_DirectoryStructure
@@ -1290,13 +1291,13 @@ IPluginGame *OrganizerCore::managedGame() const
return m_GamePlugin;
}
-std::set<QString> OrganizerCore::enabledArchives()
+std::vector<QString> OrganizerCore::enabledArchives()
{
- std::set<QString> result;
+ std::vector<QString> result;
QFile archiveFile(m_CurrentProfile->getArchivesFileName());
if (archiveFile.open(QIODevice::ReadOnly)) {
while (!archiveFile.atEnd()) {
- result.insert(QString::fromUtf8(archiveFile.readLine()).trimmed());
+ result.push_back(QString::fromUtf8(archiveFile.readLine()).trimmed());
}
archiveFile.close();
}
@@ -1310,8 +1311,9 @@ void OrganizerCore::refreshDirectoryStructure()
m_DirectoryUpdate = true;
std::vector<std::tuple<QString, QString, int> > activeModList = m_CurrentProfile->getActiveMods();
-
- m_DirectoryRefresher.setMods(activeModList, enabledArchives());
+ auto archives = enabledArchives();
+ m_DirectoryRefresher.setMods(activeModList,
+ std::set<QString>(archives.begin(), archives.end()));
QTimer::singleShot(0, &m_DirectoryRefresher, SLOT(refresh()));
}
diff --git a/src/organizercore.h b/src/organizercore.h
index e9914ea7..d60ce2ab 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -92,7 +92,7 @@ public:
Profile *currentProfile() { return m_CurrentProfile; }
void setCurrentProfile(const QString &profileName);
- std::set<QString> enabledArchives();
+ std::vector<QString> enabledArchives();
MOBase::VersionInfo getVersion() const { return m_Updater.getVersion(); }