mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Always select the current view-page in the SourceTreeView.
This commit is contained in:
@@ -111,7 +111,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
header()->setResizeMode( 0, QHeaderView::Stretch );
|
||||
|
||||
connect( this, SIGNAL( expanded( QModelIndex ) ), SLOT( onItemExpanded( QModelIndex ) ) );
|
||||
// connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
|
||||
connect( selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( onSelectionChanged() ) );
|
||||
|
||||
showOfflineSources( TomahawkSettings::instance()->showOfflineSources() );
|
||||
|
||||
@@ -245,6 +245,18 @@ SourceTreeView::showOfflineSources( bool offlineSourcesShown )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::onSelectionChanged()
|
||||
{
|
||||
if ( currentIndex() != m_selectedIndex )
|
||||
{
|
||||
selectionModel()->blockSignals( true );
|
||||
selectionModel()->select( m_selectedIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current );
|
||||
selectionModel()->blockSignals( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::onItemActivated( const QModelIndex& index )
|
||||
{
|
||||
@@ -284,6 +296,8 @@ SourceTreeView::onItemExpanded( const QModelIndex& idx )
|
||||
void
|
||||
SourceTreeView::selectRequest( const QPersistentModelIndex& idx )
|
||||
{
|
||||
m_selectedIndex = idx;
|
||||
|
||||
if ( !selectionModel()->selectedIndexes().contains( idx ) )
|
||||
{
|
||||
scrollTo( idx, QTreeView::EnsureVisible );
|
||||
@@ -708,10 +722,9 @@ SourceTreeView::keyPressEvent( QKeyEvent *event )
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||
Q_ASSERT( item );
|
||||
|
||||
if( item->playlist()->author()->isLocal() ) {
|
||||
if ( item->playlist()->author()->isLocal() )
|
||||
deletePlaylist( idx );
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
|
@@ -81,6 +81,7 @@ private slots:
|
||||
void latchModeToggled( bool checked );
|
||||
|
||||
void onCustomContextMenu( const QPoint& pos );
|
||||
void onSelectionChanged();
|
||||
|
||||
protected:
|
||||
void drawRow( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
@@ -113,6 +114,8 @@ private:
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
QPersistentModelIndex m_dropIndex;
|
||||
|
||||
QPersistentModelIndex m_selectedIndex;
|
||||
};
|
||||
|
||||
#endif // SOURCETREEVIEW_H
|
||||
|
Reference in New Issue
Block a user