Ref T705, remember matching script directories

This commit is contained in:
Klaus Basan
2019-07-20 14:20:12 +02:00
committed by Mat Sutcliffe
parent d5a4e3d70d
commit 1f148cf7f8
7 changed files with 48 additions and 11 deletions

View File

@@ -47,6 +47,15 @@ namespace BlackMisc
this->setLastModelDirectory(dir);
}
QString CDirectories::getMatchingScriptDirectoryOrDefault() const
{
if (m_dirMatchingScript.isEmpty())
{
return CDirectoryUtils::shareMatchingScriptDirectory();
}
return m_dirMatchingScript;
}
QString CDirectories::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
@@ -59,13 +68,14 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDirFlightPlan: return CVariant::fromValue(m_dirFlightPlan);
case IndexDirFlightPlanOrDefault: return CVariant::fromValue(this->getFlightPlanDirectoryOrDefault());
case IndexDirLastViewJson: return CVariant::fromValue(m_dirLastViewJson);
case IndexDirLastViewJsonOrDefault: return CVariant::fromValue(this->getLastViewJsonDirectoryOrDefault());
case IndexDirLastModelJson: return CVariant::fromValue(m_dirLastModelStashJson);
case IndexDirFlightPlan: return CVariant::fromValue(m_dirFlightPlan);
case IndexDirFlightPlanOrDefault: return CVariant::fromValue(this->getFlightPlanDirectoryOrDefault());
case IndexDirLastViewJson: return CVariant::fromValue(m_dirLastViewJson);
case IndexDirLastViewJsonOrDefault: return CVariant::fromValue(this->getLastViewJsonDirectoryOrDefault());
case IndexDirLastModelJson: return CVariant::fromValue(m_dirLastModelStashJson);
case IndexDirLastModelJsonOrDefault: return CVariant::fromValue(this->getLastModelDirectoryOrDefault());
case IndexDirLastModelStashJson: return CVariant::fromValue(m_dirLastModelStashJson);
case IndexDirLastModelStashJson: return CVariant::fromValue(m_dirLastModelStashJson);
case IndexDirMatchingScript: return CVariant::fromValue(this->getMatchingScriptDirectoryOrDefault());
case IndexDirLastModelStashJsonOrDefault: return CVariant::fromValue(this->getLastModelStashDirectoryOrDefault());
default: return CValueObject::propertyByIndex(index);
}
@@ -84,6 +94,7 @@ namespace BlackMisc
case IndexDirLastModelJson: this->setLastModelDirectory(variant.toQString()); break;
case IndexDirLastModelStashJsonOrDefault:
case IndexDirLastModelStashJson: this->setLastModelStashDirectory(variant.toQString()); break;
case IndexDirMatchingScript: this->setMatchingScriptDirectory(variant.toQString()); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}

View File

@@ -37,7 +37,8 @@ namespace BlackMisc
IndexDirLastModelJson,
IndexDirLastModelJsonOrDefault,
IndexDirLastModelStashJson,
IndexDirLastModelStashJsonOrDefault
IndexDirLastModelStashJsonOrDefault,
IndexDirMatchingScript
};
//! Constructor
@@ -85,6 +86,12 @@ namespace BlackMisc
//! Last view JSON model stash directory
void setLastModelStashDirectory(const QString &dir);
//! Matching script directory
QString getMatchingScriptDirectoryOrDefault() const;
//! Matching script directory
void setMatchingScriptDirectory(const QString &dir) { m_dirMatchingScript = dir; }
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
@@ -102,6 +109,7 @@ namespace BlackMisc
QString m_dirLastViewJson; //!< last JSON save directory
QString m_dirLastModelJson; //!< last JSON model directory
QString m_dirLastModelStashJson; //!< last JSON model stash save directory
QString m_dirMatchingScript; //!< matching script dir
//! Return checkDir if existing, defaultDir otherwise
QString existingOrDefaultDir(const QString &checkDir, const QString &defaultDir) const;
@@ -111,7 +119,8 @@ namespace BlackMisc
BLACK_METAMEMBER(dirFlightPlan),
BLACK_METAMEMBER(dirLastViewJson),
BLACK_METAMEMBER(dirLastModelJson),
BLACK_METAMEMBER(dirLastModelStashJson)
BLACK_METAMEMBER(dirLastModelStashJson),
BLACK_METAMEMBER(dirMatchingScript)
);
};

View File

@@ -241,6 +241,12 @@ namespace BlackMisc
return tpd;
}
const QString &CDirectoryUtils::shareMatchingScriptDirectory()
{
static const QString ms(CFileUtils::appendFilePaths(CDirectoryUtils::shareDirectory(), "matchingscript"));
return ms;
}
const QString &CDirectoryUtils::bootstrapFileName()
{
static const QString n("bootstrap.json");

View File

@@ -96,6 +96,9 @@ namespace BlackMisc
//! FSX/P3D terrain probe
static const QString &shareTerrainProbeDirectory();
//! Matching script examples directories
static const QString &shareMatchingScriptDirectory();
//! Bootstrap file name
static const QString &bootstrapFileName();