Added hasParent method

Do not add ItemDelegate to combobox views if inside QWebView, because ItemDelegate handling is broken in
Qt for such widgets
BUG: 339466
wilder-pre-rebase
Hugo Pereira Da Costa 12 years ago
parent 888e92f106
commit e4ffbade2f
  1. 9
      kstyle/breezestyle.cpp
  2. 33
      kstyle/breezestyle.h

@ -357,9 +357,12 @@ namespace Breeze
} else if( QComboBox *comboBox = qobject_cast<QComboBox*>( widget ) ) {
QAbstractItemView *itemView( comboBox->view() );
if( itemView && itemView->itemDelegate() && itemView->itemDelegate()->inherits( "QComboBoxDelegate" ) )
{ itemView->setItemDelegate( new BreezePrivate::ComboBoxItemDelegate( itemView ) ); }
if( !hasParent( widget, "QWebView" ) )
{
QAbstractItemView *itemView( comboBox->view() );
if( itemView && itemView->itemDelegate() && itemView->itemDelegate()->inherits( "QComboBoxDelegate" ) )
{ itemView->setItemDelegate( new BreezePrivate::ComboBoxItemDelegate( itemView ) ); }
}
} else if( widget->inherits( "QComboBoxPrivateContainer" ) ) {

@ -421,6 +421,12 @@ namespace Breeze
//* return which arrow button is hit by point for scrollbar double buttons
inline QStyle::SubControl scrollBarHitTest( const QRect&, const QPoint&, const QStyleOption* ) const;
//! return true if one of the widget's parent inherits requested type
inline bool hasParent( const QWidget*, const char* ) const;
//* return true if one of the widget's parent inherits requested type
template<typename T> bool hasParent( const QWidget* ) const;
private:
//*@name scrollbar button types (for addLine and subLine )
@ -511,6 +517,33 @@ namespace Breeze
}
//_________________________________________________________________________
bool Style::hasParent( const QWidget* widget, const char* className ) const
{
if( !widget ) return false;
while( (widget = widget->parentWidget()) )
{ if( widget->inherits( className ) ) return true; }
return false;
}
//_________________________________________________________________________
template< typename T > bool Style::hasParent( const QWidget* widget ) const
{
if( !widget ) return false;
while( (widget = widget->parentWidget()) )
{ if( qobject_cast<const T*>( widget ) ) return true; }
return false;
}
}
#endif

Loading…
Cancel
Save