Commit 607ce0c3 authored by Matěj Laitl's avatar Matěj Laitl
Browse files

PrettyTreeView: proper polymorphism, revert e1cad5e8

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

This reverts commit e1cad5e8.

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>
parent 8d5f7b37
......@@ -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;
......
......@@ -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"
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment