mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Basic inbox support, sending track suggestions kind of works sometimes.
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "DatabaseCommand_DeleteDynamicPlaylist.h"
|
#include "DatabaseCommand_DeleteDynamicPlaylist.h"
|
||||||
#include "DatabaseCommand_SetDynamicPlaylistRevision.h"
|
#include "DatabaseCommand_SetDynamicPlaylistRevision.h"
|
||||||
#include "DatabaseCommand_SocialAction.h"
|
#include "DatabaseCommand_SocialAction.h"
|
||||||
|
#include "DatabaseCommand_ShareTrack.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "DatabaseCommand_SetCollectionAttributes.h"
|
#include "DatabaseCommand_SetCollectionAttributes.h"
|
||||||
@@ -185,6 +186,13 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
|
|||||||
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
|
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
|
||||||
return 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;
|
qDebug() << "Unknown database command" << name;
|
||||||
// Q_ASSERT( false );
|
// Q_ASSERT( false );
|
||||||
|
@@ -66,14 +66,14 @@ DatabaseCommand_ShareTrack::exec( DatabaseImpl* dbi )
|
|||||||
void
|
void
|
||||||
DatabaseCommand_ShareTrack::postCommitHook()
|
DatabaseCommand_ShareTrack::postCommitHook()
|
||||||
{
|
{
|
||||||
if ( !m_query.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( source()->isLocal() )
|
if ( source()->isLocal() )
|
||||||
Servent::instance()->triggerDBSync();
|
Servent::instance()->triggerDBSync();
|
||||||
|
|
||||||
QString myDbid = Database::instance()->impl()->dbid();
|
if ( !m_query.isNull() )
|
||||||
QString sourceDbid = source()->userName(); //userName is actually a dbid -_-'
|
return;
|
||||||
|
|
||||||
|
QString myDbid = SourceList::instance()->getLocal()->nodeId();
|
||||||
|
QString sourceDbid = source()->nodeId();
|
||||||
if ( myDbid != m_recipient || sourceDbid == m_recipient )
|
if ( myDbid != m_recipient || sourceDbid == m_recipient )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class DatabaseCommand_ShareTrack : public DatabaseCommandLoggable
|
class DLLEXPORT DatabaseCommand_ShareTrack : public DatabaseCommandLoggable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( QString artist READ artist WRITE setArtist )
|
Q_PROPERTY( QString artist READ artist WRITE setArtist )
|
||||||
|
@@ -30,8 +30,6 @@ public:
|
|||||||
explicit InboxModel( QObject* parent = 0 );
|
explicit InboxModel( QObject* parent = 0 );
|
||||||
virtual ~InboxModel();
|
virtual ~InboxModel();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -21,6 +21,9 @@
|
|||||||
#include "SourceItem.h"
|
#include "SourceItem.h"
|
||||||
|
|
||||||
#include "CategoryItems.h"
|
#include "CategoryItems.h"
|
||||||
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseCommand_ShareTrack.h"
|
||||||
|
#include "DropJob.h"
|
||||||
#include "PlaylistItems.h"
|
#include "PlaylistItems.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "Playlist.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*
|
CategoryItem*
|
||||||
SourceItem::stationsCategory() const
|
SourceItem::stationsCategory() const
|
||||||
{
|
{
|
||||||
@@ -703,3 +721,43 @@ SourceItem::setPlaylistsCategory(CategoryItem* item)
|
|||||||
{
|
{
|
||||||
m_playlists = 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 setStationsCategory( CategoryItem* item );
|
||||||
void setPlaylistsCategory( 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:
|
public slots:
|
||||||
virtual void activate();
|
virtual void activate();
|
||||||
|
|
||||||
@@ -90,6 +94,8 @@ private slots:
|
|||||||
Tomahawk::ViewPage* recentPlaysClicked();
|
Tomahawk::ViewPage* recentPlaysClicked();
|
||||||
Tomahawk::ViewPage* getRecentPlaysPage() const;
|
Tomahawk::ViewPage* getRecentPlaysPage() const;
|
||||||
|
|
||||||
|
void onTracksDropped( const QList< Tomahawk::query_ptr >& queries );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
|
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
Reference in New Issue
Block a user