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

List:       kde-commits
Subject:    [amarok] src: PrettyTreeView: proper polymorphism, revert e1cad5e80f8f40b0
From:       Matěj_Laitl <matej () laitl ! cz>
Date:       2012-12-31 16:17:07
Message-ID: 20121231161707.6C1B5A6091 () git ! kde ! org
[Download RAW message or body]

Git commit 607ce0c3c3b89df3c16e19273e796092e26d156b by Matěj Laitl.
Committed on 31/12/2012 at 16:14.
Pushed by laitl into branch 'master'.

PrettyTreeView: proper polymorphism, revert e1cad5e80f8f40b0

Also revert "The correct edit() was not called, lacked polymorphism."

This reverts commit e1cad5e80f8f40b08c0c46d85afe0450db2c497c.

Bart, this is the right way to do it. Also, the polymorphism was not
the cause of failing edit, see the next commit.

CCBUG: 308703
CCMAIL: Bart Cerneels <bart.cerneels@kde.org>

M  +1    -2    src/browsers/playlistbrowser/PlaylistBrowserCategory.h
M  +6    -8    src/widgets/PrettyTreeView.cpp
M  +28   -24   src/widgets/PrettyTreeView.h

http://commits.kde.org/amarok/607ce0c3c3b89df3c16e19273e796092e26d156b

diff --git a/src/browsers/playlistbrowser/PlaylistBrowserCategory.h \
b/src/browsers/playlistbrowser/PlaylistBrowserCategory.h index 66b3233..24bdc83 \
                100644
--- a/src/browsers/playlistbrowser/PlaylistBrowserCategory.h
+++ b/src/browsers/playlistbrowser/PlaylistBrowserCategory.h
@@ -41,7 +41,6 @@ namespace Playlists {
 namespace PlaylistBrowserNS {
 
 class PlaylistBrowserModel;
-class PlaylistBrowserView;
 
 class PlaylistBrowserCategory : public BrowserCategory
 {
@@ -88,7 +87,7 @@ private:
     KActionMenu *m_providerMenu;
     QMap<const Playlists::PlaylistProvider *, QAction *> m_providerActions;
 
-    PlaylistBrowserView *m_playlistView;
+    QTreeView *m_playlistView;
 
     KAction *m_addFolderAction;
 
diff --git a/src/widgets/PrettyTreeView.cpp b/src/widgets/PrettyTreeView.cpp
index b45fa60..19ad20a 100644
--- a/src/widgets/PrettyTreeView.cpp
+++ b/src/widgets/PrettyTreeView.cpp
@@ -43,18 +43,18 @@ PrettyTreeView::~PrettyTreeView()
 void
 PrettyTreeView::edit( const QModelIndex &index )
 {
-    QModelIndex parent = index.parent();
-    while( parent.isValid() )
-    {
-        expand( parent );
-        parent = parent.parent();
-    }
     QTreeView::edit( index );
 }
 
 bool
 PrettyTreeView::edit( const QModelIndex &index, QAbstractItemView::EditTrigger \
trigger, QEvent *event )  {
+    QModelIndex parent = index.parent();
+    while( parent.isValid() )
+    {
+        expand( parent );
+        parent = parent.parent();
+    }
     return QAbstractItemView::edit( index, trigger, event );
 }
 
@@ -84,5 +84,3 @@ void PrettyTreeView::newPalette( const QPalette & palette )
     The::paletteHandler()->updateItemView( this );
     reset(); // redraw all potential delegates
 }
-
-#include "PrettyTreeView.moc"
diff --git a/src/widgets/PrettyTreeView.h b/src/widgets/PrettyTreeView.h
index 8b1cb16..698a36b 100644
--- a/src/widgets/PrettyTreeView.h
+++ b/src/widgets/PrettyTreeView.h
@@ -23,30 +23,34 @@
 
 namespace Amarok
 {
-
-/**
-    A utility QTreeView subcass that handles drawing nice, svg themed, rows and \
                palette changes
-    @author: Nikolaj Hald Nielsen <nhn@kde.org>
-*/
-class AMAROK_EXPORT PrettyTreeView : public QTreeView
-{
-    Q_OBJECT
-
-public:
-    PrettyTreeView( QWidget *parent = 0 );
-    virtual ~PrettyTreeView();
-
-public slots:
-    void edit( const QModelIndex &index ); // hides QTreeView::edit() to expand all \
                parent items
-    bool edit( const QModelIndex &index, EditTrigger trigger, QEvent *event ); // \
                silence compiler warning
-
-protected:
-    virtual void drawRow( QPainter * painter, const QStyleOptionViewItem & option, \
                const QModelIndex & index ) const;
-
-protected slots:
-    virtual void newPalette( const QPalette & palette );
-};
-
+    /**
+     * A utility QTreeView subcass that handles drawing nice, svg themed, rows and \
palette changes +     *
+     * @author: Nikolaj Hald Nielsen <nhn@kde.org>
+     */
+    class AMAROK_EXPORT PrettyTreeView : public QTreeView
+    {
+        Q_OBJECT
+
+        public:
+            PrettyTreeView( QWidget *parent = 0 );
+            virtual ~PrettyTreeView();
+
+        public slots:
+            /* There is a need to overload even this edit() variant, otherwise it \
hides +             * QAbstactItemView's implementation. Note that it is NOT safe to \
do anything +             * special in this method, as it is not virtual.
+             * bool edit( const QModelIndex &index, EditTrigger trigger, QEvent \
*event ) +             * IS virtual. */
+            void edit( const QModelIndex &index );
+
+        protected:
+            bool edit( const QModelIndex &index, EditTrigger trigger, QEvent *event \
); +            void drawRow( QPainter *painter, const QStyleOptionViewItem &option, \
const QModelIndex &index ) const; +
+        private slots:
+            virtual void newPalette( const QPalette &palette );
+    };
 }
 
 #endif


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

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