ColorMap myFgColor;
ColorMap myBgColor;
int myPressed;
+ int mySection;
+
+ friend class QtxTable::StyleItem;
};
QtxTable::Header::Header( int n, QtxTable* table, const char* name )
: QHeader( n, table, name ),
myTable( table ),
-myPressed( -1 )
+myPressed( -1 ),
+mySection( -1 )
{
}
return;
myHSpan.insert( section, sp );
- repaint( indexRect( mapToIndex( section ) ) );
+ if ( isUpdatesEnabled() )
+ repaint( indexRect( mapToIndex( section ) ) );
}
int QtxTable::Header::verticalSpan( const int section ) const
return;
myVSpan.insert( section, sp );
- repaint( indexRect( mapToIndex( section ) ) );
+ if ( isUpdatesEnabled() )
+ repaint( indexRect( mapToIndex( section ) ) );
}
QColor QtxTable::Header::foregroundColor( const int section ) const
return;
myFgColor.insert( section, c );
- repaint( indexRect( mapToIndex( section ) ) );
+ if ( isUpdatesEnabled() )
+ repaint( indexRect( mapToIndex( section ) ) );
}
void QtxTable::Header::setBackgroundColor( const int section, const QColor& c )
return;
myBgColor.insert( section, c );
- repaint( indexRect( mapToIndex( section ) ) );
+ if ( isUpdatesEnabled() )
+ repaint( indexRect( mapToIndex( section ) ) );
}
void QtxTable::Header::swapSections( const int oldIdx, const int newIdx )
QRect r = fr;
if ( index < count() )
r = indexRect( index, &idx );
+
+ // Currently painted section number. This number will be used in the drawing style.
+ // Because QHeader::paintSection() implementation doesn't send section id through style options :(
+ mySection = mapToSection( index );
+
QHeader::paintSection( p, idx, r );
+
+ mySection = -1;
}
bool QtxTable::Header::filterEvent( QMouseEvent* e ) const
return false;
Header* h = (Header*)hdr;
- int section = -1;
- for ( int i = 0; i < (int)h->count() && section < 0; i++ )
- {
- if ( r.contains( h->indexRect( i ) ) )
- section = h->mapToSection( i );
- }
+ int section = h->mySection;
if ( section < 0 )
return false;
}
}
+void QtxTable::setUpdatesEnabled( bool enable )
+{
+ QTable::setUpdatesEnabled( enable );
+
+ if ( enable )
+ {
+ updateHeaderGeometries( Horizontal );
+ updateHeaderGeometries( Vertical );
+ }
+}
+
QHeader* QtxTable::header( const Orientation o, const int idx ) const
{
HeaderVector* vec = headerVector( o );
void QtxTable::updateHeaderGeometries( const Orientation o )
{
+ if ( !isUpdatesEnabled() )
+ return;
+
updateHeaderSizes( o );
updateHeaderSpace( o );
updateGeometries();