author | mickeyl <mickeyl> | 2003-05-01 14:00:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-01 14:00:37 (UTC) |
commit | 95e533a6ac257d3b95cd8905660008fb7dcd33f1 (patch) (unidiff) | |
tree | c671954f59eaa70db2285f9abe49fd8b4512dd12 /libopie2/opieui/olistview.h | |
parent | 1d721ddb247e9000e29fba3150e0cce5f59f543e (diff) | |
download | opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.zip opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.tar.gz opie-95e533a6ac257d3b95cd8905660008fb7dcd33f1.tar.bz2 |
- restructure opieui example directory
- start work on ONamedListViewItem providing a slightly higher level interface
-rw-r--r-- | libopie2/opieui/olistview.h | 177 |
1 files changed, 126 insertions, 51 deletions
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index b62e278..99770bf 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -33,135 +33,127 @@ | |||
33 | 33 | ||
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qpen.h> | 36 | #include <qpen.h> |
37 | #include <qdatastream.h> | 37 | #include <qdatastream.h> |
38 | 38 | ||
39 | class OListViewItem; | 39 | class OListViewItem; |
40 | 40 | ||
41 | /*====================================================================================== | ||
42 | * OListView | ||
43 | *======================================================================================*/ | ||
44 | |||
41 | /** | 45 | /** |
46 | * @brief A list/tree widget. | ||
47 | * | ||
42 | * A @ref QListView variant featuring visual and functional enhancements | 48 | * A @ref QListView variant featuring visual and functional enhancements |
43 | * like an alternate background for odd rows, an autostretch mode | 49 | * like an alternate background for odd rows, an autostretch mode |
44 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 50 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
45 | * | 51 | * |
46 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
47 | * @short OListView list/tree widget. | ||
48 | */ | 53 | */ |
49 | class OListView: public QListView | 54 | class OListView: public QListView |
50 | { | 55 | { |
51 | public: | 56 | public: |
52 | /** | 57 | /** |
53 | * Constructor. | 58 | * Constructor. |
54 | * | 59 | * |
55 | * The parameters @p parent and @p name are handled by | 60 | * The parameters @a parent and @a name are handled by |
56 | * @ref QListView, as usual. | 61 | * @ref QListView, as usual. |
57 | */ | 62 | */ |
58 | OListView ( QWidget *parent = 0, const char *name = 0 ); | 63 | OListView( QWidget* parent = 0, const char* name = 0 ); |
59 | |||
60 | /** | 64 | /** |
61 | * Destructor. | 65 | * Destructor. |
62 | */ | 66 | */ |
63 | virtual ~OListView(); | 67 | virtual ~OListView(); |
64 | |||
65 | /** | 68 | /** |
66 | * Let the last column fit exactly all the available width. | 69 | * Let the last column fit exactly all the available width. |
67 | */ | 70 | */ |
68 | void setFullWidth( bool fullWidth ); | 71 | void setFullWidth( bool fullWidth ); |
69 | |||
70 | /** | 72 | /** |
71 | * Returns whether the last column is set to fit the available width. | 73 | * Returns whether the last column is set to fit the available width. |
72 | */ | 74 | */ |
73 | bool fullWidth() const; | 75 | bool fullWidth() const; |
74 | |||
75 | /** | 76 | /** |
76 | * Reimplemented for full width support | 77 | * Reimplemented for full width support |
77 | */ | 78 | */ |
78 | virtual int addColumn( const QString& label, int width = -1 ); | 79 | virtual int addColumn( const QString& label, int width = -1 ); |
79 | |||
80 | /** | 80 | /** |
81 | * Reimplemented for full width support | 81 | * Reimplemented for full width support |
82 | */ | 82 | */ |
83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | 83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); |
84 | |||
85 | /** | 84 | /** |
86 | * Reimplemented for full width support | 85 | * Reimplemented for full width support |
87 | */ | 86 | */ |
88 | virtual void removeColumn(int index); | 87 | virtual void removeColumn(int index); |
89 | |||
90 | /** | 88 | /** |
91 | * sets the alternate background background color. | 89 | * Set the alternate background background @a color. |
90 | * Set to an invalid color to disable alternate colors. | ||
92 | * This only has an effect if the items are OListViewItems | 91 | * This only has an effect if the items are OListViewItems |
93 | * | ||
94 | * @param c the color to use for every other item. Set to an invalid | ||
95 | * color to disable alternate colors. | ||
96 | */ | 92 | */ |
97 | void setAlternateBackground( const QColor &c ); | 93 | void setAlternateBackground( const QColor& color ); |
98 | |||
99 | /** | 94 | /** |
100 | * sets the column separator pen. | 95 | * Sets the column separator @a pen. |
101 | * | ||
102 | * @param p the pen used to draw the column separator. | ||
103 | */ | 96 | */ |
104 | void setColumnSeparator( const QPen &p ); | 97 | void setColumnSeparator( const QPen& pen ); |
105 | 98 | ||
106 | /** | 99 | /** |
107 | * @return the alternate background color | 100 | * @returns the alternate background color |
108 | */ | 101 | */ |
109 | const QColor& alternateBackground() const; | 102 | const QColor& alternateBackground() const; |
110 | |||
111 | /** | 103 | /** |
112 | * @return the column separator pen | 104 | * @return the column separator pen |
113 | */ | 105 | */ |
114 | const QPen& columnSeparator() const; | 106 | const QPen& columnSeparator() const; |
115 | |||
116 | /** | 107 | /** |
117 | * create a list view item as child of this object | 108 | * Create a list view item as child of this object |
118 | * @return the new object | 109 | * @returns the new object |
119 | */ | 110 | */ |
120 | virtual OListViewItem* childFactory(); | 111 | virtual OListViewItem* childFactory(); |
121 | |||
122 | #ifndef QT_NO_DATASTREAM | 112 | #ifndef QT_NO_DATASTREAM |
123 | /** | 113 | /** |
124 | * serialize this object to a @ref QDataStream | 114 | * Serialize this object to @ref QDataStream @a stream |
125 | * @param s the stream used to serialize this object. | ||
126 | */ | 115 | */ |
127 | virtual void serializeTo( QDataStream& s ) const; | 116 | virtual void serializeTo( QDataStream& stream ) const; |
128 | |||
129 | /** | 117 | /** |
130 | * serialize this object from a @ref QDataStream | 118 | * Serialize this object from a @ref QDataStream @a stream |
131 | * @param s the stream used to serialize this object. | ||
132 | */ | 119 | */ |
133 | virtual void serializeFrom( QDataStream& s ); | 120 | virtual void serializeFrom( QDataStream& s ); |
134 | #endif | 121 | #endif |
135 | 122 | ||
136 | private: | 123 | private: |
137 | QColor m_alternateBackground; | 124 | QColor m_alternateBackground; |
138 | bool m_fullWidth; | 125 | bool m_fullWidth; |
139 | QPen m_columnSeparator; | 126 | QPen m_columnSeparator; |
140 | }; | 127 | }; |
141 | 128 | ||
142 | #ifndef QT_NO_DATASTREAM | 129 | #ifndef QT_NO_DATASTREAM |
143 | /** | 130 | /** |
144 | * \relates QListView | 131 | * @relates OListView |
145 | * Writes a listview to the stream and returns a reference to the stream. | 132 | * Writes @a listview to the @a stream and returns a reference to the stream. |
146 | */ | 133 | */ |
147 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); | 134 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); |
148 | /** | 135 | /** |
149 | * \relates QListView | 136 | * @relates OListView |
150 | * Reads a listview from the stream and returns a reference to the stream. | 137 | * Reads @a listview from the @a stream and returns a reference to the stream. |
151 | */ | 138 | */ |
152 | QDataStream& operator>>( QDataStream& s, OListView& lv ); | 139 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); |
153 | #endif // QT_NO_DATASTREAM | 140 | #endif // QT_NO_DATASTREAM |
154 | 141 | ||
155 | //****************************** OListViewItem ****************************************************************** | 142 | /*====================================================================================== |
143 | * OListViewItem | ||
144 | *======================================================================================*/ | ||
156 | 145 | ||
157 | class OListViewItem: public QListViewItem | 146 | class OListViewItem: public QListViewItem |
158 | { | 147 | { |
159 | public: | 148 | public: |
149 | /** | ||
150 | * Constructors. | ||
151 | */ | ||
160 | OListViewItem( QListView * parent ); | 152 | OListViewItem( QListView * parent ); |
161 | OListViewItem( QListViewItem * parent ); | 153 | OListViewItem( QListViewItem * parent ); |
162 | OListViewItem( QListView * parent, QListViewItem * after ); | 154 | OListViewItem( QListView * parent, QListViewItem * after ); |
163 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 155 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
164 | 156 | ||
165 | OListViewItem( QListView * parent, | 157 | OListViewItem( QListView * parent, |
166 | QString, QString = QString::null, | 158 | QString, QString = QString::null, |
167 | QString = QString::null, QString = QString::null, | 159 | QString = QString::null, QString = QString::null, |
@@ -180,30 +172,43 @@ class OListViewItem: public QListViewItem | |||
180 | QString = QString::null, QString = QString::null, | 172 | QString = QString::null, QString = QString::null, |
181 | QString = QString::null, QString = QString::null ); | 173 | QString = QString::null, QString = QString::null ); |
182 | 174 | ||
183 | OListViewItem( QListViewItem * parent, QListViewItem * after, | 175 | OListViewItem( QListViewItem * parent, QListViewItem * after, |
184 | QString, QString = QString::null, | 176 | QString, QString = QString::null, |
185 | QString = QString::null, QString = QString::null, | 177 | QString = QString::null, QString = QString::null, |
186 | QString = QString::null, QString = QString::null, | 178 | QString = QString::null, QString = QString::null, |
187 | QString = QString::null, QString = QString::null ); | 179 | QString = QString::null, QString = QString::null ); |
188 | 180 | /** | |
181 | * Destructor. | ||
182 | */ | ||
189 | virtual ~OListViewItem(); | 183 | virtual ~OListViewItem(); |
190 | 184 | /** | |
185 | * @returns the background color of the list item. | ||
186 | */ | ||
191 | const QColor& backgroundColor(); | 187 | const QColor& backgroundColor(); |
188 | /** | ||
189 | * @returns true, if the item is at an odd position and | ||
190 | * thus have to be painted with the alternate background color. | ||
191 | */ | ||
192 | bool isAlternate(); | 192 | bool isAlternate(); |
193 | /** | ||
194 | * @note: Reimplemented for internal purposes - the API is not affected | ||
195 | * | ||
196 | */ | ||
193 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 197 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
198 | /** | ||
199 | * Perform object initialization. | ||
200 | */ | ||
194 | void init(); | 201 | void init(); |
195 | |||
196 | /** | 202 | /** |
197 | * create a list view item as child of this object | 203 | * create a list view item as child of this object |
198 | * @return the new object | 204 | * @returns the new object |
199 | */ | 205 | */ |
200 | virtual OListViewItem* childFactory(); | 206 | virtual OListViewItem* childFactory(); |
201 | |||
202 | #ifndef QT_NO_DATASTREAM | 207 | #ifndef QT_NO_DATASTREAM |
203 | /** | 208 | /** |
204 | * serialize this object to or from a @ref QDataStream | 209 | * serialize this object to or from a @ref QDataStream |
205 | * @param s the stream used to serialize this object. | 210 | * @param s the stream used to serialize this object. |
206 | */ | 211 | */ |
207 | virtual void serializeTo( QDataStream& s ) const; | 212 | virtual void serializeTo( QDataStream& s ) const; |
208 | 213 | ||
209 | /** | 214 | /** |
@@ -215,21 +220,91 @@ class OListViewItem: public QListViewItem | |||
215 | 220 | ||
216 | private: | 221 | private: |
217 | bool m_known; | 222 | bool m_known; |
218 | bool m_odd; | 223 | bool m_odd; |
219 | }; | 224 | }; |
220 | 225 | ||
221 | #ifndef QT_NO_DATASTREAM | 226 | #ifndef QT_NO_DATASTREAM |
222 | /** | 227 | /** |
223 | * \relates QListViewItem | 228 | * @relates QListViewItem |
224 | * Writes a listview item and all subitems recursively to the stream | 229 | * Writes listview @a item and all subitems recursively to @a stream |
225 | * and returns a reference to the stream. | 230 | * and returns a reference to the stream. |
226 | */ | 231 | */ |
227 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); | 232 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); |
228 | /** | 233 | /** |
229 | * \relates QListViewItem | 234 | * @relates QListViewItem |
230 | * Reads a listview item from the stream and returns a reference to the stream. | 235 | * Reads listview @a item from @a stream and returns a reference to the stream. |
231 | */ | 236 | */ |
232 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); | 237 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); |
233 | #endif // QT_NO_DATASTREAM | 238 | #endif // QT_NO_DATASTREAM |
234 | 239 | ||
240 | /*====================================================================================== | ||
241 | * ONamedListView | ||
242 | *======================================================================================*/ | ||
243 | |||
244 | /** | ||
245 | * @brief An OListView variant with named columns. | ||
246 | * | ||
247 | * This class provides a higher-level interface to the columns in an OListView. | ||
248 | * | ||
249 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
250 | */ | ||
251 | class ONamedListView: public OListView | ||
252 | { | ||
253 | public: | ||
254 | /** | ||
255 | * Constructor. | ||
256 | * | ||
257 | * The parameters @a parent and @a name are handled by | ||
258 | * @ref OListView, as usual. | ||
259 | */ | ||
260 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); | ||
261 | /** | ||
262 | * Destructor. | ||
263 | */ | ||
264 | virtual ~ONamedListView(); | ||
265 | /** | ||
266 | * Add a number of @a columns to the listview. | ||
267 | */ | ||
268 | virtual void addColumns( const QStringList& columns ); | ||
269 | }; | ||
270 | |||
271 | /*====================================================================================== | ||
272 | * ONamedListViewItem | ||
273 | *======================================================================================*/ | ||
274 | |||
275 | /** | ||
276 | * @brief An OListView variant with named columns. | ||
277 | * | ||
278 | * This class provides a higher-level interface to the columns in an OListViewItem. | ||
279 | * | ||
280 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
281 | */ | ||
282 | class ONamedListViewItem: public OListViewItem | ||
283 | { | ||
284 | public: | ||
285 | /** | ||
286 | * Constructor. Accepts the same parameters as a @ref OListViewItem, | ||
287 | * plus a @ref QStringList which holds an arbitrary number of @a texts. | ||
288 | */ | ||
289 | ONamedListViewItem( QListView* parent, const QStringList& texts ); | ||
290 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); | ||
291 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); | ||
292 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); | ||
293 | /** | ||
294 | * Destructor. | ||
295 | */ | ||
296 | virtual ~ONamedListViewItem(); | ||
297 | /** | ||
298 | * Sets the text in column @a column to @a text. | ||
299 | * This method differs from @ref QListViewItem::setText() in that it | ||
300 | * accepts a string as column indicator instead of an int. | ||
301 | */ | ||
302 | virtual void setText( const QString& column, const QString& text ); | ||
303 | /** | ||
304 | * Sets a number of @a texts for this item. | ||
305 | */ | ||
306 | virtual void setText( const QStringList& texts ); | ||
307 | }; | ||
308 | |||
309 | |||
235 | #endif // OLISTVIEW_H | 310 | #endif // OLISTVIEW_H |