[ENHANCEMENT] Add skeleton of setVisible()/isVisible() support to QIconView

v3.5.13-sru
Timothy Pearson 13 years ago
parent ba6061655c
commit d82327fe4f

@ -995,6 +995,7 @@ void QIconViewItem::init( QIconViewItem *after
allow_rename = FALSE; allow_rename = FALSE;
allow_drag = TRUE; allow_drag = TRUE;
allow_drop = TRUE; allow_drop = TRUE;
visible = TRUE;
selected = FALSE; selected = FALSE;
selectable = TRUE; selectable = TRUE;
#ifndef QT_NO_TEXTEDIT #ifndef QT_NO_TEXTEDIT
@ -1050,6 +1051,32 @@ int QIconViewItem::rtti() const
return RTTI; return RTTI;
} }
/*!
If \a b is TRUE, the item is made visible; otherwise it is hidden.
*/
void QIconViewItem::setVisible( bool b )
{
if ( b == (bool)visible )
return;
QIconView *iv = iconView();
if ( !iv )
return;
visible = b;
if ( iv )
iv->updateContents();
}
/*!
Returns TRUE if the item is visible; otherwise returns FALSE.
\sa setVisible()
*/
bool QIconViewItem::isVisible() const
{
return (bool)visible;
}
/*! /*!
Sets \a text as the text of the icon view item. This function Sets \a text as the text of the icon view item. This function
@ -3851,10 +3878,18 @@ void QIconView::selectAll( bool select )
viewport()->setUpdatesEnabled( FALSE ); viewport()->setUpdatesEnabled( FALSE );
QRect rr; QRect rr;
for ( ; item; item = item->next ) { for ( ; item; item = item->next ) {
if ( select != item->isSelected() ) { if (item->isVisible()) {
item->setSelected( select, TRUE ); if ( select != item->isSelected() ) {
rr = rr.unite( item->rect() ); item->setSelected( select, TRUE );
changed = TRUE; rr = rr.unite( item->rect() );
changed = TRUE;
}
else {
if ( FALSE != item->isSelected() ) {
item->setSelected( FALSE, TRUE );
changed = TRUE;
}
}
} }
} }
viewport()->setUpdatesEnabled( ue ); viewport()->setUpdatesEnabled( ue );
@ -4082,7 +4117,7 @@ void QIconView::clear()
d->drawDragShapes = FALSE; d->drawDragShapes = FALSE;
resizeContents( 0, 0 ); resizeContents( 0, 0 );
// maybe we don´t need this update, so delay it // maybe we don<EFBFBD>t need this update, so delay it
d->fullRedrawTimer->start( 0, TRUE ); d->fullRedrawTimer->start( 0, TRUE );
d->cleared = TRUE; d->cleared = TRUE;
@ -6139,17 +6174,19 @@ void QIconView::updateItemContainer( QIconViewItem *item )
return; return;
} }
c->items.append( item ); if (item->isVisible()) {
item->d->container1 = c; c->items.append( item );
item->d->container1 = c;
if ( !contains ) { if ( !contains ) {
c = c->n; c = c->n;
if ( !c ) { if ( !c ) {
appendItemContainer(); appendItemContainer();
c = d->lastContainer; c = d->lastContainer;
} }
c->items.append( item ); c->items.append( item );
item->d->container2 = c; item->d->container2 = c;
}
} }
if ( contentsWidth() < irect.right() || contentsHeight() < irect.bottom() ) if ( contentsWidth() < irect.right() || contentsHeight() < irect.bottom() )
resizeContents( QMAX( contentsWidth(), irect.right() ), QMAX( contentsHeight(), irect.bottom() ) ); resizeContents( QMAX( contentsWidth(), irect.right() ), QMAX( contentsHeight(), irect.bottom() ) );
@ -6204,40 +6241,42 @@ void QIconView::rebuildContainers()
appendItemContainer(); appendItemContainer();
c = d->lastContainer; c = d->lastContainer;
while ( item ) { while ( item ) {
if ( c->rect.contains( item->rect() ) ) { if (item->isVisible()) {
item->d->container1 = c; if ( c->rect.contains( item->rect() ) ) {
item->d->container2 = 0; item->d->container1 = c;
c->items.append( item ); item->d->container2 = 0;
item = item->next; c->items.append( item );
} else if ( c->rect.intersects( item->rect() ) ) { item = item->next;
item->d->container1 = c; } else if ( c->rect.intersects( item->rect() ) ) {
c->items.append( item ); item->d->container1 = c;
c = c->n; c->items.append( item );
if ( !c ) { c = c->n;
appendItemContainer(); if ( !c ) {
c = d->lastContainer; appendItemContainer();
} c = d->lastContainer;
c->items.append( item ); }
item->d->container2 = c; c->items.append( item );
item = item->next; item->d->container2 = c;
c = c->p; item = item->next;
} else { c = c->p;
if ( d->arrangement == LeftToRight ) {
if ( item->y() < c->rect.y() && c->p ) {
c = c->p;
continue;
}
} else { } else {
if ( item->x() < c->rect.x() && c->p ) { if ( d->arrangement == LeftToRight ) {
c = c->p; if ( item->y() < c->rect.y() && c->p ) {
continue; c = c->p;
} continue;
} }
} else {
if ( item->x() < c->rect.x() && c->p ) {
c = c->p;
continue;
}
}
c = c->n; c = c->n;
if ( !c ) { if ( !c ) {
appendItemContainer(); appendItemContainer();
c = d->lastContainer; c = d->lastContainer;
}
} }
} }
} }

@ -169,6 +169,9 @@ public:
bool isSelected() const; bool isSelected() const;
bool isSelectable() const; bool isSelectable() const;
void setVisible( bool b );
bool isVisible() const;
virtual void repaint(); virtual void repaint();
virtual bool move( int x, int y ); virtual bool move( int x, int y );
@ -249,6 +252,7 @@ private:
uint allow_rename : 1; uint allow_rename : 1;
uint allow_drag : 1; uint allow_drag : 1;
uint allow_drop : 1; uint allow_drop : 1;
uint visible : 1;
uint selected : 1; uint selected : 1;
uint selectable : 1; uint selectable : 1;
uint dirty : 1; uint dirty : 1;

Loading…
Cancel
Save