mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
* Renamed PlItem to TrackModelItem.
This commit is contained in:
@@ -78,7 +78,6 @@ set( libSources
|
|||||||
playlist/collectionflatmodel.cpp
|
playlist/collectionflatmodel.cpp
|
||||||
playlist/collectionview.cpp
|
playlist/collectionview.cpp
|
||||||
playlist/playlistmanager.cpp
|
playlist/playlistmanager.cpp
|
||||||
playlist/plitem.cpp
|
|
||||||
playlist/playlistmodel.cpp
|
playlist/playlistmodel.cpp
|
||||||
playlist/playlistproxymodel.cpp
|
playlist/playlistproxymodel.cpp
|
||||||
playlist/playlistview.cpp
|
playlist/playlistview.cpp
|
||||||
@@ -86,6 +85,7 @@ set( libSources
|
|||||||
playlist/queueproxymodel.cpp
|
playlist/queueproxymodel.cpp
|
||||||
playlist/queueview.cpp
|
playlist/queueview.cpp
|
||||||
playlist/trackmodel.cpp
|
playlist/trackmodel.cpp
|
||||||
|
playlist/trackmodelitem.cpp
|
||||||
playlist/trackproxymodel.cpp
|
playlist/trackproxymodel.cpp
|
||||||
playlist/trackview.cpp
|
playlist/trackview.cpp
|
||||||
playlist/trackheader.cpp
|
playlist/trackheader.cpp
|
||||||
@@ -232,7 +232,6 @@ set( libHeaders
|
|||||||
playlist/collectionflatmodel.h
|
playlist/collectionflatmodel.h
|
||||||
playlist/collectionview.h
|
playlist/collectionview.h
|
||||||
playlist/playlistmanager.h
|
playlist/playlistmanager.h
|
||||||
playlist/plitem.h
|
|
||||||
playlist/playlistmodel.h
|
playlist/playlistmodel.h
|
||||||
playlist/playlistproxymodel.h
|
playlist/playlistproxymodel.h
|
||||||
playlist/playlistview.h
|
playlist/playlistview.h
|
||||||
@@ -240,6 +239,7 @@ set( libHeaders
|
|||||||
playlist/queueproxymodel.h
|
playlist/queueproxymodel.h
|
||||||
playlist/queueview.h
|
playlist/queueview.h
|
||||||
playlist/trackmodel.h
|
playlist/trackmodel.h
|
||||||
|
playlist/trackmodelitem.h
|
||||||
playlist/trackproxymodel.h
|
playlist/trackproxymodel.h
|
||||||
playlist/trackview.h
|
playlist/trackview.h
|
||||||
playlist/trackheader.h
|
playlist/trackheader.h
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -42,11 +42,11 @@ CollectionFlatModel::~CollectionFlatModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
CollectionFlatModel::addCollections( const QList< collection_ptr >& collections )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
qDebug() << Q_FUNC_INFO << "Adding collections!";
|
||||||
foreach( const collection_ptr& col, collections )
|
foreach( const collection_ptr& col, collections )
|
||||||
{
|
{
|
||||||
addCollection( col );
|
addCollection( col );
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
QTime timer;
|
QTime timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
// QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
// QList<TrackModelItem*> plitems = m_collectionIndex.values( collection );
|
||||||
QList< QPair< int, int > > rows;
|
QList< QPair< int, int > > rows;
|
||||||
QList< QPair< int, int > > sortrows;
|
QList< QPair< int, int > > sortrows;
|
||||||
QPair< int, int > row;
|
QPair< int, int > row;
|
||||||
@@ -167,7 +167,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
|||||||
emit beginRemoveRows( QModelIndex(), row.first, row.second );
|
emit beginRemoveRows( QModelIndex(), row.first, row.second );
|
||||||
for ( int i = row.second; i >= row.first; i-- )
|
for ( int i = row.second; i >= row.first; i-- )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
TrackModelItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
@@ -212,12 +212,12 @@ CollectionFlatModel::processTracksToAdd()
|
|||||||
emit beginInsertRows( QModelIndex(), c, c + maxc - 1 );
|
emit beginInsertRows( QModelIndex(), c, c + maxc - 1 );
|
||||||
//beginResetModel();
|
//beginResetModel();
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
QList< Tomahawk::query_ptr >::iterator iter = m_tracksToAdd.begin();
|
QList< Tomahawk::query_ptr >::iterator iter = m_tracksToAdd.begin();
|
||||||
|
|
||||||
for( int i = 0; i < maxc; ++i )
|
for( int i = 0; i < maxc; ++i )
|
||||||
{
|
{
|
||||||
plitem = new PlItem( *iter, m_rootItem );
|
plitem = new TrackModelItem( *iter, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
@@ -245,7 +245,7 @@ CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
QList<Tomahawk::query_ptr> t = tracks;
|
QList<Tomahawk::query_ptr> t = tracks;
|
||||||
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
for ( int i = rowCount( QModelIndex() ); i >= 0 && t.count(); i-- )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
TrackModelItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
||||||
if ( !item )
|
if ( !item )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ CollectionFlatModel::onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
void
|
void
|
||||||
CollectionFlatModel::onDataChanged()
|
CollectionFlatModel::onDataChanged()
|
||||||
{
|
{
|
||||||
PlItem* p = (PlItem*)sender();
|
TrackModelItem* p = (TrackModelItem*)sender();
|
||||||
// emit itemSizeChanged( p->index );
|
// emit itemSizeChanged( p->index );
|
||||||
|
|
||||||
if ( p )
|
if ( p )
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -40,7 +40,6 @@ CollectionModel::CollectionModel( QObject* parent )
|
|||||||
|
|
||||||
CollectionModel::~CollectionModel()
|
CollectionModel::~CollectionModel()
|
||||||
{
|
{
|
||||||
// delete m_rootItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,8 +49,8 @@ CollectionModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
if ( !m_rootItem || row < 0 || column < 0 )
|
if ( !m_rootItem || row < 0 || column < 0 )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
PlItem* childItem = parentItem->children.value( row );
|
TrackModelItem* childItem = parentItem->children.value( row );
|
||||||
if ( !childItem )
|
if ( !childItem )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ CollectionModel::rowCount( const QModelIndex& parent ) const
|
|||||||
if ( parent.column() > 0 )
|
if ( parent.column() > 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
if ( !parentItem )
|
if ( !parentItem )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -83,15 +82,15 @@ CollectionModel::columnCount( const QModelIndex& parent ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
CollectionModel::parent( const QModelIndex& child ) const
|
CollectionModel::parent( const QModelIndex& child ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( child );
|
TrackModelItem* entry = itemFromIndex( child );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentEntry = entry->parent;
|
TrackModelItem* parentEntry = entry->parent;
|
||||||
if ( !parentEntry )
|
if ( !parentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* grandparentEntry = parentEntry->parent;
|
TrackModelItem* grandparentEntry = parentEntry->parent;
|
||||||
if ( !grandparentEntry )
|
if ( !grandparentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -106,7 +105,7 @@ CollectionModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( role != Qt::DisplayRole )
|
if ( role != Qt::DisplayRole )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -199,7 +198,7 @@ CollectionModel::removeCollection( const collection_ptr& collection )
|
|||||||
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
||||||
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
||||||
|
|
||||||
QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
QList<TrackModelItem*> plitems = m_collectionIndex.values( collection );
|
||||||
|
|
||||||
m_collectionIndex.remove( collection );
|
m_collectionIndex.remove( collection );
|
||||||
}
|
}
|
||||||
@@ -210,17 +209,17 @@ CollectionModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const
|
|||||||
{
|
{
|
||||||
// int c = rowCount( QModelIndex() );
|
// int c = rowCount( QModelIndex() );
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
foreach( const Tomahawk::query_ptr& query, tracks )
|
foreach( const Tomahawk::query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
PlItem* parent = m_rootItem;
|
TrackModelItem* parent = m_rootItem;
|
||||||
if ( parent->hash.contains( query->artist() ) )
|
if ( parent->hash.contains( query->artist() ) )
|
||||||
{
|
{
|
||||||
parent = parent->hash.value( query->artist() );
|
parent = parent->hash.value( query->artist() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parent = new PlItem( query->artist(), m_rootItem );
|
parent = new TrackModelItem( query->artist(), m_rootItem );
|
||||||
m_rootItem->hash.insert( query->artist(), parent );
|
m_rootItem->hash.insert( query->artist(), parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +231,14 @@ CollectionModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlItem* subitem = new PlItem( query->album(), parent );
|
TrackModelItem* subitem = new TrackModelItem( query->album(), parent );
|
||||||
parent->hash.insert( query->album(), subitem );
|
parent->hash.insert( query->album(), subitem );
|
||||||
parent->childCount++;
|
parent->childCount++;
|
||||||
subitem->childCount++;
|
subitem->childCount++;
|
||||||
parent = subitem;
|
parent = subitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
plitem = new PlItem( query, parent );
|
plitem = new TrackModelItem( query, parent );
|
||||||
m_collectionIndex.insertMulti( collection, plitem );
|
m_collectionIndex.insertMulti( collection, plitem );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,11 +274,11 @@ CollectionModel::onSourceOffline( Tomahawk::source_ptr src )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem*
|
TrackModelItem*
|
||||||
CollectionModel::itemFromIndex( const QModelIndex& index ) const
|
CollectionModel::itemFromIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
return static_cast<PlItem*>( index.internalPointer() );
|
return static_cast<TrackModelItem*>( index.internalPointer() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
||||||
virtual void setShuffled( bool shuffled ) {}
|
virtual void setShuffled( bool shuffled ) {}
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
@@ -79,8 +79,8 @@ private slots:
|
|||||||
void onSourceOffline( Tomahawk::source_ptr src );
|
void onSourceOffline( Tomahawk::source_ptr src );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlItem* m_rootItem;
|
TrackModelItem* m_rootItem;
|
||||||
QMap< Tomahawk::collection_ptr, PlItem* > m_collectionIndex;
|
QMap< Tomahawk::collection_ptr, TrackModelItem* > m_collectionIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLLECTIONMODEL_H
|
#endif // COLLECTIONMODEL_H
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -35,8 +35,8 @@ CollectionProxyModel::CollectionProxyModel( QObject* parent )
|
|||||||
bool
|
bool
|
||||||
CollectionProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
CollectionProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
||||||
{
|
{
|
||||||
PlItem* p1 = itemFromIndex( left );
|
TrackModelItem* p1 = itemFromIndex( left );
|
||||||
PlItem* p2 = itemFromIndex( right );
|
TrackModelItem* p2 = itemFromIndex( right );
|
||||||
|
|
||||||
if ( !p1 )
|
if ( !p1 )
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -24,10 +24,10 @@
|
|||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
|
|
||||||
#include "playlist/plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "playlist/trackproxymodel.h"
|
#include "trackproxymodel.h"
|
||||||
#include "playlist/trackview.h"
|
#include "trackview.h"
|
||||||
#include "playlist/trackheader.h"
|
#include "trackheader.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem&
|
|||||||
void
|
void
|
||||||
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
PlItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||||
if ( !item || item->query().isNull() )
|
if ( !item || item->query().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
if ( !loadEntries )
|
if ( !loadEntries )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
QList<plentry_ptr> entries = playlist->entries();
|
QList<plentry_ptr> entries = playlist->entries();
|
||||||
if ( entries.count() )
|
if ( entries.count() )
|
||||||
{
|
{
|
||||||
@@ -105,7 +105,7 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
foreach( const plentry_ptr& entry, entries )
|
foreach( const plentry_ptr& entry, entries )
|
||||||
{
|
{
|
||||||
qDebug() << entry->query()->toString();
|
qDebug() << entry->query()->toString();
|
||||||
plitem = new PlItem( entry, m_rootItem );
|
plitem = new TrackModelItem( entry, m_rootItem );
|
||||||
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
plitem->index = createIndex( m_rootItem->children.count() - 1, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
@@ -158,7 +158,7 @@ PlaylistModel::clear()
|
|||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
m_rootItem = 0;
|
m_rootItem = 0;
|
||||||
emit endResetModel();
|
emit endResetModel();
|
||||||
m_rootItem = new PlItem( 0, this );
|
m_rootItem = new TrackModelItem( 0, this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,13 +252,13 @@ PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_p
|
|||||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
PlItem* plitem;
|
TrackModelItem* plitem;
|
||||||
foreach( const query_ptr& query, tracks )
|
foreach( const query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
plentry_ptr entry = plentry_ptr( new PlaylistEntry() );
|
||||||
entry->setQuery( query );
|
entry->setQuery( query );
|
||||||
|
|
||||||
plitem = new PlItem( entry, m_rootItem, row + i );
|
plitem = new TrackModelItem( entry, m_rootItem, row + i );
|
||||||
plitem->index = createIndex( row + i, 0, plitem );
|
plitem->index = createIndex( row + i, 0, plitem );
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@@ -274,7 +274,7 @@ PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_p
|
|||||||
void
|
void
|
||||||
PlaylistModel::onDataChanged()
|
PlaylistModel::onDataChanged()
|
||||||
{
|
{
|
||||||
PlItem* p = (PlItem*)sender();
|
TrackModelItem* p = (TrackModelItem*)sender();
|
||||||
if ( p && p->index.isValid() )
|
if ( p && p->index.isValid() )
|
||||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount() - 1 ) );
|
||||||
}
|
}
|
||||||
@@ -350,7 +350,7 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
e->setAnnotation( "" ); // FIXME
|
e->setAnnotation( "" ); // FIXME
|
||||||
e->setQuery( query );
|
e->setQuery( query );
|
||||||
|
|
||||||
PlItem* plitem = new PlItem( e, m_rootItem, beginRow );
|
TrackModelItem* plitem = new TrackModelItem( e, m_rootItem, beginRow );
|
||||||
plitem->index = createIndex( beginRow++, 0, plitem );
|
plitem->index = createIndex( beginRow++, 0, plitem );
|
||||||
|
|
||||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
@@ -411,7 +411,7 @@ PlaylistModel::playlistEntries() const
|
|||||||
if ( !idx.isValid() )
|
if ( !idx.isValid() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PlItem* item = itemFromIndex( idx );
|
TrackModelItem* item = itemFromIndex( idx );
|
||||||
if ( item )
|
if ( item )
|
||||||
l << item->entry();
|
l << item->entry();
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
#include "collection.h"
|
#include "collection.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
@@ -33,7 +33,7 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
TrackModel::TrackModel( QObject* parent )
|
TrackModel::TrackModel( QObject* parent )
|
||||||
: QAbstractItemModel( parent )
|
: QAbstractItemModel( parent )
|
||||||
, m_rootItem( new PlItem( 0, this ) )
|
, m_rootItem( new TrackModelItem( 0, this ) )
|
||||||
, m_readOnly( true )
|
, m_readOnly( true )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@@ -55,8 +55,8 @@ TrackModel::index( int row, int column, const QModelIndex& parent ) const
|
|||||||
if ( !m_rootItem || row < 0 || column < 0 )
|
if ( !m_rootItem || row < 0 || column < 0 )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
PlItem* childItem = parentItem->children.value( row );
|
TrackModelItem* childItem = parentItem->children.value( row );
|
||||||
if ( !childItem )
|
if ( !childItem )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ TrackModel::rowCount( const QModelIndex& parent ) const
|
|||||||
if ( parent.column() > 0 )
|
if ( parent.column() > 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PlItem* parentItem = itemFromIndex( parent );
|
TrackModelItem* parentItem = itemFromIndex( parent );
|
||||||
if ( !parentItem )
|
if ( !parentItem )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -88,15 +88,15 @@ TrackModel::columnCount( const QModelIndex& parent ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
TrackModel::parent( const QModelIndex& child ) const
|
TrackModel::parent( const QModelIndex& child ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( child );
|
TrackModelItem* entry = itemFromIndex( child );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* parentEntry = entry->parent;
|
TrackModelItem* parentEntry = entry->parent;
|
||||||
if ( !parentEntry )
|
if ( !parentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PlItem* grandparentEntry = parentEntry->parent;
|
TrackModelItem* grandparentEntry = parentEntry->parent;
|
||||||
if ( !grandparentEntry )
|
if ( !grandparentEntry )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ TrackModel::parent( const QModelIndex& child ) const
|
|||||||
QVariant
|
QVariant
|
||||||
TrackModel::data( const QModelIndex& index, int role ) const
|
TrackModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -222,13 +222,13 @@ void
|
|||||||
TrackModel::setCurrentItem( const QModelIndex& index )
|
TrackModel::setCurrentItem( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry )
|
if ( oldEntry )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
PlItem* entry = itemFromIndex( index );
|
TrackModelItem* entry = itemFromIndex( index );
|
||||||
if ( entry )
|
if ( entry )
|
||||||
{
|
{
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
@@ -283,7 +283,7 @@ TrackModel::mimeData( const QModelIndexList &indexes ) const
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
QModelIndex idx = index( i.row(), 0, i.parent() );
|
QModelIndex idx = index( i.row(), 0, i.parent() );
|
||||||
PlItem* item = itemFromIndex( idx );
|
TrackModelItem* item = itemFromIndex( idx );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
const query_ptr& query = item->query();
|
const query_ptr& query = item->query();
|
||||||
@@ -315,7 +315,7 @@ TrackModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
|||||||
if ( index.column() > 0 )
|
if ( index.column() > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlItem* item = itemFromIndex( index );
|
TrackModelItem* item = itemFromIndex( index );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
||||||
@@ -337,11 +337,11 @@ TrackModel::removeIndexes( const QList<QModelIndex>& indexes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem*
|
TrackModelItem*
|
||||||
TrackModel::itemFromIndex( const QModelIndex& index ) const
|
TrackModel::itemFromIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
return static_cast<PlItem*>( index.internalPointer() );
|
return static_cast<TrackModelItem*>( index.internalPointer() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_rootItem;
|
return m_rootItem;
|
||||||
@@ -352,7 +352,7 @@ TrackModel::itemFromIndex( const QModelIndex& index ) const
|
|||||||
void
|
void
|
||||||
TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry && !oldEntry->query().isNull() && oldEntry->query()->results().contains( result ) )
|
if ( oldEntry && !oldEntry->query().isNull() && oldEntry->query()->results().contains( result ) )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
@@ -363,7 +363,7 @@ TrackModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
|
|||||||
void
|
void
|
||||||
TrackModel::onPlaybackStopped()
|
TrackModel::onPlaybackStopped()
|
||||||
{
|
{
|
||||||
PlItem* oldEntry = itemFromIndex( m_currentIndex );
|
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry )
|
if ( oldEntry )
|
||||||
{
|
{
|
||||||
oldEntry->setIsPlaying( false );
|
oldEntry->setIsPlaying( false );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "playlist/plitem.h"
|
#include "trackmodelitem.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ public:
|
|||||||
|
|
||||||
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
virtual void append( const Tomahawk::query_ptr& query ) = 0;
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const;
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
|
|
||||||
PlItem* m_rootItem;
|
TrackModelItem* m_rootItem;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plitem.h"
|
#include "trackmodelitem.h"
|
||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
PlItem::~PlItem()
|
TrackModelItem::~TrackModelItem()
|
||||||
{
|
{
|
||||||
// Don't use qDeleteAll here! The children will remove themselves
|
// Don't use qDeleteAll here! The children will remove themselves
|
||||||
// from the list when they get deleted and the qDeleteAll iterator
|
// from the list when they get deleted and the qDeleteAll iterator
|
||||||
@@ -42,7 +42,7 @@ PlItem::~PlItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( PlItem* parent, QAbstractItemModel* model )
|
TrackModelItem::TrackModelItem( TrackModelItem* parent, QAbstractItemModel* model )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->model = model;
|
this->model = model;
|
||||||
@@ -56,7 +56,7 @@ PlItem::PlItem( PlItem* parent, QAbstractItemModel* model )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const QString& caption, PlItem* parent )
|
TrackModelItem::TrackModelItem( const QString& caption, TrackModelItem* parent )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->caption = caption;
|
this->caption = caption;
|
||||||
@@ -72,35 +72,35 @@ PlItem::PlItem( const QString& caption, PlItem* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
TrackModelItem::TrackModelItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
{
|
{
|
||||||
setupItem( query, parent, row );
|
setupItem( query, parent, row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlItem::PlItem( const Tomahawk::plentry_ptr& entry, PlItem* parent, int row )
|
TrackModelItem::TrackModelItem( const Tomahawk::plentry_ptr& entry, TrackModelItem* parent, int row )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_entry( entry )
|
, m_entry( entry )
|
||||||
{
|
{
|
||||||
setupItem( entry->query(), parent, row );
|
setupItem( entry->query(), parent, row );
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tomahawk::plentry_ptr&
|
const Tomahawk::plentry_ptr&
|
||||||
PlItem::entry() const
|
TrackModelItem::entry() const
|
||||||
{
|
{
|
||||||
return m_entry;
|
return m_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tomahawk::query_ptr&
|
const Tomahawk::query_ptr&
|
||||||
PlItem::query() const
|
TrackModelItem::query() const
|
||||||
{
|
{
|
||||||
if ( !m_entry.isNull() ) return m_entry->query(); else return m_query;
|
if ( !m_entry.isNull() ) return m_entry->query(); else return m_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
TrackModelItem::setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
if ( parent )
|
if ( parent )
|
||||||
@@ -132,7 +132,7 @@ PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row )
|
|||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
|
connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
|
||||||
SIGNAL( dataChanged() ) );
|
SIGNAL( dataChanged() ) );
|
||||||
|
|
||||||
connect( query.data(), SIGNAL( resultsChanged() ),
|
connect( query.data(), SIGNAL( resultsChanged() ),
|
||||||
SIGNAL( dataChanged() ) );
|
SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -29,17 +29,17 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class DLLEXPORT PlItem : public QObject
|
class DLLEXPORT TrackModelItem : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~PlItem();
|
virtual ~TrackModelItem();
|
||||||
|
|
||||||
explicit PlItem( PlItem* parent = 0, QAbstractItemModel* model = 0 );
|
explicit TrackModelItem( TrackModelItem* parent = 0, QAbstractItemModel* model = 0 );
|
||||||
explicit PlItem( const QString& caption, PlItem* parent = 0 );
|
explicit TrackModelItem( const QString& caption, TrackModelItem* parent = 0 );
|
||||||
explicit PlItem( const Tomahawk::query_ptr& query, PlItem* parent = 0, int row = -1 );
|
explicit TrackModelItem( const Tomahawk::query_ptr& query, TrackModelItem* parent = 0, int row = -1 );
|
||||||
explicit PlItem( const Tomahawk::plentry_ptr& entry, PlItem* parent = 0, int row = -1 );
|
explicit TrackModelItem( const Tomahawk::plentry_ptr& entry, TrackModelItem* parent = 0, int row = -1 );
|
||||||
|
|
||||||
const Tomahawk::plentry_ptr& entry() const;
|
const Tomahawk::plentry_ptr& entry() const;
|
||||||
const Tomahawk::query_ptr& query() const;
|
const Tomahawk::query_ptr& query() const;
|
||||||
@@ -47,9 +47,9 @@ public:
|
|||||||
bool isPlaying() { return m_isPlaying; }
|
bool isPlaying() { return m_isPlaying; }
|
||||||
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
||||||
|
|
||||||
PlItem* parent;
|
TrackModelItem* parent;
|
||||||
QVector<PlItem*> children;
|
QVector<TrackModelItem*> children;
|
||||||
QHash<QString, PlItem*> hash;
|
QHash<QString, TrackModelItem*> hash;
|
||||||
QString caption;
|
QString caption;
|
||||||
int childCount;
|
int childCount;
|
||||||
QPersistentModelIndex index;
|
QPersistentModelIndex index;
|
||||||
@@ -60,7 +60,7 @@ signals:
|
|||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupItem( const Tomahawk::query_ptr& query, PlItem* parent, int row = -1 );
|
void setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row = -1 );
|
||||||
|
|
||||||
Tomahawk::plentry_ptr m_entry;
|
Tomahawk::plentry_ptr m_entry;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -76,7 +76,7 @@ TrackProxyModel::tracks()
|
|||||||
|
|
||||||
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) );
|
TrackModelItem* item = itemFromIndex( mapToSource( index( i, 0 ) ) );
|
||||||
if ( item )
|
if ( item )
|
||||||
queries << item->query();
|
queries << item->query();
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
if ( idx.isValid() ) do
|
||||||
{
|
{
|
||||||
PlItem* item = itemFromIndex( mapToSource( idx ) );
|
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
|
||||||
qDebug() << item->query()->toString();
|
qDebug() << item->query()->toString();
|
||||||
if ( item && item->query()->playable() )
|
if ( item && item->query()->playable() )
|
||||||
{
|
{
|
||||||
@@ -156,14 +156,14 @@ TrackProxyModel::siblingItem( int itemsAway )
|
|||||||
bool
|
bool
|
||||||
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
PlItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
TrackModelItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
if ( !pi )
|
if ( !pi )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Tomahawk::query_ptr& q = pi->query();
|
const Tomahawk::query_ptr& q = pi->query();
|
||||||
if( q.isNull() ) // uh oh? filter out invalid queries i guess
|
if( q.isNull() ) // uh oh? filter out invalid queries i guess
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Tomahawk::result_ptr r;
|
Tomahawk::result_ptr r;
|
||||||
if ( q->numResults() )
|
if ( q->numResults() )
|
||||||
r = q->results().first();
|
r = q->results().first();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
bool showOfflineResults() const { return m_showOfflineResults; }
|
bool showOfflineResults() const { return m_showOfflineResults; }
|
||||||
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
void setShowOfflineResults( bool b ) { m_showOfflineResults = b; }
|
||||||
|
|
||||||
PlItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
TrackModelItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -69,12 +69,12 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
f.setPointSize( f.pointSize() - 1 );
|
f.setPointSize( f.pointSize() - 1 );
|
||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
f.setPointSize( f.pointSize() - 2 );
|
f.setPointSize( f.pointSize() - 2 );
|
||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ TrackView::setModel( TrackModel* model )
|
|||||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
||||||
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
||||||
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
||||||
|
|
||||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
|
|
||||||
setAcceptDrops( true );
|
setAcceptDrops( true );
|
||||||
@@ -129,7 +129,7 @@ TrackView::setModel( TrackModel* model )
|
|||||||
void
|
void
|
||||||
TrackView::onItemActivated( const QModelIndex& index )
|
TrackView::onItemActivated( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
PlItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
if ( item && item->query()->numResults() )
|
if ( item && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
||||||
@@ -178,7 +178,7 @@ TrackView::addItemsToQueue()
|
|||||||
if ( idx.column() )
|
if ( idx.column() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
PlItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
TrackModelItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
||||||
if ( item && item->query()->numResults() )
|
if ( item && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
PlaylistManager::instance()->queue()->model()->append( item->query() );
|
PlaylistManager::instance()->queue()->model()->append( item->query() );
|
||||||
|
Reference in New Issue
Block a user