mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
readded the editorEvent which somehow got lost in the previous merge and cleaned up a bit
This commit is contained in:
@@ -28,7 +28,6 @@ SourceTreeItem::SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, Sou
|
|||||||
, m_type( thisType )
|
, m_type( thisType )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
, m_model( model )
|
, m_model( model )
|
||||||
//, m_dropHovering( false )
|
|
||||||
{
|
{
|
||||||
connect( this, SIGNAL( beginChildRowsAdded( int,int ) ), m_model, SLOT( onItemRowsAddedBegin( int,int ) ) );
|
connect( this, SIGNAL( beginChildRowsAdded( int,int ) ), m_model, SLOT( onItemRowsAddedBegin( int,int ) ) );
|
||||||
connect( this, SIGNAL( beginChildRowsRemoved( int,int ) ), m_model, SLOT( onItemRowsRemovedBegin( int,int ) ) );
|
connect( this, SIGNAL( beginChildRowsRemoved( int,int ) ), m_model, SLOT( onItemRowsRemovedBegin( int,int ) ) );
|
||||||
|
@@ -66,8 +66,6 @@ public:
|
|||||||
virtual bool setData( const QVariant&, bool ) { return false; }
|
virtual bool setData( const QVariant&, bool ) { return false; }
|
||||||
virtual int peerSortValue() const { return 0; } // How to sort relative to peers in the tree.
|
virtual int peerSortValue() const { return 0; } // How to sort relative to peers in the tree.
|
||||||
virtual int IDValue() const { return 0; }
|
virtual int IDValue() const { return 0; }
|
||||||
// virtual bool dropHovering() const { return m_dropHovering; }
|
|
||||||
// virtual void setDropHovering( bool dropHovering ) { m_dropHovering = dropHovering; emit updated(); }
|
|
||||||
virtual DropTypes supportedDropTypes() const { return DropTypesNone; }
|
virtual DropTypes supportedDropTypes() const { return DropTypesNone; }
|
||||||
virtual void setDropType( DropType type ) { m_dropType = type; }
|
virtual void setDropType( DropType type ) { m_dropType = type; }
|
||||||
|
|
||||||
|
@@ -5,9 +5,11 @@
|
|||||||
#include "items/playlistitems.h"
|
#include "items/playlistitems.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
#include "items/temporarypageitem.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#define TREEVIEW_INDENT_ADD -7
|
#define TREEVIEW_INDENT_ADD -7
|
||||||
|
|
||||||
@@ -291,6 +293,32 @@ SourceDelegate::updateEditorGeometry( QWidget* editor, const QStyleOptionViewIte
|
|||||||
editor->setGeometry( editor->geometry().adjusted( 2*TREEVIEW_INDENT_ADD, 0, 0, 0 ) );
|
editor->setGeometry( editor->geometry().adjusted( 2*TREEVIEW_INDENT_ADD, 0, 0, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( event->type() == QEvent::MouseButtonRelease )
|
||||||
|
{
|
||||||
|
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
||||||
|
if ( type == SourcesModel::TemporaryPage )
|
||||||
|
{
|
||||||
|
TemporaryPageItem* gpi = qobject_cast< TemporaryPageItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||||
|
Q_ASSERT( gpi );
|
||||||
|
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||||
|
|
||||||
|
QStyleOptionViewItemV4 o = option;
|
||||||
|
initStyleOption( &o, index );
|
||||||
|
int padding = 3;
|
||||||
|
QRect r ( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );
|
||||||
|
|
||||||
|
if ( r.contains( ev->pos() ) )
|
||||||
|
gpi->removeFromList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStyledItemDelegate::editorEvent ( event, model, option, index );
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SourceDelegate::dropTypeCount( SourceTreeItem* item ) const
|
SourceDelegate::dropTypeCount( SourceTreeItem* item ) const
|
||||||
{
|
{
|
||||||
|
@@ -20,9 +20,11 @@ protected:
|
|||||||
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
virtual void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
virtual int dropTypeCount( SourceTreeItem* item ) const;
|
virtual int dropTypeCount( SourceTreeItem* item ) const;
|
||||||
|
virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAbstractItemView* m_parent;
|
QAbstractItemView* m_parent;
|
||||||
|
mutable int m_iconHeight;
|
||||||
QModelIndex m_dropHoverIndex;
|
QModelIndex m_dropHoverIndex;
|
||||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||||
};
|
};
|
||||||
|
@@ -439,11 +439,6 @@ SourceTreeView::dragLeaveEvent( QDragLeaveEvent* event )
|
|||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
setDirtyRegion( m_dropRect );
|
setDirtyRegion( m_dropRect );
|
||||||
|
|
||||||
// SourceTreeItem* oldItem = m_dropIndex.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
|
||||||
// if ( oldItem )
|
|
||||||
// {
|
|
||||||
// oldItem->setDropHovering( false );
|
|
||||||
// }
|
|
||||||
m_delegate->setDropHoverIndex( QModelIndex() );
|
m_delegate->setDropHoverIndex( QModelIndex() );
|
||||||
dataChanged(m_dropIndex, m_dropIndex);
|
dataChanged(m_dropIndex, m_dropIndex);
|
||||||
m_dropIndex = QPersistentModelIndex();
|
m_dropIndex = QPersistentModelIndex();
|
||||||
@@ -461,11 +456,6 @@ SourceTreeView::dragMoveEvent( QDragMoveEvent* event )
|
|||||||
setDirtyRegion( m_dropRect );
|
setDirtyRegion( m_dropRect );
|
||||||
const QPoint pos = event->pos();
|
const QPoint pos = event->pos();
|
||||||
const QModelIndex index = indexAt( pos );
|
const QModelIndex index = indexAt( pos );
|
||||||
// SourceTreeItem* oldItem = m_dropIndex.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
|
||||||
// if ( oldItem )
|
|
||||||
// {
|
|
||||||
// oldItem->setDropHovering( false );
|
|
||||||
// }
|
|
||||||
m_delegate->setDropHoverIndex( QModelIndex() );
|
m_delegate->setDropHoverIndex( QModelIndex() );
|
||||||
dataChanged(m_dropIndex, m_dropIndex);
|
dataChanged(m_dropIndex, m_dropIndex);
|
||||||
m_dropIndex = QPersistentModelIndex( index );
|
m_dropIndex = QPersistentModelIndex( index );
|
||||||
@@ -479,7 +469,6 @@ SourceTreeView::dragMoveEvent( QDragMoveEvent* event )
|
|||||||
if( item->willAcceptDrag( event->mimeData() ) )
|
if( item->willAcceptDrag( event->mimeData() ) )
|
||||||
{
|
{
|
||||||
accept = true;
|
accept = true;
|
||||||
// item->setDropHovering( true );
|
|
||||||
m_delegate->setDropHoverIndex( index );
|
m_delegate->setDropHoverIndex( index );
|
||||||
dataChanged(index, index);
|
dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user