Author: dmacvicar Date: Tue Apr 8 17:41:40 2008 New Revision: 46251 URL: http://svn.opensuse.org/viewcvs/yast?rev=46251&view=rev Log: - introduce delegate to do the painting later Modified: trunk/qt-pkg/src/YQPkgPatternList.cc trunk/qt-pkg/src/YQPkgPatternList.h Modified: trunk/qt-pkg/src/YQPkgPatternList.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgPatternList.cc?re... ============================================================================== --- trunk/qt-pkg/src/YQPkgPatternList.cc (original) +++ trunk/qt-pkg/src/YQPkgPatternList.cc Tue Apr 8 17:41:40 2008 @@ -25,6 +25,7 @@ #include <zypp/Resolver.h> #include <QPainter> #include <QHeaderView> +#include <QItemDelegate> #include <zypp/ui/PatternContents.h> #include "YQi18n.h" @@ -40,6 +41,29 @@ #define CATEGORY_BACKGROUND QColor( 0xFF, 0xC0, 0x50 ) +class YQPkgPatternItemDelegate : public QItemDelegate +{ + YQPkgPatternList *_view; +public: + YQPkgPatternItemDelegate( YQPkgPatternList *parent ) : QItemDelegate( parent ), _view( parent ) { + } + + virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const + { + painter->save(); + QColor background = option.palette.color(QPalette::Window); + painter->setBackground( background ); + //painter->setFont( YQApplication::ui()->headingFont() ); + + YQPkgPatternListItem *item = dynamic_cast<YQPkgPatternListItem *>(_view->itemFromIndex(index)); + if ( item ) + { + //_view->drawRow( painter, option, index ); + QItemDelegate::paint(painter, option, index); + } + painter->restore(); + } +}; YQPkgPatternList::YQPkgPatternList( QWidget * parent, bool autoFill, bool autoFilter ) : YQPkgObjList( parent ) @@ -63,6 +87,8 @@ setColumnCount( 3 ); setHeaderLabels(headers); + setItemDelegateForColumn( 0, new YQPkgPatternItemDelegate( this ) ); + // Can use the same colum for "broken" and "satisfied": // Both states are mutually exclusive @@ -291,12 +317,6 @@ #endif } -void YQPkgPatternList::drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - painter->setFont( YQUI::yqApp()->headingFont() ); - QTreeWidget::drawRow ( painter, option, index ); -} - YQPkgPatternListItem::YQPkgPatternListItem( YQPkgPatternList * patternList, ZyppSel selectable, ZyppPattern zyppPattern ) Modified: trunk/qt-pkg/src/YQPkgPatternList.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgPatternList.h?rev... ============================================================================== --- trunk/qt-pkg/src/YQPkgPatternList.h (original) +++ trunk/qt-pkg/src/YQPkgPatternList.h Tue Apr 8 17:41:40 2008 @@ -54,14 +54,6 @@ **/ virtual ~YQPkgPatternList(); - /** - * Paint method. Reimplemented from @ref QTreeWidget so a different - * font can be used. - * - * Reimplemented from QY2ListViewItem. - **/ - virtual void drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - public slots: /** -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org