Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Static Public Member Functions
qSlicerUtils Class Reference

#include <Base/QTCore/qSlicerUtils.h>

Public Types

typedef qSlicerUtils Self
 

Static Public Member Functions

static QString executableExtension ()
 
static QString extractModuleNameFromClassName (const QString &className)
 
static QString extractModuleNameFromLibraryName (const QString &libraryName)
 This function returns ".dll. on windows, ".so" on linux and ".dylib" on Mac. More...
 
static bool isCLIExecutable (const QString &filePath)
 Returns true if the filePath matches the CLI executable file name requirements. More...
 
static bool isCLILoadableModule (const QString &filePath)
 
static bool isCLIScriptedExecutable (const QString &filePath)
 Returns true if the filePath matches scripted CLI requirements. More...
 
static bool isExecutableName (const QString &name)
 
static bool isLoadableModule (const QString &filePath)
 
static bool isPluginBuiltIn (const QString &filePath, const QString &applicationHomeDir, const QString &applicationRevision)
 Return true if the plugin identified with its filePath is a built-in Slicer module. More...
 
static bool isPluginInstalled (const QString &filePath, const QString &applicationHomeDir)
 
static bool isTestingModule (qSlicerAbstractCoreModule *module)
 
static bool pathEndsWith (const QString &inputPath, const QString &path)
 Return true if the inputPath ends with path. More...
 
static QString pathWithoutIntDir (const QString &path, const QString &subDirWithoutIntDir)
 
static QString pathWithoutIntDir (const QString &path, const QString &subDirWithoutIntDir, QString &intDir)
 
static QString replaceDocumentationUrlVersion (const QString &text, const QString &hostname, const QString &version)
 Return an updated text where Slicer documentation URL version is replaced with the provided one. More...
 
static QString replaceWikiUrlVersion (const QString &text, const QString &version)
 Return an updated text where Slicer wiki URL version is replaced with the provided one. It is now deprecated as the Slicer wiki is no longer recommended for storing documentation. Instead Slicer core documentation is hosted on ReadTheDocs (and versioning can be implemented using replaceDocumentationUrlVersion) and extension documentation is expected to be hosted in each extension's repository (and modules in extensions can create versioned links for their documentation using qSlicerCoreApplication::documentationVersion()). More...
 
static QString searchTargetInIntDir (const QString &directory, const QString &target)
 
static bool setPermissionsRecursively (const QString &path, QFile::Permissions directoryPermissions, QFile::Permissions filePermissions)
 

Detailed Description

Definition at line 31 of file qSlicerUtils.h.

Member Typedef Documentation

◆ Self

Definition at line 35 of file qSlicerUtils.h.

Member Function Documentation

◆ executableExtension()

static QString qSlicerUtils::executableExtension ( )
static

This function returns an empty string on all plateform expected windows where it returns ".exe"

◆ extractModuleNameFromClassName()

static QString qSlicerUtils::extractModuleNameFromClassName ( const QString &  className)
static

Extract module name givew a className For example: qSlicerThresholdModule -> Threshold

◆ extractModuleNameFromLibraryName()

static QString qSlicerUtils::extractModuleNameFromLibraryName ( const QString &  libraryName)
static

This function returns ".dll. on windows, ".so" on linux and ".dylib" on Mac.

Extract module name given a library name For example: on linux, libThresholdLib.so -> Threshold on mac, libThresholdLib.{dylib, bundle, so} -> Threshold on windows, ThresholdLib.dll -> Threshold

◆ isCLIExecutable()

static bool qSlicerUtils::isCLIExecutable ( const QString &  filePath)
static

Returns true if the filePath matches the CLI executable file name requirements.

◆ isCLILoadableModule()

static bool qSlicerUtils::isCLILoadableModule ( const QString &  filePath)
static

Returns true if the filePath matches the CLI loadable module file name requirements.

Note
Associated fileName is expected to match the following regular expression: "(lib)?.+Lib\\.(dll|DLL|so|dylib)"

◆ isCLIScriptedExecutable()

static bool qSlicerUtils::isCLIScriptedExecutable ( const QString &  filePath)
static

Returns true if the filePath matches scripted CLI requirements.

◆ isExecutableName()

static bool qSlicerUtils::isExecutableName ( const QString &  name)
static

Return true if the string name ends with one of these executable extension: ".bat", ".com", ".sh", ".csh", ".tcsh", ".pl", ".py", ".tcl", ".m", ".exe"

Note
The comparison is case insensitive

◆ isLoadableModule()

static bool qSlicerUtils::isLoadableModule ( const QString &  filePath)
static

Return true if filePath matches the loadable module file name requirements.

Note
Associated fileName is expected to match the following regular expression: "(lib)?qSlicer.+Module\\.(so, dll, dylib)"

◆ isPluginBuiltIn()

static bool qSlicerUtils::isPluginBuiltIn ( const QString &  filePath,
const QString &  applicationHomeDir,
const QString &  applicationRevision 
)
static

Return true if the plugin identified with its filePath is a built-in Slicer module.

◆ isPluginInstalled()

static bool qSlicerUtils::isPluginInstalled ( const QString &  filePath,
const QString &  applicationHomeDir 
)
static

Return true if the plugin identified with its filePath is loaded from an install tree.

Warning
Since internally the function looks for the existence of CMakeCache.txt, it will return an incorrect result if the plugin is installed in the build tree of an other project.

◆ isTestingModule()

static bool qSlicerUtils::isTestingModule ( qSlicerAbstractCoreModule module)
static

Return true is the module is for testing purposes. These modules are for testing and for troubleshooting and normally should not be displayed to end users.

◆ pathEndsWith()

static bool qSlicerUtils::pathEndsWith ( const QString &  inputPath,
const QString &  path 
)
static

Return true if the inputPath ends with path.

◆ pathWithoutIntDir() [1/2]

static QString qSlicerUtils::pathWithoutIntDir ( const QString &  path,
const QString &  subDirWithoutIntDir 
)
static

Return the path without the intermediate directory or return path if there is no expected "IntDir". subDirWithoutIntDir corresponds to N last compononent of the path excluding the "IntDir".

Path subDirWithoutIntDir Return IntDir
/path/to/lib/module/Foo lib/module /path/to/lib/module Foo
/path/to/lib/module/Release lib/module /path/to/lib/module Release
/path/to/lib/module/Release/ lib/module /path/to/lib/module Release
/path/to/lib/module/Release module /path/to/lib/module Release
/path/to/lib/module/Release (Empty string) /path/to/lib/module/Release (Empty string)
/path/to/lib/module/Release/foo.txt lib/module /path/to/lib/module/Release/foo.txt (Empty string)
/path/to/lib/module/Release/foo.txt lib/module/Release /path/to/lib/module/Release foo.txt
/path/to/lib/module/Release /path/to/lib/module /path/to/lib/module Release
/path/to/bin lib/module /path/to/bin (Empty string)
/path/to/Foo.app/Contents/MacOSX bin /path/to/Foo.app/Contents/MacOSX (Empty string)

◆ pathWithoutIntDir() [2/2]

static QString qSlicerUtils::pathWithoutIntDir ( const QString &  path,
const QString &  subDirWithoutIntDir,
QString &  intDir 
)
static

◆ replaceDocumentationUrlVersion()

static QString qSlicerUtils::replaceDocumentationUrlVersion ( const QString &  text,
const QString &  hostname,
const QString &  version 
)
static

Return an updated text where Slicer documentation URL version is replaced with the provided one.

Any URL that contains /<VERSION>/ and with URL host name that contains the provided hostname string will be updated.

Following readthedocs versioning conventions, <VERSION> can be <major>.<minor>, v<major>.<minor>, latest, or stable.

