author | mickeyl <mickeyl> | 2003-05-10 14:46:02 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-10 14:46:02 (UTC) |
commit | 7d97fa637bb1af225b9e5075982b32718b0f78e4 (patch) (unidiff) | |
tree | e06b9043c9fc3c0cf769986ea5e6a4983dbfe784 | |
parent | 8bf3021bf5e86f7f6f6083606d77427adc8d13a7 (diff) | |
download | opie-7d97fa637bb1af225b9e5075982b32718b0f78e4.zip opie-7d97fa637bb1af225b9e5075982b32718b0f78e4.tar.gz opie-7d97fa637bb1af225b9e5075982b32718b0f78e4.tar.bz2 |
- make oApp not return a const app object
- homogenize oconfig documentation
- remove debug output
-rw-r--r-- | libopie2/opiecore/oapplication.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/oconfig.h | 143 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 6 |
3 files changed, 64 insertions, 87 deletions
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h index 1bd34e2..6bc2b1c 100644 --- a/libopie2/opiecore/oapplication.h +++ b/libopie2/opiecore/oapplication.h | |||
@@ -65,5 +65,5 @@ class OApplication: public QPEApplication | |||
65 | * to every function that may require it. | 65 | * to every function that may require it. |
66 | */ | 66 | */ |
67 | static const OApplication* oApplication() { return _instance; }; | 67 | static OApplication* oApplication() { return _instance; }; |
68 | /** | 68 | /** |
69 | * Returns the application name as given during creation. | 69 | * Returns the application name as given during creation. |
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h index afe14b1..444d280 100644 --- a/libopie2/opiecore/oconfig.h +++ b/libopie2/opiecore/oconfig.h | |||
@@ -34,4 +34,5 @@ | |||
34 | 34 | ||
35 | //FIXME: Implement for X11 or reuse libqpe/Config there also? | 35 | //FIXME: Implement for X11 or reuse libqpe/Config there also? |
36 | //FIXME: Or rather use QSettings also for libqpe? | ||
36 | 37 | ||
37 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
@@ -48,100 +49,69 @@ class OConfig : public Config | |||
48 | { | 49 | { |
49 | public: | 50 | public: |
50 | 51 | /** | |
51 | /** | 52 | * Constructs a OConfig object with a @a name. |
52 | * Constructs a OConfig object. | 53 | */ |
53 | * | ||
54 | * @param name A file to parse. | ||
55 | */ | ||
56 | OConfig( const QString &name, Domain domain = User ); | 54 | OConfig( const QString &name, Domain domain = User ); |
57 | 55 | /** | |
58 | /** | 56 | * Destructs the OConfig object. |
59 | * Destructs the OConfig object. | 57 | * |
60 | * | 58 | * Writes back any dirty configuration entries, and destroys |
61 | * Writes back any dirty configuration entries, and destroys | 59 | * dynamically created objects. |
62 | * dynamically created objects. | 60 | */ |
63 | */ | ||
64 | virtual ~OConfig(); | 61 | virtual ~OConfig(); |
65 | 62 | /** | |
66 | /** | 63 | * @returns the name of the current group. |
67 | * Returns the name of the group in which we are | 64 | * The current group is used for searching keys and accessing entries. |
68 | * searching for keys and from which we are retrieving entries. | 65 | */ |
69 | * | ||
70 | * @return The current group. | ||
71 | */ | ||
72 | const QString& group() { return git.key(); }; | 66 | const QString& group() { return git.key(); }; |
73 | 67 | /** | |
74 | /** | 68 | * @returns a @ref QColor entry or a @a default value if the key is not found. |
75 | * Reads a @ref QColor entry. | 69 | */ |
76 | * | ||
77 | * Read the value of an entry specified by @p pKey in the current group | ||
78 | * and interpret it as a color. | ||
79 | * | ||
80 | * @param pKey The key to search for. | ||
81 | * @param pDefault A default value (null QColor by default) returned if the | ||
82 | * key was not found or if the value cannot be interpreted. | ||
83 | * @return The value for this key. | ||
84 | */ | ||
85 | QColor readColorEntry( const QString& key, const QColor* pDefault ) const; | 70 | QColor readColorEntry( const QString& key, const QColor* pDefault ) const; |
86 | 71 | /** | |
87 | /** | 72 | * @returns a @ref QFont value or a @a default value if the key is not found. |
88 | * Reads a @ref QFont value. | 73 | */ |
89 | * | ||
90 | * Read the value of an entry specified by @p pKey in the current group | ||
91 | * and interpret it as a font object. | ||
92 | * | ||
93 | * @param pKey The key to search for. | ||
94 | * @param pDefault A default value (null QFont by default) returned if the | ||
95 | * key was not found or if the read value cannot be interpreted. | ||
96 | * @return The value for this key. | ||
97 | */ | ||
98 | QFont readFontEntry( const QString& key, const QFont* pDefault ) const; | 74 | QFont readFontEntry( const QString& key, const QFont* pDefault ) const; |
99 | |||
100 | }; | 75 | }; |
101 | 76 | ||
102 | /** | 77 | /** |
103 | * Helper class to facilitate working with @ref OConfig / @ref OSimpleConfig | 78 | * @brief Helper class for easier use of OConfig groups. |
104 | * groups. | 79 | * |
105 | * | 80 | * Careful programmers always set the group of a |
106 | * Careful programmers always set the group of a | 81 | * @ref OConfig object to the group they want to read from |
107 | * @ref OConfig object to the group they want to read from | 82 | * and set it back to the old one of afterwards. This is usually |
108 | * and set it back to the old one of afterwards. This is usually | 83 | * written as: |
109 | * written as: | 84 | * <pre> |
110 | * <pre> | 85 | * |
111 | * | 86 | * QString oldgroup config()->group(); |
112 | * QString oldgroup config()->group(); | 87 | * config()->setGroup( "TheGroupThatIWant" ); |
113 | * config()->setGroup( "TheGroupThatIWant" ); | 88 | * ... |
114 | * ... | 89 | * config()->writeEntry( "Blah", "Blubb" ); |
115 | * config()->writeEntry( "Blah", "Blubb" ); | 90 | * |
116 | * | 91 | * config()->setGroup( oldgroup ); |
117 | * config()->setGroup( oldgroup ); | 92 | * </pre> |
118 | * </pre> | 93 | * |
119 | * | 94 | * In order to facilitate this task, you can use |
120 | * In order to facilitate this task, you can use | 95 | * OConfigGroupSaver. Simply construct such an object ON THE STACK |
121 | * OConfigGroupSaver. Simply construct such an object ON THE STACK | 96 | * when you want to switch to a new group. Then, when the object goes |
122 | * when you want to switch to a new group. Then, when the object goes | 97 | * out of scope, the group will automatically be restored. If you |
123 | * out of scope, the group will automatically be restored. If you | 98 | * want to use several different groups within a function or method, |
124 | * want to use several different groups within a function or method, | 99 | * you can still use OConfigGroupSaver: Simply enclose all work with |
125 | * you can still use OConfigGroupSaver: Simply enclose all work with | 100 | * one group (including the creation of the OConfigGroupSaver object) |
126 | * one group (including the creation of the OConfigGroupSaver object) | 101 | * in one block. |
127 | * in one block. | 102 | * |
128 | * | 103 | * @author Matthias Kalle Dalheimer <Kalle@kde.org> |
129 | * @author Matthias Kalle Dalheimer <Kalle@kde.org> | 104 | * @version $Id$ |
130 | * @version $Id$ | 105 | * @see OConfig |
131 | * @see OConfig | 106 | */ |
132 | * @short Helper class for easier use of OConfig groups | ||
133 | */ | ||
134 | 107 | ||
135 | class OConfigGroupSaver | 108 | class OConfigGroupSaver |
136 | { | 109 | { |
137 | public: | 110 | public: |
138 | /** | 111 | /** |
139 | * Constructor. You pass a pointer to the OConfigBase-derived | 112 | * Constructor. |
140 | * object you want to work with and a string indicating the _new_ | 113 | * Create the object giving a @config object and a @a group to become |
141 | * group. | 114 | * the current group. |
142 | * @param config The OConfig-derived object this | 115 | */ |
143 | * OConfigGroupSaver works on. | ||
144 | * @param group The new group that the config object should switch to. | ||
145 | */ | ||
146 | OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) | 116 | OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) |
147 | { _config->setGroup( group ); } | 117 | { _config->setGroup( group ); } |
@@ -152,5 +122,8 @@ class OConfigGroupSaver | |||
152 | OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) | 122 | OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) |
153 | { _config->setGroup( group ); } | 123 | { _config->setGroup( group ); } |
154 | 124 | /** | |
125 | * Destructor. | ||
126 | * Restores the last current group. | ||
127 | */ | ||
155 | ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } | 128 | ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } |
156 | 129 | ||
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index c185fc5..c3c213c 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -16,5 +16,5 @@ | |||
16 | #include "omanufacturerdb.h" | 16 | #include "omanufacturerdb.h" |
17 | 17 | ||
18 | // Qt | 18 | /* QT */ |
19 | #include <qstring.h> | 19 | #include <qstring.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
@@ -82,10 +82,14 @@ OManufacturerDB::OManufacturerDB() | |||
82 | s.skipWhiteSpace(); | 82 | s.skipWhiteSpace(); |
83 | extManu = s.readLine(); | 83 | extManu = s.readLine(); |
84 | #ifdef DEBUG | ||
84 | qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu ); | 85 | qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu ); |
86 | #endif | ||
85 | manufacturersExt.insert( addr, extManu ); | 87 | manufacturersExt.insert( addr, extManu ); |
86 | } | 88 | } |
87 | else | 89 | else |
88 | s.readLine(); | 90 | s.readLine(); |
91 | #ifdef DEBUG | ||
89 | qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu ); | 92 | qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu ); |
93 | #endif | ||
90 | manufacturers.insert( addr, manu ); | 94 | manufacturers.insert( addr, manu ); |
91 | 95 | ||