mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Implement delete support in Inbox.
This commit is contained in:
@@ -44,6 +44,7 @@ set( libGuiSources
|
|||||||
infobar/InfoBar.cpp
|
infobar/InfoBar.cpp
|
||||||
|
|
||||||
playlist/InboxModel.cpp
|
playlist/InboxModel.cpp
|
||||||
|
playlist/InboxView.cpp
|
||||||
playlist/FlexibleHeader.cpp
|
playlist/FlexibleHeader.cpp
|
||||||
playlist/FlexibleView.cpp
|
playlist/FlexibleView.cpp
|
||||||
playlist/TreeModel.cpp
|
playlist/TreeModel.cpp
|
||||||
@@ -269,6 +270,7 @@ list(APPEND libSources
|
|||||||
database/DatabaseCommand_SetTrackAttributes.cpp
|
database/DatabaseCommand_SetTrackAttributes.cpp
|
||||||
database/DatabaseCommand_PlaybackCharts.cpp
|
database/DatabaseCommand_PlaybackCharts.cpp
|
||||||
database/DatabaseCommand_ShareTrack.cpp
|
database/DatabaseCommand_ShareTrack.cpp
|
||||||
|
database/DatabaseCommand_DeleteInboxEntry.cpp
|
||||||
database/Database.cpp
|
database/Database.cpp
|
||||||
database/TomahawkSqlQuery.cpp
|
database/TomahawkSqlQuery.cpp
|
||||||
database/IdThreadWorker.cpp
|
database/IdThreadWorker.cpp
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
|
|
||||||
#include "playlist/InboxModel.h"
|
#include "playlist/InboxModel.h"
|
||||||
|
#include "playlist/InboxView.h"
|
||||||
#include "playlist/PlaylistLargeItemDelegate.h"
|
#include "playlist/PlaylistLargeItemDelegate.h"
|
||||||
#include "playlist/RecentlyPlayedModel.h"
|
#include "playlist/RecentlyPlayedModel.h"
|
||||||
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
||||||
@@ -440,7 +441,7 @@ ViewManager::showInboxPage()
|
|||||||
{
|
{
|
||||||
if ( !m_inboxWidget )
|
if ( !m_inboxWidget )
|
||||||
{
|
{
|
||||||
TrackView* inboxView = new TrackView( m_widget );
|
TrackView* inboxView = new InboxView( m_widget );
|
||||||
|
|
||||||
PlaylistLargeItemDelegate* delegate =
|
PlaylistLargeItemDelegate* delegate =
|
||||||
new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::Inbox,
|
new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::Inbox,
|
||||||
|
@@ -0,0 +1,60 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@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 "DatabaseCommand_DeleteInboxEntry.h"
|
||||||
|
#include "DatabaseImpl.h"
|
||||||
|
#include "Query.h"
|
||||||
|
|
||||||
|
|
||||||
|
DatabaseCommand_DeleteInboxEntry::DatabaseCommand_DeleteInboxEntry( const Tomahawk::query_ptr& query,
|
||||||
|
QObject* parent )
|
||||||
|
: DatabaseCommand( parent )
|
||||||
|
, m_query( query )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DatabaseCommand_DeleteInboxEntry::exec( DatabaseImpl* dbi )
|
||||||
|
{
|
||||||
|
TomahawkSqlQuery query = dbi->newquery();
|
||||||
|
|
||||||
|
Q_ASSERT( !m_query.isNull() );
|
||||||
|
|
||||||
|
if ( m_query->track().isEmpty() || m_query->artist().isEmpty() )
|
||||||
|
{
|
||||||
|
emit done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
query.prepare(
|
||||||
|
"DELETE FROM social_attributes "
|
||||||
|
"WHERE social_attributes.k = ? AND social_attributes.id = ( "
|
||||||
|
"SELECT id FROM track "
|
||||||
|
"WHERE track.name = ? AND track.artist = ( "
|
||||||
|
"SELECT id FROM artist WHERE artist.name = ? "
|
||||||
|
") "
|
||||||
|
")" );
|
||||||
|
query.addBindValue( "Inbox" );
|
||||||
|
query.addBindValue( m_query->track() );
|
||||||
|
query.addBindValue( m_query->artist() );
|
||||||
|
|
||||||
|
query.exec();
|
||||||
|
|
||||||
|
emit done();
|
||||||
|
}
|
44
src/libtomahawk/database/DatabaseCommand_DeleteInboxEntry.h
Normal file
44
src/libtomahawk/database/DatabaseCommand_DeleteInboxEntry.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@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 DATABASECOMMAND_DELETEINBOXENTRY_H
|
||||||
|
#define DATABASECOMMAND_DELETEINBOXENTRY_H
|
||||||
|
|
||||||
|
#include "DatabaseCommand.h"
|
||||||
|
|
||||||
|
class DatabaseCommand_DeleteInboxEntry : public DatabaseCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DatabaseCommand_DeleteInboxEntry( const Tomahawk::query_ptr& query, QObject *parent = 0 );
|
||||||
|
|
||||||
|
virtual void exec( DatabaseImpl* dbi );
|
||||||
|
virtual bool doesMutates() const { return true; }
|
||||||
|
virtual bool groupable() const { return true; }
|
||||||
|
virtual bool localOnly() const { return true; }
|
||||||
|
virtual QString commandname() const { return "deleteinboxentry"; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void done();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tomahawk::query_ptr m_query;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DATABASECOMMAND_DELETEINBOXENTRY_H
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
#include "database/DatabaseCommand_GenericSelect.h"
|
#include "database/DatabaseCommand_GenericSelect.h"
|
||||||
|
#include "database/DatabaseCommand_DeleteInboxEntry.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Closure.h"
|
#include "utils/Closure.h"
|
||||||
@@ -117,6 +118,20 @@ InboxModel::insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InboxModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
||||||
|
{
|
||||||
|
PlayableItem* item = itemFromIndex( index );
|
||||||
|
if ( item && !item->query().isNull() )
|
||||||
|
{
|
||||||
|
DatabaseCommand_DeleteInboxEntry* cmd = new DatabaseCommand_DeleteInboxEntry( item->query() );
|
||||||
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistModel::removeIndex( index, moreToCome );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InboxModel::clear()
|
InboxModel::clear()
|
||||||
{
|
{
|
||||||
|
@@ -39,6 +39,8 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
virtual void insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int row = 0 );
|
virtual void insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int row = 0 );
|
||||||
|
|
||||||
|
virtual void removeIndex( const QModelIndex &index, bool moreToCome );
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
38
src/libtomahawk/playlist/InboxView.cpp
Normal file
38
src/libtomahawk/playlist/InboxView.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@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 "InboxView.h"
|
||||||
|
#include "InboxModel.h"
|
||||||
|
#include "PlayableProxyModel.h"
|
||||||
|
|
||||||
|
InboxView::InboxView(QWidget *parent) :
|
||||||
|
TrackView(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InboxView::deleteSelectedItems()
|
||||||
|
{
|
||||||
|
InboxModel* inboxModel = qobject_cast< InboxModel* >( model() );
|
||||||
|
if ( inboxModel != 0 )
|
||||||
|
{
|
||||||
|
proxyModel()->removeIndexes( selectedIndexes() );
|
||||||
|
}
|
||||||
|
}
|
38
src/libtomahawk/playlist/InboxView.h
Normal file
38
src/libtomahawk/playlist/InboxView.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@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 INBOXVIEW_H
|
||||||
|
#define INBOXVIEW_H
|
||||||
|
|
||||||
|
#include "TrackView.h"
|
||||||
|
|
||||||
|
class InboxView : public TrackView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit InboxView( QWidget* parent = 0 );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* Reimplemented in order to ignore PlayableModel::isReadOnly()
|
||||||
|
*/
|
||||||
|
virtual void deleteSelectedItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INBOXVIEW_H
|
@@ -91,7 +91,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void onItemActivated( const QModelIndex& index );
|
virtual void onItemActivated( const QModelIndex& index );
|
||||||
|
|
||||||
void deleteSelectedItems();
|
virtual void deleteSelectedItems();
|
||||||
|
|
||||||
void playItem();
|
void playItem();
|
||||||
void onMenuTriggered( int action );
|
void onMenuTriggered( int action );
|
||||||
|
Reference in New Issue
Block a user