mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
To temporary pages it is!
This commit is contained in:
@@ -62,6 +62,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
sourcetree/items/playlistitems.cpp
|
sourcetree/items/playlistitems.cpp
|
||||||
sourcetree/items/categoryitems.cpp
|
sourcetree/items/categoryitems.cpp
|
||||||
sourcetree/items/genericpageitems.cpp
|
sourcetree/items/genericpageitems.cpp
|
||||||
|
sourcetree/items/temporarypageitem.cpp
|
||||||
|
|
||||||
transferview.cpp
|
transferview.cpp
|
||||||
PipelineStatusView.cpp
|
PipelineStatusView.cpp
|
||||||
@@ -106,6 +107,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
|||||||
sourcetree/items/playlistitems.h
|
sourcetree/items/playlistitems.h
|
||||||
sourcetree/items/categoryitems.h
|
sourcetree/items/categoryitems.h
|
||||||
sourcetree/items/genericpageitems.h
|
sourcetree/items/genericpageitems.h
|
||||||
|
sourcetree/items/temporarypageitem.h
|
||||||
|
|
||||||
transferview.h
|
transferview.h
|
||||||
PipelineStatusView.h
|
PipelineStatusView.h
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <widgets/SocialPlaylistWidget.h>
|
#include <widgets/SocialPlaylistWidget.h>
|
||||||
#include <playlist/customplaylistview.h>
|
#include <playlist/customplaylistview.h>
|
||||||
|
#include "temporarypageitem.h"
|
||||||
|
|
||||||
/// CollectionItem
|
/// CollectionItem
|
||||||
|
|
||||||
@@ -40,7 +41,6 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
, m_sourceInfoItem( 0 )
|
, m_sourceInfoItem( 0 )
|
||||||
, m_coolPlaylistsItem( 0 )
|
, m_coolPlaylistsItem( 0 )
|
||||||
, m_lovedTracksItem()
|
, m_lovedTracksItem()
|
||||||
, m_curTempPage( 0 )
|
|
||||||
, m_sourceInfoPage( 0 )
|
, m_sourceInfoPage( 0 )
|
||||||
, m_coolPlaylistsPage( 0 )
|
, m_coolPlaylistsPage( 0 )
|
||||||
, m_lovedTracksPage( 0 )
|
, m_lovedTracksPage( 0 )
|
||||||
@@ -369,51 +369,24 @@ CollectionItem::requestExpanding()
|
|||||||
void
|
void
|
||||||
CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
|
CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
|
||||||
{
|
{
|
||||||
QString name = v->title();
|
int idx = children().count();
|
||||||
m_curTempPage = v;
|
|
||||||
if( m_tempItem.isNull() ) {
|
foreach ( TemporaryPageItem* page, m_tempItems )
|
||||||
emit beginRowsAdded( children().count(), children().count() );
|
{
|
||||||
m_tempItem = QWeakPointer< GenericPageItem >( new GenericPageItem( model(), this, name, QIcon( RESPATH "images/playlist-icon.png" ),
|
if ( page->page() == v )
|
||||||
boost::bind( &CollectionItem::tempItemClicked, this ),
|
{
|
||||||
boost::bind( &CollectionItem::getTempPage, this ) ) );
|
emit selectRequest( page );
|
||||||
m_tempItem.data()->setDeleteFunc( boost::bind( &CollectionItem::deleteTempPage, this ) );
|
return;
|
||||||
m_tempItem.data()->setIsTemp( true );
|
}
|
||||||
emit endRowsAdded();
|
|
||||||
} else {
|
|
||||||
m_tempItem.data()->setText( name );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model()->linkSourceItemToPage( m_tempItem.data(), v );
|
emit beginRowsAdded( idx, idx );
|
||||||
emit selectRequest( m_tempItem.data() );
|
TemporaryPageItem* tempPage = new TemporaryPageItem( model(), this, v, idx );
|
||||||
|
m_tempItems << tempPage;
|
||||||
|
endRowsAdded();
|
||||||
|
emit selectRequest( tempPage );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
CollectionItem::deleteTempPage()
|
|
||||||
{
|
|
||||||
model()->removeSourceItemLink( m_tempItem.data() );
|
|
||||||
ViewManager::instance()->removeFromHistory( m_curTempPage );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
|
||||||
CollectionItem::tempItemClicked()
|
|
||||||
{
|
|
||||||
if( m_curTempPage ) {
|
|
||||||
// show the last temporary page the user displayed
|
|
||||||
return ViewManager::instance()->show( m_curTempPage );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
|
||||||
CollectionItem::getTempPage() const
|
|
||||||
{
|
|
||||||
return m_curTempPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::sourceInfoClicked()
|
CollectionItem::sourceInfoClicked()
|
||||||
{
|
{
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "sourcetreeitem.h"
|
#include "sourcetreeitem.h"
|
||||||
|
|
||||||
|
class TemporaryPageItem;
|
||||||
class GenericPageItem;
|
class GenericPageItem;
|
||||||
class CategoryItem;
|
class CategoryItem;
|
||||||
namespace Tomahawk {
|
namespace Tomahawk {
|
||||||
@@ -57,9 +58,6 @@ private slots:
|
|||||||
void requestExpanding();
|
void requestExpanding();
|
||||||
|
|
||||||
void tempPageActivated( Tomahawk::ViewPage* );
|
void tempPageActivated( Tomahawk::ViewPage* );
|
||||||
Tomahawk::ViewPage* tempItemClicked();
|
|
||||||
Tomahawk::ViewPage* getTempPage() const;
|
|
||||||
void deleteTempPage();
|
|
||||||
|
|
||||||
Tomahawk::ViewPage* sourceInfoClicked();
|
Tomahawk::ViewPage* sourceInfoClicked();
|
||||||
Tomahawk::ViewPage* getSourceInfoPage() const;
|
Tomahawk::ViewPage* getSourceInfoPage() const;
|
||||||
@@ -80,12 +78,11 @@ private:
|
|||||||
CategoryItem* m_playlists;
|
CategoryItem* m_playlists;
|
||||||
CategoryItem* m_stations;
|
CategoryItem* m_stations;
|
||||||
|
|
||||||
QWeakPointer<GenericPageItem> m_tempItem;
|
QList< TemporaryPageItem* > m_tempItems;
|
||||||
GenericPageItem* m_sourceInfoItem;
|
GenericPageItem* m_sourceInfoItem;
|
||||||
GenericPageItem* m_coolPlaylistsItem;
|
GenericPageItem* m_coolPlaylistsItem;
|
||||||
GenericPageItem* m_lovedTracksItem;
|
GenericPageItem* m_lovedTracksItem;
|
||||||
|
|
||||||
Tomahawk::ViewPage* m_curTempPage;
|
|
||||||
Tomahawk::ViewPage* m_sourceInfoPage;
|
Tomahawk::ViewPage* m_sourceInfoPage;
|
||||||
Tomahawk::ViewPage* m_coolPlaylistsPage;
|
Tomahawk::ViewPage* m_coolPlaylistsPage;
|
||||||
Tomahawk::ViewPage* m_lovedTracksPage;
|
Tomahawk::ViewPage* m_lovedTracksPage;
|
||||||
|
@@ -31,7 +31,6 @@ GenericPageItem::GenericPageItem( SourcesModel* model, SourceTreeItem* parent, c
|
|||||||
, m_icon( icon )
|
, m_icon( icon )
|
||||||
, m_text( text )
|
, m_text( text )
|
||||||
, m_sortValue( 0 )
|
, m_sortValue( 0 )
|
||||||
, m_temp( false )
|
|
||||||
, m_show( show )
|
, m_show( show )
|
||||||
, m_get( get )
|
, m_get( get )
|
||||||
{
|
{
|
||||||
@@ -82,23 +81,3 @@ GenericPageItem::setText( const QString &text )
|
|||||||
emit updated();
|
emit updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GenericPageItem::deleteTempPage()
|
|
||||||
{
|
|
||||||
Q_ASSERT( m_temp );
|
|
||||||
|
|
||||||
if ( ViewManager::instance()->currentPage() == m_get() )
|
|
||||||
{
|
|
||||||
ViewManager::instance()->historyBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_delete();
|
|
||||||
|
|
||||||
int idx = parent()->children().indexOf( this );
|
|
||||||
parent()->beginRowsRemoved( idx, idx );
|
|
||||||
parent()->removeChild( this );
|
|
||||||
parent()->endRowsRemoved();
|
|
||||||
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -42,11 +42,6 @@ public:
|
|||||||
void setText( const QString& text );
|
void setText( const QString& text );
|
||||||
void setSortValue( int value ) { m_sortValue = value; }
|
void setSortValue( int value ) { m_sortValue = value; }
|
||||||
|
|
||||||
void setIsTemp( bool temp ) { m_temp = temp; }
|
|
||||||
bool isTempItem() { return m_temp; }
|
|
||||||
|
|
||||||
void setDeleteFunc( boost::function<void()> deleter ) { m_delete = deleter; };
|
|
||||||
void deleteTempPage();
|
|
||||||
signals:
|
signals:
|
||||||
void activated();
|
void activated();
|
||||||
|
|
||||||
@@ -54,10 +49,8 @@ private:
|
|||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QString m_text;
|
QString m_text;
|
||||||
int m_sortValue;
|
int m_sortValue;
|
||||||
bool m_temp;
|
|
||||||
boost::function< Tomahawk::ViewPage*() > m_show;
|
boost::function< Tomahawk::ViewPage*() > m_show;
|
||||||
boost::function< Tomahawk::ViewPage*() > m_get;
|
boost::function< Tomahawk::ViewPage*() > m_get;
|
||||||
boost::function< void() > m_delete;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
71
src/sourcetree/items/temporarypageitem.cpp
Normal file
71
src/sourcetree/items/temporarypageitem.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.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 "temporarypageitem.h"
|
||||||
|
#include <viewmanager.h>
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
TemporaryPageItem::TemporaryPageItem ( SourcesModel* mdl, SourceTreeItem* parent, ViewPage* page, int sortValue )
|
||||||
|
: SourceTreeItem( mdl, parent, SourcesModel::TemporaryPage )
|
||||||
|
, m_page( page )
|
||||||
|
, m_icon( QIcon( RESPATH "images/playlist-icon.png" ) )
|
||||||
|
, m_sortValue( sortValue )
|
||||||
|
{
|
||||||
|
model()->linkSourceItemToPage( this, page );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
TemporaryPageItem::text() const
|
||||||
|
{
|
||||||
|
return m_page->title();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TemporaryPageItem::activate()
|
||||||
|
{
|
||||||
|
ViewManager::instance()->show( m_page );
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon
|
||||||
|
TemporaryPageItem::icon() const
|
||||||
|
{
|
||||||
|
return m_icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TemporaryPageItem::peerSortValue() const
|
||||||
|
{
|
||||||
|
return m_sortValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TemporaryPageItem::removeFromList()
|
||||||
|
{
|
||||||
|
ViewManager::instance()->removeFromHistory( m_page );
|
||||||
|
|
||||||
|
model()->removeSourceItemLink( this );
|
||||||
|
|
||||||
|
int idx = parent()->children().indexOf( this );
|
||||||
|
parent()->beginRowsRemoved( idx, idx );
|
||||||
|
parent()->removeChild( this );
|
||||||
|
parent()->endRowsRemoved();
|
||||||
|
|
||||||
|
deleteLater();
|
||||||
|
}
|
46
src/sourcetree/items/temporarypageitem.h
Normal file
46
src/sourcetree/items/temporarypageitem.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.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 TEMPORARYPAGEITEM_H
|
||||||
|
#define TEMPORARYPAGEITEM_H
|
||||||
|
|
||||||
|
#include "items/sourcetreeitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
class TemporaryPageItem : public SourceTreeItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TemporaryPageItem ( SourcesModel* model, SourceTreeItem* parent, Tomahawk::ViewPage* page, int sortValue );
|
||||||
|
|
||||||
|
virtual QString text() const;
|
||||||
|
virtual void activate();
|
||||||
|
|
||||||
|
virtual QIcon icon() const;
|
||||||
|
virtual int peerSortValue() const;
|
||||||
|
|
||||||
|
void removeFromList();
|
||||||
|
Tomahawk::ViewPage* page() const { return m_page; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tomahawk::ViewPage* m_page;
|
||||||
|
QIcon m_icon;
|
||||||
|
int m_sortValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEMPORARYPAGEITEM_H
|
@@ -50,7 +50,8 @@ public:
|
|||||||
AutomaticPlaylist = 4,
|
AutomaticPlaylist = 4,
|
||||||
Station = 5,
|
Station = 5,
|
||||||
|
|
||||||
GenericPage = 6
|
GenericPage = 6,
|
||||||
|
TemporaryPage = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CategoryType {
|
enum CategoryType {
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "items/genericpageitems.h"
|
#include "items/genericpageitems.h"
|
||||||
|
#include "items/temporarypageitem.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -698,12 +699,12 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
{
|
{
|
||||||
QStyledItemDelegate::paint( painter, o, index );
|
QStyledItemDelegate::paint( painter, o, index );
|
||||||
|
|
||||||
if ( type == SourcesModel::GenericPage )
|
if ( type == SourcesModel::TemporaryPage )
|
||||||
{
|
{
|
||||||
GenericPageItem* gpi = qobject_cast< GenericPageItem* >( item );
|
TemporaryPageItem* gpi = qobject_cast< TemporaryPageItem* >( item );
|
||||||
Q_ASSERT( gpi );
|
Q_ASSERT( gpi );
|
||||||
|
|
||||||
if ( gpi->isTempItem() && o3.state & QStyle::State_MouseOver )
|
if ( gpi && o3.state & QStyle::State_MouseOver )
|
||||||
{
|
{
|
||||||
// draw close icon
|
// draw close icon
|
||||||
int padding = 3;
|
int padding = 3;
|
||||||
@@ -745,24 +746,19 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
|
|||||||
if ( event->type() == QEvent::MouseButtonRelease )
|
if ( event->type() == QEvent::MouseButtonRelease )
|
||||||
{
|
{
|
||||||
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
||||||
if ( type == SourcesModel::GenericPage )
|
if ( type == SourcesModel::TemporaryPage )
|
||||||
{
|
{
|
||||||
GenericPageItem* gpi = qobject_cast< GenericPageItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
TemporaryPageItem* gpi = qobject_cast< TemporaryPageItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||||
Q_ASSERT( gpi );
|
Q_ASSERT( gpi );
|
||||||
if ( gpi->isTempItem() )
|
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||||
{
|
|
||||||
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
|
||||||
|
|
||||||
QStyleOptionViewItemV4 o = option;
|
QStyleOptionViewItemV4 o = option;
|
||||||
initStyleOption( &o, index );
|
initStyleOption( &o, index );
|
||||||
int padding = 3;
|
int padding = 3;
|
||||||
QRect r ( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );
|
QRect r ( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );
|
||||||
|
|
||||||
if ( r.contains( ev->pos() ) )
|
if ( r.contains( ev->pos() ) )
|
||||||
{
|
gpi->removeFromList();
|
||||||
gpi->deleteTempPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user