1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-10 14:10:42 +02:00

Compare commits

...

33 Commits

Author SHA1 Message Date
Uwe L. Korn
92811215a5 Revert "Miscellaneous cppcheck fixes" 2014-10-20 17:49:15 +02:00
Uwe L. Korn
c1d99b4868 Merge pull request #268 from lorenzhs/misc-fixes
Miscellaneous cppcheck fixes
2014-10-20 17:48:06 +02:00
Lorenz Hübschle-Schneider
8bb14cc26c Unsigned comparison <= 0 is identical to check for 0 2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
d74c465e58 Remove break after return, it is redundant 2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
69653c4934 Reduce variable scopes 2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
46239947f5 Servent: Fix IP protocol version distinction
Uwe failed at C&P!
2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
eee50b2f93 Remove dead code
Q_ASSERT(Compiler isn't a total moron);
2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
655edf3e98 Catch exception by reference 2014-10-20 17:41:55 +02:00
Lorenz Hübschle-Schneider
45e6d52db7 DropJob: don't touch iterator after erasing element
Also drops a redundant condition
2014-10-20 17:05:17 +02:00
Jason Herskowitz
b6dd736fea Add white icon for use with dark menu option in Yosemite 2014-10-19 22:46:05 -04:00
Christian Muehlhaeuser
0229746f8b Don't create (multiple) layouts with same parent in AccountWidget. 2014-10-20 04:47:39 +02:00
Christian Muehlhaeuser
ea18ab891f Don't pass parent widget in constructor. We call setLayout later. 2014-10-20 04:43:18 +02:00
Christian Muehlhaeuser
906285e442 pngcrush images. 2014-10-20 04:23:01 +02:00
Christian Muehlhaeuser
0812855b60 Store model pointers in a QPointer for safety. 2014-10-20 03:51:38 +02:00
Christian Muehlhaeuser
5e2253881f Correct warning message in ColumnView. 2014-10-20 03:49:56 +02:00
Christian Muehlhaeuser
e9c7fd7a16 Reload Collection-related models when it changed. 2014-10-20 03:49:23 +02:00
Christian Muehlhaeuser
1a6a15844b Removed old SuperCollection related methods in TreeModel. 2014-10-20 03:47:59 +02:00
Christian Muehlhaeuser
8dd8c77610 Cleaned up CollectionViewPage ctor and removed obsoleted code. 2014-10-20 03:11:58 +02:00
Christian Muehlhaeuser
16a3e9eccb Removed a bunch of unneeded code from CollectionViewPage. 2014-10-20 02:56:17 +02:00
Christian Muehlhaeuser
225d5764e7 CollectionViewPage should do all the grunt work. Pass the collection_ptr to its ctor. 2014-10-20 02:49:11 +02:00
Christian Muehlhaeuser
44ffefb1fb Hide composer column per default and removed obsoleted code from CollectionViewPage. 2014-10-20 02:35:34 +02:00
Christian Muehlhaeuser
1d3d8001a4 Removed obsolete extraHeader from CollectionViewPage. 2014-10-20 02:34:46 +02:00
Christian Muehlhaeuser
29ba03444b Remove redundant boost include. 2014-10-20 02:34:00 +02:00
Christian Muehlhaeuser
51fe1aa0df Renamed and moved FlexibleTreeView to CollectionViewPage. 2014-10-20 02:20:52 +02:00
Jason Herskowitz
5d9b42182b Make progress bar match the red of the Tomahawk logo - #ff004c 2014-10-19 13:19:16 -04:00
Christian Muehlhaeuser
01534d222f Drop the multiple versions of the empty-collection hint. 2014-10-19 10:40:22 +02:00
Christian Muehlhaeuser
8a58114f73 Create IndexStatusManager in JobStatusView. 2014-10-19 10:21:47 +02:00
Christian Muehlhaeuser
a8642a687f Added IndexStatusManager, which observes indexing progress and creates a job-item accordingly. 2014-10-19 10:21:18 +02:00
Christian Muehlhaeuser
fb66be9746 Added missing GPL headers. 2014-10-19 10:19:59 +02:00
Christian Muehlhaeuser
22a58b7e21 Don't create JobStatusItem in DatabaseCommand. 2014-10-19 10:19:39 +02:00
Christian Muehlhaeuser
f55ff6f13b Emit signal when indexing starts. 2014-10-19 10:18:49 +02:00
Christian Muehlhaeuser
af0b14b728 Removed dupe collection background image. 2014-10-18 14:57:03 +02:00
Christian Muehlhaeuser
99f6330b95 0.8.0rc1 2014-10-17 21:51:35 +02:00
42 changed files with 241 additions and 276 deletions

View File

@@ -33,8 +33,8 @@ ENDIF()
SET( TOMAHAWK_VERSION_MAJOR 0 ) SET( TOMAHAWK_VERSION_MAJOR 0 )
SET( TOMAHAWK_VERSION_MINOR 8 ) SET( TOMAHAWK_VERSION_MINOR 8 )
SET( TOMAHAWK_VERSION_PATCH 99 ) SET( TOMAHAWK_VERSION_PATCH 0 )
#SET( TOMAHAWK_VERSION_RC 0 ) SET( TOMAHAWK_VERSION_RC 1 )
SET( TOMAHAWK_TRANSLATION_LANGUAGES ar bg bn_IN ca cs de en el es fi fr hi_IN hu gl it ja lt pl pt_BR ro ru sv tr zh_CN zh_TW ) SET( TOMAHAWK_TRANSLATION_LANGUAGES ar bg bn_IN ca cs de en el es fi fr hi_IN hu gl it ja lt pl pt_BR ro ru sv tr zh_CN zh_TW )

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 893 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 KiB

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 KiB

After

Width:  |  Height:  |  Size: 507 KiB

View File

@@ -1,7 +1,6 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>data/images/collection_background.png</file> <file>data/images/collection_background.png</file>
<file>data/images/collection_background_small.png</file>
<file>data/images/playlist_background.png</file> <file>data/images/playlist_background.png</file>
<file>data/images/filter.svg</file> <file>data/images/filter.svg</file>
<file>data/images/loved.svg</file> <file>data/images/loved.svg</file>
@@ -162,5 +161,6 @@
<file>data/images/copy.svg</file> <file>data/images/copy.svg</file>
<file>data/icons/tomahawk-icon-1024x1024.png</file> <file>data/icons/tomahawk-icon-1024x1024.png</file>
<file>data/images/plugins.svg</file> <file>data/images/plugins.svg</file>
<file>data/icons/tomahawk-white-icon-128x128.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -38,7 +38,6 @@ set( libGuiSources
playlist/InboxModel.cpp playlist/InboxModel.cpp
playlist/InboxView.cpp playlist/InboxView.cpp
playlist/ContextView.cpp playlist/ContextView.cpp
playlist/FlexibleTreeView.cpp
playlist/TreeModel.cpp playlist/TreeModel.cpp
playlist/TreeProxyModel.cpp playlist/TreeProxyModel.cpp
playlist/TreeProxyModelPlaylistInterface.cpp playlist/TreeProxyModelPlaylistInterface.cpp
@@ -121,6 +120,7 @@ set( libGuiSources
viewpages/AlbumViewPage.cpp viewpages/AlbumViewPage.cpp
viewpages/TrackViewPage.cpp viewpages/TrackViewPage.cpp
viewpages/PlaylistViewPage.cpp viewpages/PlaylistViewPage.cpp
viewpages/CollectionViewPage.cpp
widgets/AnimatedSplitter.cpp widgets/AnimatedSplitter.cpp
widgets/BasicHeader.cpp widgets/BasicHeader.cpp

View File

@@ -27,7 +27,6 @@
#include "audio/AudioEngine.h" #include "audio/AudioEngine.h"
#include "playlist/ContextView.h" #include "playlist/ContextView.h"
#include "playlist/FlexibleTreeView.h"
#include "playlist/TreeModel.h" #include "playlist/TreeModel.h"
#include "playlist/PlaylistModel.h" #include "playlist/PlaylistModel.h"
#include "playlist/TrackView.h" #include "playlist/TrackView.h"
@@ -42,13 +41,12 @@
#include "playlist/RecentlyPlayedModel.h" #include "playlist/RecentlyPlayedModel.h"
#include "playlist/dynamic/widgets/DynamicWidget.h" #include "playlist/dynamic/widgets/DynamicWidget.h"
#include "resolvers/ScriptCollection.h"
#include "viewpages/PlaylistViewPage.h" #include "viewpages/PlaylistViewPage.h"
#include "viewpages/SourceViewPage.h" #include "viewpages/SourceViewPage.h"
#include "viewpages/ArtistViewPage.h" #include "viewpages/ArtistViewPage.h"
#include "viewpages/AlbumViewPage.h" #include "viewpages/AlbumViewPage.h"
#include "viewpages/TrackViewPage.h" #include "viewpages/TrackViewPage.h"
#include "viewpages/CollectionViewPage.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
@@ -261,32 +259,12 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
{ {
m_currentCollection = collection; m_currentCollection = collection;
FlexibleTreeView* view; CollectionViewPage* view;
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() ) if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
{ {
view = new FlexibleTreeView(); view = new CollectionViewPage( collection );
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel();
view->setTreeModel( model );
view->setFlatModel( flatModel );
view->setAlbumModel( albumModel );
model->addCollection( collection );
flatModel->appendTracks( collection );
albumModel->appendAlbums( collection );
setPage( view ); setPage( view );
if ( !collection.isNull() )
view->setEmptyTip( collection->emptyText() );
if ( collection.objectCast<ScriptCollection>() )
view->trackView()->setEmptyTip( tr( "Cloud collections aren't supported in the flat view yet. We will have them covered soon. Switch to another view to navigate them." ) );
m_collectionViews.insert( collection, view ); m_collectionViews.insert( collection, view );
} }
else else

View File

@@ -42,7 +42,7 @@ class AlbumInfoWidget;
class ArtistInfoWidget; class ArtistInfoWidget;
class CollectionModel; class CollectionModel;
class PlaylistViewPage; class PlaylistViewPage;
class FlexibleTreeView; class CollectionViewPage;
class PlaylistModel; class PlaylistModel;
class TrackProxyModel; class TrackProxyModel;
class TrackModel; class TrackModel;
@@ -164,7 +164,7 @@ private:
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders; QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets; QHash< Tomahawk::dynplaylist_ptr, QPointer<Tomahawk::DynamicWidget> > m_dynamicWidgets;
QHash< Tomahawk::collection_ptr, QPointer<FlexibleTreeView> > m_collectionViews; QHash< Tomahawk::collection_ptr, QPointer<CollectionViewPage> > m_collectionViews;
QHash< Tomahawk::artist_ptr, QPointer<ArtistInfoWidget> > m_artistViews; QHash< Tomahawk::artist_ptr, QPointer<ArtistInfoWidget> > m_artistViews;
QHash< Tomahawk::album_ptr, QPointer<AlbumInfoWidget> > m_albumViews; QHash< Tomahawk::album_ptr, QPointer<AlbumInfoWidget> > m_albumViews;
QHash< Tomahawk::query_ptr, QPointer<TrackInfoWidget> > m_trackViews; QHash< Tomahawk::query_ptr, QPointer<TrackInfoWidget> > m_trackViews;

View File

@@ -98,13 +98,6 @@ Collection::bigIcon() const
} }
QString
Collection::emptyText() const
{
return tr( "This collection is empty." );
}
const const
source_ptr& Collection::source() const source_ptr& Collection::source() const
{ {

View File

@@ -67,7 +67,6 @@ public:
virtual BackendType backendType() const { return NullCollectionType; } virtual BackendType backendType() const { return NullCollectionType; }
virtual QIcon icon() const; virtual QIcon icon() const;
virtual QPixmap bigIcon() const; //for the ViewPage header virtual QPixmap bigIcon() const; //for the ViewPage header
virtual QString emptyText() const;
virtual void loadPlaylists(); virtual void loadPlaylists();
virtual void loadAutoPlaylists(); virtual void loadAutoPlaylists();

View File

@@ -119,6 +119,7 @@ Database::Database( const QString& dbname, QObject* parent )
tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads"; tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads";
connect( m_impl, SIGNAL( indexReady() ), SLOT( markAsReady() ) ); connect( m_impl, SIGNAL( indexReady() ), SLOT( markAsReady() ) );
connect( m_impl, SIGNAL( indexStarted() ), SIGNAL( indexStarted() ) );
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) ); connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
Q_ASSERT( m_workerRW ); Q_ASSERT( m_workerRW );

View File

@@ -101,7 +101,8 @@ public:
} }
signals: signals:
void indexReady(); // search index void indexStarted();
void indexReady();
void ready(); void ready();
void newJobRO( Tomahawk::dbcmd_ptr ); void newJobRO( Tomahawk::dbcmd_ptr );

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012 Leo Franchi <lfranchi@kde.org> * Copyright 2012 Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -26,9 +26,6 @@
#include "TomahawkSqlQuery.h" #include "TomahawkSqlQuery.h"
#include "fuzzyindex/DatabaseFuzzyIndex.h" #include "fuzzyindex/DatabaseFuzzyIndex.h"
#include "jobview/IndexingJobItem.h"
#include "jobview/JobStatusView.h"
#include "jobview/JobStatusModel.h"
#include "utils/Logger.h" #include "utils/Logger.h"
namespace Tomahawk namespace Tomahawk
@@ -36,22 +33,14 @@ namespace Tomahawk
DatabaseCommand_UpdateSearchIndex::DatabaseCommand_UpdateSearchIndex() DatabaseCommand_UpdateSearchIndex::DatabaseCommand_UpdateSearchIndex()
: DatabaseCommand() : DatabaseCommand()
, m_statusJob( new IndexingJobItem )
{ {
tLog() << Q_FUNC_INFO << "Updating index."; tDebug() << Q_FUNC_INFO << "Updating index.";
JobStatusView::addJob( m_statusJob );
} }
DatabaseCommand_UpdateSearchIndex::~DatabaseCommand_UpdateSearchIndex() DatabaseCommand_UpdateSearchIndex::~DatabaseCommand_UpdateSearchIndex()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
if ( ! m_statusJob.isNull() )
{
m_statusJob.data()->done();
}
} }

View File

@@ -23,8 +23,6 @@
#include "DllMacro.h" #include "DllMacro.h"
#include <QPointer> #include <QPointer>
class IndexingJobItem;
namespace Tomahawk namespace Tomahawk
{ {
@@ -47,9 +45,6 @@ public:
virtual QString commandname() const { return "updatesearchindex"; } virtual QString commandname() const { return "updatesearchindex"; }
virtual bool doesMutates() const { return true; } virtual bool doesMutates() const { return true; }
virtual void exec( DatabaseImpl* db ); virtual void exec( DatabaseImpl* db );
private:
QPointer<IndexingJobItem> m_statusJob;
}; };
} }

View File

@@ -199,6 +199,7 @@ Tomahawk::DatabaseImpl::dumpDatabase()
void void
Tomahawk::DatabaseImpl::loadIndex() Tomahawk::DatabaseImpl::loadIndex()
{ {
connect( m_fuzzyIndex, SIGNAL( indexStarted() ), SIGNAL( indexStarted() ) );
connect( m_fuzzyIndex, SIGNAL( indexReady() ), SIGNAL( indexReady() ) ); connect( m_fuzzyIndex, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
m_fuzzyIndex->loadLuceneIndex(); m_fuzzyIndex->loadLuceneIndex();
} }

View File

@@ -86,7 +86,9 @@ public:
void loadIndex(); void loadIndex();
signals: signals:
void indexStarted();
void indexReady(); void indexReady();
void schemaUpdateStarted(); void schemaUpdateStarted();
void schemaUpdateStatus( const QString& message ); void schemaUpdateStatus( const QString& message );
void schemaUpdateDone(); void schemaUpdateDone();

View File

@@ -1,7 +1,6 @@
/* /*
Copyright (C) 2011 Leo Franchi <lfranchi@kde.org> Copyright (C) 2011 Leo Franchi <lfranchi@kde.org>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
@@ -42,10 +41,3 @@ LocalCollection::prettyName() const
{ {
return tr( "Your Collection" ); return tr( "Your Collection" );
} }
QString
LocalCollection::emptyText() const
{
return tr( "After you have scanned your music collection you will find your tracks right here." );
}

View File

@@ -34,7 +34,6 @@ public:
explicit LocalCollection( const Tomahawk::source_ptr& source, QObject* parent = 0 ); explicit LocalCollection( const Tomahawk::source_ptr& source, QObject* parent = 0 );
virtual QString prettyName() const; virtual QString prettyName() const;
virtual QString emptyText() const;
}; };
} }

View File

@@ -1,3 +1,21 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-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 "DatabaseFuzzyIndex.h" #include "DatabaseFuzzyIndex.h"
#include "database/DatabaseImpl.h" #include "database/DatabaseImpl.h"
@@ -8,7 +26,6 @@ namespace Tomahawk {
DatabaseFuzzyIndex::DatabaseFuzzyIndex( QObject* parent, bool wipe ) DatabaseFuzzyIndex::DatabaseFuzzyIndex( QObject* parent, bool wipe )
: FuzzyIndex( parent, "tomahawk.lucene", wipe ) : FuzzyIndex( parent, "tomahawk.lucene", wipe )
{ {
} }

View File

@@ -1,3 +1,21 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-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 TOMAHAWK_DATABASEFUZZYINDEX_H #ifndef TOMAHAWK_DATABASEFUZZYINDEX_H
#define TOMAHAWK_DATABASEFUZZYINDEX_H #define TOMAHAWK_DATABASEFUZZYINDEX_H

View File

@@ -94,6 +94,7 @@ FuzzyIndex::updateIndexSlot()
void void
FuzzyIndex::beginIndexing() FuzzyIndex::beginIndexing()
{ {
emit indexStarted();
m_mutex.lock(); m_mutex.lock();
try try

View File

@@ -52,6 +52,7 @@ public:
virtual void updateIndex(); virtual void updateIndex();
signals: signals:
void indexStarted();
void indexReady(); void indexReady();
public slots: public slots:

View File

@@ -18,7 +18,11 @@
#include "IndexingJobItem.h" #include "IndexingJobItem.h"
#include "JobStatusModel.h"
#include "JobStatusView.h"
#include "database/Database.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include <QPixmap> #include <QPixmap>
@@ -29,16 +33,40 @@ IndexingJobItem::mainText() const
return tr( "Indexing Music Library" ); return tr( "Indexing Music Library" );
} }
QPixmap QPixmap
IndexingJobItem::icon() const IndexingJobItem::icon() const
{ {
return TomahawkUtils::defaultPixmap( TomahawkUtils::ViewRefresh, TomahawkUtils::Original, QSize( 128, 128 ) ); return TomahawkUtils::defaultPixmap( TomahawkUtils::ViewRefresh, TomahawkUtils::Original, QSize( 128, 128 ) );
} }
void IndexingJobItem::done() void
IndexingJobItem::done()
{ {
emit finished(); emit finished();
} }
IndexStatusManager::IndexStatusManager( QObject* parent )
: QObject( parent )
{
connect( Tomahawk::Database::instance(), SIGNAL( indexStarted() ), SLOT( started() ) );
connect( Tomahawk::Database::instance(), SIGNAL( indexReady() ), SLOT( finished() ) );
}
void
IndexStatusManager::started()
{
m_curItem = new IndexingJobItem;
JobStatusView::instance()->model()->addJob( m_curItem.data() );
}
void
IndexStatusManager::finished()
{
if ( m_curItem )
m_curItem->done();
}

View File

@@ -19,8 +19,9 @@
#ifndef INDEXINGJOBITEM_H #ifndef INDEXINGJOBITEM_H
#define INDEXINGJOBITEM_H #define INDEXINGJOBITEM_H
#include <jobview/JobStatusItem.h> #include "JobStatusItem.h"
#include <QPointer>
class IndexingJobItem : public JobStatusItem class IndexingJobItem : public JobStatusItem
{ {
@@ -37,4 +38,19 @@ public:
virtual QString type() const { return "indexerjob"; } virtual QString type() const { return "indexerjob"; }
}; };
class IndexStatusManager : public QObject
{
Q_OBJECT
public:
explicit IndexStatusManager( QObject* parent = 0 );
virtual ~IndexStatusManager() {}
private slots:
void started();
void finished();
private:
QPointer<IndexingJobItem> m_curItem;
};
#endif // INDEXINGJOBITEM_H #endif // INDEXINGJOBITEM_H

View File

@@ -1,6 +1,6 @@
/* === 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-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org> * Copyright 2011, Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -26,6 +26,7 @@
#include "JobStatusDelegate.h" #include "JobStatusDelegate.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "Source.h" #include "Source.h"
#include "IndexingJobItem.h"
#include "PipelineStatusItem.h" #include "PipelineStatusItem.h"
#include "TransferStatusItem.h" #include "TransferStatusItem.h"
#include "LatchedStatusItem.h" #include "LatchedStatusItem.h"
@@ -92,6 +93,7 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
m_view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_view->setUniformItemSizes( false ); m_view->setUniformItemSizes( false );
new IndexStatusManager( this );
new PipelineStatusManager( this ); new PipelineStatusManager( this );
new TransferStatusManager( this ); new TransferStatusManager( this );
new LatchedStatusManager( this ); new LatchedStatusManager( this );

View File

@@ -110,7 +110,7 @@ void
ColumnView::setModel( QAbstractItemModel* model ) ColumnView::setModel( QAbstractItemModel* model )
{ {
Q_UNUSED( model ); Q_UNUSED( model );
tDebug() << "Explicitly use setPlaylistModel instead"; tDebug() << "Explicitly use setTreeModel instead";
Q_ASSERT( false ); Q_ASSERT( false );
} }

View File

@@ -50,7 +50,7 @@ ContextView::ContextView( QWidget* parent, const QString& caption )
m_trackView->proxyModel()->setStyle( PlayableProxyModel::Fancy ); m_trackView->proxyModel()->setStyle( PlayableProxyModel::Fancy );
TomahawkStyle::styleScrollBar( m_trackView->verticalScrollBar() ); TomahawkStyle::styleScrollBar( m_trackView->verticalScrollBar() );
setLayout( new QVBoxLayout( this ) ); setLayout( new QVBoxLayout() );
TomahawkUtils::unmarginLayout( layout() ); TomahawkUtils::unmarginLayout( layout() );
m_trackView->setStyleSheet( QString( "QTreeView { background-color: white; }" ) ); m_trackView->setStyleSheet( QString( "QTreeView { background-color: white; }" ) );
@@ -63,7 +63,7 @@ ContextView::ContextView( QWidget* parent, const QString& caption )
vbox->setPalette( pal ); vbox->setPalette( pal );
vbox->setAutoFillBackground( true ); vbox->setAutoFillBackground( true );
QVBoxLayout* vboxl = new QVBoxLayout( this ); QVBoxLayout* vboxl = new QVBoxLayout();
TomahawkUtils::unmarginLayout( vboxl ); TomahawkUtils::unmarginLayout( vboxl );
vboxl->setContentsMargins( 32, 32, 32, 32 ); vboxl->setContentsMargins( 32, 32, 32, 32 );
vboxl->setSpacing( 32 ); vboxl->setSpacing( 32 );
@@ -71,11 +71,11 @@ ContextView::ContextView( QWidget* parent, const QString& caption )
vbox->setLayout( vboxl ); vbox->setLayout( vboxl );
QWidget* hbox = new QWidget; QWidget* hbox = new QWidget;
QHBoxLayout* hboxl = new QHBoxLayout( this ); QHBoxLayout* hboxl = new QHBoxLayout();
TomahawkUtils::unmarginLayout( hboxl ); TomahawkUtils::unmarginLayout( hboxl );
hboxl->setSpacing( 32 ); hboxl->setSpacing( 32 );
m_innerLayout = new QVBoxLayout( this ); m_innerLayout = new QVBoxLayout();
TomahawkUtils::unmarginLayout( m_innerLayout ); TomahawkUtils::unmarginLayout( m_innerLayout );
m_innerLayout->addWidget( m_trackView, 1 ); m_innerLayout->addWidget( m_trackView, 1 );
m_innerLayout->addStretch(); m_innerLayout->addStretch();

View File

@@ -566,3 +566,10 @@ GridView::onScrollTimeout()
m_proxyModel->updateDetailedInfo( m_proxyModel->index( i, 0 ) ); m_proxyModel->updateDetailedInfo( m_proxyModel->index( i, 0 ) );
} }
} }
PlayableModel*
GridView::model() const
{
return m_model.data();
}

View File

@@ -52,7 +52,7 @@ public:
void setProxyModel( PlayableProxyModel* model ); void setProxyModel( PlayableProxyModel* model );
PlayableModel* model() const { return m_model; } PlayableModel* model() const;
PlayableProxyModel* proxyModel() const { return m_proxyModel; } PlayableProxyModel* proxyModel() const { return m_proxyModel; }
GridItemDelegate* delegate() const { return m_delegate; } GridItemDelegate* delegate() const { return m_delegate; }
@@ -117,7 +117,7 @@ private slots:
void verifySize(); void verifySize();
private: private:
PlayableModel* m_model; QPointer<PlayableModel> m_model;
PlayableProxyModel* m_proxyModel; PlayableProxyModel* m_proxyModel;
GridItemDelegate* m_delegate; GridItemDelegate* m_delegate;
AnimatedSpinner* m_loadingSpinner; AnimatedSpinner* m_loadingSpinner;

View File

@@ -137,7 +137,7 @@ private:
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const; bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const; bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
PlayableModel* m_model; QPointer<PlayableModel> m_model;
bool m_showOfflineResults; bool m_showOfflineResults;
bool m_hideEmptyParents; bool m_hideEmptyParents;

View File

@@ -27,8 +27,6 @@
#include <QPainter> #include <QPainter>
#include <QToolTip> #include <QToolTip>
#include <boost/concept_check.hpp>
#include "Query.h" #include "Query.h"
#include "Result.h" #include "Result.h"
#include "Artist.h" #include "Artist.h"
@@ -673,7 +671,7 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
{ {
painter->save(); painter->save();
painter->setPen( Qt::transparent ); painter->setPen( Qt::transparent );
painter->setBrush( Qt::darkRed ); painter->setBrush( QColor( "#ff004c" ));
QRect playBar = r.adjusted( 0, r.height() + 2, 0, 0 ); QRect playBar = r.adjusted( 0, r.height() + 2, 0, 0 );
playBar.setHeight( 2 ); playBar.setHeight( 2 );

View File

@@ -941,3 +941,10 @@ TrackView::selectFirstTrack()
currentChanged( idx, QModelIndex() ); currentChanged( idx, QModelIndex() );
} }
} }
PlayableModel*
TrackView::model() const
{
return m_model.data();
}

View File

@@ -53,7 +53,7 @@ public:
virtual void setModel( QAbstractItemModel* model ); virtual void setModel( QAbstractItemModel* model );
void setProxyModel( PlayableProxyModel* model ); void setProxyModel( PlayableProxyModel* model );
virtual PlayableModel* model() const { return m_model; } virtual PlayableModel* model() const;
PlayableProxyModel* proxyModel() const { return m_proxyModel; } PlayableProxyModel* proxyModel() const { return m_proxyModel; }
PlaylistItemDelegate* delegate() const { return m_delegate; } PlaylistItemDelegate* delegate() const { return m_delegate; }
ViewHeader* header() const { return m_header; } ViewHeader* header() const { return m_header; }
@@ -143,7 +143,7 @@ private:
void updateHoverIndex( const QPoint& pos ); void updateHoverIndex( const QPoint& pos );
QString m_guid; QString m_guid;
PlayableModel* m_model; QPointer<PlayableModel> m_model;
PlayableProxyModel* m_proxyModel; PlayableProxyModel* m_proxyModel;
PlaylistItemDelegate* m_delegate; PlaylistItemDelegate* m_delegate;
ViewHeader* m_header; ViewHeader* m_header;

View File

@@ -131,30 +131,6 @@ TreeModel::fetchMore( const QModelIndex& parent )
} }
void
TreeModel::addAllCollections()
{
startLoading();
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists();
connect( cmd, SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
SLOT( onArtistsAdded( QList<Tomahawk::artist_ptr> ) ) );
Database::instance()->enqueue( Tomahawk::dbcmd_ptr( cmd ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::UniqueConnection );
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
foreach ( const source_ptr& source, sources )
{
connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
}
setTitle( tr( "All Artists" ) );
}
void void
TreeModel::addArtists( const artist_ptr& artist ) TreeModel::addArtists( const artist_ptr& artist )
{ {
@@ -262,25 +238,12 @@ TreeModel::addCollection( const collection_ptr& collection )
this, SLOT( onArtistsAdded( QList< Tomahawk::artist_ptr > ) ), Qt::UniqueConnection ); this, SLOT( onArtistsAdded( QList< Tomahawk::artist_ptr > ) ), Qt::UniqueConnection );
req->enqueue(); req->enqueue();
connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
setIcon( collection->bigIcon() ); setIcon( collection->bigIcon() );
setTitle( collection->prettyName() ); setTitle( collection->prettyName() );
setDescription( collection->description() ); setDescription( collection->description() );
} }
void
TreeModel::reloadCollection()
{
if ( m_collection.isNull() )
return;
if ( !isLoading() )
onCollectionChanged();
}
//void //void
//TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order ) //TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order )
//{ //{
@@ -305,25 +268,6 @@ TreeModel::reloadCollection()
//} //}
void
TreeModel::onSourceAdded( const Tomahawk::source_ptr& source )
{
connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
}
void
TreeModel::onCollectionChanged()
{
clear();
if ( m_collection )
addCollection( m_collection );
else
addAllCollections();
}
void void
TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists ) TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
{ {

View File

@@ -51,7 +51,6 @@ public:
Tomahawk::collection_ptr collection() const; Tomahawk::collection_ptr collection() const;
void addAllCollections();
void addCollection( const Tomahawk::collection_ptr& collection ); void addCollection( const Tomahawk::collection_ptr& collection );
//TODO: Unused, but will be useful for supporting filtered queries. - Teo 1/2013 //TODO: Unused, but will be useful for supporting filtered queries. - Teo 1/2013
//void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order ); //void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
@@ -71,7 +70,6 @@ public:
public slots: public slots:
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums ); void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
void reloadCollection();
signals: signals:
void modeChanged( Tomahawk::ModelMode mode ); void modeChanged( Tomahawk::ModelMode mode );
@@ -86,9 +84,6 @@ private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index ); void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection ); void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection );
void onSourceAdded( const Tomahawk::source_ptr& source );
void onCollectionChanged();
private: private:
Tomahawk::ModelMode m_mode; Tomahawk::ModelMode m_mode;
Tomahawk::collection_ptr m_collection; Tomahawk::collection_ptr m_collection;

View File

@@ -45,7 +45,7 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
void void
TreeProxyModel::setSourcePlayableModel( TreeModel* model ) TreeProxyModel::setSourcePlayableModel( TreeModel* model )
{ {
if ( sourceModel() ) if ( m_model )
{ {
disconnect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( onRowsInserted( QModelIndex, int, int ) ) ); disconnect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( onRowsInserted( QModelIndex, int, int ) ) );
disconnect( m_model, SIGNAL( modelReset() ), this, SLOT( onModelReset() ) ); disconnect( m_model, SIGNAL( modelReset() ), this, SLOT( onModelReset() ) );
@@ -54,7 +54,7 @@ TreeProxyModel::setSourcePlayableModel( TreeModel* model )
PlayableProxyModel::setSourcePlayableModel( model ); PlayableProxyModel::setSourcePlayableModel( model );
m_model = model; m_model = model;
if ( sourceModel() ) if ( m_model )
{ {
connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) ); connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) );
connect( m_model, SIGNAL( modelReset() ), SLOT( onModelReset() ) ); connect( m_model, SIGNAL( modelReset() ), SLOT( onModelReset() ) );

View File

@@ -78,7 +78,7 @@ private:
Tomahawk::ArtistsRequest* m_artistsFilterCmd; Tomahawk::ArtistsRequest* m_artistsFilterCmd;
QString m_filter; QString m_filter;
TreeModel* m_model; QPointer<TreeModel> m_model;
}; };
#endif // TREEPROXYMODEL_H #endif // TREEPROXYMODEL_H

View File

@@ -17,7 +17,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "FlexibleTreeView.h" #include "CollectionViewPage.h"
#include <QRadioButton> #include <QRadioButton>
#include <QStackedWidget> #include <QStackedWidget>
@@ -29,7 +29,8 @@
#include "playlist/ColumnView.h" #include "playlist/ColumnView.h"
#include "playlist/TrackView.h" #include "playlist/TrackView.h"
#include "playlist/GridView.h" #include "playlist/GridView.h"
#include "PlayableProxyModelPlaylistInterface.h" #include "playlist/PlayableProxyModelPlaylistInterface.h"
#include "resolvers/ScriptCollection.h"
#include "TomahawkSettings.h" #include "TomahawkSettings.h"
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/TomahawkStyle.h" #include "utils/TomahawkStyle.h"
@@ -40,7 +41,7 @@
using namespace Tomahawk; using namespace Tomahawk;
FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader ) CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_header( new FilterHeader( this ) ) , m_header( new FilterHeader( this ) )
, m_columnView( new ColumnView() ) , m_columnView( new ColumnView() )
@@ -48,22 +49,16 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
, m_albumView( new GridView() ) , m_albumView( new GridView() )
, m_model( 0 ) , m_model( 0 )
, m_flatModel( 0 ) , m_flatModel( 0 )
, m_temporary( false ) , m_albumModel( 0 )
{ {
qRegisterMetaType< FlexibleTreeViewMode >( "FlexibleTreeViewMode" ); qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" );
m_header->setBackgroundColor( Qt::black ); m_header->setBackground( ImageRegistry::instance()->pixmap( RESPATH "images/collection_background.png", QSize( 0, 0 ) ), false );
m_header->setBackground( ImageRegistry::instance()->pixmap( RESPATH "images/collection_background_small.png", QSize( 0, 0 ) ), false );
setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultCollection, TomahawkUtils::Original, QSize( 256, 256 ) ) ); setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultCollection, TomahawkUtils::Original, QSize( 256, 256 ) ) );
// m_trackView->setPlaylistInterface( m_playlistInterface ); m_columnView->proxyModel()->setStyle( PlayableProxyModel::Collection );
// m_columnView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
// m_gridView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
/* m_columnView->setColumnHidden( PlayableModel::Age, true ); // Hide age column per default
m_columnView->setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default
m_columnView->setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default*/
m_trackView->setColumnHidden( PlayableModel::Composer, true );
m_trackView->setColumnHidden( PlayableModel::Origin, true ); m_trackView->setColumnHidden( PlayableModel::Origin, true );
m_trackView->setColumnHidden( PlayableModel::Score, true ); m_trackView->setColumnHidden( PlayableModel::Score, true );
m_trackView->setGuid( QString( "trackview/flat" ) ); m_trackView->setGuid( QString( "trackview/flat" ) );
@@ -71,7 +66,6 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
{ {
m_albumView->setAutoResize( false ); m_albumView->setAutoResize( false );
m_albumView->setAutoFitItems( true ); m_albumView->setAutoFitItems( true );
// m_albumView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_albumView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_albumView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_albumView->setItemSize( QSize( 170, 170 + 56 ) ); m_albumView->setItemSize( QSize( 170, 170 + 56 ) );
@@ -105,14 +99,12 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
m_header->ui->anchor2Label->setFixedWidth( fm.width( m_header->ui->anchor2Label->text() ) + 16 ); m_header->ui->anchor2Label->setFixedWidth( fm.width( m_header->ui->anchor2Label->text() ) + 16 );
m_header->ui->anchor3Label->setFixedWidth( fm.width( m_header->ui->anchor3Label->text() ) + 16 ); m_header->ui->anchor3Label->setFixedWidth( fm.width( m_header->ui->anchor3Label->text() ) + 16 );
NewClosure( m_header->ui->anchor1Label, SIGNAL( clicked() ), const_cast< FlexibleTreeView* >( this ), SLOT( setCurrentMode( FlexibleTreeViewMode ) ), FlexibleTreeView::Columns )->setAutoDelete( false ); NewClosure( m_header->ui->anchor1Label, SIGNAL( clicked() ), const_cast< CollectionViewPage* >( this ), SLOT( setCurrentMode( CollectionViewPageMode ) ), CollectionViewPage::Columns )->setAutoDelete( false );
NewClosure( m_header->ui->anchor2Label, SIGNAL( clicked() ), const_cast< FlexibleTreeView* >( this ), SLOT( setCurrentMode( FlexibleTreeViewMode ) ), FlexibleTreeView::Albums )->setAutoDelete( false ); NewClosure( m_header->ui->anchor2Label, SIGNAL( clicked() ), const_cast< CollectionViewPage* >( this ), SLOT( setCurrentMode( CollectionViewPageMode ) ), CollectionViewPage::Albums )->setAutoDelete( false );
NewClosure( m_header->ui->anchor3Label, SIGNAL( clicked() ), const_cast< FlexibleTreeView* >( this ), SLOT( setCurrentMode( FlexibleTreeViewMode ) ), FlexibleTreeView::Flat )->setAutoDelete( false ); NewClosure( m_header->ui->anchor3Label, SIGNAL( clicked() ), const_cast< CollectionViewPage* >( this ), SLOT( setCurrentMode( CollectionViewPageMode ) ), CollectionViewPage::Flat )->setAutoDelete( false );
} }
layout()->addWidget( m_header ); layout()->addWidget( m_header );
if ( extraHeader )
layout()->addWidget( extraHeader );
layout()->addWidget( m_stack ); layout()->addWidget( m_stack );
m_stack->addWidget( m_columnView ); m_stack->addWidget( m_columnView );
@@ -120,108 +112,89 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader )
m_stack->addWidget( m_trackView ); m_stack->addWidget( m_trackView );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) ); connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
loadCollection( collection );
} }
FlexibleTreeView::~FlexibleTreeView() CollectionViewPage::~CollectionViewPage()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
} }
void void
FlexibleTreeView::setTrackView( TrackView* view ) CollectionViewPage::loadCollection( const collection_ptr& collection )
{ {
if ( m_trackView ) if ( m_collection )
{ {
m_stack->removeWidget( m_trackView ); disconnect( collection.data(), SIGNAL( changed() ), this, SLOT( onCollectionChanged() ) );
delete m_trackView;
} }
// view->setPlaylistInterface( m_playlistInterface ); m_collection = collection;
connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
m_trackView = view; onCollectionChanged();
m_stack->addWidget( view );
} }
void void
FlexibleTreeView::setColumnView( ColumnView* view ) CollectionViewPage::setTreeModel( TreeModel* model )
{ {
if ( m_columnView ) QPointer<PlayableModel> oldModel = m_model;
{
m_stack->removeWidget( m_columnView );
delete m_columnView;
}
connect( view, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
// view->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
m_columnView = view;
m_stack->addWidget( view );
}
void
FlexibleTreeView::setTreeModel( TreeModel* model )
{
if ( m_model )
{
disconnect( m_model, SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete m_model;
}
m_model = model; m_model = model;
// m_trackView->setPlayableModel( model );
m_columnView->setTreeModel( model ); m_columnView->setTreeModel( model );
/* m_trackView->setSortingEnabled( false );
m_trackView->sortByColumn( -1 );
m_trackView->proxyModel()->sort( -1 );
m_columnView->proxyModel()->sort( -1 );
m_gridView->proxyModel()->sort( -1 );*/
connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection ); connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
onModelChanged(); onModelChanged();
if ( oldModel )
{
disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete oldModel.data();
}
} }
void void
FlexibleTreeView::setFlatModel( PlayableModel* model ) CollectionViewPage::setFlatModel( PlayableModel* model )
{ {
if ( m_flatModel ) QPointer<PlayableModel> oldModel = m_flatModel;
{
// disconnect( m_flatModel, SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete m_flatModel;
}
m_flatModel = model; m_flatModel = model;
m_trackView->setPlayableModel( model ); m_trackView->setPlayableModel( model );
m_trackView->setSortingEnabled( true ); m_trackView->setSortingEnabled( true );
m_trackView->sortByColumn( 0, Qt::AscendingOrder ); m_trackView->sortByColumn( 0, Qt::AscendingOrder );
/* connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection ); if ( oldModel )
onModelChanged();*/ {
disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete oldModel.data();
}
} }
void void
FlexibleTreeView::setAlbumModel( PlayableModel* model ) CollectionViewPage::setAlbumModel( PlayableModel* model )
{ {
QPointer<PlayableModel> oldModel = m_albumModel;
if ( m_albumModel )
delete m_albumModel;
m_albumModel = model; m_albumModel = model;
m_albumView->setPlayableModel( model ); m_albumView->setPlayableModel( model );
/* connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection ); if ( oldModel )
* onModelChanged();*/ {
disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete oldModel.data();
}
} }
void void
FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode ) CollectionViewPage::setCurrentMode( CollectionViewPageMode mode )
{ {
if ( m_mode != mode ) if ( m_mode != mode )
{ {
@@ -289,35 +262,35 @@ FlexibleTreeView::setCurrentMode( FlexibleTreeViewMode mode )
Tomahawk::playlistinterface_ptr Tomahawk::playlistinterface_ptr
FlexibleTreeView::playlistInterface() const CollectionViewPage::playlistInterface() const
{ {
return m_columnView->proxyModel()->playlistInterface(); return m_columnView->proxyModel()->playlistInterface();
} }
QString QString
FlexibleTreeView::title() const CollectionViewPage::title() const
{ {
return m_model->title(); return m_model->title();
} }
QString QString
FlexibleTreeView::description() const CollectionViewPage::description() const
{ {
return m_model->description(); return m_model->description();
} }
QPixmap QPixmap
FlexibleTreeView::pixmap() const CollectionViewPage::pixmap() const
{ {
return m_pixmap; return m_pixmap;
} }
bool bool
FlexibleTreeView::jumpToCurrentTrack() CollectionViewPage::jumpToCurrentTrack()
{ {
tDebug() << Q_FUNC_INFO; tDebug() << Q_FUNC_INFO;
@@ -333,7 +306,7 @@ FlexibleTreeView::jumpToCurrentTrack()
bool bool
FlexibleTreeView::setFilter( const QString& pattern ) CollectionViewPage::setFilter( const QString& pattern )
{ {
ViewPage::setFilter( pattern ); ViewPage::setFilter( pattern );
@@ -346,27 +319,29 @@ FlexibleTreeView::setFilter( const QString& pattern )
void void
FlexibleTreeView::restoreViewMode() CollectionViewPage::restoreViewMode()
{ {
//FIXME: needs be moved to TomahawkSettings
TomahawkSettings::instance()->beginGroup( "ui" ); TomahawkSettings::instance()->beginGroup( "ui" );
int modeNumber = TomahawkSettings::instance()->value( "flexibleTreeViewMode", Columns ).toInt(); int modeNumber = TomahawkSettings::instance()->value( "flexibleTreeViewMode", Columns ).toInt();
m_mode = static_cast< FlexibleTreeViewMode >( modeNumber ); m_mode = static_cast< CollectionViewPageMode >( modeNumber );
TomahawkSettings::instance()->endGroup(); TomahawkSettings::instance()->endGroup();
setCurrentMode( (FlexibleTreeViewMode)modeNumber ); setCurrentMode( (CollectionViewPageMode)modeNumber );
} }
void void
FlexibleTreeView::setEmptyTip( const QString& tip ) CollectionViewPage::setEmptyTip( const QString& tip )
{ {
m_columnView->setEmptyTip( tip ); m_columnView->setEmptyTip( tip );
m_albumView->setEmptyTip( tip );
m_trackView->setEmptyTip( tip ); m_trackView->setEmptyTip( tip );
} }
void void
FlexibleTreeView::setPixmap( const QPixmap& pixmap, bool tinted ) CollectionViewPage::setPixmap( const QPixmap& pixmap, bool tinted )
{ {
m_pixmap = pixmap; m_pixmap = pixmap;
m_header->setPixmap( pixmap, tinted ); m_header->setPixmap( pixmap, tinted );
@@ -374,40 +349,50 @@ FlexibleTreeView::setPixmap( const QPixmap& pixmap, bool tinted )
void void
FlexibleTreeView::onModelChanged() CollectionViewPage::onModelChanged()
{ {
setPixmap( m_model->icon(), false ); setPixmap( m_model->icon(), false );
m_header->setCaption( m_model->title() ); m_header->setCaption( m_model->title() );
m_header->setDescription( m_model->description() ); m_header->setDescription( m_model->description() );
setEmptyTip( tr( "This collection is currently empty." ) );
} }
void void
FlexibleTreeView::onWidgetDestroyed( QWidget* widget ) CollectionViewPage::onCollectionChanged()
{ {
Q_UNUSED( widget ); TreeModel* model = new TreeModel();
emit destroyed( this ); PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel();
setTreeModel( model );
setFlatModel( flatModel );
setAlbumModel( albumModel );
model->addCollection( m_collection );
flatModel->appendTracks( m_collection );
albumModel->appendAlbums( m_collection );
if ( m_collection && m_collection->source() && m_collection->source()->isLocal() )
{
setEmptyTip( tr( "After you have scanned your music collection you will find your tracks right here." ) );
}
else
setEmptyTip( tr( "This collection is empty." ) );
if ( m_collection.objectCast<ScriptCollection>() )
m_trackView->setEmptyTip( tr( "Cloud collections aren't supported in the flat view yet. We will have them covered soon. Switch to another view to navigate them." ) );
} }
bool bool
FlexibleTreeView::isTemporaryPage() const CollectionViewPage::isTemporaryPage() const
{ {
return m_temporary; return false;
}
void
FlexibleTreeView::setTemporaryPage( bool b )
{
m_temporary = b;
} }
bool bool
FlexibleTreeView::isBeingPlayed() const CollectionViewPage::isBeingPlayed() const
{ {
if ( !playlistInterface() ) if ( !playlistInterface() )
return false; return false;

View File

@@ -17,8 +17,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FLEXIBLETREEVIEW_H #ifndef COLLECTIONVIEWPAGE_H
#define FLEXIBLETREEVIEW_H #define COLLECTIONVIEWPAGE_H
#include "ViewPage.h" #include "ViewPage.h"
#include "PlaylistInterface.h" #include "PlaylistInterface.h"
@@ -34,16 +34,16 @@ class PlayableModel;
class PlaylistModel; class PlaylistModel;
class FilterHeader; class FilterHeader;
class DLLEXPORT FlexibleTreeView : public QWidget, public Tomahawk::ViewPage class DLLEXPORT CollectionViewPage : public QWidget, public Tomahawk::ViewPage
{ {
Q_OBJECT Q_OBJECT
public: public:
enum FlexibleTreeViewMode enum CollectionViewPageMode
{ Columns = 0, Albums = 1, Flat = 2 }; { Columns = 0, Albums = 1, Flat = 2 };
explicit FlexibleTreeView( QWidget* parent = 0, QWidget* extraHeader = 0 ); explicit CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent = 0 );
~FlexibleTreeView(); ~CollectionViewPage();
virtual QWidget* widget() { return this; } virtual QWidget* widget() { return this; }
virtual Tomahawk::playlistinterface_ptr playlistInterface() const; virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
@@ -55,13 +55,6 @@ public:
virtual bool jumpToCurrentTrack(); virtual bool jumpToCurrentTrack();
virtual bool isTemporaryPage() const; virtual bool isTemporaryPage() const;
virtual bool isBeingPlayed() const; virtual bool isBeingPlayed() const;
void setTemporaryPage( bool b );
ColumnView* columnView() const { return m_columnView; }
TrackView* trackView() const { return m_trackView; }
void setColumnView( ColumnView* view );
void setTrackView( TrackView* view );
void setTreeModel( TreeModel* model ); void setTreeModel( TreeModel* model );
void setFlatModel( PlayableModel* model ); void setFlatModel( PlayableModel* model );
@@ -71,17 +64,19 @@ public:
void setEmptyTip( const QString& tip ); void setEmptyTip( const QString& tip );
public slots: public slots:
void setCurrentMode( FlexibleTreeViewMode mode ); void setCurrentMode( CollectionViewPageMode mode );
virtual bool setFilter( const QString& pattern ); virtual bool setFilter( const QString& pattern );
void restoreViewMode(); //ViewManager calls this on every show void restoreViewMode(); //ViewManager calls this on every show
void loadCollection( const Tomahawk::collection_ptr& collection );
signals: signals:
void modeChanged( FlexibleTreeViewMode mode ); void modeChanged( CollectionViewPageMode mode );
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
private slots: private slots:
void onModelChanged(); void onModelChanged();
void onWidgetDestroyed( QWidget* widget ); void onCollectionChanged();
private: private:
FilterHeader* m_header; FilterHeader* m_header;
@@ -96,10 +91,11 @@ private:
PlayableModel* m_albumModel; PlayableModel* m_albumModel;
QStackedWidget* m_stack; QStackedWidget* m_stack;
FlexibleTreeViewMode m_mode; Tomahawk::collection_ptr m_collection;
bool m_temporary;
CollectionViewPageMode m_mode;
}; };
Q_DECLARE_METATYPE( FlexibleTreeView::FlexibleTreeViewMode ); Q_DECLARE_METATYPE( CollectionViewPage::CollectionViewPageMode );
#endif // FLEXIBLETREEVIEW_H #endif // COLLECTIONVIEWPAGE_H

View File

@@ -46,7 +46,7 @@ AccountWidget::AccountWidget( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, TomahawkUtils::DpiScaler( this ) , TomahawkUtils::DpiScaler( this )
{ {
QHBoxLayout *mainLayout = new QHBoxLayout( this ); QHBoxLayout *mainLayout = new QHBoxLayout();
TomahawkUtils::unmarginLayout( mainLayout ); TomahawkUtils::unmarginLayout( mainLayout );
setLayout( mainLayout ); setLayout( mainLayout );
setContentsMargins( 0, scaledY( 8 ), 0, scaledY( 8 ) ); setContentsMargins( 0, scaledY( 8 ), 0, scaledY( 8 ) );
@@ -55,7 +55,7 @@ AccountWidget::AccountWidget( QWidget* parent )
mainLayout->addWidget( m_imageLabel ); mainLayout->addWidget( m_imageLabel );
mainLayout->setSpacing( scaledX( 4 ) ); mainLayout->setSpacing( scaledX( 4 ) );
QGridLayout* vLayout = new QGridLayout( this ); QGridLayout* vLayout = new QGridLayout();
vLayout->setSpacing( 8 ); vLayout->setSpacing( 8 );
mainLayout->addLayout( vLayout ); mainLayout->addLayout( vLayout );
@@ -63,7 +63,7 @@ AccountWidget::AccountWidget( QWidget* parent )
idContainer->setAttribute( Qt::WA_TranslucentBackground, false ); idContainer->setAttribute( Qt::WA_TranslucentBackground, false );
vLayout->addWidget( idContainer, 0, 0 ); vLayout->addWidget( idContainer, 0, 0 );
QHBoxLayout* idContLayout = new QHBoxLayout( idContainer ); QHBoxLayout* idContLayout = new QHBoxLayout();
idContainer->setLayout( idContLayout ); idContainer->setLayout( idContLayout );
idContainer->setContentsMargins( 0, 0, 0, 0 ); idContainer->setContentsMargins( 0, 0, 0, 0 );
idContLayout->setMargin( 2 ); idContLayout->setMargin( 2 );
@@ -96,7 +96,7 @@ AccountWidget::AccountWidget( QWidget* parent )
m_statusToggle->setContentsMargins( 0, 0, 0, 0 ); m_statusToggle->setContentsMargins( 0, 0, 0, 0 );
m_statusToggle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); m_statusToggle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
m_statusToggle->setFixedSize( m_statusToggle->sizeHint() ); m_statusToggle->setFixedSize( m_statusToggle->sizeHint() );
QHBoxLayout *statusToggleLayout = new QHBoxLayout( this ); QHBoxLayout *statusToggleLayout = new QHBoxLayout();
vLayout->addLayout( statusToggleLayout, 0, 1, 1, 1 ); vLayout->addLayout( statusToggleLayout, 0, 1, 1, 1 );
statusToggleLayout->addStretch(); statusToggleLayout->addStretch();
statusToggleLayout->addWidget( m_statusToggle ); statusToggleLayout->addWidget( m_statusToggle );
@@ -109,7 +109,7 @@ AccountWidget::AccountWidget( QWidget* parent )
m_inviteContainer->setContentsMargins( 1, 1, 1, 2 ); m_inviteContainer->setContentsMargins( 1, 1, 1, 2 );
m_inviteContainer->setAttribute( Qt::WA_TranslucentBackground, false ); m_inviteContainer->setAttribute( Qt::WA_TranslucentBackground, false );
QHBoxLayout* containerLayout = new QHBoxLayout( m_inviteContainer ); QHBoxLayout* containerLayout = new QHBoxLayout();
m_inviteContainer->setLayout( containerLayout ); m_inviteContainer->setLayout( containerLayout );
TomahawkUtils::unmarginLayout( containerLayout ); TomahawkUtils::unmarginLayout( containerLayout );
containerLayout->setContentsMargins( 1, 1, 0, 0 ); containerLayout->setContentsMargins( 1, 1, 0, 0 );