Author: dmacvicar Date: Thu Apr 10 18:50:39 2008 New Revision: 46371 URL: http://svn.opensuse.org/viewcvs/yast?rev=46371&view=rev Log: - more beauty, big icons, and display how much of the pattern is installed once the content is available, still need some alignement Modified: trunk/qt-pkg/src/YQPkgObjList.cc trunk/qt-pkg/src/YQPkgObjList.h trunk/qt-pkg/src/YQPkgPatternList.cc trunk/qt-pkg/src/YQPkgPatternList.h Modified: trunk/qt-pkg/src/YQPkgObjList.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgObjList.cc?rev=46... ============================================================================== --- trunk/qt-pkg/src/YQPkgObjList.cc (original) +++ trunk/qt-pkg/src/YQPkgObjList.cc Thu Apr 10 18:50:39 2008 @@ -69,6 +69,7 @@ // an abstract base class: It doesn't know which columns are desired and in // what order. + _iconCol = -42; _statusCol = -42; _nameCol = -42; _versionCol = -42; Modified: trunk/qt-pkg/src/YQPkgObjList.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgObjList.h?rev=463... ============================================================================== --- trunk/qt-pkg/src/YQPkgObjList.h (original) +++ trunk/qt-pkg/src/YQPkgObjList.h Thu Apr 10 18:50:39 2008 @@ -68,6 +68,7 @@ // Column numbers + int iconCol() const { return _iconCol; } int statusCol() const { return _statusCol; } int nameCol() const { return _nameCol; } int summaryCol() const { return _summaryCol; } @@ -336,6 +337,7 @@ // Data members + int _iconCol; int _statusCol; int _nameCol; int _summaryCol; @@ -624,13 +626,14 @@ **/ void setText( int column, const string text ); + public: /** * Re-declare ordinary setText() method so the compiler doesn't get * confused which one to use. **/ void setText( int column, const QString & text ) - { QTreeWidgetItem::setText( column, text ); } - + { QTreeWidgetItem::setText( column, text ); } + protected: /** * Set a column text via Edition. **/ 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 Thu Apr 10 18:50:39 2008 @@ -25,6 +25,8 @@ #include <zypp/Resolver.h> #include <QPainter> #include <QHeaderView> +#include <QLabel> +#include <QLayout> #include <QItemDelegate> #include <zypp/ui/PatternContents.h> @@ -56,9 +58,13 @@ YQPkgPatternCategoryItem *citem = dynamic_cast<YQPkgPatternCategoryItem *>(_view->itemFromIndex(index)); if ( citem ) { + QFont f = painter->font(); + f.setWeight(QFont::Bold); + f.setPointSize(f.pointSize()+1); + painter->setFont(f); + painter->fillRect(option.rect, CATEGORY_BACKGROUND); //painter->setBackground( ); - painter->setFont( YQUI::yqApp()->headingFont() ); //_view->drawRow( painter, option, index ); } @@ -67,9 +73,11 @@ { //_view->drawRow( painter, option, index ); } + QItemDelegate::paint(painter, option, index); painter->restore(); } + }; YQPkgPatternList::YQPkgPatternList( QWidget * parent, bool autoFill, bool autoFilter ) @@ -80,6 +88,7 @@ int numCol = 0; QStringList headers; //headers << ""; + headers << ""; _iconCol = numCol++; headers << ""; _statusCol = numCol++; // Translators: "Pattern" refers to so-called "installation patterns", @@ -90,14 +99,17 @@ // is only of little relevance, though. headers << _( "Pattern" ); _summaryCol = numCol++; + headers << ""; _howmanyCol = numCol++; - setColumnCount( 2 ); + setColumnCount( 4 ); setHeaderLabels(headers); setIndentation(0); + setItemDelegateForColumn( _iconCol, new YQPkgPatternItemDelegate( this ) ); setItemDelegateForColumn( _statusCol, new YQPkgPatternItemDelegate( this ) ); setItemDelegateForColumn( _summaryCol, new YQPkgPatternItemDelegate( this ) ); + setItemDelegateForColumn( _howmanyCol, new YQPkgPatternItemDelegate( this ) ); // Can use the same colum for "broken" and "satisfied": // Both states are mutually exclusive @@ -115,11 +127,14 @@ header()->setResizeMode( statusCol(), QHeaderView::Fixed ); header()->setResizeMode( summaryCol(), QHeaderView::Stretch ); - + header()->setResizeMode( howmanyCol(), QHeaderView::Stretch ); + header()->resizeSection( statusCol(), 25 ); setColumnWidth( statusCol(), 25 ); setColumnWidth( summaryCol(), 100 ); - header()->resizeSection( 0, 0 ); + setColumnWidth( howmanyCol(), 7 ); + + //header()->resizeSection( 0, 0 ); //header()->setMinimumSectionSize( 25 ); @@ -129,6 +144,9 @@ this, SLOT ( filter() ) ); } + setIconSize(QSize(32,32)); + header()->resizeSection( iconCol(), 34 ); + if ( autoFill ) { fillList(); @@ -174,7 +192,9 @@ } yuiDebug() << "Pattern list filled" << endl; + resizeColumnToContents(_iconCol); resizeColumnToContents(_statusCol); + resizeColumnToContents(_howmanyCol); } @@ -218,7 +238,9 @@ if ( zyppPattern ) { - + int total = 0; + int installed = 0; + zypp::Pattern::Contents c(zyppPattern->contents()); for ( zypp::Pattern::Contents::Selectable_iterator it = c.selectableBegin(); it != c.selectableEnd(); @@ -227,14 +249,19 @@ ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); if ( zyppPkg ) { + if ( (*it)->installedSize() > 0 ) + ++installed; + ++total; + emit filterMatch( *it, zyppPkg ); } } - + selection()->setText( _howmanyCol, QString().sprintf("[%d/%d]", installed, total)); } } emit filterFinished(); + resizeColumnToContents(_howmanyCol); } @@ -252,9 +279,18 @@ YQPkgPatternListItem * item = 0; if ( cat ) - item = new YQPkgPatternListItem( this, cat, selectable, zyppPattern ); + { + item = new YQPkgPatternListItem( this, cat, selectable, zyppPattern ); + } else - item = new YQPkgPatternListItem( this, selectable, zyppPattern ); + { + item = new YQPkgPatternListItem( this, selectable, zyppPattern ); + item->setTextAlignment( howmanyCol(), Qt::AlignRight ); + + } + + resizeColumnToContents(_howmanyCol); + resizeColumnToContents(_summaryCol); addTopLevelItem(item); applyExcludeRules( item ); @@ -284,17 +320,21 @@ if ( categoryItem ) { - if ( button == Qt::LeftButton ) - { - if ( col == statusCol() ) - { - categoryItem->setExpanded( ! categoryItem->isExpanded() ); - } - } + if ( button == Qt::LeftButton ) + { + if ( col == iconCol() ) + { + categoryItem->setExpanded( ! categoryItem->isExpanded() ); + } + } } else { - YQPkgObjList::pkgObjClicked( button, listViewItem, col, pos ); + //QSize size = listViewItem->sizeHint(_iconCol); + //size.scale(size.width(), size.height()*2, Qt::IgnoreAspectRatio); + //listViewItem->setSizeHint(_iconCol, size); + + YQPkgObjList::pkgObjClicked( button, listViewItem, col, pos ); } } @@ -352,6 +392,11 @@ if ( ! _zyppPattern ) _zyppPattern = tryCastToZyppPattern( selectable()->theObj() ); + if (_zyppPattern) + { + setIcon(_patternList->iconCol(), QIcon(QString("/usr/share/icons/hicolor/32x32/apps/") + _zyppPattern->icon().c_str() + QString(".png"))); + } + setStatusIcon(); setFirstColumnSpanned ( false ); } @@ -429,7 +474,7 @@ void YQPkgPatternCategoryItem::setTreeIcon() { - setIcon( _patternList->statusCol(), + setIcon( _patternList->iconCol(), isExpanded() ? YQIconPool::treeMinus() : YQIconPool::treePlus() ); 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 Thu Apr 10 18:50:39 2008 @@ -110,7 +110,7 @@ **/ YQPkgPatternListItem * selection() const; - + int howmanyCol() const { return _howmanyCol; } signals: /** @@ -145,6 +145,7 @@ // QMap<QString, YQPkgPatternCategoryItem*> _categories; + int _howmanyCol; }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org