mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Basic inbox support, sending track suggestions kind of works sometimes.
This commit is contained in:
parent
04fc5f6f37
commit
3847eae6cc
@ -29,6 +29,7 @@
|
||||
#include "DatabaseCommand_DeleteDynamicPlaylist.h"
|
||||
#include "DatabaseCommand_SetDynamicPlaylistRevision.h"
|
||||
#include "DatabaseCommand_SocialAction.h"
|
||||
#include "DatabaseCommand_ShareTrack.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "DatabaseCommand_SetCollectionAttributes.h"
|
||||
@ -185,6 +186,13 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
|
||||
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
|
||||
return cmd;
|
||||
}
|
||||
else if( name == "sharetrack" )
|
||||
{
|
||||
DatabaseCommand_ShareTrack * cmd = new DatabaseCommand_ShareTrack;
|
||||
cmd->setSource( source );
|
||||
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
|
||||
return cmd;
|
||||
}
|
||||
|
||||
qDebug() << "Unknown database command" << name;
|
||||
// Q_ASSERT( false );
|
||||
|
@ -66,14 +66,14 @@ DatabaseCommand_ShareTrack::exec( DatabaseImpl* dbi )
|
||||
void
|
||||
DatabaseCommand_ShareTrack::postCommitHook()
|
||||
{
|
||||
if ( !m_query.isNull() )
|
||||
return;
|
||||
|
||||
if ( source()->isLocal() )
|
||||
Servent::instance()->triggerDBSync();
|
||||
|
||||
QString myDbid = Database::instance()->impl()->dbid();
|
||||
QString sourceDbid = source()->userName(); //userName is actually a dbid -_-'
|
||||
if ( !m_query.isNull() )
|
||||
return;
|
||||
|
||||
QString myDbid = SourceList::instance()->getLocal()->nodeId();
|
||||
QString sourceDbid = source()->nodeId();
|
||||
if ( myDbid != m_recipient || sourceDbid == m_recipient )
|
||||
return;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
class DatabaseCommand_ShareTrack : public DatabaseCommandLoggable
|
||||
class DLLEXPORT DatabaseCommand_ShareTrack : public DatabaseCommandLoggable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString artist READ artist WRITE setArtist )
|
||||
|
@ -30,8 +30,6 @@ public:
|
||||
explicit InboxModel( QObject* parent = 0 );
|
||||
virtual ~InboxModel();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "SourceItem.h"
|
||||
|
||||
#include "CategoryItems.h"
|
||||
#include "database/Database.h"
|
||||
#include "database/DatabaseCommand_ShareTrack.h"
|
||||
#include "DropJob.h"
|
||||
#include "PlaylistItems.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Playlist.h"
|
||||
@ -677,6 +680,21 @@ SourceItem::getRecentPlaysPage() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceItem::onTracksDropped( const QList< query_ptr >& queries )
|
||||
{
|
||||
foreach ( const query_ptr& query, queries )
|
||||
{
|
||||
DatabaseCommand_ShareTrack* cmd =
|
||||
new DatabaseCommand_ShareTrack( query, m_source->nodeId() );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
}
|
||||
tDebug() << "I am" << SourceList::instance()->getLocal()->nodeId();
|
||||
tDebug() << "Dropped tracks on source item" << text() << m_source->friendlyName() << m_source->nodeId();
|
||||
}
|
||||
|
||||
|
||||
CategoryItem*
|
||||
SourceItem::stationsCategory() const
|
||||
{
|
||||
@ -703,3 +721,43 @@ SourceItem::setPlaylistsCategory(CategoryItem* item)
|
||||
{
|
||||
m_playlists = item;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourceItem::willAcceptDrag( const QMimeData* data ) const
|
||||
{
|
||||
return DropJob::acceptsMimeData( data, DropJob::Track );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourceItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
||||
{
|
||||
Q_UNUSED( action );
|
||||
|
||||
QList< Tomahawk::query_ptr > queries;
|
||||
if ( !DropJob::acceptsMimeData( data, DropJob::Track ) )
|
||||
return false;
|
||||
|
||||
if ( source()->isLocal() )
|
||||
return false;
|
||||
|
||||
DropJob* dj = new DropJob();
|
||||
dj->setDropTypes( DropJob::Track );
|
||||
|
||||
connect( dj, SIGNAL( tracks( QList< Tomahawk::query_ptr > ) ),
|
||||
this, SLOT( onTracksDropped( QList< Tomahawk::query_ptr > ) ) );
|
||||
dj->tracksFromMimeData( data, false, false );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SourceTreeItem::DropTypes
|
||||
SourceItem::supportedDropTypes( const QMimeData* data ) const
|
||||
{
|
||||
if ( data->hasFormat( "application/tomahawk.result.list" ) ||
|
||||
data->hasFormat( "application/tomahawk.query.list" ) )
|
||||
return DropTypeThisTrack;
|
||||
|
||||
return DropTypesNone;
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ public:
|
||||
void setStationsCategory( CategoryItem* item );
|
||||
void setPlaylistsCategory( CategoryItem* item );
|
||||
|
||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
||||
virtual DropTypes supportedDropTypes( const QMimeData* data ) const;
|
||||
|
||||
public slots:
|
||||
virtual void activate();
|
||||
|
||||
@ -90,6 +94,8 @@ private slots:
|
||||
Tomahawk::ViewPage* recentPlaysClicked();
|
||||
Tomahawk::ViewPage* getRecentPlaysPage() const;
|
||||
|
||||
void onTracksDropped( const QList< Tomahawk::query_ptr >& queries );
|
||||
|
||||
private:
|
||||
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
|
||||
template< typename T >
|
||||
|
Loading…
x
Reference in New Issue
Block a user