oopapidocs
2.0
|
An object-oriented enumerator class. More...
#include <enum.h>
Public Member Functions | |
virtual const NameMap & | nameMap () const =0 |
You must override this method for your specific enumerator type. | |
virtual QString | toString () const |
Converts from the int value to a String. | |
virtual bool | fromString (QString str) |
Converts from a string to the internal enum value. | |
virtual int | intValue () const |
QStringList | names () const |
Static Protected Member Functions | |
static NameMap & | initMap (NameMap &nameMap, QStringList nameList, bool &initialized, int startIndex=0) |
Adds symbols to the map with enum values starting at 0. |
An object-oriented enumerator class.
This enum uses QStrings instead of compiler symbols, and provides bidirectional mapping between QStrings and int values. No compiler symbols are introduced.
Does not have the same limitation as QMetaEnum, which must be attached to a particular Q_OBJECT class.
This is an abstract class, and derived types can be used as custom QVariant property types provided they are declared and registered also.
bool Enum::fromString | ( | QString | str | ) | [virtual] |
NameMap & Enum::initMap | ( | NameMap & | nameMap, |
QStringList | nameList, | ||
bool & | initialized, | ||
int | startIndex = 0 |
||
) | [static, protected] |
Adds symbols to the map with enum values starting at 0.
nameMap | - the destination map to contain strings to numbers |
nameList | - a string list of names to add to the map, with optional =value suffixes |
initialized | - if true, do nothing (to avoid repeat-redundant calls
|
Definition at line 112 of file enum.cpp.
References nameMap().
Referenced by Preference::nameMap().
int Enum::intValue | ( | ) | const [virtual] |
virtual const NameMap& Enum::nameMap | ( | ) | const [pure virtual] |
You must override this method for your specific enumerator type.
Implemented in Preference.
Referenced by fromString(), initMap(), names(), and toString().
QStringList Enum::names | ( | ) | const |