From 71bc764d2ddae1b82dc4d273dac369d87ca5e4e2 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 15 Jul 2014 01:30:13 +0100 Subject: [PATCH] [whatsnew] Once deleted, never list again in SourcesModel --- src/libtomahawk/ViewPage.cpp | 7 +++++++ src/libtomahawk/ViewPage.h | 8 ++++++++ src/tomahawk/sourcetree/SourcesModel.cpp | 12 ++++++++++++ src/tomahawk/sourcetree/SourcesModel.h | 4 +++- src/viewpages/whatsnew_0_8/WhatsNew_0_8.cpp | 14 ++++++++++++++ src/viewpages/whatsnew_0_8/WhatsNew_0_8.h | 3 +++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/ViewPage.cpp b/src/libtomahawk/ViewPage.cpp index bd7c1dbc6..beecf8a36 100644 --- a/src/libtomahawk/ViewPage.cpp +++ b/src/libtomahawk/ViewPage.cpp @@ -57,3 +57,10 @@ bool ViewPage::addPageItem() const { return true; } + + +void +ViewPage::onItemDeleted() +{ + // no-op +} diff --git a/src/libtomahawk/ViewPage.h b/src/libtomahawk/ViewPage.h index 5f252f965..7519617ee 100644 --- a/src/libtomahawk/ViewPage.h +++ b/src/libtomahawk/ViewPage.h @@ -86,6 +86,12 @@ public: * page will not be listed in the search history. */ virtual bool isDeletable() const { return false; } + + /** + * The ViewPage item in the SourcesModel was deleted. + */ + virtual void onItemDeleted(); + virtual bool isBeingPlayed() const { return false; } virtual QList updaters() const { return QList(); } @@ -108,4 +114,6 @@ private: } // ns +Q_DECLARE_METATYPE( Tomahawk::ViewPage* ) + #endif //VIEWPAGE_H diff --git a/src/tomahawk/sourcetree/SourcesModel.cpp b/src/tomahawk/sourcetree/SourcesModel.cpp index f64d7ba48..b43ecaf55 100644 --- a/src/tomahawk/sourcetree/SourcesModel.cpp +++ b/src/tomahawk/sourcetree/SourcesModel.cpp @@ -39,6 +39,7 @@ #include "playlist/TreeView.h" #include "playlist/PlaylistView.h" #include "playlist/dynamic/widgets/DynamicWidget.h" +#include "utils/Closure.h" #include "utils/ImageRegistry.h" #include "utils/Logger.h" #include "utils/PluginLoader.h" @@ -574,6 +575,13 @@ SourcesModel::onScriptCollectionRemoved( const collection_ptr& collection ) } +void +SourcesModel::onViewPageRemoved( Tomahawk::ViewPage *p ) +{ + p->onItemDeleted(); +} + + ViewPage* SourcesModel::scriptCollectionClicked( const Tomahawk::collection_ptr& collection ) { @@ -665,6 +673,10 @@ SourcesModel::linkSourceItemToPage( SourceTreeItem* item, ViewPage* p ) connect( obj, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection ); } m_viewPageDelayedCacheItem = 0; + + if ( p->isDeletable() ) { + NewClosure( item, SIGNAL( removed() ), this, SLOT( onViewPageRemoved( Tomahawk::ViewPage* ) ), p ); + } } diff --git a/src/tomahawk/sourcetree/SourcesModel.h b/src/tomahawk/sourcetree/SourcesModel.h index 2d61b6bbb..a584ea79f 100644 --- a/src/tomahawk/sourcetree/SourcesModel.h +++ b/src/tomahawk/sourcetree/SourcesModel.h @@ -24,6 +24,7 @@ #include "Typedefs.h" #include "Source.h" +#include "ViewPage.h" #include #include @@ -38,7 +39,6 @@ class GroupItem; namespace Tomahawk { class Source; class Playlist; - class ViewPage; } class SourcesModel : public QAbstractItemModel @@ -141,6 +141,8 @@ private slots: void onScriptCollectionAdded( const Tomahawk::collection_ptr& collection ); void onScriptCollectionRemoved( const Tomahawk::collection_ptr& collection ); + void onViewPageRemoved( Tomahawk::ViewPage* p ); + Tomahawk::ViewPage* scriptCollectionClicked( const Tomahawk::collection_ptr& collection ); Tomahawk::ViewPage* getScriptCollectionPage( const Tomahawk::collection_ptr& collection ) const; diff --git a/src/viewpages/whatsnew_0_8/WhatsNew_0_8.cpp b/src/viewpages/whatsnew_0_8/WhatsNew_0_8.cpp index 981eb3586..e24b5ab01 100644 --- a/src/viewpages/whatsnew_0_8/WhatsNew_0_8.cpp +++ b/src/viewpages/whatsnew_0_8/WhatsNew_0_8.cpp @@ -21,6 +21,7 @@ #include "utils/ImageRegistry.h" #include "utils/TomahawkStyle.h" +#include "TomahawkSettings.h" #include #include @@ -60,6 +61,19 @@ WhatsNew_0_8::~WhatsNew_0_8() } +bool +WhatsNew_0_8::addPageItem() const +{ + return !TomahawkSettings::instance()->value( "whatsnew/deleted-for-0.8", false ).toBool(); +} + + +void +WhatsNew_0_8::onItemDeleted() +{ + TomahawkSettings::instance()->setValue( "whatsnew/deleted-for-0.8", true ); +} + WhatsNewWidget_0_8::WhatsNewWidget_0_8( QWidget* parent ) : QWidget( parent ) diff --git a/src/viewpages/whatsnew_0_8/WhatsNew_0_8.h b/src/viewpages/whatsnew_0_8/WhatsNew_0_8.h index 8e2b4f9e8..d162f2d94 100644 --- a/src/viewpages/whatsnew_0_8/WhatsNew_0_8.h +++ b/src/viewpages/whatsnew_0_8/WhatsNew_0_8.h @@ -88,7 +88,10 @@ public: QString title() const { return tr( "What's new in 0.8?" ); } QString description() const { return tr( "An overview of the changes and additions since 0.7." ); } const QString pixmapPath() const { return ( RESPATH "images/whatsnew.png" ); } + + bool addPageItem() const; bool isDeletable() const { return true; } + void onItemDeleted(); int sortValue() { return 1; }