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