mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-19 04:11:46 +02:00
* More work on sidebar reorganization.
This commit is contained in:
@@ -133,6 +133,7 @@ signals:
|
||||
void hideQueueRequested();
|
||||
|
||||
void tomahawkLoaded();
|
||||
|
||||
public slots:
|
||||
Tomahawk::ViewPage* showSuperCollection();
|
||||
Tomahawk::ViewPage* showWelcomePage();
|
||||
|
@@ -28,9 +28,8 @@ using namespace Tomahawk;
|
||||
|
||||
|
||||
GroupItem::GroupItem( SourcesModel* model, SourceTreeItem* parent, const QString& text, int peerSortValue )
|
||||
: SourceTreeItem( model, parent, SourcesModel::Group )
|
||||
: SourceTreeItem( model, parent, SourcesModel::Group, peerSortValue )
|
||||
, m_text( text )
|
||||
, m_peerSortValue( peerSortValue )
|
||||
{
|
||||
// expand by default
|
||||
QTimer::singleShot( 0, this, SLOT( requestExpanding() ) );
|
||||
|
@@ -36,7 +36,6 @@ public:
|
||||
virtual QString text() const;
|
||||
virtual bool willAcceptDrag( const QMimeData* data ) const { Q_UNUSED( data ); return false; }
|
||||
virtual QIcon icon() const { return QIcon(); }
|
||||
virtual int peerSortValue() const { return m_peerSortValue; }
|
||||
virtual bool isBeingPlayed() const { return false; }
|
||||
|
||||
public slots:
|
||||
@@ -50,7 +49,6 @@ private slots:
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
int m_peerSortValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -23,11 +23,12 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
SourceTreeItem::SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, SourcesModel::RowType thisType, int index )
|
||||
SourceTreeItem::SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, SourcesModel::RowType thisType, int peerSortValue, int index )
|
||||
: QObject()
|
||||
, m_type( thisType )
|
||||
, m_parent( parent )
|
||||
, m_model( model )
|
||||
, m_peerSortValue( peerSortValue )
|
||||
{
|
||||
connect( this, SIGNAL( beginChildRowsAdded( int, int ) ), m_model, SLOT( onItemRowsAddedBegin( int, int ) ) );
|
||||
connect( this, SIGNAL( beginChildRowsRemoved( int, int ) ), m_model, SLOT( onItemRowsRemovedBegin( int, int ) ) );
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
Q_DECLARE_FLAGS( DropTypes, DropType )
|
||||
|
||||
SourceTreeItem() : m_type( SourcesModel::Invalid ), m_parent( 0 ), m_model( 0 ) {}
|
||||
SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, SourcesModel::RowType thisType, int index = -1 ); // if index is -1, append at end of parent's child list
|
||||
SourceTreeItem( SourcesModel* model, SourceTreeItem* parent, SourcesModel::RowType thisType, int peerSortValue = 0, int index = -1 ); // if index is -1, append at end of parent's child list
|
||||
virtual ~SourceTreeItem();
|
||||
|
||||
// generic info used by the tree model
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
virtual bool willAcceptDrag( const QMimeData* ) const { return false; }
|
||||
virtual bool dropMimeData( const QMimeData*, Qt::DropAction ) { 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 m_peerSortValue; } // How to sort relative to peers in the tree.
|
||||
virtual int IDValue() const { return 0; }
|
||||
virtual DropTypes supportedDropTypes( const QMimeData* mimeData ) const { Q_UNUSED( mimeData ); return DropTypesNone; }
|
||||
virtual void setDropType( DropType type ) { m_dropType = type; }
|
||||
@@ -101,6 +101,7 @@ private:
|
||||
SourceTreeItem* m_parent;
|
||||
QList< SourceTreeItem* > m_children;
|
||||
SourcesModel* m_model;
|
||||
int m_peerSortValue;
|
||||
|
||||
DropType m_dropType;
|
||||
};
|
||||
|
@@ -82,7 +82,7 @@ SourceDelegate::~SourceDelegate()
|
||||
QSize
|
||||
SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
SourceTreeItem *item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
||||
SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
||||
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
||||
|
||||
if ( type == SourcesModel::Collection )
|
||||
@@ -93,6 +93,10 @@ SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex&
|
||||
{
|
||||
return QSize( option.rect.width(), 6 );
|
||||
}
|
||||
else if ( type == SourcesModel::Group && index.row() > 0 )
|
||||
{
|
||||
return QSize( option.rect.width(), 24 );
|
||||
}
|
||||
else if ( m_expandedMap.contains( index ) )
|
||||
{
|
||||
if ( !m_expandedMap.value( index )->initialized() )
|
||||
@@ -305,7 +309,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
|
||||
font.setBold( true );
|
||||
painter->setFont( font );
|
||||
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
QTextOption to( Qt::AlignBottom );
|
||||
|
||||
painter->setPen( option.palette.color( QPalette::Base ) );
|
||||
painter->setBrush( option.palette.color( QPalette::Base ) );
|
||||
@@ -325,7 +329,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
|
||||
|
||||
font.setPixelSize( font.pixelSize() - 1 );
|
||||
painter->setFont( font );
|
||||
QTextOption to( Qt::AlignVCenter | Qt::AlignRight );
|
||||
QTextOption to( Qt::AlignBottom | Qt::AlignRight );
|
||||
|
||||
// draw close icon
|
||||
painter->setPen( Qt::white );
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "globalactionmanager.h"
|
||||
#include "dropjob.h"
|
||||
#include "items/playlistitems.h"
|
||||
#include "playlist/artistview.h"
|
||||
#include "playlist/playlistview.h"
|
||||
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
||||
|
||||
@@ -53,8 +54,6 @@ SourcesModel::SourcesModel( QObject* parent )
|
||||
m_rootItem = new SourceTreeItem( this, 0, Invalid );
|
||||
|
||||
appendGroups();
|
||||
appendItem( source_ptr() );
|
||||
|
||||
onSourcesAdded( SourceList::instance()->sources() );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
@@ -265,28 +264,34 @@ SourcesModel::appendGroups()
|
||||
{
|
||||
beginInsertRows( QModelIndex(), rowCount(), rowCount() + 2 );
|
||||
|
||||
new SourceTreeItem( this, m_rootItem, SourcesModel::Divider, 0 );
|
||||
new HistoryItem( this, m_rootItem, tr( "History" ), 5 );
|
||||
GroupItem* browse = new GroupItem( this, m_rootItem, tr( "Browse" ), 10 );
|
||||
GroupItem* browse = new GroupItem( this, m_rootItem, tr( "Browse" ), 0 );
|
||||
new HistoryItem( this, m_rootItem, tr( "Search History" ), 1 );
|
||||
// new SourceTreeItem( this, m_rootItem, SourcesModel::Divider, 2 );
|
||||
m_myMusicGroup = new GroupItem( this, m_rootItem, tr( "My Music" ), 3 );
|
||||
|
||||
// super collection
|
||||
GenericPageItem* sc = new GenericPageItem( this, browse, tr( "SuperCollection" ), QIcon( RESPATH "images/supercollection.png" ),
|
||||
boost::bind( &ViewManager::showSuperCollection, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::superCollectionView, ViewManager::instance() ) );
|
||||
sc->setSortValue( 1 );
|
||||
|
||||
// browse section
|
||||
GenericPageItem* loved = new GenericPageItem( this, browse, tr( "Top Loved Tracks" ), QIcon( RESPATH "images/loved_playlist.png" ),
|
||||
boost::bind( &ViewManager::showTopLovedPage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::topLovedWidget, ViewManager::instance() ) );
|
||||
loved->setSortValue( -250 );
|
||||
loved->setSortValue( 2 );
|
||||
|
||||
// add misc children of root node
|
||||
GenericPageItem* recent = new GenericPageItem( this, browse, tr( "Dashboard" ), QIcon( RESPATH "images/dashboard.png" ),
|
||||
boost::bind( &ViewManager::showWelcomePage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::welcomeWidget, ViewManager::instance() ) );
|
||||
recent->setSortValue( -300 );
|
||||
recent->setSortValue( 0 );
|
||||
|
||||
GenericPageItem* hot = new GenericPageItem( this, browse, tr( "Charts" ), QIcon( RESPATH "images/charts.png" ),
|
||||
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::whatsHotWidget, ViewManager::instance() ) );
|
||||
hot->setSortValue( -300 );
|
||||
hot->setSortValue( 3 );
|
||||
|
||||
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 15 );
|
||||
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 );
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
@@ -298,7 +303,7 @@ SourcesModel::appendItem( const Tomahawk::source_ptr& source )
|
||||
SourceTreeItem* parent;
|
||||
if ( !source.isNull() && source->isLocal() )
|
||||
{
|
||||
parent = m_rootItem;
|
||||
parent = m_myMusicGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -139,6 +139,7 @@ private:
|
||||
|
||||
SourceTreeItem* m_rootItem;
|
||||
GroupItem* m_collectionsGroup;
|
||||
GroupItem* m_myMusicGroup;
|
||||
|
||||
QList< Tomahawk::source_ptr > m_sourcesWithViewPage;
|
||||
QHash< Tomahawk::source_ptr, SourceTreeItem* > m_sourcesWithViewPageItems;
|
||||
|
@@ -66,7 +66,7 @@ SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePar
|
||||
|
||||
if ( item && item->type() != SourcesModel::Divider && item->parent()->parent() == 0 && !item->children().count() )
|
||||
return false;
|
||||
|
||||
|
||||
if ( !m_filtered )
|
||||
return true;
|
||||
|
||||
|
Reference in New Issue
Block a user