[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] Bug 88964 - Highlighting of files in Detailed List View
From:       Andre Moreira Magalhaes <andrunko () yahoo ! com ! br>
Date:       2004-10-28 21:50:53
Message-ID: 20041028215053.29356.qmail () web51903 ! mail ! yahoo ! com
[Download RAW message or body]

I have fixed another bug. 88964 - "Highlighting of files in Detailed
List View does not correspond to the area of activation".
What do you think about?

If nobody objects i will commit.

cheers
Andrunko


	
	
		
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/
["bug88964.diff" (text/x-diff)]

Index: konqueror/listview/konq_infolistviewitem.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_infolistviewitem.cc,v
retrieving revision 1.10
diff -u -p -r1.10 konq_infolistviewitem.cc
--- konqueror/listview/konq_infolistviewitem.cc	3 May 2004 06:03:28 -0000	1.10
+++ konqueror/listview/konq_infolistviewitem.cc	28 Oct 2004 21:44:26 -0000
@@ -25,6 +25,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <qpainter.h>
+#include <qheader.h>
 #include <kiconloader.h>
 #include "konq_infolistviewitem.h"
 #include "konq_infolistviewwidget.h"
@@ -208,18 +209,59 @@ void KonqInfoListViewItem::setDisabled( 
 
 void KonqInfoListViewItem::paintCell( QPainter *_painter, const QColorGroup & _cg, \
int _column, int _width, int _alignment )  {
-  QColorGroup cg( _cg );
+    QColorGroup cg( _cg );
 
-  if ( _column == 0 )
-  {
-     _painter->setFont( static_cast<KonqBaseListViewWidget \
                *>(listView())->itemFont() );
-  }
-  //else
-  //   _painter->setPen( static_cast<KonqBaseListViewWidget *>(listView())->color() \
); +    if ( _column == 0 )
+    {
+        _painter->setFont( m_pListViewWidget->itemFont() );
+    }
 
-  cg.setColor( QColorGroup::Text, static_cast<KonqBaseListViewWidget \
*>(listView())->itemColor() ); +    cg.setColor( QColorGroup::Text, \
m_pListViewWidget->itemColor() );  
-  KListViewItem::paintCell( _painter, cg, _column, _width, _alignment );
+    KListView *lv = static_cast< KListView* >( listView() );
+    const QPixmap *pm = lv->viewport()->paletteBackgroundPixmap();
+    if ( _column == 0 && isSelected() && !lv->allColumnsShowFocus() )
+    {
+        int newWidth = width( lv->fontMetrics(), lv, _column );
+        if ( pm && !pm->isNull() )
+        {
+            cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(), *pm ) );
+            QPoint o = _painter->brushOrigin();
+            _painter->setBrushOrigin( o.x() - lv->contentsX(), o.y() - \
lv->contentsY() ); +            const QColorGroup::ColorRole crole = 
+                QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() \
); +            _painter->fillRect( newWidth, 0, _width - newWidth, height(), \
cg.brush( crole ) ); +            _painter->setBrushOrigin( o );
+        }
+        else if ( isAlternate() )
+        {
+            _painter->fillRect( newWidth, 0, _width - newWidth, height(), 
+                lv->alternateBackground() );
+        }
+        else
+        {
+            const QColorGroup::ColorRole crole = 
+                QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() \
); +            if ( cg.brush( crole ) != lv->colorGroup().brush( crole ) )
+                _painter->fillRect( newWidth, 0, _width - newWidth, height(), \
cg.brush( crole ) ); +            else
+                m_pListViewWidget->paintEmptyArea( _painter, QRect( newWidth, 0, \
_width - newWidth, height() ) ); +        }
+
+        _width = newWidth;
+    }
+	
+    KListViewItem::paintCell( _painter, cg, _column, _width, _alignment );
+}
+
+void KonqInfoListViewItem::paintFocus( QPainter * _painter, const QColorGroup & cg, \
const QRect & _r ) +{
+    QRect r( _r );
+    QListView *lv = static_cast< QListView * >( listView() );
+    r.setWidth( width( lv->fontMetrics(), lv, 0 ) );
+    if ( r.right() > lv->header()->sectionRect( 0 ).right() )
+        r.setRight( lv->header()->sectionRect( 0 ).right() );
+    QListViewItem::paintFocus( _painter, cg, r );
 }
 
 #if 0
Index: konqueror/listview/konq_infolistviewitem.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_infolistviewitem.h,v
retrieving revision 1.7
diff -u -p -r1.7 konq_infolistviewitem.h
--- konqueror/listview/konq_infolistviewitem.h	3 May 2004 06:03:28 -0000	1.7
+++ konqueror/listview/konq_infolistviewitem.h	28 Oct 2004 21:44:26 -0000
@@ -57,6 +57,7 @@ class KonqInfoListViewItem : public Konq
 
       virtual void paintCell( QPainter *_painter, const QColorGroup & cg,
                               int column, int width, int alignment );
