diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-05-01 18:00:31 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-05-07 12:16:33 +0200 |
| commit | 40c433580f69006a42dc27a6444ebd9a6cccc440 (patch) | |
| tree | 426524068d3dbfcf9aba495d78a5c7bd4316dca8 /src/modinforegular.cpp | |
| parent | cd2b7683b78503d4fef1946de088108b812b387c (diff) | |
Update ModInfo classes to handle plugin game and clean some declarations.
Diffstat (limited to 'src/modinforegular.cpp')
| -rw-r--r-- | src/modinforegular.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 3cff914a..6a0a1b7d 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -1,4 +1,5 @@ #include "modinforegular.h" +#include "installationtester.h" #include "categories.h" #include "messagedialog.h" @@ -29,6 +30,7 @@ ModInfoRegular::ModInfoRegular(PluginContainer *pluginContainer, const IPluginGa , m_Name(path.dirName()) , m_Path(path.absolutePath()) , m_Repository() + , m_GamePlugin(game) , m_GameName(game->gameShortName()) , m_IsAlternate(false) , m_Converted(false) @@ -269,6 +271,34 @@ void ModInfoRegular::saveMeta() } } +bool ModInfoRegular::doTestValid() const { + + bool valid = false; + QDirIterator dirIter(absolutePath()); + while (dirIter.hasNext()) { + dirIter.next(); + if (dirIter.fileInfo().isDir()) { + if (InstallationTester::isTopLevelDirectory(dirIter.fileName())) { + valid = true; + break; + } + } + else { + if (InstallationTester::isTopLevelSuffix(dirIter.fileName())) { + valid = true; + break; + } + } + } + + // NOTE: in Qt 4.7 it seems that QDirIterator leaves a file handle open if it is not iterated to the + // end + while (dirIter.hasNext()) { + dirIter.next(); + } + + return valid; +} bool ModInfoRegular::updateAvailable() const { @@ -467,10 +497,12 @@ void ModInfoRegular::setNotes(const QString ¬es) m_MetaInfoChanged = true; } -void ModInfoRegular::setGameName(const QString &gameName) +void ModInfoRegular::setGamePlugin(const MOBase::IPluginGame* gamePlugin) { - m_GameName = gameName; + m_GamePlugin = gamePlugin; + m_GameName = gamePlugin->gameShortName(); m_MetaInfoChanged = true; + testValid(); } void ModInfoRegular::setNexusID(int modID) |
