From 3d0ccc665e549aabfd375b5a45e3b63b0fc547bc Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 5 Aug 2011 02:30:30 -0500 Subject: Forward-port the following Qt3 GIT commits to TQt4: 3653f049bf83636d00237e61781e68ae7c3b499a [ENHANCEMENT] Add skeleton of setVisible()/isVisible() support to QIconView 4dd6a7ae2cf8d7fc3df7c9743129cec736c0d591 [ENHANCEMENT] Add new PE_HeaderSectionMenu primitive element --- tqtinterface/qt4/src/iconview/tqiconview.cpp | 131 +++++++++++++++++--------- tqtinterface/qt4/src/iconview/tqiconview.h | 4 + tqtinterface/qt4/src/kernel/tqstyle.h | 2 + tqtinterface/qt4/src/styles/tqcommonstyle.cpp | 1 + 4 files changed, 92 insertions(+), 46 deletions(-) (limited to 'tqtinterface') diff --git a/tqtinterface/qt4/src/iconview/tqiconview.cpp b/tqtinterface/qt4/src/iconview/tqiconview.cpp index 08ab4bd..c1705c7 100644 --- a/tqtinterface/qt4/src/iconview/tqiconview.cpp +++ b/tqtinterface/qt4/src/iconview/tqiconview.cpp @@ -995,6 +995,7 @@ void TQIconViewItem::init( TQIconViewItem *after allow_rename = FALSE; allow_drag = TRUE; allow_drop = TRUE; + visible = TRUE; selected = FALSE; selectable = TRUE; #ifndef TQT_NO_TEXTEDIT @@ -1050,6 +1051,32 @@ int TQIconViewItem::rtti() const return RTTI; } +/*! + If \a b is TRUE, the item is made visible; otherwise it is hidden. +*/ + +void TQIconViewItem::setVisible( bool b ) +{ + if ( b == (bool)visible ) + return; + TQIconView *iv = iconView(); + if ( !iv ) + return; + visible = b; + if ( iv ) + iv->updateContents(); +} + +/*! + Returns TRUE if the item is visible; otherwise returns FALSE. + + \sa setVisible() +*/ + +bool TQIconViewItem::isVisible() const +{ + return (bool)visible; +} /*! Sets \a text as the text of the icon view item. This function @@ -3852,10 +3879,18 @@ void TQIconView::selectAll( bool select ) viewport()->setUpdatesEnabled( FALSE ); TQRect rr; for ( ; item; item = item->next ) { - if ( select != item->isSelected() ) { - item->setSelected( select, TRUE ); - rr = rr.unite( item->rect() ); - changed = TRUE; + if (item->isVisible()) { + if ( select != item->isSelected() ) { + item->setSelected( select, TRUE ); + rr = rr.unite( item->rect() ); + changed = TRUE; + } + else { + if ( FALSE != item->isSelected() ) { + item->setSelected( FALSE, TRUE ); + changed = TRUE; + } + } } } viewport()->setUpdatesEnabled( ue ); @@ -6148,17 +6183,19 @@ void TQIconView::updateItemContainer( TQIconViewItem *item ) return; } - c->items.append( item ); - item->d->container1 = c; + if (item->isVisible()) { + c->items.append( item ); + item->d->container1 = c; - if ( !tqcontains ) { - c = c->n; - if ( !c ) { - appendItemContainer(); - c = d->lastContainer; - } - c->items.append( item ); - item->d->container2 = c; + if ( !tqcontains ) { + c = c->n; + if ( !c ) { + appendItemContainer(); + c = d->lastContainer; + } + c->items.append( item ); + item->d->container2 = c; + } } if ( contentsWidth() < irect.right() || contentsHeight() < irect.bottom() ) resizeContents( TQMAX( contentsWidth(), irect.right() ), TQMAX( contentsHeight(), irect.bottom() ) ); @@ -6213,40 +6250,42 @@ void TQIconView::rebuildContainers() appendItemContainer(); c = d->lastContainer; while ( item ) { - if ( c->rect.tqcontains( item->rect() ) ) { - item->d->container1 = c; - item->d->container2 = 0; - c->items.append( item ); - item = item->next; - } else if ( c->rect.intersects( item->rect() ) ) { - item->d->container1 = c; - c->items.append( item ); - c = c->n; - if ( !c ) { - appendItemContainer(); - c = d->lastContainer; - } - c->items.append( item ); - item->d->container2 = c; - item = item->next; - c = c->p; - } else { - if ( d->arrangement == LeftToRight ) { - if ( item->y() < c->rect.y() && c->p ) { - c = c->p; - continue; - } + if (item->isVisible()) { + if ( c->rect.tqcontains( item->rect() ) ) { + item->d->container1 = c; + item->d->container2 = 0; + c->items.append( item ); + item = item->next; + } else if ( c->rect.intersects( item->rect() ) ) { + item->d->container1 = c; + c->items.append( item ); + c = c->n; + if ( !c ) { + appendItemContainer(); + c = d->lastContainer; + } + c->items.append( item ); + item->d->container2 = c; + item = item->next; + c = c->p; } else { - if ( item->x() < c->rect.x() && c->p ) { - c = c->p; - continue; - } - } + if ( d->arrangement == LeftToRight ) { + if ( item->y() < c->rect.y() && c->p ) { + c = c->p; + continue; + } + } else { + if ( item->x() < c->rect.x() && c->p ) { + c = c->p; + continue; + } + } - c = c->n; - if ( !c ) { - appendItemContainer(); - c = d->lastContainer; + c = c->n; + if ( !c ) { + appendItemContainer(); + c = d->lastContainer; + } } } } diff --git a/tqtinterface/qt4/src/iconview/tqiconview.h b/tqtinterface/qt4/src/iconview/tqiconview.h index 9ca8a42..3bbb6f8 100644 --- a/tqtinterface/qt4/src/iconview/tqiconview.h +++ b/tqtinterface/qt4/src/iconview/tqiconview.h @@ -170,6 +170,9 @@ public: bool isSelected() const; bool isSelectable() const; + void setVisible( bool b ); + bool isVisible() const; + virtual void tqrepaint(); virtual bool move( int x, int y ); @@ -250,6 +253,7 @@ private: uint allow_rename : 1; uint allow_drag : 1; uint allow_drop : 1; + uint visible : 1; uint selected : 1; uint selectable : 1; uint dirty : 1; diff --git a/tqtinterface/qt4/src/kernel/tqstyle.h b/tqtinterface/qt4/src/kernel/tqstyle.h index 5d657d8..7ffda16 100644 --- a/tqtinterface/qt4/src/kernel/tqstyle.h +++ b/tqtinterface/qt4/src/kernel/tqstyle.h @@ -744,6 +744,8 @@ public: PE_PanelGroupBox, PE_RubberBand, + PE_HeaderSectionMenu, + // do not add any values below/greater this PE_CustomBase = 0xf000000 }; diff --git a/tqtinterface/qt4/src/styles/tqcommonstyle.cpp b/tqtinterface/qt4/src/styles/tqcommonstyle.cpp index c69fea7..79439b9 100644 --- a/tqtinterface/qt4/src/styles/tqcommonstyle.cpp +++ b/tqtinterface/qt4/src/styles/tqcommonstyle.cpp @@ -283,6 +283,7 @@ void TQCommonStyle::tqdrawPrimitive( TQ_PrimitiveElement pe, case TQStyle::PE_ButtonTool: case TQStyle::PE_ButtonDropDown: case TQStyle::PE_HeaderSection: + case TQStyle::PE_HeaderSectionMenu: qDrawShadePanel(p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1, &cg.brush(TQColorGroup::Button)); break; -- cgit v1.2.3