+      virtual void paintFocus( QPainter * _painter, const QColorGroup & cg, const \
QRect & r );  virtual void updateContents();
       virtual void setDisabled( bool disabled );
 
Index: konqueror/listview/konq_listviewitems.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_listviewitems.cc,v
retrieving revision 1.66
diff -u -p -r1.66 konq_listviewitems.cc
--- konqueror/listview/konq_listviewitems.cc	20 Aug 2004 19:08:10 -0000	1.66
+++ konqueror/listview/konq_listviewitems.cc	28 Oct 2004 21:44:26 -0000
@@ -261,16 +261,59 @@ int KonqBaseListViewItem::compare( QList
 
 void KonqListViewItem::paintCell( QPainter *_painter, const QColorGroup & _cg, int \
_column, int _width, int _alignment )  {
-  QColorGroup cg( _cg );
+    QColorGroup cg( _cg );
 
-  if ( _column == 0 )
-  {
-    _painter->setFont( m_pListViewWidget->itemFont() );
-  }
+    if ( _column == 0 )
+    {
+        _painter->setFont( m_pListViewWidget->itemFont() );
+    }
+
+    cg.setColor( QColorGroup::Text, m_pListViewWidget->itemColor() );
+
+    KListView *lv = static_cast< KListView* >( listView() );
+    const QPixmap *pm = lv->viewport()->paletteBackgroundPixmap();
+    if ( _column == 0 && isSelected() && !lv->allColumnsShowFocus() )
+    {
+        int newWidth = width( lv->fontMetrics(), lv, _column );
+        if ( pm && !pm->isNull() )
+        {
+            cg.setBrush( QColorGroup::Base, QBrush( backgroundColor(), *pm ) );
+            QPoint o = _painter->brushOrigin();
+            _painter->setBrushOrigin( o.x() - lv->contentsX(), o.y() - \
lv->contentsY() ); +            const QColorGroup::ColorRole crole = 
+                QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() \
); +            _painter->fillRect( newWidth, 0, _width - newWidth, height(), \
cg.brush( crole ) ); +            _painter->setBrushOrigin( o );
+        }
+        else if ( isAlternate() )
+        {
+            _painter->fillRect( newWidth, 0, _width - newWidth, height(), 
+                lv->alternateBackground() );
+        }
+        else
+        {
+            const QColorGroup::ColorRole crole = 
+                QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() \
); +            if ( cg.brush( crole ) != lv->colorGroup().brush( crole ) )
+                _painter->fillRect( newWidth, 0, _width - newWidth, height(), \
cg.brush( crole ) ); +            else
+                m_pListViewWidget->paintEmptyArea( _painter, QRect( newWidth, 0, \
_width - newWidth, height() ) ); +        }
 
-  cg.setColor( QColorGroup::Text, m_pListViewWidget->itemColor() );
+        _width = newWidth;
+    }
+	
+    KListViewItem::paintCell( _painter, cg, _column, _width, _alignment );
+}
 
-  KListViewItem::paintCell( _painter, cg, _column, _width, _alignment );
+void KonqListViewItem::paintFocus( QPainter * _painter, const QColorGroup & cg, \
const QRect & _r ) +{
+    QRect r( _r );
+    QListView *lv = static_cast< QListView * >( listView() );
+    r.setWidth( width( lv->fontMetrics(), lv, 0 ) );
+    if ( r.right() > lv->header()->sectionRect( 0 ).right() )
+        r.setRight( lv->header()->sectionRect( 0 ).right() );
+    QListViewItem::paintFocus( _painter, cg, r );
 }
 
 const char* KonqBaseListViewItem::makeAccessString( const mode_t mode)
Index: konqueror/listview/konq_listviewitems.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_listviewitems.h,v
retrieving revision 1.29
diff -u -p -r1.29 konq_listviewitems.h
--- konqueror/listview/konq_listviewitems.h	20 Aug 2004 19:08:10 -0000	1.29
+++ konqueror/listview/konq_listviewitems.h	28 Oct 2004 21:44:26 -0000
@@ -105,6 +105,7 @@ class KonqListViewItem : public KonqBase
 
       virtual void paintCell( QPainter *_painter, const QColorGroup & cg,
                               int column, int width, int alignment );
+      virtual void paintFocus( QPainter * _painter, const QColorGroup & cg, const \
QRect & r );  virtual void updateContents();
       virtual void setDisabled( bool disabled );
       virtual void setActive  ( bool active   );
Index: konqueror/listview/konq_listviewwidget.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_listviewwidget.cc,v
retrieving revision 1.249
diff -u -p -r1.249 konq_listviewwidget.cc
--- konqueror/listview/konq_listviewwidget.cc	4 Sep 2004 19:20:09 -0000	1.249
+++ konqueror/listview/konq_listviewwidget.cc	28 Oct 2004 21:44:26 -0000
@@ -411,11 +411,9 @@ void KonqBaseListViewWidget::contentsMou
       if ( e->button() == LeftButton )
       {
          m_rubber = new QRect( e->x(), e->y(), 0, 0 );
-         if ( ! ( e->state() & ControlButton ) )
-            setSelected( itemAt( vp ), false );
+	 clearSelection();
+	 emit selectionChanged();
       }
