mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Add "Mark as Listened" to Inbox.
This commit is contained in:
parent
a81d13a91f
commit
ed575aa033
@ -214,6 +214,9 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||
|
||||
addSeparator();
|
||||
|
||||
if ( m_supportedActions & ActionMarkListened )
|
||||
m_sigmap->setMapping( addAction( tr( "Mark as &Listened" ) ), ActionMarkListened );
|
||||
|
||||
if ( m_supportedActions & ActionDelete )
|
||||
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), ActionDelete );
|
||||
|
||||
|
@ -49,7 +49,8 @@ public:
|
||||
ActionAlbumPage = 67,
|
||||
ActionEditMetadata = 128,
|
||||
ActionPlaylist = 256,
|
||||
ActionSend = 512
|
||||
ActionSend = 512,
|
||||
ActionMarkListened = 1024
|
||||
};
|
||||
|
||||
explicit ContextMenu( QWidget* parent = 0 );
|
||||
|
@ -172,7 +172,7 @@ Track::startPlaying()
|
||||
DatabaseCommand_LogPlayback::Started );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
|
||||
markAsListened();
|
||||
}
|
||||
|
||||
|
||||
@ -183,7 +183,12 @@ Track::finishPlaying( int timeElapsed )
|
||||
DatabaseCommand_LogPlayback::Finished,
|
||||
timeElapsed );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::markAsListened()
|
||||
{
|
||||
bool isUnlistened = false;
|
||||
foreach ( Tomahawk::SocialAction action, allSocialActions() )
|
||||
{
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
|
||||
void startPlaying();
|
||||
void finishPlaying( int timeElapsed );
|
||||
void markAsListened();
|
||||
|
||||
signals:
|
||||
void coverChanged();
|
||||
|
@ -171,6 +171,20 @@ InboxModel::showNotification( InboxJobItem::Side side,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::markAsListened( const QModelIndexList& indexes )
|
||||
{
|
||||
foreach ( QModelIndex index, indexes )
|
||||
{
|
||||
PlayableItem* item = itemFromIndex( index );
|
||||
if ( item && !item->query().isNull() )
|
||||
{
|
||||
item->query()->queryTrack()->markAsListened();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::loadTracks()
|
||||
{
|
||||
|
@ -53,6 +53,8 @@ public slots:
|
||||
const QString& dbid,
|
||||
const Tomahawk::trackdata_ptr& track );
|
||||
|
||||
virtual void markAsListened( const QModelIndexList& indexes );
|
||||
|
||||
|
||||
private slots:
|
||||
void loadTracks();
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "InboxView.h"
|
||||
#include "InboxModel.h"
|
||||
#include "PlayableProxyModel.h"
|
||||
#include "ContextMenu.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
InboxView::InboxView(QWidget *parent) :
|
||||
TrackView(parent)
|
||||
@ -36,3 +38,28 @@ InboxView::deleteSelectedItems()
|
||||
proxyModel()->removeIndexes( selectedIndexes() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxView::onMenuTriggered( int action )
|
||||
{
|
||||
if ( action == Tomahawk::ContextMenu::ActionMarkListened )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Mark as Listened";
|
||||
InboxModel* inboxModel = qobject_cast< InboxModel* >( model() );
|
||||
if ( inboxModel != 0 )
|
||||
{
|
||||
QModelIndexList sourceIndexes;
|
||||
foreach ( const QModelIndex& index, selectedIndexes() )
|
||||
{
|
||||
if ( index.column() )
|
||||
continue;
|
||||
|
||||
sourceIndexes << proxyModel()->mapToSource( index );
|
||||
}
|
||||
inboxModel->markAsListened( sourceIndexes );
|
||||
}
|
||||
}
|
||||
else
|
||||
TrackView::onMenuTriggered( action );
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public slots:
|
||||
* Reimplemented in order to ignore PlayableModel::isReadOnly()
|
||||
*/
|
||||
virtual void deleteSelectedItems();
|
||||
|
||||
virtual void onMenuTriggered( int action );
|
||||
};
|
||||
|
||||
#endif // INBOXVIEW_H
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "utils/Closure.h"
|
||||
#include "utils/AnimatedSpinner.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "InboxModel.h"
|
||||
|
||||
|
||||
#include <QKeyEvent>
|
||||
@ -45,7 +46,6 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
TrackView::TrackView( QWidget* parent )
|
||||
: QTreeView( parent )
|
||||
, m_model( 0 )
|
||||
@ -651,6 +651,9 @@ TrackView::onCustomContextMenu( const QPoint& pos )
|
||||
|
||||
if ( model() && !model()->isReadOnly() )
|
||||
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionDelete );
|
||||
if ( model() && qobject_cast< InboxModel* >( model() ) )
|
||||
m_contextMenu->setSupportedActions( m_contextMenu->supportedActions() | ContextMenu::ActionMarkListened
|
||||
| ContextMenu::ActionDelete );
|
||||
|
||||
QList<query_ptr> queries;
|
||||
foreach ( const QModelIndex& index, selectedIndexes() )
|
||||
|
@ -93,7 +93,7 @@ public slots:
|
||||
virtual void deleteSelectedItems();
|
||||
|
||||
void playItem();
|
||||
void onMenuTriggered( int action );
|
||||
virtual void onMenuTriggered( int action );
|
||||
|
||||
void onViewChanged();
|
||||
void onScrollTimeout();
|
||||
|
Loading…
x
Reference in New Issue
Block a user