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