-      if ( e->button() != RightButton )
-         QListView::contentsMousePressEvent( e );
    }
    // Store list of selected items at mouse-press time.
    // This is used when autoscrolling (why?)
@@ -523,16 +521,20 @@ void KonqBaseListViewWidget::slotAutoScr
    bool block = signalsBlocked();
    blockSignals( true );
 
+   QRect nr = m_rubber->normalize();
    if ( cur )
    {
       QRect rect = itemRect( cur );
+      if ( !allColumnsShowFocus() )
+          rect.setWidth( executeArea( cur ) );
+      
       rect = QRect( viewportToContents( rect.topLeft() ),
                     viewportToContents( rect.bottomRight() ) );
 
       if ( !allColumnsShowFocus() )
       {
          rect.setLeft( header()->sectionPos( 0 ) );
-         rect.setWidth( header()->sectionSize( 0 ) );
+         rect.setWidth( rect.width() );
       }
       else
       {
@@ -545,7 +547,7 @@ void KonqBaseListViewWidget::slotAutoScr
 
       while ( cur && rect.top() <= oldBottom )
       {
-         if ( rect.intersects( m_rubber->normalize() ) )
+         if ( rect.intersects( nr ) )
          {
             if ( !cur->isSelected() && cur->isSelectable() )
                setSelected( cur, true );
@@ -553,6 +555,8 @@ void KonqBaseListViewWidget::slotAutoScr
             setSelected( cur, false );
 
          cur = cur->itemBelow();
+         if (cur && !allColumnsShowFocus())
+            rect.setWidth( executeArea( cur ) );
          rect.moveBy( 0, rect.height() );
       }
 
@@ -562,7 +566,7 @@ void KonqBaseListViewWidget::slotAutoScr
 
       while ( cur && rect.bottom() >= oldTop )
       {
-         if ( rect.intersects( m_rubber->normalize() ) )
+         if ( rect.intersects( nr ) )
          {
             if ( !cur->isSelected() && cur->isSelectable() )
                setSelected( cur, true );
@@ -570,6 +574,8 @@ void KonqBaseListViewWidget::slotAutoScr
             setSelected( cur, false );
 
          cur = cur->itemAbove();
+         if (cur && !allColumnsShowFocus())
+            rect.setWidth( executeArea( cur ) );
          rect.moveBy( 0, -rect.height() );
       }
    }
@@ -843,10 +849,10 @@ void KonqBaseListViewWidget::slotReturnP
       KMessageBox::information( 0, i18n("You must take the file out of the trash \
before being able to use it.") );  }
 
-void KonqBaseListViewWidget::slotPopupMenu( QListViewItem *, const QPoint &point, \
int c ) +void KonqBaseListViewWidget::slotPopupMenu( QListViewItem *i, const QPoint \
&point, int c )  {
    kdDebug(1202) << "KonqBaseListViewWidget::slotPopupMenu" << endl;
-   popupMenu( point, c == -1 ); //  c == -1 when activated by keyboard
+   popupMenu( point, ( i != 0 && c == -1 ) ); // i != 0 && c == -1 when activated by \
keyboard  }
 
 void KonqBaseListViewWidget::popupMenu( const QPoint& _global, bool \
alwaysForSelectedFiles ) @@ -1311,4 +1317,22 @@ bool \
KonqBaseListViewWidget::caseInsensi  return \
m_pBrowserView->m_pProps->isCaseInsensitiveSort();  }
 
+// based on isExecuteArea from klistview.cpp
+int KonqBaseListViewWidget::executeArea( QListViewItem *_item )
+{
+   if ( !_item )
+      return 0;
+    
+   int width = treeStepSize() * ( _item->depth() + ( rootIsDecorated() ? 1 : 0 ) );
+   width += itemMargin();
+   int ca = AlignHorizontal_Mask & columnAlignment( 0 );
+   if ( ca == AlignLeft || ca == AlignAuto ) 
+   {
+      width += _item->width( fontMetrics(), this, 0 );      
+      if ( width > columnWidth( 0 ) )
+         width = columnWidth( 0 );
+   }
+   return width;
+}
+
 #include "konq_listviewwidget.moc"
Index: konqueror/listview/konq_listviewwidget.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/listview/konq_listviewwidget.h,v
retrieving revision 1.92
diff -u -p -r1.92 konq_listviewwidget.h
--- konqueror/listview/konq_listviewwidget.h	23 Aug 2004 19:30:58 -0000	1.92
+++ konqueror/listview/konq_listviewwidget.h	28 Oct 2004 21:44:26 -0000
@@ -219,6 +219,8 @@ protected:
    //KDirLister *dirLister() const { return m_dirLister; }
 
 protected:
+   int executeArea( QListViewItem *_item );
+
    /** The directory lister for this URL */
    KDirLister *m_dirLister;
 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic