1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-24 22:46:03 +02:00

* Added CollectionItem, container for collections in sidebar.

This commit is contained in:
Christian Muehlhaeuser
2014-08-25 16:44:26 +02:00
parent a4367be07b
commit c3cdde0734
3 changed files with 137 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
sourcetree/items/LovedTracksItem.cpp
sourcetree/items/TemporaryPageItem.cpp
sourcetree/items/GroupItem.cpp
sourcetree/items/CollectionItem.cpp
sourcetree/items/HistoryItem.cpp
sourcetree/items/InboxItem.cpp
sourcetree/items/QueueItem.cpp

View File

@@ -0,0 +1,86 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CollectionItem.h"
#include "utils/ImageRegistry.h"
#include "playlist/TrackView.h"
#include "playlist/PlayableProxyModel.h"
#include "ViewManager.h"
#include "ViewPage.h"
#include <QString>
#include <QIcon>
CollectionItem::CollectionItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::collection_ptr& collection )
: SourceTreeItem( model, parent, SourcesModel::Collection )
, m_sortValue( -150 )
, m_collection( collection )
{
m_text = tr( "Collection" );
m_icon = ImageRegistry::instance()->icon( RESPATH "images/collection.svg" );
}
CollectionItem::~CollectionItem()
{}
QString
CollectionItem::text() const
{
return m_text;
}
QIcon
CollectionItem::icon() const
{
return m_icon;
}
int
CollectionItem::peerSortValue() const
{
return m_sortValue;
}
void
CollectionItem::setSortValue( int value )
{
m_sortValue = value;
}
int
CollectionItem::trackCount() const
{
return m_collection->trackCount();
}
void
CollectionItem::activate()
{
Tomahawk::ViewPage* page = ViewManager::instance()->show( m_collection );
model()->linkSourceItemToPage( this, page );
}

View File

@@ -0,0 +1,50 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COLLECTIONITEM_H
#define COLLECTIONITEM_H
#include "SourceTreeItem.h"
#include "libtomahawk/collection/Collection.h"
class CollectionItem : public SourceTreeItem
{
Q_OBJECT
public:
explicit CollectionItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::collection_ptr& collection );
virtual ~CollectionItem();
virtual QString text() const;
virtual QIcon icon() const;
virtual int peerSortValue() const;
void setSortValue( int value );
int trackCount() const;
public slots:
virtual void activate();
private:
int m_sortValue;
QIcon m_icon;
QString m_text;
Tomahawk::collection_ptr m_collection;
};
#endif // COLLECTIONITEM_H