1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-19 07:27:59 +01:00

TWK-710: Don't expand items when clicking on headphones or lock icon

This commit is contained in:
Leo Franchi 2012-03-02 00:15:16 -05:00
parent f79ed86b57
commit df758aa3f8
3 changed files with 11 additions and 4 deletions

View File

@ -195,7 +195,7 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
painter->setFont( normal );
textRect = option.rect.adjusted( iconRect.width() + 8, option.rect.height() / 2, -figWidth - 24, -6 );
bool privacyOn = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::FullyPrivate;
if ( !colItem->source().isNull() && colItem->source()->isLocal() && privacyOn )
{
@ -627,6 +627,12 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
}
}
// We emit our own clicked() signal instead of relying on QTreeView's, because that is fired whether or not a delegate accepts
// a mouse press event. Since we want to swallow click events when they are on headphones other action items, here wemake sure we only
// emit if we really want to
if ( event->type() == QEvent::MouseButtonRelease )
emit clicked( index );
return QStyledItemDelegate::editorEvent ( event, model, option, index );
}

View File

@ -42,6 +42,7 @@ public:
SourceTreeItem::DropType hoveredDropType() const;
signals:
void clicked( const QModelIndex& idx );
void latchOn( const Tomahawk::source_ptr& idx );
void latchOff( const Tomahawk::source_ptr& idx );
void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime );

View File

@ -87,6 +87,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) );
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) );
connect( m_delegate, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
setItemDelegate( m_delegate );
@ -104,7 +105,6 @@ SourceTreeView::SourceTreeView( QWidget* parent )
header()->setStretchLastSection( false );
header()->setResizeMode( 0, QHeaderView::Stretch );
connect( this, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
connect( this, SIGNAL( expanded( QModelIndex ) ), SLOT( onItemExpanded( QModelIndex ) ) );
// connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
@ -431,11 +431,11 @@ SourceTreeView::latchModeToggled( bool checked )
qDebug() << Q_FUNC_INFO;
if ( !m_contextMenuIndex.isValid() )
return;
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
if( type != SourcesModel::Collection )
return;
const SourceItem* item = itemFromIndex< SourceItem >( m_contextMenuIndex );
const source_ptr source = item->source();
emit latchModeChangeRequest( source, checked );