SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmmvis::project::examples Namespace Reference

Classes

struct  ExampleInfo
 

Functions

QString seedMarkerFileName ()
 
QString installExamplesDir ()
 
QString appDataExamplesDir ()
 
bool copyDirectoryRecursively (const QString &srcDir, const QString &dstDir, QString *err=nullptr)
 Recursively copies srcDir into dstDir (created if missing).
 
bool syncFromInstall (const QString &srcDir, const QString &dstDir, const QString &version, QString *err=nullptr)
 Syncs the install payload into the per-user dir.
 
QString preferredExamplesDir (const QString &version)
 Seeds and returns the directory the Welcome panel should scan.
 
QVector< ExampleInfodiscoverExamples (const QString &dir)
 Enumerates examples in dir.
 

Function Documentation

◆ appDataExamplesDir()

QString openswmmvis::project::examples::appDataExamplesDir ( )

The per-user writable mirror: QStandardPaths::writableLocation(AppLocalDataLocation) + "/examples". Requires the application identity (org/app name) to be set first.

Here is the caller graph for this function:

◆ copyDirectoryRecursively()

bool openswmmvis::project::examples::copyDirectoryRecursively ( const QString &  srcDir,
const QString &  dstDir,
QString *  err = nullptr 
)

Recursively copies srcDir into dstDir (created if missing).

Existing destination files are overwritten only when size or mtime differ (so re-seeding is cheap and user file timestamps survive no-op syncs). The seed marker file is never copied.

Returns
false on the first failed mkdir/copy, with err describing it.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ discoverExamples()

QVector< ExampleInfo > openswmmvis::project::examples::discoverExamples ( const QString &  dir)

Enumerates examples in dir.

Directory examples: every subdirectory containing at least one .oswp (preferred open target) or .inp. Flat examples: every top-level .inp (legacy single-file bundles). Display name/description/category come from an optional example.json manifest ({"name": …, "description": …, "category": …}) in the subdirectory, falling back to the prettified dir/file base name ('_'/'-' → spaces) and an empty category.

◆ installExamplesDir()

QString openswmmvis::project::examples::installExamplesDir ( )

First existing candidate of the install payload dir, matching the historical Welcome-panel scan: <appdir>/../share/openswmmgui/examples, <appdir>/../Resources/examples (macOS bundle), <appdir>/examples. Empty when none exists (dev build without staged examples).

Here is the caller graph for this function:

◆ preferredExamplesDir()

QString openswmmvis::project::examples::preferredExamplesDir ( const QString &  version)

Seeds and returns the directory the Welcome panel should scan.

Sync install → appdata and return the appdata dir; on any failure (unwritable appdata, …) warn and fall back to the read-only install dir. Empty when no install payload exists either.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ seedMarkerFileName()

QString openswmmvis::project::examples::seedMarkerFileName ( )

Name of the version-marker file written into the appdata examples dir ("\.seeded_version"). Excluded from discovery and from copy-on-open.

Here is the caller graph for this function:

◆ syncFromInstall()

bool openswmmvis::project::examples::syncFromInstall ( const QString &  srcDir,
const QString &  dstDir,
const QString &  version,
QString *  err = nullptr 
)

Syncs the install payload into the per-user dir.

The tree is always walked (see copyDirectoryRecursively — a per-file size + mtime no-op, so an up-to-date mirror costs one stat per file) and the marker is rewritten with version as a record of the last seeding app. There is deliberately no marker-equals-version fast path: the payload changes within a version on every dev build and on any release that adds examples without a version bump, and a fast path left the mirror — and therefore the Welcome page — without the new examples.

Known limitation: the sync only adds and refreshes. An example removed from the install payload is NOT pruned from the mirror and keeps appearing on the Welcome page until the per-user examples dir is deleted.

Returns
false when the destination could not be created/written.
Here is the call graph for this function:
Here is the caller graph for this function: