Diffstat (limited to 'libopie2/opieui/oversatileview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/oversatileview.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp index 6808539..65fe3d8 100644 --- a/libopie2/opieui/oversatileview.cpp +++ b/libopie2/opieui/oversatileview.cpp | |||
@@ -15,54 +15,55 @@ | |||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* OPIE */ | ||
32 | |||
33 | #include <opie2/odebug.h> | ||
34 | #include <opie2/oversatileview.h> | ||
35 | #include <opie2/oversatileviewitem.h> | ||
36 | #include <opie2/olistview.h> | ||
37 | |||
31 | /* QT */ | 38 | /* QT */ |
32 | 39 | ||
33 | #include <qaction.h> | 40 | #include <qaction.h> |
34 | #include <qbrush.h> | 41 | #include <qbrush.h> |
35 | #include <qfont.h> | 42 | #include <qfont.h> |
36 | #include <qiconset.h> | 43 | #include <qiconset.h> |
37 | #include <qiconview.h> | 44 | #include <qiconview.h> |
38 | #include <qlistview.h> | 45 | #include <qlistview.h> |
39 | #include <qpalette.h> | 46 | #include <qpalette.h> |
40 | #include <qpoint.h> | 47 | #include <qpoint.h> |
41 | #include <qpopupmenu.h> | 48 | #include <qpopupmenu.h> |
42 | #include <qrect.h> | 49 | #include <qrect.h> |
43 | #include <qsize.h> | 50 | #include <qsize.h> |
44 | #include <qstring.h> | 51 | #include <qstring.h> |
45 | #include <qwidgetstack.h> | 52 | #include <qwidgetstack.h> |
46 | 53 | ||
47 | /* OPIE */ | ||
48 | |||
49 | #include <opie2/oversatileview.h> | ||
50 | #include <opie2/oversatileviewitem.h> | ||
51 | #include <opie2/olistview.h> | ||
52 | |||
53 | /* XPM */ | 54 | /* XPM */ |
54 | static const char * view_icon_xpm[] = { | 55 | static const char * view_icon_xpm[] = { |
55 | "16 16 16 1", | 56 | "16 16 16 1", |
56 | " c None", | 57 | " c None", |
57 | ".c #87BD88", | 58 | ".c #87BD88", |
58 | "+c #8BBE8B", | 59 | "+c #8BBE8B", |
59 | "@c #81BA81", | 60 | "@c #81BA81", |
60 | "#c #6DAF6D", | 61 | "#c #6DAF6D", |
61 | "$c #87BD87", | 62 | "$c #87BD87", |
62 | "%c #FCFDFC", | 63 | "%c #FCFDFC", |
63 | "&c #AED0AE", | 64 | "&c #AED0AE", |
64 | "*c #4E9C4C", | 65 | "*c #4E9C4C", |
65 | "=c #91BD91", | 66 | "=c #91BD91", |
66 | "-c #72B172", | 67 | "-c #72B172", |
67 | ";c #448643", | 68 | ";c #448643", |
68 | ">c #519F50", | 69 | ">c #519F50", |
@@ -276,101 +277,101 @@ bool OVersatileView::synchronization() | |||
276 | void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) | 277 | void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) |
277 | { | 278 | { |
278 | if ( mode == Tree ) | 279 | if ( mode == Tree ) |
279 | { | 280 | { |
280 | _treeleaf = leaf; | 281 | _treeleaf = leaf; |
281 | _treeopened = opened; | 282 | _treeopened = opened; |
282 | _treeclosed = closed; | 283 | _treeclosed = closed; |
283 | } | 284 | } |
284 | else if ( mode == Icons ) | 285 | else if ( mode == Icons ) |
285 | { | 286 | { |
286 | _iconleaf = leaf; | 287 | _iconleaf = leaf; |
287 | _iconopened = opened; | 288 | _iconopened = opened; |
288 | _iconclosed = closed; | 289 | _iconclosed = closed; |
289 | } | 290 | } |
290 | else | 291 | else |
291 | { | 292 | { |
292 | qDebug( "OVersatileView::setDefaultPixmaps(): invalid mode" ); | 293 | odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl; |
293 | } | 294 | } |
294 | } | 295 | } |
295 | 296 | ||
296 | QIconView* OVersatileView::iconView() const | 297 | QIconView* OVersatileView::iconView() const |
297 | { | 298 | { |
298 | return _iconview; | 299 | return _iconview; |
299 | } | 300 | } |
300 | 301 | ||
301 | OListView* OVersatileView::listView() const | 302 | OListView* OVersatileView::listView() const |
302 | { | 303 | { |
303 | return _listview; | 304 | return _listview; |
304 | } | 305 | } |
305 | 306 | ||
306 | void OVersatileView::setViewMode( int mode ) | 307 | void OVersatileView::setViewMode( int mode ) |
307 | { | 308 | { |
308 | if ( mode == Tree ) | 309 | if ( mode == Tree ) |
309 | { | 310 | { |
310 | _viewmode = mode; | 311 | _viewmode = mode; |
311 | raiseWidget( _listview ); | 312 | raiseWidget( _listview ); |
312 | } | 313 | } |
313 | else if ( mode == Icons ) | 314 | else if ( mode == Icons ) |
314 | { | 315 | { |
315 | _viewmode = mode; | 316 | _viewmode = mode; |
316 | raiseWidget( _iconview ); | 317 | raiseWidget( _iconview ); |
317 | } | 318 | } |
318 | else | 319 | else |
319 | { | 320 | { |
320 | qDebug( "OVersatileView::setViewMode(): invalid mode" ); | 321 | odebug << "OVersatileView::setViewMode(): invalid mode" << oendl; |
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
324 | void OVersatileView::setIconViewMode() | 325 | void OVersatileView::setIconViewMode() |
325 | { | 326 | { |
326 | setViewMode( Icons ); | 327 | setViewMode( Icons ); |
327 | } | 328 | } |
328 | 329 | ||
329 | void OVersatileView::setTreeViewMode() | 330 | void OVersatileView::setTreeViewMode() |
330 | { | 331 | { |
331 | setViewMode( Tree ); | 332 | setViewMode( Tree ); |
332 | } | 333 | } |
333 | 334 | ||
334 | bool OVersatileView::isValidViewMode( int mode ) const | 335 | bool OVersatileView::isValidViewMode( int mode ) const |
335 | { | 336 | { |
336 | switch ( _warningpolicy ) | 337 | switch ( _warningpolicy ) |
337 | { | 338 | { |
338 | case OVersatileView::None: | 339 | case OVersatileView::None: |
339 | { | 340 | { |
340 | return true; | 341 | return true; |
341 | } | 342 | } |
342 | case OVersatileView::Warn: | 343 | case OVersatileView::Warn: |
343 | { | 344 | { |
344 | if ( _viewmode != mode ) | 345 | if ( _viewmode != mode ) |
345 | { | 346 | { |
346 | qDebug( "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." ); | 347 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; |
347 | return true; | 348 | return true; |
348 | } | 349 | } |
349 | } | 350 | } |
350 | case OVersatileView::WarnReturn: | 351 | case OVersatileView::WarnReturn: |
351 | { | 352 | { |
352 | if ( _viewmode != mode ) | 353 | if ( _viewmode != mode ) |
353 | { | 354 | { |
354 | qDebug( "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." ); | 355 | odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl; |
355 | return false; | 356 | return false; |
356 | } | 357 | } |
357 | } | 358 | } |
358 | default: | 359 | default: |
359 | { | 360 | { |
360 | qWarning( "OVersatileView::isValidViewMode(): Inconsistent object state!" ); | 361 | owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl; |
361 | return true; | 362 | return true; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | } | 365 | } |
365 | void OVersatileView::setWarningPolicy( int policy ) const | 366 | void OVersatileView::setWarningPolicy( int policy ) const |
366 | { | 367 | { |
367 | _warningpolicy = policy; | 368 | _warningpolicy = policy; |
368 | } | 369 | } |
369 | bool OVersatileView::warningPolicy() const | 370 | bool OVersatileView::warningPolicy() const |
370 | { | 371 | { |
371 | return _warningpolicy; | 372 | return _warningpolicy; |
372 | } | 373 | } |
373 | //==============================================================================================// | 374 | //==============================================================================================// |
374 | // Stupid Signal forwarders... | 375 | // Stupid Signal forwarders... |
375 | // Folks, this is why I like python with its dynamic typing: | 376 | // Folks, this is why I like python with its dynamic typing: |
376 | // I can code the following dozens of lines C++ in four Python lines... | 377 | // I can code the following dozens of lines C++ in four Python lines... |
@@ -435,33 +436,33 @@ void OVersatileView::returnPressed( QIconViewItem * item ) | |||
435 | { | 436 | { |
436 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); | 437 | emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); |
437 | } | 438 | } |
438 | 439 | ||
439 | void OVersatileView::onItem( QListViewItem * item ) | 440 | void OVersatileView::onItem( QListViewItem * item ) |
440 | { | 441 | { |
441 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); | 442 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); |
442 | } | 443 | } |
443 | 444 | ||
444 | void OVersatileView::onItem( QIconViewItem * item ) | 445 | void OVersatileView::onItem( QIconViewItem * item ) |
445 | { | 446 | { |
446 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); | 447 | emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); |
447 | } | 448 | } |
448 | 449 | ||
449 | void OVersatileView::expanded( QListViewItem *item ) // QListView | 450 | void OVersatileView::expanded( QListViewItem *item ) // QListView |
450 | { | 451 | { |
451 | //qDebug( "OVersatileView::expanded(): opening tree..." ); | 452 | //odebug << "OVersatileView::expanded(): opening tree..." << oendl; |
452 | if ( !_treeopened.isNull() ) | 453 | if ( !_treeopened.isNull() ) |
453 | item->setPixmap( 0, _treeopened ); | 454 | item->setPixmap( 0, _treeopened ); |
454 | emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); | 455 | emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); |
455 | } | 456 | } |
456 | void OVersatileView::collapsed( QListViewItem *item ) // QListView | 457 | void OVersatileView::collapsed( QListViewItem *item ) // QListView |
457 | { | 458 | { |
458 | if ( !_treeclosed.isNull() ) | 459 | if ( !_treeclosed.isNull() ) |
459 | item->setPixmap( 0, _treeclosed ); | 460 | item->setPixmap( 0, _treeclosed ); |
460 | emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); | 461 | emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); |
461 | } | 462 | } |
462 | 463 | ||
463 | //=============================================================================================// | 464 | //=============================================================================================// |
464 | // OVersatileView Case I - API only existing in QListView or QIconView but not in both! | 465 | // OVersatileView Case I - API only existing in QListView or QIconView but not in both! |
465 | //==============================================================================================// | 466 | //==============================================================================================// |
466 | 467 | ||
467 | int OVersatileView::treeStepSize() const // QListView | 468 | int OVersatileView::treeStepSize() const // QListView |