libyui
3.4.2
|
Abstract base class for filter views with hierarchical filter criteria - e.g., RPM group tags, MIME types. More...
#include <YStringTree.h>
Public Member Functions | |
YStringTree (const char *textdomain) | |
Constructor. More... | |
virtual | ~YStringTree () |
Destructor. | |
YStringTreeItem * | addBranch (const std::string &content, char delimiter=0, YStringTreeItem *parent=0) |
Add a unique new branch with text content 'content' to the tree, beginning at 'parent' (root if parent == 0). More... | |
std::string | origPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true) |
Construct a complete original path for the specified tree item. More... | |
std::string | translatedPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true) |
Construct a complete original path for the specified tree item. More... | |
YTransText | path (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true) |
Construct a complete path (both original and translated) for the specified tree item. More... | |
void | logTree () |
Debugging - dump the tree into the log file. | |
YStringTreeItem * | root () const |
Returns the root of the filter view tree. More... | |
const char * | textdomain () const |
Returns the textdomain used internally for translation of pathname components. | |
void | setTextdomain (const char *domain) |
Set the textdomain used internally for translation of pathname components. More... | |
std::string | translate (const std::string &orig) |
Translate message 'orig' using the internal textdomain. More... | |
Protected Member Functions | |
std::string | completePath (const YStringTreeItem *item, bool translated, char delimiter, bool startWithDelimiter) |
Construct a complete original or translated path for the specified tree item. More... | |
void | logBranch (YStringTreeItem *branch, std::string indentation) |
Debugging - dump one branch of the tree into the log file. | |
Protected Attributes | |
YStringTreeItem * | _root |
std::string | _textdomain |
Abstract base class for filter views with hierarchical filter criteria - e.g., RPM group tags, MIME types.
Definition at line 41 of file YStringTree.h.
YStringTree::YStringTree | ( | const char * | textdomain | ) |
Constructor.
'textdomain' specifies the gettext textdomain to use to translate pathname components as new branches are added.
NOTE: This will NOT change the gettext environment in any way - the tree uses dgettext() internally. The caller is responsible to bind that textdomain to a message catalog (bindtextdomain() etc.).
Definition at line 32 of file YStringTree.cc.
YStringTreeItem * YStringTree::addBranch | ( | const std::string & | content, |
char | delimiter = 0 , |
||
YStringTreeItem * | parent = 0 |
||
) |
Add a unique new branch with text content 'content' to the tree, beginning at 'parent' (root if parent == 0).
This content can be a path specification delimited with character 'delimiter' (if not 0), i.e. this method will split 'content' up into path components and insert tree items for each level as appropriate. Leading delimiters will be ignored. If 'delimiter' is 0, 'content' is not split but used 'as is'. Items are automatically sorted alphabetically. Pathname components are automatically translated using the textdomain specified in the constructor.
Returns the tree node for this branch - either newly created or the existing one.
Example: addBranch( "/usr/local/bin", '/' ) addBranch( "/usr/lib", '/' )
"usr" "lib" "local" "bin"
Definition at line 48 of file YStringTree.cc.
|
protected |
Construct a complete original or translated path for the specified tree item.
'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.
Definition at line 127 of file YStringTree.cc.
|
inline |
Construct a complete original path for the specified tree item.
'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.
Definition at line 97 of file YStringTree.h.
YTransText YStringTree::path | ( | const YStringTreeItem * | item, |
char | delimiter, | ||
bool | startWithDelimiter = true |
||
) |
Construct a complete path (both original and translated) for the specified tree item.
'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.
Note: origPath() or translatedPath() are much cheaper if only one version (original or translated) is required.
Definition at line 158 of file YStringTree.cc.
|
inline |
Returns the root of the filter view tree.
Note: In most cases, the root item itself will not contain any useful information. Consider it the handle for the entire tree, not an actual data element.
Definition at line 139 of file YStringTree.h.
|
inline |
Set the textdomain used internally for translation of pathname components.
NOTE: This will NOT change the gettext environment in any way - the tree uses dgettext() internally. The caller is responsible to bind that textdomain to a message catalog (bindtextdomain() etc.).
Definition at line 157 of file YStringTree.h.
std::string YStringTree::translate | ( | const std::string & | orig | ) |
Translate message 'orig' using the internal textdomain.
Returns the translated text or the original if there is no translation.
Definition at line 118 of file YStringTree.cc.
|
inline |
Construct a complete original path for the specified tree item.
'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.
Definition at line 108 of file YStringTree.h.