ProxyBase::ProxyBase( AbstractModel *belowModel, QObject *parent )
    : QSortFilterProxyModel( parent )
    , m_belowModel( belowModel )
{
    setSourceModel( m_belowModel->qaim() );

    // Proxy the Playlist::AbstractModel signals.
    //   If you need to do something special in a subclass, disconnect() this signal and
    //   do your own connect() call.
    connect( sourceModel(), SIGNAL(activeTrackChanged(quint64)), this, SIGNAL(activeTrackChanged(quint64)) );
    connect( sourceModel(), SIGNAL(queueChanged()), this, SIGNAL(queueChanged()) );
}
Пример #2
0
Playlist::RepeatTrackNavigator::RepeatTrackNavigator()
{
    m_trackid = m_model->activeId();

    connect( m_model->qaim(), SIGNAL(activeTrackChanged(quint64)),
             this, SLOT(recvActiveTrackChanged(quint64)) );
}
Playlist::DynamicTrackNavigator::DynamicTrackNavigator()
    : m_playlist( 0 )
{
    connect( m_model->qaim(), SIGNAL(activeTrackChanged(quint64)), SLOT(trackChanged()) );
    connect( m_model->qaim(), SIGNAL(modelReset()), SLOT(repopulate()) );

    connect( Dynamic::DynamicModel::instance(), SIGNAL(activeChanged(int)),
             SLOT(activePlaylistChanged()) );
    activePlaylistChanged();
}
Пример #4
0
Playlist::PrettyListView::PrettyListView( QWidget* parent )
        : QListView( parent )
        , ViewCommon()
        , m_headerPressIndex( QModelIndex() )
        , m_mousePressInHeader( false )
        , m_skipAutoScroll( false )
        , m_firstScrollToActiveTrack( true )
        , m_rowsInsertedScrollItem( 0 )
        , m_showOnlyMatches( false )
        , m_pd( 0 )
{
    // QAbstractItemView basics
    setModel( The::playlist()->qaim() );

    m_prettyDelegate = new PrettyItemDelegate( this );
    connect( m_prettyDelegate, SIGNAL( redrawRequested() ), this, SLOT( redrawActive() ) );
    setItemDelegate( m_prettyDelegate );

    setSelectionMode( ExtendedSelection );
    setDragDropMode( DragDrop );
    setDropIndicatorShown( false ); // we draw our own drop indicator
    setEditTriggers ( SelectedClicked | EditKeyPressed );
    setAutoScroll( true );

    setVerticalScrollMode( ScrollPerPixel );

    setMouseTracking( true );

    // Rendering adjustments
    setFrameShape( QFrame::NoFrame );
    setAlternatingRowColors( true) ;
    The::paletteHandler()->updateItemView( this );
    connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(newPalette(QPalette)) );

    setAutoFillBackground( false );


    // Signal connections
    connect( this, SIGNAL(doubleClicked(QModelIndex)),
             this, SLOT(trackActivated(QModelIndex)) );
    connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             this, SLOT(slotSelectionChanged()) );

    connect( LayoutManager::instance(), SIGNAL(activeLayoutChanged()), this, SLOT(playlistLayoutChanged()) );

    connect( model(), SIGNAL(activeTrackChanged(quint64)), this, SLOT(slotPlaylistActiveTrackChanged()) );

    connect( model(), SIGNAL(queueChanged()), viewport(), SLOT(update()) );

    //   Warning, this one doesn't connect to the normal 'model()' (i.e. '->top()'), but to '->bottom()'.
    connect( Playlist::ModelStack::instance()->bottom(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(bottomModelRowsInserted(QModelIndex,int,int)) );

    // Timers
    m_proxyUpdateTimer = new QTimer( this );
    m_proxyUpdateTimer->setSingleShot( true );
    connect( m_proxyUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProxyTimeout()) );

    m_animationTimer = new QTimer(this);
    connect( m_animationTimer, SIGNAL(timeout()), this, SLOT(redrawActive()) );
    m_animationTimer->setInterval( 250 );

    playlistLayoutChanged();

    // We do the following call here to be formally correct, but note:
    //   - It happens to be redundant, because 'playlistLayoutChanged()' already schedules
    //     another one, via a QTimer( 0 ).
    //   - Both that one and this one don't work right (they scroll like 'PositionAtTop',
    //     not 'PositionAtCenter'). This is probably because MainWindow changes its
    //     geometry in a QTimer( 0 )? As a fix, MainWindow does a 'slotShowActiveTrack()'
    //     at the end of its QTimer slot, which will finally scroll to the right spot.
    slotPlaylistActiveTrackChanged();
}