Represents container for settings read from the resource file. More...
Public Member Functions | |
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... | |
Protected Member Functions | |
QtxResourceMgr * | resMgr () const |
Get resource manager. More... | |
Private Types | |
typedef QMap< QString, Section > | SectionMap |
typedef QMap< QString, QString > | OptionsMap |
Private Member Functions | |
Section | section (const QString &) |
Get resources section by specified name. More... | |
const Section | section (const QString &) const |
Get resources section by specified name. More... | |
QString | makeSubstitution (const QString &, const QString &, const QString &, const OptionsMap &) const |
Substitute variables by their values. More... | |
QString | fileName (const QString &, const QString &, const QString &, const OptionsMap &) const |
Get file path. More... | |
Private Attributes | |
QtxResourceMgr * | myMgr |
resources manager More... | |
SectionMap | mySections |
sections map More... | |
QString | myFileName |
resources file name More... | |
QMap< QString, QPixmap > | myPixmapCache |
pixmaps cache More... | |
Friends | |
class | QtxResourceMgr::Format |
Represents container for settings read from the resource file.
|
private |
|
private |
QtxResourceMgr::Resources::Resources | ( | QtxResourceMgr * | mgr, |
const QString & | fileName | ||
) |
Constructor.
mgr | parent resources manager |
fileName | resources file name |
|
virtual |
Destructor.
void QtxResourceMgr::Resources::clear | ( | ) |
Remove all sections.
QString QtxResourceMgr::Resources::file | ( | ) | const |
Get resources file name.
This file is used to load/save operations.
|
private |
Get file path.
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.
sec | section name |
prefix | parameter containing directory name |
name | file name |
References Qtx::addSlash(), QtxResourceMgr::constants(), Qtx::dir(), QtxResourceMgr::hasValue(), QtxResourceMgr::path(), and QtxResourceMgr::value().
bool QtxResourceMgr::Resources::hasSection | ( | const QString & | sect | ) | const |
Check section existence.
sect | section name |
true
if section exists bool QtxResourceMgr::Resources::hasValue | ( | const QString & | sect, |
const QString & | name | ||
) | const |
Check parameter existence.
sect | section name |
name | parameter name |
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 |
Load and return pixmap from external file.
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.
sect | section name |
prefix | parameter containing resources directory name |
name | pixmap file name |
References QtxResourceMgr::constants().
QTranslator * QtxResourceMgr::Resources::loadTranslator | ( | const QString & | sect, |
const QString & | prefix, | ||
const QString & | name, | ||
const OptionsMap & | constants | ||
) | const |
Load translator.
sect | section name |
prefix | parameter containing resources directory |
name | translation file name |
References QtxResourceMgr::constants(), Qtx::dir(), and Qtx::file().
|
private |
Substitute variables by their values.
Environment variable is substituted by its value. For other variables resource manager tries to find value among defined resources parameters.
str | string to be processed |
sect | section, where variables are searched |
name | name of variable which must be ignored during substitution |
References QtxResourceMgr::constants(), Qtx::findEnvVar(), Qtx::getenv(), QtxResourceMgr::hasValue(), and QtxResourceMgr::value().
QStringList QtxResourceMgr::Resources::parameters | ( | const QString & | sec | ) | const |
Get all parameters name in specified section.
sec | section name |
References QtxResourceMgr::hasSection().
QString QtxResourceMgr::Resources::path | ( | const QString & | sec, |
const QString & | prefix, | ||
const QString & | name, | ||
const OptionsMap & | constants | ||
) | const |
Get absolute path to the file which name is defined by the parameter.
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.
sec | section name |
prefix | parameter containing directory name |
name | file name |
References QtxResourceMgr::constants().
void QtxResourceMgr::Resources::removeSection | ( | const QString & | sect | ) |
Remove resourcs section.
sect | secton name |
void QtxResourceMgr::Resources::removeValue | ( | const QString & | sect, |
const QString & | name | ||
) |
Remove parameter from the section.
sect | section name |
name | parameter name |
|
protected |
Get resource manager.
|
private |
Get resources section by specified name.
If section does not exist it is created (empty).
sn | section name |
References IMap< Key, Value >::insert().
|
private |
Get resources section by specified name.
sn | section name |
QStringList QtxResourceMgr::Resources::sections | ( | ) | const |
Get all sections names.
void QtxResourceMgr::Resources::setFile | ( | const QString & | fn | ) |
void QtxResourceMgr::Resources::setValue | ( | const QString & | sect, |
const QString & | name, | ||
const QString & | val | ||
) |
Set parameter value.
sect | section name |
name | parameter name |
val | parameter value |
QString QtxResourceMgr::Resources::value | ( | const QString & | sect, |
const QString & | name, | ||
const bool | subst, | ||
const OptionsMap & | constants | ||
) | const |
Get string representation of parameter value.
sect | section name |
name | parameter name |
subst | if true , perform variables substitution |
References QtxResourceMgr::constants(), and QtxResourceMgr::hasValue().
|
friend |
|
private |
resources file name
|
private |
resources manager
|
private |
pixmaps cache
|
private |
sections map