Represents container for settings read from the resource file.
More...
|
| Resources (QtxResourceMgr *, const QString &) |
| Constructor. More...
|
|
virtual | ~Resources () |
| Destructor. More...
|
|
QString | file () const |
| Get resources file name. More...
|
|
void | setFile (const QString &) |
| Set resources file name. More...
|
|
QString | value (const QString &, const QString &, const bool, const OptionsMap &) const |
| Get string representation of parameter value. More...
|
|
void | setValue (const QString &, const QString &, const QString &) |
| Set parameter value. More...
|
|
bool | hasSection (const QString &) const |
| Check section existence. More...
|
|
bool | hasValue (const QString &, const QString &) const |
| Check parameter existence. More...
|
|
void | removeSection (const QString &) |
| Remove resourcs section. More...
|
|
void | removeValue (const QString &, const QString &) |
| Remove parameter from the section. More...
|
|
QPixmap | loadPixmap (const QString &, const QString &, const QString &, const OptionsMap &) const |
| Load and return pixmap from external file. More...
|
|
QTranslator * | loadTranslator (const QString &, const QString &, const QString &, const OptionsMap &) const |
| Load translator. More...
|
|
void | clear () |
| Remove all sections. More...
|
|
QStringList | sections () const |
| Get all sections names. More...
|
|
QStringList | parameters (const QString &) const |
| Get all parameters name in specified section. More...
|
|
QString | path (const QString &, const QString &, const QString &, const OptionsMap &) const |
| Get absolute path to the file which name is defined by the parameter. More...
|
|
- Parameters
-
mgr | parent resources manager |
fileName | resources file name |
QtxResourceMgr::Resources::~Resources |
( |
| ) |
|
|
virtual |
void QtxResourceMgr::Resources::clear |
( |
| ) |
|
QString QtxResourceMgr::Resources::file |
( |
| ) |
const |
This file is used to load/save operations.
- Returns
- file name
- See Also
- setFile()
QString QtxResourceMgr::Resources::fileName |
( |
const QString & |
sect, |
|
|
const QString & |
prefix, |
|
|
const QString & |
name, |
|
|
const OptionsMap & |
constants |
|
) |
| const |
|
private |
The file name is defined by name argument, while directory name is retrieved from resources parameter prefix of section sec. Both directory and file name can be relative. If the directory is relative, it is calculated from the initial resources file name (see file()). Directory parameter can contain environment variables, which are substituted automatically. File existence is not checked.
- Parameters
-
sec | section name |
prefix | parameter containing directory name |
name | file name |
- Returns
- absolute file path or null QString if prefix parameter does not exist in section
- See Also
- path(), file(), makeSubstitution()
References Qtx::addSlash(), Qtx::dir(), QtxResourceMgr::hasValue(), QtxResourceMgr::path(), and QtxResourceMgr::value().
bool QtxResourceMgr::Resources::hasSection |
( |
const QString & |
sect | ) |
const |
- Parameters
-
- Returns
true
if section exists
bool QtxResourceMgr::Resources::hasValue |
( |
const QString & |
sect, |
|
|
const QString & |
name |
|
) |
| const |
- Parameters
-
sect | section name |
name | parameter name |
- Returns
true
if parameter exists in specified section
References QtxResourceMgr::hasSection().
QPixmap QtxResourceMgr::Resources::loadPixmap |
( |
const QString & |
sect, |
|
|
const QString & |
prefix, |
|
|
const QString & |
name, |
|
|
const OptionsMap & |
constants |
|
) |
| const |
If QtxResourceMgr::isPixmapCached() is true
then cached pixmap is returned (if it is already loaded), otherwise it is loaded from file. If the file name is invalid, null pixmap is returned.
- Parameters
-
sect | section name |
prefix | parameter containing resources directory name |
name | pixmap file name |
- Returns
- pixmap loaded from file
- Parameters
-
sect | section name |
prefix | parameter containing resources directory |
name | translation file name |
- Returns
- just created and loaded translator or 0 in case of error
References Qtx::dir(), and Qtx::file().
QString QtxResourceMgr::Resources::makeSubstitution |
( |
const QString & |
str, |
|
|
const QString & |
sect, |
|
|
const QString & |
name, |
|
|
const OptionsMap & |
constants |
|
) |
| const |
|
private |
Environment variable is substituted by its value. For other variables resource manager tries to find value among defined resources parameters.
- Parameters
-
str | string to be processed |
sect | section, where variables are searched |
name | name of variable which must be ignored during substitution |
- Returns
- processed string (with all substitutions made)
References Qtx::findEnvVar(), QtxResourceMgr::hasValue(), and QtxResourceMgr::value().
QStringList QtxResourceMgr::Resources::parameters |
( |
const QString & |
sec | ) |
const |
The file name is defined by name argument, while directory name is retrieved from resources parameter prefix of section sec. Both directory and file name can be relative. If the directory is relative, it is calculated from the initial resources file name (see file()). Directory parameter can contain environment variables, which are substituted automatically.
- Parameters
-
sec | section name |
prefix | parameter containing directory name |
name | file name |
- Returns
- absolute file path or null QString if file does not exist
- See Also
- fileName(), file(), makeSubstitution()
void QtxResourceMgr::Resources::removeSection |
( |
const QString & |
sect | ) |
|
void QtxResourceMgr::Resources::removeValue |
( |
const QString & |
sect, |
|
|
const QString & |
name |
|
) |
| |
- Parameters
-
sect | section name |
name | parameter name |
- Returns
- resource manager pointer
- Parameters
-
- Returns
- resources section
QStringList QtxResourceMgr::Resources::sections |
( |
| ) |
const |
- Returns
- list of section names
void QtxResourceMgr::Resources::setFile |
( |
const QString & |
fn | ) |
|
void QtxResourceMgr::Resources::setValue |
( |
const QString & |
sect, |
|
|
const QString & |
name, |
|
|
const QString & |
val |
|
) |
| |
QString QtxResourceMgr::Resources::myFileName |
|
private |
QMap<QString,QPixmap> QtxResourceMgr::Resources::myPixmapCache |
|
private |
The documentation for this class was generated from the following file: