author | zecke <zecke> | 2004-03-26 22:36:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-26 22:36:43 (UTC) |
commit | c54a3c8cc47258743381d4dee4200304d247182d (patch) (unidiff) | |
tree | bc96497821743c7b7789004fd700f58f10f0f772 | |
parent | 2487838d0f9358d6efdf714e9dfd892f92802b46 (diff) | |
download | opie-c54a3c8cc47258743381d4dee4200304d247182d.zip opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.gz opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.bz2 |
Add WFlags to the c'tor so we eventually can use this
in the designer... but anyway making it more consistent with Qt
Ah and this is binary incompatible but the API isn't marked as stable
anyway
-rw-r--r-- | libopie2/opieui/olistview.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/olistview.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 38670b4..d7c92fd 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,764 +1,764 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | 31 | ||
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
37 | #include <opie2/olistview.h> | 37 | #include <opie2/olistview.h> |
38 | 38 | ||
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | 40 | ||
41 | 41 | ||
42 | namespace Opie { | 42 | namespace Opie { |
43 | namespace Ui { | 43 | namespace Ui { |
44 | /*====================================================================================== | 44 | /*====================================================================================== |
45 | * OListView | 45 | * OListView |
46 | *======================================================================================*/ | 46 | *======================================================================================*/ |
47 | 47 | ||
48 | OListView::OListView( QWidget *parent, const char *name ) | 48 | OListView::OListView( QWidget *parent, const char *name, WFlags fl ) |
49 | :QListView( parent, name ) | 49 | :QListView( parent, name, fl ) |
50 | { | 50 | { |
51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | 51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* |
52 | 52 | ||
53 | m_alternateBackground = QColor( 238, 246, 255 ); | 53 | m_alternateBackground = QColor( 238, 246, 255 ); |
54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | 54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); |
55 | m_fullWidth = true; | 55 | m_fullWidth = true; |
56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
57 | } | 57 | } |
58 | 58 | ||
59 | OListView::~OListView() | 59 | OListView::~OListView() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | void OListView::setFullWidth( bool fullWidth ) | 63 | void OListView::setFullWidth( bool fullWidth ) |
64 | { | 64 | { |
65 | m_fullWidth = m_fullWidth; | 65 | m_fullWidth = m_fullWidth; |
66 | #if QT_VERSION > 290 | 66 | #if QT_VERSION > 290 |
67 | header()->setStretchEnabled( fullWidth, columns()-1 ); | 67 | header()->setStretchEnabled( fullWidth, columns()-1 ); |
68 | #endif | 68 | #endif |
69 | } | 69 | } |
70 | 70 | ||
71 | bool OListView::fullWidth() const | 71 | bool OListView::fullWidth() const |
72 | { | 72 | { |
73 | return m_fullWidth; | 73 | return m_fullWidth; |
74 | } | 74 | } |
75 | 75 | ||
76 | int OListView::addColumn( const QString& label, int width ) | 76 | int OListView::addColumn( const QString& label, int width ) |
77 | { | 77 | { |
78 | int result = QListView::addColumn( label, width ); | 78 | int result = QListView::addColumn( label, width ); |
79 | #if QT_VERSION > 290 | 79 | #if QT_VERSION > 290 |
80 | if (m_fullWidth) { | 80 | if (m_fullWidth) { |
81 | header()->setStretchEnabled( false, columns()-2 ); | 81 | header()->setStretchEnabled( false, columns()-2 ); |
82 | header()->setStretchEnabled( true, columns()-1 ); | 82 | header()->setStretchEnabled( true, columns()-1 ); |
83 | } | 83 | } |
84 | #endif | 84 | #endif |
85 | return result; | 85 | return result; |
86 | } | 86 | } |
87 | 87 | ||
88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
89 | { | 89 | { |
90 | int result = QListView::addColumn( iconset, label, width ); | 90 | int result = QListView::addColumn( iconset, label, width ); |
91 | #if QT_VERSION > 290 | 91 | #if QT_VERSION > 290 |
92 | if (m_fullWidth) { | 92 | if (m_fullWidth) { |
93 | header()->setStretchEnabled( false, columns()-2 ); | 93 | header()->setStretchEnabled( false, columns()-2 ); |
94 | header()->setStretchEnabled( true, columns()-1 ); | 94 | header()->setStretchEnabled( true, columns()-1 ); |
95 | } | 95 | } |
96 | #endif | 96 | #endif |
97 | return result; | 97 | return result; |
98 | } | 98 | } |
99 | 99 | ||
100 | void OListView::removeColumn( int index ) | 100 | void OListView::removeColumn( int index ) |
101 | { | 101 | { |
102 | QListView::removeColumn(index); | 102 | QListView::removeColumn(index); |
103 | #if QT_VERSION > 290 | 103 | #if QT_VERSION > 290 |
104 | if ( m_fullWidth && index == columns() ) | 104 | if ( m_fullWidth && index == columns() ) |
105 | { | 105 | { |
106 | header()->setStretchEnabled( true, columns()-1 ); | 106 | header()->setStretchEnabled( true, columns()-1 ); |
107 | } | 107 | } |
108 | #endif | 108 | #endif |
109 | } | 109 | } |
110 | 110 | ||
111 | const QColor& OListView::alternateBackground() const | 111 | const QColor& OListView::alternateBackground() const |
112 | { | 112 | { |
113 | return m_alternateBackground; | 113 | return m_alternateBackground; |
114 | } | 114 | } |
115 | 115 | ||
116 | void OListView::setAlternateBackground( const QColor &c ) | 116 | void OListView::setAlternateBackground( const QColor &c ) |
117 | { | 117 | { |
118 | m_alternateBackground = c; | 118 | m_alternateBackground = c; |
119 | repaint(); | 119 | repaint(); |
120 | } | 120 | } |
121 | 121 | ||
122 | const QPen& OListView::columnSeparator() const | 122 | const QPen& OListView::columnSeparator() const |
123 | { | 123 | { |
124 | return m_columnSeparator; | 124 | return m_columnSeparator; |
125 | } | 125 | } |
126 | 126 | ||
127 | void OListView::setColumnSeparator( const QPen& p ) | 127 | void OListView::setColumnSeparator( const QPen& p ) |
128 | { | 128 | { |
129 | m_columnSeparator = p; | 129 | m_columnSeparator = p; |
130 | repaint(); | 130 | repaint(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void OListView::expand(QListViewItem *item) | 133 | void OListView::expand(QListViewItem *item) |
134 | { | 134 | { |
135 | ((OListViewItem*)item)->expand(); | 135 | ((OListViewItem*)item)->expand(); |
136 | } | 136 | } |
137 | 137 | ||
138 | OListViewItem* OListView::childFactory() | 138 | OListViewItem* OListView::childFactory() |
139 | { | 139 | { |
140 | return new OListViewItem( this ); | 140 | return new OListViewItem( this ); |
141 | } | 141 | } |
142 | 142 | ||
143 | #ifndef QT_NO_DATASTREAM | 143 | #ifndef QT_NO_DATASTREAM |
144 | void OListView::serializeTo( QDataStream& s ) const | 144 | void OListView::serializeTo( QDataStream& s ) const |
145 | { | 145 | { |
146 | #warning Caution... the binary format is still under construction... | 146 | #warning Caution... the binary format is still under construction... |
147 | odebug << "storing OListView..." << oendl; | 147 | odebug << "storing OListView..." << oendl; |
148 | 148 | ||
149 | // store number of columns and the labels | 149 | // store number of columns and the labels |
150 | s << columns(); | 150 | s << columns(); |
151 | for ( int i = 0; i < columns(); ++i ) | 151 | for ( int i = 0; i < columns(); ++i ) |
152 | s << columnText( i ); | 152 | s << columnText( i ); |
153 | 153 | ||
154 | // calculate the number of top-level items to serialize | 154 | // calculate the number of top-level items to serialize |
155 | int items = 0; | 155 | int items = 0; |
156 | QListViewItem* item = firstChild(); | 156 | QListViewItem* item = firstChild(); |
157 | while ( item ) | 157 | while ( item ) |
158 | { | 158 | { |
159 | item = item->nextSibling(); | 159 | item = item->nextSibling(); |
160 | items++; | 160 | items++; |
161 | } | 161 | } |
162 | 162 | ||
163 | // store number of items and the items itself | 163 | // store number of items and the items itself |
164 | s << items; | 164 | s << items; |
165 | item = firstChild(); | 165 | item = firstChild(); |
166 | for ( int i = 0; i < items; ++i ) | 166 | for ( int i = 0; i < items; ++i ) |
167 | { | 167 | { |
168 | s << *static_cast<OListViewItem*>( item ); | 168 | s << *static_cast<OListViewItem*>( item ); |
169 | item = item->nextSibling(); | 169 | item = item->nextSibling(); |
170 | } | 170 | } |
171 | 171 | ||
172 | odebug << "OListview stored." << oendl; | 172 | odebug << "OListview stored." << oendl; |
173 | } | 173 | } |
174 | 174 | ||
175 | void OListView::serializeFrom( QDataStream& s ) | 175 | void OListView::serializeFrom( QDataStream& s ) |
176 | { | 176 | { |
177 | #warning Caution... the binary format is still under construction... | 177 | #warning Caution... the binary format is still under construction... |
178 | odebug << "loading OListView..." << oendl; | 178 | odebug << "loading OListView..." << oendl; |
179 | 179 | ||
180 | int cols; | 180 | int cols; |
181 | s >> cols; | 181 | s >> cols; |
182 | odebug << "read number of columns = " << cols << oendl; | 182 | odebug << "read number of columns = " << cols << oendl; |
183 | 183 | ||
184 | while ( columns() < cols ) addColumn( QString::null ); | 184 | while ( columns() < cols ) addColumn( QString::null ); |
185 | 185 | ||
186 | for ( int i = 0; i < cols; ++i ) | 186 | for ( int i = 0; i < cols; ++i ) |
187 | { | 187 | { |
188 | QString coltext; | 188 | QString coltext; |
189 | s >> coltext; | 189 | s >> coltext; |
190 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 190 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
191 | setColumnText( i, coltext ); | 191 | setColumnText( i, coltext ); |
192 | } | 192 | } |
193 | 193 | ||
194 | int items; | 194 | int items; |
195 | s >> items; | 195 | s >> items; |
196 | odebug << "read number of items = " << items << oendl; | 196 | odebug << "read number of items = " << items << oendl; |
197 | 197 | ||
198 | for ( int i = 0; i < items; ++i ) | 198 | for ( int i = 0; i < items; ++i ) |
199 | { | 199 | { |
200 | OListViewItem* item = childFactory(); | 200 | OListViewItem* item = childFactory(); |
201 | s >> *item; | 201 | s >> *item; |
202 | } | 202 | } |
203 | 203 | ||
204 | odebug << "OListView loaded." << oendl; | 204 | odebug << "OListView loaded." << oendl; |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | void OListView::expand() | 209 | void OListView::expand() |
210 | { | 210 | { |
211 | odebug << "OListView::expand" << oendl; | 211 | odebug << "OListView::expand" << oendl; |
212 | 212 | ||
213 | QListViewItemIterator it( this ); | 213 | QListViewItemIterator it( this ); |
214 | while ( it.current() ) { | 214 | while ( it.current() ) { |
215 | it.current()->setOpen( true ); | 215 | it.current()->setOpen( true ); |
216 | ++it; | 216 | ++it; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void OListView::collapse() | 221 | void OListView::collapse() |
222 | { | 222 | { |
223 | odebug << "OListView::collapse" << oendl; | 223 | odebug << "OListView::collapse" << oendl; |
224 | QListViewItemIterator it( this ); | 224 | QListViewItemIterator it( this ); |
225 | while ( it.current() ) { | 225 | while ( it.current() ) { |
226 | it.current()->setOpen( false ); | 226 | it.current()->setOpen( false ); |
227 | ++it; | 227 | ++it; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 232 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
233 | { | 233 | { |
234 | lv.serializeTo( s ); | 234 | lv.serializeTo( s ); |
235 | } | 235 | } |
236 | 236 | ||
237 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | 237 | QDataStream& operator>>( QDataStream& s, OListView& lv ) |
238 | { | 238 | { |
239 | lv.serializeFrom( s ); | 239 | lv.serializeFrom( s ); |
240 | } | 240 | } |
241 | #endif // QT_NO_DATASTREAM | 241 | #endif // QT_NO_DATASTREAM |
242 | 242 | ||
243 | /*====================================================================================== | 243 | /*====================================================================================== |
244 | * OListViewItem | 244 | * OListViewItem |
245 | *======================================================================================*/ | 245 | *======================================================================================*/ |
246 | 246 | ||
247 | OListViewItem::OListViewItem(QListView *parent) | 247 | OListViewItem::OListViewItem(QListView *parent) |
248 | : QListViewItem(parent) | 248 | : QListViewItem(parent) |
249 | { | 249 | { |
250 | init(); | 250 | init(); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | OListViewItem::OListViewItem(QListViewItem *parent) | 254 | OListViewItem::OListViewItem(QListViewItem *parent) |
255 | : QListViewItem(parent) | 255 | : QListViewItem(parent) |
256 | { | 256 | { |
257 | init(); | 257 | init(); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) | 261 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) |
262 | : QListViewItem(parent, after) | 262 | : QListViewItem(parent, after) |
263 | { | 263 | { |
264 | init(); | 264 | init(); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) | 268 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) |
269 | : QListViewItem(parent, after) | 269 | : QListViewItem(parent, after) |
270 | { | 270 | { |
271 | init(); | 271 | init(); |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | OListViewItem::OListViewItem(QListView *parent, | 275 | OListViewItem::OListViewItem(QListView *parent, |
276 | QString label1, QString label2, QString label3, QString label4, | 276 | QString label1, QString label2, QString label3, QString label4, |
277 | QString label5, QString label6, QString label7, QString label8) | 277 | QString label5, QString label6, QString label7, QString label8) |
278 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 278 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
279 | { | 279 | { |
280 | init(); | 280 | init(); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | OListViewItem::OListViewItem(QListViewItem *parent, | 284 | OListViewItem::OListViewItem(QListViewItem *parent, |
285 | QString label1, QString label2, QString label3, QString label4, | 285 | QString label1, QString label2, QString label3, QString label4, |
286 | QString label5, QString label6, QString label7, QString label8) | 286 | QString label5, QString label6, QString label7, QString label8) |
287 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 287 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
288 | { | 288 | { |
289 | init(); | 289 | init(); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, | 293 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, |
294 | QString label1, QString label2, QString label3, QString label4, | 294 | QString label1, QString label2, QString label3, QString label4, |
295 | QString label5, QString label6, QString label7, QString label8) | 295 | QString label5, QString label6, QString label7, QString label8) |
296 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 296 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
297 | { | 297 | { |
298 | init(); | 298 | init(); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, | 302 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, |
303 | QString label1, QString label2, QString label3, QString label4, | 303 | QString label1, QString label2, QString label3, QString label4, |
304 | QString label5, QString label6, QString label7, QString label8) | 304 | QString label5, QString label6, QString label7, QString label8) |
305 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 305 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
306 | { | 306 | { |
307 | init(); | 307 | init(); |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | OListViewItem::~OListViewItem() | 311 | OListViewItem::~OListViewItem() |
312 | { | 312 | { |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void OListViewItem::init() | 316 | void OListViewItem::init() |
317 | { | 317 | { |
318 | m_known = false; | 318 | m_known = false; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | const QColor &OListViewItem::backgroundColor() | 322 | const QColor &OListViewItem::backgroundColor() |
323 | { | 323 | { |
324 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | 324 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : |
325 | listView()->viewport()->colorGroup().base(); | 325 | listView()->viewport()->colorGroup().base(); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | bool OListViewItem::isAlternate() | 329 | bool OListViewItem::isAlternate() |
330 | { | 330 | { |
331 | OListView *lv = static_cast<OListView*>( listView() ); | 331 | OListView *lv = static_cast<OListView*>( listView() ); |
332 | 332 | ||
333 | // check if the item above is an OListViewItem | 333 | // check if the item above is an OListViewItem |
334 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); | 334 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); |
335 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ | 335 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ |
336 | 336 | ||
337 | // check if we have a valid alternate background color | 337 | // check if we have a valid alternate background color |
338 | if (!(lv && lv->alternateBackground().isValid())) return false; | 338 | if (!(lv && lv->alternateBackground().isValid())) return false; |
339 | 339 | ||
340 | m_known = above ? above->m_known : true; | 340 | m_known = above ? above->m_known : true; |
341 | if (m_known) | 341 | if (m_known) |
342 | { | 342 | { |
343 | m_odd = above ? !above->m_odd : false; | 343 | m_odd = above ? !above->m_odd : false; |
344 | } | 344 | } |
345 | else | 345 | else |
346 | { | 346 | { |
347 | OListViewItem *item; | 347 | OListViewItem *item; |
348 | bool previous = true; | 348 | bool previous = true; |
349 | if (parent()) | 349 | if (parent()) |
350 | { | 350 | { |
351 | item = static_cast<OListViewItem *>(parent()); | 351 | item = static_cast<OListViewItem *>(parent()); |
352 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; | 352 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; |
353 | item = static_cast<OListViewItem *>(parent()->firstChild()); | 353 | item = static_cast<OListViewItem *>(parent()->firstChild()); |
354 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ | 354 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ |
355 | } | 355 | } |
356 | else | 356 | else |
357 | { | 357 | { |
358 | item = static_cast<OListViewItem *>(lv->firstChild()); | 358 | item = static_cast<OListViewItem *>(lv->firstChild()); |
359 | } | 359 | } |
360 | 360 | ||
361 | while(item) | 361 | while(item) |
362 | { | 362 | { |
363 | item->m_odd = previous = !previous; | 363 | item->m_odd = previous = !previous; |
364 | item->m_known = true; | 364 | item->m_known = true; |
365 | item = static_cast<OListViewItem *>(item->nextSibling()); | 365 | item = static_cast<OListViewItem *>(item->nextSibling()); |
366 | /* if (!item.inherits( "OListViewItem" ) ) break; */ | 366 | /* if (!item.inherits( "OListViewItem" ) ) break; */ |
367 | } | 367 | } |
368 | } | 368 | } |
369 | return m_odd; | 369 | return m_odd; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 373 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
374 | { | 374 | { |
375 | QColorGroup _cg = cg; | 375 | QColorGroup _cg = cg; |
376 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 376 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
377 | if (pm && !pm->isNull()) | 377 | if (pm && !pm->isNull()) |
378 | { | 378 | { |
379 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | 379 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); |
380 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 380 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
381 | } | 381 | } |
382 | else if ( isAlternate() ) | 382 | else if ( isAlternate() ) |
383 | { | 383 | { |
384 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 384 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
385 | } | 385 | } |
386 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 386 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
387 | 387 | ||
388 | //FIXME: Use styling here! | 388 | //FIXME: Use styling here! |
389 | 389 | ||
390 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 390 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
391 | p->setPen( pen ); | 391 | p->setPen( pen ); |
392 | p->drawLine( width-1, 0, width-1, height() ); | 392 | p->drawLine( width-1, 0, width-1, height() ); |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | OListViewItem* OListViewItem::childFactory() | 396 | OListViewItem* OListViewItem::childFactory() |
397 | { | 397 | { |
398 | return new OListViewItem( this ); | 398 | return new OListViewItem( this ); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | #ifndef QT_NO_DATASTREAM | 402 | #ifndef QT_NO_DATASTREAM |
403 | void OListViewItem::serializeTo( QDataStream& s ) const | 403 | void OListViewItem::serializeTo( QDataStream& s ) const |
404 | { | 404 | { |
405 | #warning Caution... the binary format is still under construction... | 405 | #warning Caution... the binary format is still under construction... |
406 | odebug << "storing OListViewItem..." << oendl; | 406 | odebug << "storing OListViewItem..." << oendl; |
407 | 407 | ||
408 | // store item text | 408 | // store item text |
409 | for ( int i = 0; i < listView()->columns(); ++i ) | 409 | for ( int i = 0; i < listView()->columns(); ++i ) |
410 | { | 410 | { |
411 | s << text( i ); | 411 | s << text( i ); |
412 | } | 412 | } |
413 | 413 | ||
414 | // calculate the number of children to serialize | 414 | // calculate the number of children to serialize |
415 | int items = 0; | 415 | int items = 0; |
416 | QListViewItem* item = firstChild(); | 416 | QListViewItem* item = firstChild(); |
417 | while ( item ) | 417 | while ( item ) |
418 | { | 418 | { |
419 | item = item->nextSibling(); | 419 | item = item->nextSibling(); |
420 | items++; | 420 | items++; |
421 | } | 421 | } |
422 | 422 | ||
423 | // store number of items and the items itself | 423 | // store number of items and the items itself |
424 | s << items; | 424 | s << items; |
425 | item = firstChild(); | 425 | item = firstChild(); |
426 | for ( int i = 0; i < items; ++i ) | 426 | for ( int i = 0; i < items; ++i ) |
427 | { | 427 | { |
428 | s << *static_cast<OListViewItem*>( item ); | 428 | s << *static_cast<OListViewItem*>( item ); |
429 | item = item->nextSibling(); | 429 | item = item->nextSibling(); |
430 | } | 430 | } |
431 | 431 | ||
432 | odebug << "OListviewItem stored." << oendl; | 432 | odebug << "OListviewItem stored." << oendl; |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void OListViewItem::serializeFrom( QDataStream& s ) | 436 | void OListViewItem::serializeFrom( QDataStream& s ) |
437 | { | 437 | { |
438 | #warning Caution... the binary format is still under construction... | 438 | #warning Caution... the binary format is still under construction... |
439 | odebug << "loading OListViewItem..." << oendl; | 439 | odebug << "loading OListViewItem..." << oendl; |
440 | 440 | ||
441 | for ( int i = 0; i < listView()->columns(); ++i ) | 441 | for ( int i = 0; i < listView()->columns(); ++i ) |
442 | { | 442 | { |
443 | QString coltext; | 443 | QString coltext; |
444 | s >> coltext; | 444 | s >> coltext; |
445 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 445 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
446 | setText( i, coltext ); | 446 | setText( i, coltext ); |
447 | } | 447 | } |
448 | 448 | ||
449 | int items; | 449 | int items; |
450 | s >> items; | 450 | s >> items; |
451 | qDebug( "read number of items = %d", items ); | 451 | qDebug( "read number of items = %d", items ); |
452 | 452 | ||
453 | for ( int i = 0; i < items; ++i ) | 453 | for ( int i = 0; i < items; ++i ) |
454 | { | 454 | { |
455 | OListViewItem* item = childFactory(); | 455 | OListViewItem* item = childFactory(); |
456 | s >> (*item); | 456 | s >> (*item); |
457 | } | 457 | } |
458 | 458 | ||
459 | odebug << "OListViewItem loaded." << oendl; | 459 | odebug << "OListViewItem loaded." << oendl; |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | 463 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) |
464 | { | 464 | { |
465 | lvi.serializeTo( s ); | 465 | lvi.serializeTo( s ); |
466 | } | 466 | } |
467 | 467 | ||
468 | 468 | ||
469 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | 469 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) |
470 | { | 470 | { |
471 | lvi.serializeFrom( s ); | 471 | lvi.serializeFrom( s ); |
472 | } | 472 | } |
473 | #endif // QT_NO_DATASTREAM | 473 | #endif // QT_NO_DATASTREAM |
474 | 474 | ||
475 | 475 | ||
476 | /*====================================================================================== | 476 | /*====================================================================================== |
477 | * OCheckListItem | 477 | * OCheckListItem |
478 | *======================================================================================*/ | 478 | *======================================================================================*/ |
479 | 479 | ||
480 | OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) | 480 | OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) |
481 | :QCheckListItem( parent, text, t ) | 481 | :QCheckListItem( parent, text, t ) |
482 | { | 482 | { |
483 | init(); | 483 | init(); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) | 487 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) |
488 | :QCheckListItem( parent, text, t ) | 488 | :QCheckListItem( parent, text, t ) |
489 | { | 489 | { |
490 | init(); | 490 | init(); |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) | 494 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) |
495 | :QCheckListItem( parent, text, t ) | 495 | :QCheckListItem( parent, text, t ) |
496 | { | 496 | { |
497 | init(); | 497 | init(); |
498 | } | 498 | } |
499 | 499 | ||
500 | 500 | ||
501 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) | 501 | OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) |
502 | :QCheckListItem( parent, text, p ) | 502 | :QCheckListItem( parent, text, p ) |
503 | { | 503 | { |
504 | init(); | 504 | init(); |
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) | 508 | OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) |
509 | :QCheckListItem( parent, text, p ) | 509 | :QCheckListItem( parent, text, p ) |
510 | { | 510 | { |
511 | init(); | 511 | init(); |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | OCheckListItem::~OCheckListItem() | 515 | OCheckListItem::~OCheckListItem() |
516 | { | 516 | { |
517 | } | 517 | } |
518 | 518 | ||
519 | void OCheckListItem::init() | 519 | void OCheckListItem::init() |
520 | { | 520 | { |
521 | m_known = false; | 521 | m_known = false; |
522 | } | 522 | } |
523 | 523 | ||
524 | 524 | ||
525 | const QColor &OCheckListItem::backgroundColor() | 525 | const QColor &OCheckListItem::backgroundColor() |
526 | { | 526 | { |
527 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | 527 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : |
528 | listView()->viewport()->colorGroup().base(); | 528 | listView()->viewport()->colorGroup().base(); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | bool OCheckListItem::isAlternate() | 532 | bool OCheckListItem::isAlternate() |
533 | { | 533 | { |
534 | OListView *lv = static_cast<OListView*>( listView() ); | 534 | OListView *lv = static_cast<OListView*>( listView() ); |
535 | 535 | ||
536 | // check if the item above is an OCheckListItem | 536 | // check if the item above is an OCheckListItem |
537 | OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); | 537 | OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); |
538 | /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ | 538 | /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ |
539 | 539 | ||
540 | // check if we have a valid alternate background color | 540 | // check if we have a valid alternate background color |
541 | if (!(lv && lv->alternateBackground().isValid())) return false; | 541 | if (!(lv && lv->alternateBackground().isValid())) return false; |
542 | 542 | ||
543 | m_known = above ? above->m_known : true; | 543 | m_known = above ? above->m_known : true; |
544 | if (m_known) | 544 | if (m_known) |
545 | { | 545 | { |
546 | m_odd = above ? !above->m_odd : false; | 546 | m_odd = above ? !above->m_odd : false; |
547 | } | 547 | } |
548 | else | 548 | else |
549 | { | 549 | { |
550 | OCheckListItem *item; | 550 | OCheckListItem *item; |
551 | bool previous = true; | 551 | bool previous = true; |
552 | if (parent()) | 552 | if (parent()) |
553 | { | 553 | { |
554 | item = static_cast<OCheckListItem *>(parent()); | 554 | item = static_cast<OCheckListItem *>(parent()); |
555 | if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; | 555 | if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; |
556 | item = static_cast<OCheckListItem *>(parent()->firstChild()); | 556 | item = static_cast<OCheckListItem *>(parent()->firstChild()); |
557 | /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ | 557 | /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ |
558 | } | 558 | } |
559 | else | 559 | else |
560 | { | 560 | { |
561 | item = static_cast<OCheckListItem *>(lv->firstChild()); | 561 | item = static_cast<OCheckListItem *>(lv->firstChild()); |
562 | } | 562 | } |
563 | 563 | ||
564 | while(item) | 564 | while(item) |
565 | { | 565 | { |
566 | item->m_odd = previous = !previous; | 566 | item->m_odd = previous = !previous; |
567 | item->m_known = true; | 567 | item->m_known = true; |
568 | item = static_cast<OCheckListItem *>(item->nextSibling()); | 568 | item = static_cast<OCheckListItem *>(item->nextSibling()); |
569 | /* if (!item.inherits( "OCheckListItem" ) ) break; */ | 569 | /* if (!item.inherits( "OCheckListItem" ) ) break; */ |
570 | } | 570 | } |
571 | } | 571 | } |
572 | return m_odd; | 572 | return m_odd; |
573 | } | 573 | } |
574 | 574 | ||
575 | 575 | ||
576 | void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 576 | void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
577 | { | 577 | { |
578 | QColorGroup _cg = cg; | 578 | QColorGroup _cg = cg; |
579 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 579 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
580 | if (pm && !pm->isNull()) | 580 | if (pm && !pm->isNull()) |
581 | { | 581 | { |
582 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | 582 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); |
583 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 583 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
584 | } | 584 | } |
585 | else if ( isAlternate() ) | 585 | else if ( isAlternate() ) |
586 | { | 586 | { |
587 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 587 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
588 | } | 588 | } |
589 | QCheckListItem::paintCell( p, _cg, column, width, alignment ); | 589 | QCheckListItem::paintCell( p, _cg, column, width, alignment ); |
590 | 590 | ||
591 | //FIXME: Use styling here! | 591 | //FIXME: Use styling here! |
592 | 592 | ||
593 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 593 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
594 | p->setPen( pen ); | 594 | p->setPen( pen ); |
595 | p->drawLine( width-1, 0, width-1, height() ); | 595 | p->drawLine( width-1, 0, width-1, height() ); |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | /*====================================================================================== | 599 | /*====================================================================================== |
600 | * ONamedListView | 600 | * ONamedListView |
601 | *======================================================================================*/ | 601 | *======================================================================================*/ |
602 | 602 | ||
603 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) | 603 | ONamedListView::ONamedListView( QWidget *parent, const char *name ) |
604 | :OListView( parent, name ) | 604 | :OListView( parent, name ) |
605 | { | 605 | { |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | ONamedListView::~ONamedListView() | 609 | ONamedListView::~ONamedListView() |
610 | { | 610 | { |
611 | } | 611 | } |
612 | 612 | ||
613 | 613 | ||
614 | void ONamedListView::addColumns( const QStringList& columns ) | 614 | void ONamedListView::addColumns( const QStringList& columns ) |
615 | { | 615 | { |
616 | for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) | 616 | for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) |
617 | { | 617 | { |
618 | qDebug( "adding column %s", (const char*) *it ); | 618 | qDebug( "adding column %s", (const char*) *it ); |
619 | addColumn( *it ); | 619 | addColumn( *it ); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | int ONamedListView::findColumn( const QString& text ) const | 624 | int ONamedListView::findColumn( const QString& text ) const |
625 | { | 625 | { |
626 | //FIXME: If used excessively, this will slow down performance of updates | 626 | //FIXME: If used excessively, this will slow down performance of updates |
627 | //FIXME: because of the linear search over all column texts. | 627 | //FIXME: because of the linear search over all column texts. |
628 | //FIXME: I will optimize later by using a hash map. | 628 | //FIXME: I will optimize later by using a hash map. |
629 | for ( int i = 0; i < columns(); ++i ) | 629 | for ( int i = 0; i < columns(); ++i ) |
630 | if ( columnText( i ) == text ) | 630 | if ( columnText( i ) == text ) |
631 | return i; | 631 | return i; |
632 | return -1; | 632 | return -1; |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const | 636 | ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const |
637 | { | 637 | { |
638 | return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); | 638 | return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); |
639 | } | 639 | } |
640 | 640 | ||
641 | 641 | ||
642 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const | 642 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const |
643 | { | 643 | { |
644 | ONamedListViewItem* result; | 644 | ONamedListViewItem* result; |
645 | while ( item && item->text( column ) != text ) | 645 | while ( item && item->text( column ) != text ) |
646 | { | 646 | { |
647 | qDebug( "checked %s", (const char*) item->text( column ) ); | 647 | qDebug( "checked %s", (const char*) item->text( column ) ); |
648 | 648 | ||
649 | if ( recurse < 0 || recurse > 0 ) | 649 | if ( recurse < 0 || recurse > 0 ) |
650 | { | 650 | { |
651 | qDebug( "recursion is %d - recursing into...", recurse ); | 651 | qDebug( "recursion is %d - recursing into...", recurse ); |
652 | result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); | 652 | result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); |
653 | if ( result ) return result; | 653 | if ( result ) return result; |
654 | } | 654 | } |
655 | 655 | ||
656 | 656 | ||
657 | item = (ONamedListViewItem*) item->itemBelow(); | 657 | item = (ONamedListViewItem*) item->itemBelow(); |
658 | } | 658 | } |
659 | if ( item && item->text( column ) == text ) | 659 | if ( item && item->text( column ) == text ) |
660 | return item; | 660 | return item; |
661 | else | 661 | else |
662 | return 0; | 662 | return 0; |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const | 666 | ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const |
667 | { | 667 | { |
668 | int col = findColumn( column ); | 668 | int col = findColumn( column ); |
669 | if ( col != -1 ) | 669 | if ( col != -1 ) |
670 | return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); | 670 | return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); |
671 | else | 671 | else |
672 | return 0; | 672 | return 0; |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const | 676 | ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const |
677 | { | 677 | { |
678 | int col = findColumn( column ); | 678 | int col = findColumn( column ); |
679 | if ( col != -1 ) | 679 | if ( col != -1 ) |
680 | return find( item, col, text, recurse ); | 680 | return find( item, col, text, recurse ); |
681 | else | 681 | else |
682 | return 0; | 682 | return 0; |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | /*====================================================================================== | 686 | /*====================================================================================== |
687 | * ONamedListViewItem | 687 | * ONamedListViewItem |
688 | *======================================================================================*/ | 688 | *======================================================================================*/ |
689 | 689 | ||
690 | ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) | 690 | ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) |
691 | :OListViewItem( parent ) | 691 | :OListViewItem( parent ) |
692 | { | 692 | { |
693 | setText( texts ); | 693 | setText( texts ); |
694 | } | 694 | } |
695 | 695 | ||
696 | 696 | ||
697 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) | 697 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) |
698 | :OListViewItem( parent ) | 698 | :OListViewItem( parent ) |
699 | { | 699 | { |
700 | setText( texts ); | 700 | setText( texts ); |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) | 704 | ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) |
705 | :OListViewItem( parent, after ) | 705 | :OListViewItem( parent, after ) |
706 | { | 706 | { |
707 | setText( texts ); | 707 | setText( texts ); |
708 | } | 708 | } |
709 | 709 | ||
710 | 710 | ||
711 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) | 711 | ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) |
712 | :OListViewItem( parent, after ) | 712 | :OListViewItem( parent, after ) |
713 | { | 713 | { |
714 | setText( texts ); | 714 | setText( texts ); |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | ONamedListViewItem::~ONamedListViewItem() | 718 | ONamedListViewItem::~ONamedListViewItem() |
719 | { | 719 | { |
720 | } | 720 | } |
721 | 721 | ||
722 | 722 | ||
723 | void ONamedListViewItem::setText( const QStringList& texts ) | 723 | void ONamedListViewItem::setText( const QStringList& texts ) |
724 | { | 724 | { |
725 | int col = 0; | 725 | int col = 0; |
726 | for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) | 726 | for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) |
727 | { | 727 | { |
728 | qDebug( "setting column %d = text %s", col, (const char*) *it ); | 728 | qDebug( "setting column %d = text %s", col, (const char*) *it ); |
729 | OListViewItem::setText( col++, *it ); | 729 | OListViewItem::setText( col++, *it ); |
730 | } | 730 | } |
731 | 731 | ||
732 | } | 732 | } |
733 | 733 | ||
734 | 734 | ||
735 | void ONamedListViewItem::setText( const QString& column, const QString& text ) | 735 | void ONamedListViewItem::setText( const QString& column, const QString& text ) |
736 | { | 736 | { |
737 | //FIXME: If used excessively, this will slow down performance of updates | 737 | //FIXME: If used excessively, this will slow down performance of updates |
738 | //FIXME: because of the linear search over all column texts. | 738 | //FIXME: because of the linear search over all column texts. |
739 | //FIXME: I will optimize later by using a hash map. | 739 | //FIXME: I will optimize later by using a hash map. |
740 | int col = ( (ONamedListView*) listView() )->findColumn( column ); | 740 | int col = ( (ONamedListView*) listView() )->findColumn( column ); |
741 | if ( col != -1 ) | 741 | if ( col != -1 ) |
742 | OListViewItem::setText( col, text ); | 742 | OListViewItem::setText( col, text ); |
743 | else | 743 | else |
744 | qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); | 744 | qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); |
745 | } | 745 | } |
746 | 746 | ||
747 | 747 | ||
748 | ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const | 748 | ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const |
749 | { | 749 | { |
750 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); | 750 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); |
751 | } | 751 | } |
752 | 752 | ||
753 | 753 | ||
754 | ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const | 754 | ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const |
755 | { | 755 | { |
756 | int col = ( (ONamedListView*) listView() )->findColumn( column ); | 756 | int col = ( (ONamedListView*) listView() )->findColumn( column ); |
757 | if ( col != -1 ) | 757 | if ( col != -1 ) |
758 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); | 758 | return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); |
759 | else | 759 | else |
760 | return 0; | 760 | return 0; |
761 | } | 761 | } |
762 | 762 | ||
763 | } | 763 | } |
764 | } | 764 | } |
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index 8195a62..3ff11ef 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -1,426 +1,426 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OLISTVIEW_H | 30 | #ifndef OLISTVIEW_H |
31 | #define OLISTVIEW_H | 31 | #define OLISTVIEW_H |
32 | 32 | ||
33 | #include <qcolor.h> | 33 | #include <qcolor.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qpen.h> | 35 | #include <qpen.h> |
36 | #include <qdatastream.h> | 36 | #include <qdatastream.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | 39 | ||
40 | namespace Opie { | 40 | namespace Opie { |
41 | namespace Ui { | 41 | namespace Ui { |
42 | class OListViewItem; | 42 | class OListViewItem; |
43 | 43 | ||
44 | 44 | ||
45 | /*====================================================================================== | 45 | /*====================================================================================== |
46 | * OListView | 46 | * OListView |
47 | *======================================================================================*/ | 47 | *======================================================================================*/ |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * @brief A list/tree widget. | 50 | * @brief A list/tree widget. |
51 | * | 51 | * |
52 | * A @ref QListView variant featuring visual and functional enhancements | 52 | * A @ref QListView variant featuring visual and functional enhancements |
53 | * like an alternate background for odd rows, an autostretch mode | 53 | * like an alternate background for odd rows, an autostretch mode |
54 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 54 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
55 | * | 55 | * |
56 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 56 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
57 | */ | 57 | */ |
58 | class OListView: public QListView | 58 | class OListView: public QListView |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | /** | 62 | /** |
63 | * Constructor. | 63 | * Constructor. |
64 | * | 64 | * |
65 | * The parameters @a parent and @a name are handled by | 65 | * The parameters @a parent and @a name are handled by |
66 | * @ref QListView, as usual. | 66 | * @ref QListView, as usual. |
67 | */ | 67 | */ |
68 | OListView( QWidget* parent = 0, const char* name = 0 ); | 68 | OListView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
69 | /** | 69 | /** |
70 | * Destructor. | 70 | * Destructor. |
71 | */ | 71 | */ |
72 | virtual ~OListView(); | 72 | virtual ~OListView(); |
73 | /** | 73 | /** |
74 | * Let the last column fit exactly all the available width. | 74 | * Let the last column fit exactly all the available width. |
75 | */ | 75 | */ |
76 | void setFullWidth( bool fullWidth ); | 76 | void setFullWidth( bool fullWidth ); |
77 | /** | 77 | /** |
78 | * Returns whether the last column is set to fit the available width. | 78 | * Returns whether the last column is set to fit the available width. |
79 | */ | 79 | */ |
80 | bool fullWidth() const; | 80 | bool fullWidth() const; |
81 | /** | 81 | /** |
82 | * Reimplemented for full width support | 82 | * Reimplemented for full width support |
83 | */ | 83 | */ |
84 | virtual int addColumn( const QString& label, int width = -1 ); | 84 | virtual int addColumn( const QString& label, int width = -1 ); |
85 | /** | 85 | /** |
86 | * Reimplemented for full width support | 86 | * Reimplemented for full width support |
87 | */ | 87 | */ |
88 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | 88 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); |
89 | /** | 89 | /** |
90 | * Reimplemented for full width support | 90 | * Reimplemented for full width support |
91 | */ | 91 | */ |
92 | virtual void removeColumn(int index); | 92 | virtual void removeColumn(int index); |
93 | /** | 93 | /** |
94 | * Set the alternate background background @a color. | 94 | * Set the alternate background background @a color. |
95 | * Set to an invalid color to disable alternate colors. | 95 | * Set to an invalid color to disable alternate colors. |
96 | * This only has an effect if the items are OListViewItems | 96 | * This only has an effect if the items are OListViewItems |
97 | */ | 97 | */ |
98 | void setAlternateBackground( const QColor& color ); | 98 | void setAlternateBackground( const QColor& color ); |
99 | /** | 99 | /** |
100 | * Sets the column separator @a pen. | 100 | * Sets the column separator @a pen. |
101 | */ | 101 | */ |
102 | void setColumnSeparator( const QPen& pen ); | 102 | void setColumnSeparator( const QPen& pen ); |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * @returns the alternate background color | 105 | * @returns the alternate background color |
106 | */ | 106 | */ |
107 | const QColor& alternateBackground() const; | 107 | const QColor& alternateBackground() const; |
108 | /** | 108 | /** |
109 | * @return the column separator pen | 109 | * @return the column separator pen |
110 | */ | 110 | */ |
111 | const QPen& columnSeparator() const; | 111 | const QPen& columnSeparator() const; |
112 | /** | 112 | /** |
113 | * Create a list view item as child of this object | 113 | * Create a list view item as child of this object |
114 | * @returns the new object | 114 | * @returns the new object |
115 | */ | 115 | */ |
116 | virtual OListViewItem* childFactory(); | 116 | virtual OListViewItem* childFactory(); |
117 | #ifndef QT_NO_DATASTREAM | 117 | #ifndef QT_NO_DATASTREAM |
118 | /** | 118 | /** |
119 | * Serialize this object to @ref QDataStream @a stream | 119 | * Serialize this object to @ref QDataStream @a stream |
120 | */ | 120 | */ |
121 | virtual void serializeTo( QDataStream& stream ) const; | 121 | virtual void serializeTo( QDataStream& stream ) const; |
122 | /** | 122 | /** |
123 | * Serialize this object from a @ref QDataStream @a stream | 123 | * Serialize this object from a @ref QDataStream @a stream |
124 | */ | 124 | */ |
125 | virtual void serializeFrom( QDataStream& s ); | 125 | virtual void serializeFrom( QDataStream& s ); |
126 | #endif | 126 | #endif |
127 | 127 | ||
128 | public slots: | 128 | public slots: |
129 | /** | 129 | /** |
130 | * Expand all items | 130 | * Expand all items |
131 | */ | 131 | */ |
132 | void expand(); | 132 | void expand(); |
133 | /** | 133 | /** |
134 | * Collapse all items | 134 | * Collapse all items |
135 | */ | 135 | */ |
136 | void collapse(); | 136 | void collapse(); |
137 | 137 | ||
138 | protected slots: | 138 | protected slots: |
139 | /** | 139 | /** |
140 | * expand the current OListViewItem | 140 | * expand the current OListViewItem |
141 | */ | 141 | */ |
142 | void expand(QListViewItem*); | 142 | void expand(QListViewItem*); |
143 | 143 | ||
144 | private: | 144 | private: |
145 | QColor m_alternateBackground; | 145 | QColor m_alternateBackground; |
146 | bool m_fullWidth : 1; | 146 | bool m_fullWidth : 1; |
147 | QPen m_columnSeparator; | 147 | QPen m_columnSeparator; |
148 | class Private; | 148 | class Private; |
149 | Private *d; | 149 | Private *d; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | #ifndef QT_NO_DATASTREAM | 152 | #ifndef QT_NO_DATASTREAM |
153 | /** | 153 | /** |
154 | * @relates OListView | 154 | * @relates OListView |
155 | * Writes @a listview to the @a stream and returns a reference to the stream. | 155 | * Writes @a listview to the @a stream and returns a reference to the stream. |
156 | */ | 156 | */ |
157 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); | 157 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); |
158 | /** | 158 | /** |
159 | * @relates OListView | 159 | * @relates OListView |
160 | * Reads @a listview from the @a stream and returns a reference to the stream. | 160 | * Reads @a listview from the @a stream and returns a reference to the stream. |
161 | */ | 161 | */ |
162 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); | 162 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); |
163 | #endif // QT_NO_DATASTREAM | 163 | #endif // QT_NO_DATASTREAM |
164 | 164 | ||
165 | /*====================================================================================== | 165 | /*====================================================================================== |
166 | * OListViewItem | 166 | * OListViewItem |
167 | *======================================================================================*/ | 167 | *======================================================================================*/ |
168 | 168 | ||
169 | class OListViewItem: public QListViewItem | 169 | class OListViewItem: public QListViewItem |
170 | { | 170 | { |
171 | friend class OCheckListItem; | 171 | friend class OCheckListItem; |
172 | public: | 172 | public: |
173 | /** | 173 | /** |
174 | * Constructors. | 174 | * Constructors. |
175 | */ | 175 | */ |
176 | OListViewItem( QListView * parent ); | 176 | OListViewItem( QListView * parent ); |
177 | OListViewItem( QListViewItem * parent ); | 177 | OListViewItem( QListViewItem * parent ); |
178 | OListViewItem( QListView * parent, QListViewItem * after ); | 178 | OListViewItem( QListView * parent, QListViewItem * after ); |
179 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 179 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
180 | 180 | ||
181 | OListViewItem( QListView * parent, | 181 | OListViewItem( QListView * parent, |
182 | QString, QString = QString::null, | 182 | QString, QString = QString::null, |
183 | QString = QString::null, QString = QString::null, | 183 | QString = QString::null, QString = QString::null, |
184 | QString = QString::null, QString = QString::null, | 184 | QString = QString::null, QString = QString::null, |
185 | QString = QString::null, QString = QString::null ); | 185 | QString = QString::null, QString = QString::null ); |
186 | 186 | ||
187 | OListViewItem( QListViewItem * parent, | 187 | OListViewItem( QListViewItem * parent, |
188 | QString, QString = QString::null, | 188 | QString, QString = QString::null, |
189 | QString = QString::null, QString = QString::null, | 189 | QString = QString::null, QString = QString::null, |
190 | QString = QString::null, QString = QString::null, | 190 | QString = QString::null, QString = QString::null, |
191 | QString = QString::null, QString = QString::null ); | 191 | QString = QString::null, QString = QString::null ); |
192 | 192 | ||
193 | OListViewItem( QListView * parent, QListViewItem * after, | 193 | OListViewItem( QListView * parent, QListViewItem * after, |
194 | QString, QString = QString::null, | 194 | QString, QString = QString::null, |
195 | QString = QString::null, QString = QString::null, | 195 | QString = QString::null, QString = QString::null, |
196 | QString = QString::null, QString = QString::null, | 196 | QString = QString::null, QString = QString::null, |
197 | QString = QString::null, QString = QString::null ); | 197 | QString = QString::null, QString = QString::null ); |
198 | 198 | ||
199 | OListViewItem( QListViewItem * parent, QListViewItem * after, | 199 | OListViewItem( QListViewItem * parent, QListViewItem * after, |
200 | QString, QString = QString::null, | 200 | QString, QString = QString::null, |
201 | QString = QString::null, QString = QString::null, | 201 | QString = QString::null, QString = QString::null, |
202 | QString = QString::null, QString = QString::null, | 202 | QString = QString::null, QString = QString::null, |
203 | QString = QString::null, QString = QString::null ); | 203 | QString = QString::null, QString = QString::null ); |
204 | /** | 204 | /** |
205 | * Destructor. | 205 | * Destructor. |
206 | */ | 206 | */ |
207 | virtual ~OListViewItem(); | 207 | virtual ~OListViewItem(); |
208 | /** | 208 | /** |
209 | * @returns the background color of the list item. | 209 | * @returns the background color of the list item. |
210 | */ | 210 | */ |
211 | const QColor& backgroundColor(); | 211 | const QColor& backgroundColor(); |
212 | /** | 212 | /** |
213 | * @returns true, if the item is at an odd position and | 213 | * @returns true, if the item is at an odd position and |
214 | * thus have to be painted with the alternate background color. | 214 | * thus have to be painted with the alternate background color. |
215 | */ | 215 | */ |
216 | bool isAlternate(); | 216 | bool isAlternate(); |
217 | /** | 217 | /** |
218 | * @note: Reimplemented for internal purposes - the API is not affected | 218 | * @note: Reimplemented for internal purposes - the API is not affected |
219 | * | 219 | * |
220 | */ | 220 | */ |
221 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 221 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
222 | /** | 222 | /** |
223 | * Perform object initialization. | 223 | * Perform object initialization. |
224 | */ | 224 | */ |
225 | void init(); | 225 | void init(); |
226 | /** | 226 | /** |
227 | * create a list view item as child of this object | 227 | * create a list view item as child of this object |
228 | * @returns the new object | 228 | * @returns the new object |
229 | */ | 229 | */ |
230 | virtual OListViewItem* childFactory(); | 230 | virtual OListViewItem* childFactory(); |
231 | #ifndef QT_NO_DATASTREAM | 231 | #ifndef QT_NO_DATASTREAM |
232 | /** | 232 | /** |
233 | * serialize this object to or from a @ref QDataStream | 233 | * serialize this object to or from a @ref QDataStream |
234 | * @param s the stream used to serialize this object. | 234 | * @param s the stream used to serialize this object. |
235 | */ | 235 | */ |
236 | virtual void serializeTo( QDataStream& s ) const; | 236 | virtual void serializeTo( QDataStream& s ) const; |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * serialize this object to or from a @ref QDataStream | 239 | * serialize this object to or from a @ref QDataStream |
240 | * @param s the stream used to serialize this object. | 240 | * @param s the stream used to serialize this object. |
241 | */ | 241 | */ |
242 | virtual void serializeFrom( QDataStream& s ); | 242 | virtual void serializeFrom( QDataStream& s ); |
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | /** | 245 | /** |
246 | * expand the the item | 246 | * expand the the item |
247 | */ | 247 | */ |
248 | virtual void expand(){}; | 248 | virtual void expand(){}; |
249 | 249 | ||
250 | private: | 250 | private: |
251 | bool m_known : 1; | 251 | bool m_known : 1; |
252 | bool m_odd : 1; | 252 | bool m_odd : 1; |
253 | class Private; | 253 | class Private; |
254 | Private *d; | 254 | Private *d; |
255 | }; | 255 | }; |
256 | 256 | ||
257 | #ifndef QT_NO_DATASTREAM | 257 | #ifndef QT_NO_DATASTREAM |
258 | /** | 258 | /** |
259 | * @relates QListViewItem | 259 | * @relates QListViewItem |
260 | * Writes listview @a item and all subitems recursively to @a stream | 260 | * Writes listview @a item and all subitems recursively to @a stream |
261 | * and returns a reference to the stream. | 261 | * and returns a reference to the stream. |
262 | */ | 262 | */ |
263 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); | 263 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); |
264 | /** | 264 | /** |
265 | * @relates QListViewItem | 265 | * @relates QListViewItem |
266 | * Reads listview @a item from @a stream and returns a reference to the stream. | 266 | * Reads listview @a item from @a stream and returns a reference to the stream. |
267 | */ | 267 | */ |
268 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); | 268 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); |
269 | #endif // QT_NO_DATASTREAM | 269 | #endif // QT_NO_DATASTREAM |
270 | 270 | ||
271 | 271 | ||
272 | /*====================================================================================== | 272 | /*====================================================================================== |
273 | * OCheckListItem | 273 | * OCheckListItem |
274 | *======================================================================================*/ | 274 | *======================================================================================*/ |
275 | 275 | ||
276 | class OCheckListItem : public QCheckListItem | 276 | class OCheckListItem : public QCheckListItem |
277 | { | 277 | { |
278 | public: | 278 | public: |
279 | 279 | ||
280 | OCheckListItem( QCheckListItem *parent, const QString &text, | 280 | OCheckListItem( QCheckListItem *parent, const QString &text, |
281 | Type = Controller ); | 281 | Type = Controller ); |
282 | OCheckListItem( QListViewItem *parent, const QString &text, | 282 | OCheckListItem( QListViewItem *parent, const QString &text, |
283 | Type = Controller ); | 283 | Type = Controller ); |
284 | OCheckListItem( QListView *parent, const QString &text, | 284 | OCheckListItem( QListView *parent, const QString &text, |
285 | Type = Controller ); | 285 | Type = Controller ); |
286 | OCheckListItem( QListViewItem *parent, const QString &text, | 286 | OCheckListItem( QListViewItem *parent, const QString &text, |
287 | const QPixmap & ); | 287 | const QPixmap & ); |
288 | OCheckListItem( QListView *parent, const QString &text, | 288 | OCheckListItem( QListView *parent, const QString &text, |
289 | const QPixmap & ); | 289 | const QPixmap & ); |
290 | ~OCheckListItem(); | 290 | ~OCheckListItem(); |
291 | /** | 291 | /** |
292 | * @returns the background color of the list item. | 292 | * @returns the background color of the list item. |
293 | */ | 293 | */ |
294 | const QColor& backgroundColor(); | 294 | const QColor& backgroundColor(); |
295 | /** | 295 | /** |
296 | * @returns true, if the item is at an odd position and | 296 | * @returns true, if the item is at an odd position and |
297 | * thus have to be painted with the alternate background color. | 297 | * thus have to be painted with the alternate background color. |
298 | */ | 298 | */ |
299 | bool isAlternate(); | 299 | bool isAlternate(); |
300 | /** | 300 | /** |
301 | * @note: Reimplemented for internal purposes - the API is not affected | 301 | * @note: Reimplemented for internal purposes - the API is not affected |
302 | * | 302 | * |
303 | */ | 303 | */ |
304 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 304 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
305 | /** | 305 | /** |
306 | * Perform object initialization. | 306 | * Perform object initialization. |
307 | */ | 307 | */ |
308 | void init(); | 308 | void init(); |
309 | 309 | ||
310 | private: | 310 | private: |
311 | bool m_known; | 311 | bool m_known; |
312 | bool m_odd; | 312 | bool m_odd; |
313 | }; | 313 | }; |
314 | 314 | ||
315 | 315 | ||
316 | /*====================================================================================== | 316 | /*====================================================================================== |
317 | * ONamedListView | 317 | * ONamedListView |
318 | *======================================================================================*/ | 318 | *======================================================================================*/ |
319 | 319 | ||
320 | class ONamedListViewItem; | 320 | class ONamedListViewItem; |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * @brief An OListView variant with named columns. | 323 | * @brief An OListView variant with named columns. |
324 | * | 324 | * |
325 | * This class provides a higher-level interface to an OListView. | 325 | * This class provides a higher-level interface to an OListView. |
326 | * | 326 | * |
327 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 327 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
328 | */ | 328 | */ |
329 | class ONamedListView: public OListView | 329 | class ONamedListView: public OListView |
330 | { | 330 | { |
331 | public: | 331 | public: |
332 | /** | 332 | /** |
333 | * Constructor. | 333 | * Constructor. |
334 | * | 334 | * |
335 | * The parameters @a parent and @a name are handled by | 335 | * The parameters @a parent and @a name are handled by |
336 | * @ref OListView, as usual. | 336 | * @ref OListView, as usual. |
337 | */ | 337 | */ |
338 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); | 338 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); |
339 | /** | 339 | /** |
340 | * Destructor. | 340 | * Destructor. |
341 | */ | 341 | */ |
342 | virtual ~ONamedListView(); | 342 | virtual ~ONamedListView(); |
343 | /** | 343 | /** |
344 | * Add a number of @a columns to the listview. | 344 | * Add a number of @a columns to the listview. |
345 | */ | 345 | */ |
346 | virtual void addColumns( const QStringList& columns ); | 346 | virtual void addColumns( const QStringList& columns ); |
347 | /** | 347 | /** |
348 | * @returns the column index matching to @a text or -1 if not found. | 348 | * @returns the column index matching to @a text or -1 if not found. |
349 | */ | 349 | */ |
350 | virtual int findColumn( const QString& text ) const; | 350 | virtual int findColumn( const QString& text ) const; |
351 | /** | 351 | /** |
352 | * @returns the first item which has a @a text in column @a column. | 352 | * @returns the first item which has a @a text in column @a column. |
353 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 353 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
354 | * <li>set it to 0 to search only among direct childs, | 354 | * <li>set it to 0 to search only among direct childs, |
355 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 355 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
356 | * <li>set it to -1 for maximum recursion. | 356 | * <li>set it to -1 for maximum recursion. |
357 | * </ul> | 357 | * </ul> |
358 | * @sa ONamedListViewItem::find() | 358 | * @sa ONamedListViewItem::find() |
359 | */ | 359 | */ |
360 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; | 360 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; |
361 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 361 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
362 | 362 | ||
363 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; | 363 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; |
364 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 364 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
365 | private: | 365 | private: |
366 | class Private; | 366 | class Private; |
367 | Private *d; | 367 | Private *d; |
368 | }; | 368 | }; |
369 | 369 | ||
370 | /*====================================================================================== | 370 | /*====================================================================================== |
371 | * ONamedListViewItem | 371 | * ONamedListViewItem |
372 | *======================================================================================*/ | 372 | *======================================================================================*/ |
373 | 373 | ||
374 | /** | 374 | /** |
375 | * @brief An OListView variant with named columns. | 375 | * @brief An OListView variant with named columns. |
376 | * | 376 | * |
377 | * This class provides a higher-level interface to an OListViewItem. | 377 | * This class provides a higher-level interface to an OListViewItem. |
378 | * | 378 | * |
379 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 379 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
380 | */ | 380 | */ |
381 | class ONamedListViewItem: public OListViewItem | 381 | class ONamedListViewItem: public OListViewItem |
382 | { | 382 | { |
383 | public: | 383 | public: |
384 | /** | 384 | /** |
385 | * Constructor. Accepts the same parameters as a @ref OListViewItem, | 385 | * Constructor. Accepts the same parameters as a @ref OListViewItem, |
386 | * plus a @ref QStringList which holds an arbitrary number of @a texts. | 386 | * plus a @ref QStringList which holds an arbitrary number of @a texts. |
387 | */ | 387 | */ |
388 | ONamedListViewItem( QListView* parent, const QStringList& texts ); | 388 | ONamedListViewItem( QListView* parent, const QStringList& texts ); |
389 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); | 389 | ONamedListViewItem( QListViewItem* parent, const QStringList& texts ); |
390 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); | 390 | ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ); |
391 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); | 391 | ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ); |
392 | /** | 392 | /** |
393 | * Destructor. | 393 | * Destructor. |
394 | */ | 394 | */ |
395 | virtual ~ONamedListViewItem(); | 395 | virtual ~ONamedListViewItem(); |
396 | /** | 396 | /** |
397 | * Sets the text in column @a column to @a text. | 397 | * Sets the text in column @a column to @a text. |
398 | * This method differs from @ref QListViewItem::setText() in that it | 398 | * This method differs from @ref QListViewItem::setText() in that it |
399 | * accepts a string as column indicator instead of an int. | 399 | * accepts a string as column indicator instead of an int. |
400 | */ | 400 | */ |
401 | virtual void setText( const QString& column, const QString& text ); | 401 | virtual void setText( const QString& column, const QString& text ); |
402 | /** | 402 | /** |
403 | * Sets a number of @a texts for this item. | 403 | * Sets a number of @a texts for this item. |
404 | */ | 404 | */ |
405 | virtual void setText( const QStringList& texts ); | 405 | virtual void setText( const QStringList& texts ); |
406 | /** | 406 | /** |
407 | * @returns the first child which has a @a text in column @a column. | 407 | * @returns the first child which has a @a text in column @a column. |
408 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 408 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
409 | * <li>set it to 0 to search only among direct childs, | 409 | * <li>set it to 0 to search only among direct childs, |
410 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 410 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
411 | * <li>set it to -1 for maximum recursion. | 411 | * <li>set it to -1 for maximum recursion. |
412 | * </ul> | 412 | * </ul> |
413 | * @sa ONamedListView::find() | 413 | * @sa ONamedListView::find() |
414 | */ | 414 | */ |
415 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 415 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
416 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 416 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
417 | 417 | ||
418 | private: | 418 | private: |
419 | class Private; | 419 | class Private; |
420 | Private *d; | 420 | Private *d; |
421 | 421 | ||
422 | }; | 422 | }; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | #endif // OLISTVIEW_H | 426 | #endif // OLISTVIEW_H |