Diffstat (limited to 'libopie2/opieui/oversatileview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/oversatileview.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp index 78154b7..f6c6410 100644 --- a/libopie2/opieui/oversatileview.cpp +++ b/libopie2/opieui/oversatileview.cpp @@ -27,32 +27,35 @@ Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/odebug.h> #include <opie2/oversatileview.h> #include <opie2/oversatileviewitem.h> #include <opie2/olistview.h> /* QT */ #include <qaction.h> #include <qpopupmenu.h> +using namespace Opie::Core; +using namespace Opie::Ui; + /* XPM */ static const char * view_icon_xpm[] = { "16 16 16 1", " c None", ". c #87BD88", "+ c #8BBE8B", "@ c #81BA81", "# c #6DAF6D", "$ c #87BD87", "% c #FCFDFC", "& c #AED0AE", "* c #4E9C4C", "= c #91BD91", "- c #72B172", "; c #448643", "> c #519F50", @@ -119,119 +122,119 @@ OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) _treeleaf(), _treeopened(), _treeclosed(), _iconleaf(), _iconopened(), _iconclosed() { // // Create child widgets and set some reasonable default styles // _listview = new OListView( this, "oversatileview embedded listview" ); _iconview = new QIconView( this, "oversatileview embedded iconview" ); _listview->setAllColumnsShowFocus( true ); _listview->setRootIsDecorated( true ); _listview->setShowSortIndicator( true ); _iconview->setGridX( 90 ); _iconview->setGridY( 42 ); _iconview->setAutoArrange( true ); - + #ifdef QWS // TODO: Let this depend on current geometry (rotation) _iconview->setArrangement( QIconView::TopToBottom ); #else _iconview->setArrangement( QIconView::LeftToRight ); #endif - + _iconview->setResizeMode( QIconView::Adjust ); - + // qt-embedded: map stylus right on hold to right button press #ifdef QWS ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); #endif setViewMode( mode ); // TODO: Read last style from config // setSynchronization( true ); // TODO: Implement this // create context menu allowing to switch between the views _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); _contextmenu->setCaption( "Style" ); _contextmenu->setCheckable( true ); QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), "View Icons", 0, ag, "viewicon action", true ); QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), "View Tree", 0, ag, "viewtree action", true ); ag->addTo( _contextmenu ); if ( mode == Icons ) a1->setOn( true ); else if ( mode == Tree ) a2->setOn( true ); connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); - + #if (QT_VERSION >= 0x030000) connect( _listview, SIGNAL( contextMenuRequested(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); connect( _iconview, SIGNAL( contextMenuRequested(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); #else connect( _listview, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); connect( _iconview, SIGNAL( rightButtonPressed(QIconViewItem*,const QPoint&) ), this, SLOT( contextMenuRequested(QIconViewItem*,const QPoint&) ) ); #endif - + // // signal forwarders // // unfortunately we can't short-circuit all the QListView and QIconView signals // to OVersatileView signals, because the signal/slot mechanism doesn't allow // type-conversion :-( // common signals for listview - + connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( _listview, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( selectionChanged(QListViewItem*) ) ); - connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); + connect( _listview, SIGNAL( currentChanged(QListViewItem*) ), this, SLOT( currentChanged(QListViewItem*) ) ); connect( _listview, SIGNAL( clicked(QListViewItem*) ), this, SLOT( clicked(QListViewItem*) ) ); connect( _listview, SIGNAL( pressed(QListViewItem*) ), this, SLOT( pressed(QListViewItem*) ) ); - + connect( _listview, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( doubleClicked(QListViewItem*) ) ); connect( _listview, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( returnPressed(QListViewItem*) ) ); - + connect( _listview, SIGNAL( onItem(QListViewItem*) ), this, SLOT( onItem(QListViewItem*) ) ); connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); // common signals for iconview - + connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( _iconview, SIGNAL( selectionChanged(QIconViewItem*) ), this, SLOT( selectionChanged(QIconViewItem*) ) ); - connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); + connect( _iconview, SIGNAL( currentChanged(QIconViewItem*) ), this, SLOT( currentChanged(QIconViewItem*) ) ); connect( _iconview, SIGNAL( clicked(QIconViewItem*) ), this, SLOT( clicked(QIconViewItem*) ) ); connect( _iconview, SIGNAL( pressed(QIconViewItem*) ), this, SLOT( pressed(QIconViewItem*) ) ); - + connect( _iconview, SIGNAL( doubleClicked(QIconViewItem*) ), this, SLOT( doubleClicked(QIconViewItem*) ) ); connect( _iconview, SIGNAL( returnPressed(QIconViewItem*) ), this, SLOT( returnPressed(QIconViewItem*) ) ); - + connect( _iconview, SIGNAL( onItem(QIconViewItem*) ), this, SLOT( onItem(QIconViewItem*) ) ); connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); - + // listview only signals - + connect( _listview, SIGNAL( expanded(QListViewItem*) ), this, SLOT( expanded(QListViewItem*) ) ); connect( _listview, SIGNAL( collapsed(QListViewItem*) ), this, SLOT( collapsed(QListViewItem*) ) ); - + // iconview only signals - + connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); } OVersatileView::~OVersatileView() { } QPopupMenu* OVersatileView::contextMenu() const { return _contextmenu; } void OVersatileView::contextMenuRequested( QListViewItem* item, const QPoint& pos, int col ) { // can't use QObject::inherits here, because ListViewItems, beit Q, O or K, // do not inherit from QObject - assuming here the programmer is @@ -407,66 +410,66 @@ void OVersatileView::pressed( QIconViewItem * item ) } void OVersatileView::doubleClicked( QListViewItem * item ) { emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::doubleClicked( QIconViewItem * item ) { emit( doubleClicked( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::returnPressed( QListViewItem * item ) { emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); } - + void OVersatileView::returnPressed( QIconViewItem * item ) { emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::onItem( QListViewItem * item ) { emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::onItem( QIconViewItem * item ) { emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::expanded( QListViewItem *item ) // QListView { //odebug << "OVersatileView::expanded(): opening tree..." << oendl; if ( !_treeopened.isNull() ) item->setPixmap( 0, _treeopened ); emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); } void OVersatileView::collapsed( QListViewItem *item ) // QListView { if ( !_treeclosed.isNull() ) item->setPixmap( 0, _treeclosed ); emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); } //=============================================================================================// // OVersatileView Case I - API only existing in QListView or QIconView but not in both! //==============================================================================================// - + int OVersatileView::treeStepSize() const // QListView { if ( !isValidViewMode( Tree ) ) { return -1; } return _listview->treeStepSize(); } void OVersatileView::setTreeStepSize( int size ) // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->setTreeStepSize( size ); } @@ -732,33 +735,33 @@ bool OVersatileView::showSortIndicator() const // QListView } return _listview->showSortIndicator(); } void OVersatileView::triggerUpdate() // QListView { if ( !isValidViewMode( Tree ) ) { return; } _listview->triggerUpdate(); } // // only in QIconView // - + uint OVersatileView::count() const // QIconView { if ( !isValidViewMode( Icons ) ) { return 0; } return _iconview->count(); } int OVersatileView::index( const OVersatileViewItem *item ) const // QIconView { if ( !isValidViewMode( Icons ) ) { return -1; } return _iconview->index( item ); |