Skip to content

Commit a002b31

Browse files
Split profiles method into profileNames and getProfile
1 parent 1a4ced0 commit a002b31

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

src/organizercore.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -614,21 +614,22 @@ void OrganizerCore::setCurrentProfile(const QString& profileName)
614614
m_ProfileChanged(oldProfile.get(), m_CurrentProfile.get());
615615
}
616616

617-
std::vector<std::shared_ptr<const MOBase::IProfile>> OrganizerCore::profiles() const
617+
QStringList OrganizerCore::profileNames() const
618618
{
619619
QDir profilesDir(m_Settings.paths().profiles());
620-
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles;
621-
for (auto info : profilesDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot)) {
622-
try {
623-
profiles.push_back(std::make_shared<const Profile>(
624-
info.absoluteFilePath(), managedGame(), gameFeatures()));
625-
} catch (std::exception& e) {
626-
log::error("failed to load profile '{}': {}", info.fileName(), e.what());
627-
continue;
628-
}
620+
return profilesDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
621+
}
622+
623+
std::shared_ptr<const MOBase::IProfile>
624+
OrganizerCore::getProfile(const QString& profileName) const
625+
{
626+
QDir profileDir(m_Settings.paths().profiles());
627+
profileDir.cd(profileName);
628+
if (!profileDir.exists()) {
629+
return nullptr;
629630
}
630631

631-
return profiles;
632+
return std::make_shared<Profile>(profileDir, managedGame(), gameFeatures());
632633
}
633634

634635
MOBase::IModRepositoryBridge* OrganizerCore::createNexusBridge() const

src/organizercore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose
273273
Profile* currentProfile() const { return m_CurrentProfile.get(); }
274274
void setCurrentProfile(const QString& profileName);
275275

276-
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles() const;
276+
QStringList profileNames() const;
277+
std::shared_ptr<const MOBase::IProfile> getProfile(const QString& profileName) const;
277278

278279
std::vector<QString> enabledArchives();
279280

src/organizerproxy.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <QObject>
1818

1919
#include <memory>
20-
#include <vector>
2120

2221
using namespace MOBase;
2322
using namespace MOShared;
@@ -376,9 +375,15 @@ MOBase::IProfile* OrganizerProxy::profile() const
376375
return m_Proxied->currentProfile();
377376
}
378377

379-
std::vector<std::shared_ptr<const MOBase::IProfile>> OrganizerProxy::profiles() const
378+
QStringList OrganizerProxy::profileNames() const
380379
{
381-
return m_Proxied->profiles();
380+
return m_Proxied->profileNames();
381+
}
382+
383+
std::shared_ptr<const MOBase::IProfile>
384+
OrganizerProxy::getProfile(const QString& name) const
385+
{
386+
return m_Proxied->getProfile(name);
382387
}
383388

384389
MOBase::IPluginGame const* OrganizerProxy::managedGame() const

src/organizerproxy.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class OrganizerProxy : public MOBase::IOrganizer
6666
MOBase::IPluginList* pluginList() const override;
6767
MOBase::IModList* modList() const override;
6868
MOBase::IProfile* profile() const override;
69-
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles() const override;
69+
QStringList profileNames() const override;
70+
std::shared_ptr<const MOBase::IProfile>
71+
getProfile(const QString& name) const override;
72+
7073
MOBase::IGameFeatures* gameFeatures() const override;
7174

7275
HANDLE startApplication(const QString& executable,

0 commit comments

Comments
 (0)