Only the first occurrence of version is replaced (to keep file or directory names that have a name that matches accepted version patterns unchanged). For example, in https://slicer.readthedocs.io/en/latest/user_guide/schema/1.0/something.html the 1.0 folder name will not be changed (only latest will be set to the actual version).

Limitations:

  • language code is not updated (the language specified in the original URL will be used)
  • extensions that have versioned documentation maintained in their own repository have to generate their versioned links (for example, using qSlicerCoreApplication::documentationVersion()).

◆ replaceWikiUrlVersion()

static QString qSlicerUtils::replaceWikiUrlVersion ( const QString &  text,
const QString &  version 
)
static

Return an updated text where Slicer wiki URL version is replaced with the provided one. It is now deprecated as the Slicer wiki is no longer recommended for storing documentation. Instead Slicer core documentation is hosted on ReadTheDocs (and versioning can be implemented using replaceDocumentationUrlVersion) and extension documentation is expected to be hosted in each extension's repository (and modules in extensions can create versioned links for their documentation using qSlicerCoreApplication::documentationVersion()).

Any URL containing Documentation/<VERSION>/ will be updated.

More specifically, in an URL with http or https protocol that contains "Documentation" path element, the following path element is replaced by the provided version. If there are multiple "Documentation" path elements then only the first one is considered.

Note
The "path element" term is defined in this rfc: https://tools.ietf.org/html/rfc3986 "A path consists of a sequence of path segments separated by a slash ("/") character."

Examples:

CHECK_QSTRING(
qSlicerUtils::replaceWikiUrlVersion("https://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/SlicerToKiwiExporter", "4.4"),
"https://wiki.slicer.org/slicerWiki/index.php/Documentation/4.4/Extensions/SlicerToKiwiExporter");
CHECK_QSTRING(
qSlicerUtils::replaceWikiUrlVersion("https://wiki.slicer.org/slicerWiki/index.php/Documentation/Foo/Extensions/SlicerToKiwiExporter", "Bar"),
"https://wiki.slicer.org/slicerWiki/index.php/Documentation/Bar/Extensions/SlicerToKiwiExporter");
CHECK_QSTRING(
qSlicerUtils::replaceWikiUrlVersion("https://wiki.slicer.org/slicerWiki/index.php/Documentation/Foo/Extensions/SlicerToKiwiExporter/Foo", "Bar"),
"https://wiki.slicer.org/slicerWiki/index.php/Documentation/Bar/Extensions/SlicerToKiwiExporter/Foo");
QString input =
"Read documentation at "
"https://wiki.slicer.org/slicerWiki/index.php/Documentation/4.4/Extensions/SlicerToKiwiExporter."
"You will learn how to ...";
QString expectedOutput =
"Read documentation at "
"https://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/SlicerToKiwiExporter."
"You will learn how to ...";
CHECK_QSTRING(qSlicerUtils::replaceWikiUrlVersion(input, "Nightly"), expectedOutput);

◆ searchTargetInIntDir()

static QString qSlicerUtils::searchTargetInIntDir ( const QString &  directory,
const QString &  target 
)
static

Look for target file in build intermediate directory. On windows, the intermediate directory includes: . Debug RelWithDebInfo Release MinSizeRel And it return the first matched directory On the other plateform, this function just return the directory passed as a first argument

◆ setPermissionsRecursively()

static bool qSlicerUtils::setPermissionsRecursively ( const QString &  path,
QFile::Permissions  directoryPermissions,
QFile::Permissions  filePermissions 
)
static

Set permissions of path. If path is a directory, permissions will be set to all its descendant. While recursively traversing the tree structure, if path or one of its descendant is a file, filePermissions will be set otherwise directoryPermissions will be set.

Note
If for some reason, permissions on a file or directory failed to be set, the traversing will be aborted and the permission already set won't be reverted.
Returns
true on success, false otherwise.
See also
QFile::setPermissions()

The documentation for this class was generated from the following file: