1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

[whatsnew] Once deleted, never list again in SourcesModel

This commit is contained in:
Uwe L. Korn
2014-07-15 01:30:13 +01:00
parent dee164f34a
commit 71bc764d2d
6 changed files with 47 additions and 1 deletions

View File

@@ -57,3 +57,10 @@ bool
ViewPage::addPageItem() const { ViewPage::addPageItem() const {
return true; return true;
} }
void
ViewPage::onItemDeleted()
{
// no-op
}

View File

@@ -86,6 +86,12 @@ public:
* page will not be listed in the search history. * page will not be listed in the search history.
*/ */
virtual bool isDeletable() const { return false; } virtual bool isDeletable() const { return false; }
/**
* The ViewPage item in the SourcesModel was deleted.
*/
virtual void onItemDeleted();
virtual bool isBeingPlayed() const { return false; } virtual bool isBeingPlayed() const { return false; }
virtual QList<PlaylistUpdaterInterface*> updaters() const { return QList<PlaylistUpdaterInterface*>(); } virtual QList<PlaylistUpdaterInterface*> updaters() const { return QList<PlaylistUpdaterInterface*>(); }
@@ -108,4 +114,6 @@ private:
} // ns } // ns
Q_DECLARE_METATYPE( Tomahawk::ViewPage* )
#endif //VIEWPAGE_H #endif //VIEWPAGE_H

View File

@@ -39,6 +39,7 @@
#include "playlist/TreeView.h" #include "playlist/TreeView.h"
#include "playlist/PlaylistView.h" #include "playlist/PlaylistView.h"
#include "playlist/dynamic/widgets/DynamicWidget.h" #include "playlist/dynamic/widgets/DynamicWidget.h"
#include "utils/Closure.h"
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/PluginLoader.h" #include "utils/PluginLoader.h"
@@ -574,6 +575,13 @@ SourcesModel::onScriptCollectionRemoved( const collection_ptr& collection )
} }
void
SourcesModel::onViewPageRemoved( Tomahawk::ViewPage *p )
{
p->onItemDeleted();
}
ViewPage* ViewPage*
SourcesModel::scriptCollectionClicked( const Tomahawk::collection_ptr& collection ) 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 ); connect( obj, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
} }
m_viewPageDelayedCacheItem = 0; m_viewPageDelayedCacheItem = 0;
if ( p->isDeletable() ) {
NewClosure( item, SIGNAL( removed() ), this, SLOT( onViewPageRemoved( Tomahawk::ViewPage* ) ), p );
}
} }

View File

@@ -24,6 +24,7 @@
#include "Typedefs.h" #include "Typedefs.h"
#include "Source.h" #include "Source.h"
#include "ViewPage.h"
#include <QModelIndex> #include <QModelIndex>
#include <QStringList> #include <QStringList>
@@ -38,7 +39,6 @@ class GroupItem;
namespace Tomahawk { namespace Tomahawk {
class Source; class Source;
class Playlist; class Playlist;
class ViewPage;
} }
class SourcesModel : public QAbstractItemModel class SourcesModel : public QAbstractItemModel
@@ -141,6 +141,8 @@ private slots:
void onScriptCollectionAdded( const Tomahawk::collection_ptr& collection ); void onScriptCollectionAdded( const Tomahawk::collection_ptr& collection );
void onScriptCollectionRemoved( 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* scriptCollectionClicked( const Tomahawk::collection_ptr& collection );
Tomahawk::ViewPage* getScriptCollectionPage( const Tomahawk::collection_ptr& collection ) const; Tomahawk::ViewPage* getScriptCollectionPage( const Tomahawk::collection_ptr& collection ) const;

View File

@@ -21,6 +21,7 @@
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/TomahawkStyle.h" #include "utils/TomahawkStyle.h"
#include "TomahawkSettings.h"
#include <QLayout> #include <QLayout>
#include <QScrollArea> #include <QScrollArea>
@@ -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 ) WhatsNewWidget_0_8::WhatsNewWidget_0_8( QWidget* parent )
: QWidget( parent ) : QWidget( parent )

View File

@@ -88,7 +88,10 @@ public:
QString title() const { return tr( "What's new in 0.8?" ); } 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." ); } QString description() const { return tr( "An overview of the changes and additions since 0.7." ); }
const QString pixmapPath() const { return ( RESPATH "images/whatsnew.png" ); } const QString pixmapPath() const { return ( RESPATH "images/whatsnew.png" ); }
bool addPageItem() const;
bool isDeletable() const { return true; } bool isDeletable() const { return true; }
void onItemDeleted();
int sortValue() { return 1; } int sortValue() { return 1; }