mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-01 06:22:43 +01:00
Moved Inbox social action updating to Track.
This commit is contained in:
parent
bdce14b02e
commit
f434b1937f
src/libtomahawk
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Christian Muehlhaeuser <muesli@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
|
||||
@ -24,6 +25,7 @@
|
||||
#include "database/Database.h"
|
||||
#include "database/DatabaseImpl.h"
|
||||
#include "database/DatabaseCommand_LogPlayback.h"
|
||||
#include "database/DatabaseCommand_ModifyInboxEntry.h"
|
||||
#include "Album.h"
|
||||
#include "collection/Collection.h"
|
||||
#include "Pipeline.h"
|
||||
@ -169,6 +171,8 @@ Track::startPlaying()
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( weakRef().toStrongRef(),
|
||||
DatabaseCommand_LogPlayback::Started );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -180,6 +184,33 @@ Track::finishPlaying( int timeElapsed )
|
||||
timeElapsed );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
bool isUnlistened = false;
|
||||
foreach ( Tomahawk::SocialAction action, allSocialActions() )
|
||||
{
|
||||
if ( action.action == "Inbox" && action.value.toBool() == true )
|
||||
{
|
||||
isUnlistened = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isUnlistened )
|
||||
{
|
||||
DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
// The dbcmd does this in the DB, but let's update the TrackData ASAP
|
||||
QList< Tomahawk::SocialAction > actions = allSocialActions();
|
||||
for ( QList< Tomahawk::SocialAction >::iterator it = actions.begin();
|
||||
it != actions.end(); ++it )
|
||||
{
|
||||
if ( it->action == "Inbox" )
|
||||
{
|
||||
it->value = false; //listened!
|
||||
}
|
||||
}
|
||||
m_trackData->setAllSocialActions( actions ); //emits socialActionsLoaded which gets propagated here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Christian Muehlhaeuser <muesli@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
|
||||
|
@ -35,9 +35,6 @@ InboxModel::InboxModel( QObject* parent )
|
||||
else
|
||||
NewClosure( SourceList::instance(), SIGNAL( ready() ),
|
||||
this, SLOT( loadTracks() ) );
|
||||
|
||||
connect( this, SIGNAL( currentIndexChanged() ),
|
||||
SLOT( onCurrentIndexChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -215,8 +212,7 @@ InboxModel::tracksLoaded( QList< Tomahawk::query_ptr > incoming )
|
||||
|
||||
QList< Tomahawk::SocialAction > actions;
|
||||
actions << action;
|
||||
//FIXME
|
||||
// newQuery->queryTrack()->setAllSocialActions( actions );
|
||||
newQuery->queryTrack()->loadSocialActions();
|
||||
|
||||
newQuery->setProperty( "data", QVariant() ); //clear
|
||||
}
|
||||
@ -233,32 +229,3 @@ InboxModel::tracksLoaded( QList< Tomahawk::query_ptr > incoming )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InboxModel::onCurrentIndexChanged()
|
||||
{
|
||||
QPersistentModelIndex idx = currentItem();
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
PlayableItem* item = itemFromIndex( idx );
|
||||
if ( item && !item->query().isNull() )
|
||||
{
|
||||
Tomahawk::query_ptr qry = item->query();
|
||||
DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( qry, false );
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
|
||||
QList< Tomahawk::SocialAction > actions = item->query()->queryTrack()->allSocialActions();
|
||||
for ( QList< Tomahawk::SocialAction >::iterator it = actions.begin();
|
||||
it != actions.end(); ++it )
|
||||
{
|
||||
if ( it->action == "Inbox" )
|
||||
{
|
||||
it->value = false; //listened!
|
||||
}
|
||||
}
|
||||
//FIXME
|
||||
// item->query()->queryTrack()->setAllSocialActions( actions );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ private slots:
|
||||
void loadTracks();
|
||||
|
||||
void tracksLoaded( QList< Tomahawk::query_ptr > );
|
||||
void onCurrentIndexChanged();
|
||||
|
||||
private:
|
||||
static QList< Tomahawk::SocialAction > mergeSocialActions( QList< Tomahawk::SocialAction > first,
|
||||
|
Loading…
x
Reference in New Issue
Block a user