mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Work on latched job action
fixes
This commit is contained in:
@@ -220,6 +220,7 @@ set( libSources
|
|||||||
jobview/JobStatusDelegate.cpp
|
jobview/JobStatusDelegate.cpp
|
||||||
jobview/PipelineStatusItem.cpp
|
jobview/PipelineStatusItem.cpp
|
||||||
jobview/TransferStatusItem.cpp
|
jobview/TransferStatusItem.cpp
|
||||||
|
jobview/LatchedStatusItem.cpp
|
||||||
|
|
||||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
||||||
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
||||||
@@ -433,6 +434,7 @@ set( libHeaders
|
|||||||
jobview/JobStatusItem.h
|
jobview/JobStatusItem.h
|
||||||
jobview/PipelineStatusItem.h
|
jobview/PipelineStatusItem.h
|
||||||
jobview/TransferStatusItem.h
|
jobview/TransferStatusItem.h
|
||||||
|
jobview/LatchedStatusItem.h
|
||||||
|
|
||||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
|
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
|
||||||
thirdparty/Qocoa/qsearchfield.h
|
thirdparty/Qocoa/qsearchfield.h
|
||||||
|
@@ -1,55 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@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_Latched.h"
|
|
||||||
|
|
||||||
DatabaseCommand_Latched::DatabaseCommand_Latched(QObject* parent): DatabaseCommandLoggable(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DatabaseCommand_Latched::DatabaseCommand_Latched(const Tomahawk::source_ptr& s, QObject* parent): DatabaseCommandLoggable(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseCommand_Latched::doesMutates() const
|
|
||||||
{
|
|
||||||
return DatabaseCommand::doesMutates();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseCommand_Latched::exec(DatabaseImpl* )
|
|
||||||
{
|
|
||||||
DatabaseCommand::exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseCommand_Latched::postCommitHook()
|
|
||||||
{
|
|
||||||
DatabaseCommand::postCommitHook();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseCommand_Latched::singletonCmd() const
|
|
||||||
{
|
|
||||||
return DatabaseCommand::singletonCmd();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseCommand_Latched::localOnly() const
|
|
||||||
{
|
|
||||||
return DatabaseCommand::localOnly();
|
|
||||||
}
|
|
||||||
|
|
@@ -1,45 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@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_LATCHED_H
|
|
||||||
#define DATABASECOMMAND_LATCHED_H
|
|
||||||
|
|
||||||
#include "database/databasecommandloggable.h"
|
|
||||||
|
|
||||||
class DatabaseImpl;
|
|
||||||
|
|
||||||
class DatabaseCommand_Latched : public DatabaseCommandLoggable
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
enum LatchAction {
|
|
||||||
LatchedOn = 0,
|
|
||||||
LatchedOff
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit DatabaseCommand_Latched( QObject* parent = 0 );
|
|
||||||
explicit DatabaseCommand_Latched( const Tomahawk::source_ptr& s, QObject* parent = 0 );
|
|
||||||
|
|
||||||
virtual bool doesMutates() const { return true; }
|
|
||||||
virtual void exec( DatabaseImpl* );
|
|
||||||
virtual void postCommitHook();
|
|
||||||
virtual bool singletonCmd() const;
|
|
||||||
virtual bool localOnly() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DATABASECOMMAND_LATCHED_H
|
|
@@ -37,7 +37,7 @@ DatabaseCommand_SocialAction::postCommitHook()
|
|||||||
Servent::instance()->triggerDBSync();
|
Servent::instance()->triggerDBSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
source()->reportSocialAttributesChanged();
|
source()->reportSocialAttributesChanged( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,16 +52,19 @@ DatabaseCommand_SocialAction::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
|
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
|
||||||
|
|
||||||
bool autoCreate = true;
|
int trkid = -2;
|
||||||
int artid = dbi->artistId( m_artist, autoCreate );
|
if ( !m_result.isNull() && !m_artist.isNull() && !m_track.isEmpty() )
|
||||||
if ( artid < 1 )
|
{
|
||||||
return;
|
bool autoCreate = true;
|
||||||
|
int artid = dbi->artistId( m_artist, autoCreate );
|
||||||
autoCreate = true; // artistId overwrites autoCreate (reference)
|
if ( artid < 1 )
|
||||||
int trkid = dbi->trackId( artid, m_track, autoCreate );
|
return;
|
||||||
if ( trkid < 1 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
autoCreate = true; // artistId overwrites autoCreate (reference)
|
||||||
|
trkid = dbi->trackId( artid, m_track, autoCreate );
|
||||||
|
if ( trkid < 1 )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// update if it already exists
|
// update if it already exists
|
||||||
TomahawkSqlQuery find = dbi->newquery();
|
TomahawkSqlQuery find = dbi->newquery();
|
||||||
@@ -82,7 +85,7 @@ DatabaseCommand_SocialAction::exec( DatabaseImpl* dbi )
|
|||||||
query.prepare( "INSERT INTO social_attributes(id, source, k, v, timestamp) "
|
query.prepare( "INSERT INTO social_attributes(id, source, k, v, timestamp) "
|
||||||
"VALUES (?, ?, ?, ?, ?)" );
|
"VALUES (?, ?, ?, ?, ?)" );
|
||||||
|
|
||||||
query.bindValue( 0, trkid );
|
query.bindValue( 0, trkid >= -1 ? trkid : QVariant() );
|
||||||
query.bindValue( 1, srcid );
|
query.bindValue( 1, srcid );
|
||||||
query.bindValue( 2, m_action );
|
query.bindValue( 2, m_action );
|
||||||
query.bindValue( 3, m_comment );
|
query.bindValue( 3, m_comment );
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include "TransferStatusItem.h"
|
#include "TransferStatusItem.h"
|
||||||
|
#include "LatchedStatusItem.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
|
|||||||
|
|
||||||
new PipelineStatusManager( this );
|
new PipelineStatusManager( this );
|
||||||
new TransferStatusManager( this );
|
new TransferStatusManager( this );
|
||||||
|
new LatchedStatusManager( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
95
src/libtomahawk/jobview/LatchedStatusItem.cpp
Normal file
95
src/libtomahawk/jobview/LatchedStatusItem.cpp
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@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 "LatchedStatusItem.h"
|
||||||
|
|
||||||
|
#include "source.h"
|
||||||
|
#include "sourcelist.h"
|
||||||
|
#include "JobStatusView.h"
|
||||||
|
#include "JobStatusModel.h"
|
||||||
|
|
||||||
|
LatchedStatusItem::LatchedStatusItem( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to, LatchedStatusManager* parent )
|
||||||
|
: JobStatusItem()
|
||||||
|
, m_from( from )
|
||||||
|
, m_to( to )
|
||||||
|
, m_parent( parent )
|
||||||
|
{
|
||||||
|
m_text = tr( "%1 is listening along to you!" ).arg( from->friendlyName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
LatchedStatusItem::~LatchedStatusItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
LatchedStatusItem::icon() const
|
||||||
|
{
|
||||||
|
return m_parent->pixmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
LatchedStatusItem::mainText() const
|
||||||
|
{
|
||||||
|
return m_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
LatchedStatusItem::type() const
|
||||||
|
{
|
||||||
|
return "latched";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatchedStatusItem::stop()
|
||||||
|
{
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
LatchedStatusManager::LatchedStatusManager( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
connect( SourceList::instance(), SIGNAL( sourceLatchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||||
|
connect( SourceList::instance(), SIGNAL( sourceLatchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LatchedStatusManager::latchedOn( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to )
|
||||||
|
{
|
||||||
|
if ( from.isNull() || to.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( to->isLocal() )
|
||||||
|
{
|
||||||
|
LatchedStatusItem* item = new LatchedStatusItem( from, to, this );
|
||||||
|
m_jobs[ from->userName() ] = item;
|
||||||
|
JobStatusView::instance()->model()->addJob( item );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LatchedStatusManager::latchedOff( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to )
|
||||||
|
{
|
||||||
|
if ( from.isNull() || to.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( to->isLocal() && m_jobs.contains( from->userName() ) )
|
||||||
|
{
|
||||||
|
QWeakPointer< LatchedStatusItem > item = m_jobs.take( from->userName() );
|
||||||
|
if ( !item.isNull() )
|
||||||
|
item.data()->stop();
|
||||||
|
}
|
||||||
|
}
|
65
src/libtomahawk/jobview/LatchedStatusItem.h
Normal file
65
src/libtomahawk/jobview/LatchedStatusItem.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@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 LATCHEDSTATUSITEM_H
|
||||||
|
#define LATCHEDSTATUSITEM_H
|
||||||
|
|
||||||
|
#include "JobStatusItem.h"
|
||||||
|
#include "typedefs.h"
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
|
class LatchedStatusManager;
|
||||||
|
|
||||||
|
class LatchedStatusItem : public JobStatusItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LatchedStatusItem( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to, LatchedStatusManager* );
|
||||||
|
virtual ~LatchedStatusItem();
|
||||||
|
|
||||||
|
virtual QString rightColumnText() const { return QString(); }
|
||||||
|
virtual QString mainText() const;
|
||||||
|
virtual QPixmap icon() const;
|
||||||
|
virtual QString type() const;
|
||||||
|
|
||||||
|
void stop();
|
||||||
|
private:
|
||||||
|
Tomahawk::source_ptr m_from, m_to;
|
||||||
|
QString m_text;
|
||||||
|
LatchedStatusManager* m_parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LatchedStatusManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LatchedStatusManager( QObject* parent = 0 );
|
||||||
|
virtual ~LatchedStatusManager() {}
|
||||||
|
|
||||||
|
QPixmap pixmap() const { return m_pixmap; }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||||
|
void latchedOff( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap m_pixmap;
|
||||||
|
QHash< QString, QWeakPointer< LatchedStatusItem > > m_jobs;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LATCHEDSTATUSITEM_H
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
#include "database/databasecommand_socialaction.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -309,8 +310,21 @@ Source::trackTimerFired()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Source::reportSocialAttributesChanged()
|
Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action )
|
||||||
{
|
{
|
||||||
emit socialAttributesChanged();
|
emit socialAttributesChanged();
|
||||||
|
|
||||||
|
if ( action->action() == "latchOn" )
|
||||||
|
{
|
||||||
|
const source_ptr to = SourceList::instance()->get( action->comment() );
|
||||||
|
if ( !to.isNull() )
|
||||||
|
emit latchedOn( to );
|
||||||
|
}
|
||||||
|
else if ( action->action() == "latchOff" )
|
||||||
|
{
|
||||||
|
const source_ptr from = SourceList::instance()->get( action->comment() );
|
||||||
|
if ( !from.isNull() )
|
||||||
|
emit latchedOff( from );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,6 +98,9 @@ signals:
|
|||||||
|
|
||||||
void socialAttributesChanged();
|
void socialAttributesChanged();
|
||||||
|
|
||||||
|
void latchedOn( const Tomahawk::source_ptr& to );
|
||||||
|
void latchedOff( const Tomahawk::source_ptr& from );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setStats( const QVariantMap& m );
|
void setStats( const QVariantMap& m );
|
||||||
|
|
||||||
@@ -115,7 +118,7 @@ private slots:
|
|||||||
void trackTimerFired();
|
void trackTimerFired();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reportSocialAttributesChanged();
|
void reportSocialAttributesChanged( DatabaseCommand_SocialAction* action );
|
||||||
|
|
||||||
QList< QSharedPointer<Collection> > m_collections;
|
QList< QSharedPointer<Collection> > m_collections;
|
||||||
QVariantMap m_stats;
|
QVariantMap m_stats;
|
||||||
|
@@ -112,6 +112,9 @@ SourceList::setLocal( const Tomahawk::source_ptr& localSrc )
|
|||||||
m_local = localSrc;
|
m_local = localSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
connect( localSrc.data(), SIGNAL( latchedOn( Tomahawk::source_ptr ) ), this, SLOT( latchedOn( Tomahawk::source_ptr ) ) );
|
||||||
|
connect( localSrc.data(), SIGNAL( latchedOff( Tomahawk::source_ptr ) ), this, SLOT( latchedOff( Tomahawk::source_ptr ) ) );
|
||||||
emit sourceAdded( localSrc );
|
emit sourceAdded( localSrc );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +134,8 @@ SourceList::add( const source_ptr& source )
|
|||||||
collection_ptr coll( new RemoteCollection( source ) );
|
collection_ptr coll( new RemoteCollection( source ) );
|
||||||
source->addCollection( coll );
|
source->addCollection( coll );
|
||||||
|
|
||||||
|
connect( source.data(), SIGNAL( latchedOn( Tomahawk::source_ptr ) ), this, SLOT( latchedOn( Tomahawk::source_ptr ) ) );
|
||||||
|
connect( source.data(), SIGNAL( latchedOff( Tomahawk::source_ptr ) ), this, SLOT( latchedOff( Tomahawk::source_ptr ) ) );
|
||||||
emit sourceAdded( source );
|
emit sourceAdded( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,3 +216,23 @@ SourceList::count() const
|
|||||||
QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mut );
|
||||||
return m_sources.size();
|
return m_sources.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceList::latchedOff( const source_ptr& to )
|
||||||
|
{
|
||||||
|
Source* s = qobject_cast< Source* >( sender() );
|
||||||
|
const source_ptr source = m_sources[ s->userName() ];
|
||||||
|
|
||||||
|
emit sourceLatchedOff( source, to );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceList::latchedOn( const source_ptr& to )
|
||||||
|
{
|
||||||
|
|
||||||
|
Source* s = qobject_cast< Source* >( sender() );
|
||||||
|
const source_ptr source = m_sources[ s->userName() ];
|
||||||
|
|
||||||
|
emit sourceLatchedOn( source, to );
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -60,10 +60,15 @@ signals:
|
|||||||
void sourceAdded( const Tomahawk::source_ptr& );
|
void sourceAdded( const Tomahawk::source_ptr& );
|
||||||
void sourceRemoved( const Tomahawk::source_ptr& );
|
void sourceRemoved( const Tomahawk::source_ptr& );
|
||||||
|
|
||||||
|
void sourceLatchedOn( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to );
|
||||||
|
void sourceLatchedOff( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setSources( const QList<Tomahawk::source_ptr>& sources );
|
void setSources( const QList<Tomahawk::source_ptr>& sources );
|
||||||
void sourceSynced();
|
void sourceSynced();
|
||||||
|
|
||||||
|
void latchedOn( const Tomahawk::source_ptr& );
|
||||||
|
void latchedOff( const Tomahawk::source_ptr& );
|
||||||
private:
|
private:
|
||||||
void add( const Tomahawk::source_ptr& source );
|
void add( const Tomahawk::source_ptr& source );
|
||||||
|
|
||||||
|
@@ -43,6 +43,8 @@
|
|||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "items/genericpageitems.h"
|
#include "items/genericpageitems.h"
|
||||||
#include "items/temporarypageitem.h"
|
#include "items/temporarypageitem.h"
|
||||||
|
#include <database/databasecommand_socialaction.h>
|
||||||
|
#include <database/database.h>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -354,6 +356,13 @@ SourceTreeView::latchOn()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||||
|
cmd->setSource( SourceList::instance()->getLocal() );
|
||||||
|
cmd->setAction( "latchOn");
|
||||||
|
cmd->setComment( source->userName() );
|
||||||
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +379,19 @@ SourceTreeView::latchOff()
|
|||||||
if( type != SourcesModel::Collection )
|
if( type != SourcesModel::Collection )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
||||||
|
const source_ptr source = item->source();
|
||||||
|
|
||||||
|
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||||
|
cmd->setSource( SourceList::instance()->getLocal() );
|
||||||
|
cmd->setAction( "latchOff");
|
||||||
|
cmd->setComment( source->userName() );
|
||||||
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
|
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||||
|
|
||||||
|
|
||||||
AudioEngine::instance()->stop();
|
AudioEngine::instance()->stop();
|
||||||
AudioEngine::instance()->setPlaylist( 0 );
|
AudioEngine::instance()->setPlaylist( 0 );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user