--nextPart1157575.YAEknFxzkm Content-Type: multipart/mixed; boundary="Boundary-01=_QtMtBrLkubDHrO2" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_QtMtBrLkubDHrO2 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, attached is a patch for http://bugs.kde.org/show_bug.cgi?id=3D59791 which adds the possibility to give a visual feedback for the sorted column = in=20 KListView: The column background is a little bit darker than the others. Also, due to konqis new highlighting of items, the patch includes this, too. ok to commit ? =2D-=20 Best regards/Sch=F6ne Gr=FC=DFe Martin () ascii ribbon campaign - against html mail=20 /\ - against microsoft attachments Some operating systems are called 'user friendly', Linux however is 'expert friendly'. --Boundary-01=_QtMtBrLkubDHrO2 Content-Type: text/x-diff; charset="iso-8859-1"; name="59791.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="59791.patch" Index: kdelibs/kdeui/klistview.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdeui/klistview.cpp,v retrieving revision 1.243 diff -u -3 -p -r1.243 klistview.cpp =2D-- kdelibs/kdeui/klistview.cpp 1 Dec 2004 08:07:17 -0000 1.243 +++ kdelibs/kdeui/klistview.cpp 6 Dec 2004 20:09:56 -0000 @@ -100,7 +100,8 @@ public: paintAbove (0), paintCurrent (0), paintBelow (0), =2D painting (false) + painting (false), + shadeSortColumn (true) { renameable.append(0); connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(don= eEditing(QListViewItem*,int))); @@ -145,7 +146,7 @@ public: bool fullWidth:1; bool sortAscending:1; bool tabRename:1; =2D + =20 int sortColumn; =20 //+1 means downwards (y increases, -1 means upwards, 0 means not selecte= d), aleXXX @@ -165,7 +166,8 @@ public: QListViewItem *paintAbove; QListViewItem *paintCurrent; QListViewItem *paintBelow; =2D bool painting; + bool painting:1; + bool shadeSortColumn:1; =20 QColor alternateBackground; }; @@ -1985,6 +1987,17 @@ void KListView::setAlternateBackground(c repaint(); } =20 +void KListView::setShadeSortColumn(bool shadeSortColumn) +{ + d->shadeSortColumn =3D shadeSortColumn; + repaint(); +} + +bool KListView::shadeSortColumn() const +{ + return d->shadeSortColumn; +} + void KListView::saveLayout(KConfig *config, const QString &group) const { KConfigGroupSaver saver(config, group); @@ -2185,6 +2198,20 @@ const QColor &KListViewItem::backgroundC return listView()->viewport()->colorGroup().base(); } =20 +QColor KListViewItem::backgroundColor(int column) +{ + KListView* view =3D static_cast< KListView* >(listView()); =20 + QColor color =3D isAlternate() ? + view->alternateBackground() : + view->viewport()->colorGroup().base(); + + //darken the color if the current column is sorted (only if more than 1 = column) + if ( (view->columns() > 1) && view->shadeSortColumn() && (column =3D=3D = view->columnSorted()) ) + color =3D color.dark(104); + + return color; +} + bool KListViewItem::isAlternate() { KListView* const lv =3D static_cast(listView()); @@ -2263,18 +2290,19 @@ void KListViewItem::paintCell(QPainter * { QColorGroup _cg =3D cg; const QPixmap *pm =3D listView()->viewport()->backgroundPixmap(); + if (pm && !pm->isNull()) { =2D _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); =2D QPoint o =3D p->brushOrigin(); =2D p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView= ()->contentsY() ); =2D } =2D else if (isAlternate()) =2D if (listView()->viewport()->backgroundMode()=3D=3DQt::FixedColor) =2D _cg.setColor(QColorGroup::Background, static_cast< KListView= * >(listView())->alternateBackground()); =2D else =2D _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listVi= ew())->alternateBackground()); =2D + _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(column), *pm)); + QPoint o =3D p->brushOrigin(); + p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->co= ntentsY() ); + } + else + { + _cg.setColor((listView()->viewport()->backgroundMode() =3D=3D Qt::Fixe= dColor) ? + QColorGroup::Background : QColorGroup::Base, + backgroundColor(column)); + } QListViewItem::paintCell(p, _cg, column, width, alignment); } =20 Index: kdelibs/kdeui/klistview.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdeui/klistview.h,v retrieving revision 1.127 diff -u -3 -p -r1.127 klistview.h =2D-- kdelibs/kdeui/klistview.h 19 Nov 2004 12:53:00 -0000 1.127 +++ kdelibs/kdeui/klistview.h 6 Dec 2004 20:09:59 -0000 @@ -65,7 +65,8 @@ class KDEUI_EXPORT KListView : public QL Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn= ) Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setD= ropVisualizerWidth ) Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE s= etAlternateBackground ) =2D + Q_PROPERTY( bool shadeSortColumn READ shadeSortColumn WRITE setShadeSort= Column ) + =20 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE s= etSelectionModeExt ) =20 public: @@ -385,6 +386,17 @@ public: */ virtual void takeItem(QListViewItem *i); =20 + /** + * Set to true if the currently sorted column should be drawn shaded. De= faults to true + * @param shadeSortColumn True if sort column should be shaded. + */ + void setShadeSortColumn(bool shadeSortColumn); + =20 + /** + * See if the sort column should be drawn shaded + * @return true if the sort column should be shaded + */ + bool shadeSortColumn(void) const; signals: =20 /** @@ -1033,7 +1045,6 @@ public: =20 virtual void insertItem(QListViewItem *item); virtual void takeItem(QListViewItem *item); =2D /** * returns true if this item is to be drawn with the alternate background */ @@ -1041,7 +1052,16 @@ public: /** * returns the background color for this item */ =2D const QColor &backgroundColor(); + const QColor &backgroundColor() KDE_DEPRECATED; // #### should be remov= ed in 4.0; use below instead + + /** + * returns the background color for this item at given column + * This can be different in the column which is sorted due to shading + * ### could be merged with above (column =3D -1) to be source compatible + * ### but will only work if sort-shading is not used or the listView has + * ### only 1 column + */ + QColor backgroundColor(int column); =20 virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment); Index: kdebase/konqueror/listview/konq_infolistviewitem.cc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdebase/konqueror/listview/konq_infolistviewitem.cc,v retrieving revision 1.12 diff -u -3 -p -r1.12 konq_infolistviewitem.cc =2D-- kdebase/konqueror/listview/konq_infolistviewitem.cc 9 Nov 2004 17:32:= 54 -0000 1.12 +++ kdebase/konqueror/listview/konq_infolistviewitem.cc 6 Dec 2004 20:18:03= -0000 @@ -227,7 +227,7 @@ void KonqInfoListViewItem::paintCell( QP newWidth =3D _width; if ( pm && !pm->isNull() ) { =2D cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(), *= pm ) ); + cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(_colum= n), *pm ) ); QPoint o =3D _painter->brushOrigin(); _painter->setBrushOrigin( o.x() - lv->contentsX(), o.y() - lv-= >contentsY() ); const QColorGroup::ColorRole crole =3D=20 @@ -235,19 +235,9 @@ void KonqInfoListViewItem::paintCell( QP _painter->fillRect( newWidth, 0, _width - newWidth, height(), = cg.brush( crole ) ); _painter->setBrushOrigin( o ); } =2D else if ( isAlternate() ) =2D { =2D _painter->fillRect( newWidth, 0, _width - newWidth, height()= ,=20 =2D lv->alternateBackground() ); =2D } else { =2D const QColorGroup::ColorRole crole =3D=20 =2D QPalette::backgroundRoleFromMode( lv->viewport()->backgr= oundMode() ); =2D if ( cg.brush( crole ) !=3D lv->colorGroup().brush( crole ) ) =2D _painter->fillRect( newWidth, 0, _width - newWidth, heig= ht(), cg.brush( crole ) ); =2D else =2D m_pListViewWidget->paintEmptyArea( _painter, QRect( newW= idth, 0, _width - newWidth, height() ) ); + _painter->fillRect( newWidth, 0, _width - newWidth, height(), = backgroundColor(_column) ); } =20 _width =3D newWidth; Index: kdebase/konqueror/listview/konq_listviewitems.cc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdebase/konqueror/listview/konq_listviewitems.cc,v retrieving revision 1.68 diff -u -3 -p -r1.68 konq_listviewitems.cc =2D-- kdebase/konqueror/listview/konq_listviewitems.cc 9 Nov 2004 17:32:54 = =2D0000 1.68 +++ kdebase/konqueror/listview/konq_listviewitems.cc 6 Dec 2004 20:18:05 -0= 000 @@ -279,7 +279,7 @@ void KonqListViewItem::paintCell( QPaint newWidth =3D _width; if ( pm && !pm->isNull() ) { =2D cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(), *= pm ) ); + cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(_colum= n), *pm ) ); QPoint o =3D _painter->brushOrigin(); _painter->setBrushOrigin( o.x() - lv->contentsX(), o.y() - lv-= >contentsY() ); const QColorGroup::ColorRole crole =3D=20 @@ -287,19 +287,9 @@ void KonqListViewItem::paintCell( QPaint _painter->fillRect( newWidth, 0, _width - newWidth, height(), = cg.brush( crole ) ); _painter->setBrushOrigin( o ); } =2D else if ( isAlternate() ) =2D { =2D _painter->fillRect( newWidth, 0, _width - newWidth, height()= ,=20 =2D lv->alternateBackground() ); =2D } else { =2D const QColorGroup::ColorRole crole =3D=20 =2D QPalette::backgroundRoleFromMode( lv->viewport()->backgr= oundMode() ); =2D if ( cg.brush( crole ) !=3D lv->colorGroup().brush( crole ) ) =2D _painter->fillRect( newWidth, 0, _width - newWidth, heig= ht(), cg.brush( crole ) ); =2D else =2D m_pListViewWidget->paintEmptyArea( _painter, QRect( newW= idth, 0, _width - newWidth, height() ) ); + _painter->fillRect( newWidth, 0, _width - newWidth, height(), = backgroundColor(_column) ); } =20 _width =3D newWidth; --Boundary-01=_QtMtBrLkubDHrO2-- --nextPart1157575.YAEknFxzkm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBBtMtQUeHBRvgua64RApOIAJ9k32CYk0yrffaB0OHBBq7O3BEykQCZAeCQ TEXYTRhytvbBP48PYEdzWbs= =pe3h -----END PGP SIGNATURE----- --nextPart1157575.YAEknFxzkm--