return map.keys();
}
+/*!
+ \brief Get all sections names matching specified regular expression.
+ \param re searched regular expression
+ \return list of sections names
+*/
+QStringList QtxResourceMgr::sections(const QRegExp& re) const
+{
+ return sections().filter( re );
+}
+
+/*!
+ \brief Get all sections names with the prefix specified by passed
+ list of parent sections names.
+
+ Sub-sections are separated inside the section name by the sections
+ separator token, for example "splash:color:label".
+
+ \param names parent sub-sections names
+ \return list of sections names
+*/
+QStringList QtxResourceMgr::sections(const QStringList& names) const
+{
+ QStringList nm = names;
+ nm << ".+";
+ QRegExp re( QString( "^%1$" ).arg( nm.join( sectionsToken() ) ) );
+ return sections( re );
+}
+
+/*!
+ \brief Get list of sub-sections names for the specified parent section name.
+
+ Sub-sections are separated inside the section name by the sections
+ separator token, for example "splash:color:label".
+
+ \param section parent sub-section name
+ \param full if \c true return full names of child sub-sections, if \c false,
+ return only top-level sub-sections names
+ \return list of sub-sections names
+*/
+QStringList QtxResourceMgr::subSections(const QString& section, const bool full) const
+{
+ QStringList names = sections( QStringList() << section );
+ QMutableListIterator<QString> it( names );
+ while ( it.hasNext() ) {
+ QString name = it.next().mid( section.size() ).trimmed();
+ if ( name.isEmpty() ) {
+ it.remove();
+ continue;
+ }
+ if ( !full ) name = name.split( sectionsToken() ).first();
+ it.setValue( name );
+ }
+ names.removeDuplicates();
+ names.sort();
+ return names;
+}
+
/*!
\brief Get all parameters name in specified section.
\param sec section name
\brief Get application resources section name.
By default, application resources section name is "resources" but
- it can be changed by setting the corresponding resources manager option.
+ it can be changed by setting the "res_section_name" resources manager option.
\return section corresponding to the resources directories
\sa option(), setOption()
\brief Get application language section name.
By default, application language section name is "language" but
- it can be changed by setting the corresponding resources manager option.
+ it can be changed by setting the "lang_section_name" resources manager option.
\return section corresponding to the application language settings
\sa option(), setOption()
return res;
}
+/*!
+ \brief Get sections separator token.
+
+ By default, sections separator token is colon symbol ":" but
+ it can be changed by setting the "section_token" resources manager option.
+
+ \return string corresponding to the current section separator token
+ \sa option(), setOption()
+*/
+QString QtxResourceMgr::sectionsToken() const
+{
+ QString res = option( "section_token" );
+ if ( res.isEmpty() )
+ res = QString( ":" );
+ return res;
+}
+
/*!
\brief Get default pixmap.
QString resSection() const;
QString langSection() const;
+ QString sectionsToken() const;
QPixmap loadPixmap( const QString&, const QString& ) const;
QPixmap loadPixmap( const QString&, const QString&, const bool ) const;
bool save();
QStringList sections() const;
+ QStringList sections(const QRegExp&) const;
+ QStringList sections(const QStringList&) const;
+ QStringList subSections(const QString&, const bool = true) const;
QStringList parameters( const QString& ) const;
void refresh();