mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-02-22 19:05:05 +01:00
Initial commit for listening suggestions. Dbcmd and stubs.
This commit is contained in:
parent
24d8788ee2
commit
04fc5f6f37
@ -43,6 +43,7 @@ set( libGuiSources
|
||||
|
||||
infobar/InfoBar.cpp
|
||||
|
||||
playlist/InboxModel.cpp
|
||||
playlist/FlexibleHeader.cpp
|
||||
playlist/FlexibleView.cpp
|
||||
playlist/TreeModel.cpp
|
||||
@ -267,6 +268,7 @@ list(APPEND libSources
|
||||
database/DatabaseCommand_TrackAttributes.cpp
|
||||
database/DatabaseCommand_SetTrackAttributes.cpp
|
||||
database/DatabaseCommand_PlaybackCharts.cpp
|
||||
database/DatabaseCommand_ShareTrack.cpp
|
||||
database/Database.cpp
|
||||
database/TomahawkSqlQuery.cpp
|
||||
database/IdThreadWorker.cpp
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
* Copyright 2010-2012, Leo Franchi <lfranchi@kde.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
|
||||
@ -37,6 +38,7 @@
|
||||
#include "SourceList.h"
|
||||
#include "TomahawkSettings.h"
|
||||
|
||||
#include "playlist/InboxModel.h"
|
||||
#include "playlist/PlaylistLargeItemDelegate.h"
|
||||
#include "playlist/RecentlyPlayedModel.h"
|
||||
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
||||
@ -78,6 +80,7 @@ ViewManager::ViewManager( QObject* parent )
|
||||
, m_whatsHotWidget( 0 )
|
||||
, m_newReleasesWidget( 0 )
|
||||
, m_recentPlaysWidget( 0 )
|
||||
, m_inboxWidget( 0 )
|
||||
, m_currentPage( 0 )
|
||||
, m_loaded( false )
|
||||
{
|
||||
@ -87,6 +90,11 @@ ViewManager::ViewManager( QObject* parent )
|
||||
m_infobar = new InfoBar();
|
||||
m_stack = new QStackedWidget();
|
||||
|
||||
m_inboxModel = new InboxModel( this );
|
||||
m_inboxModel->setTitle( tr( "Inbox" ) );
|
||||
m_inboxModel->setDescription( tr( "Listening suggestions from your friends" ) );
|
||||
m_inboxModel->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::Inbox ) );
|
||||
|
||||
m_contextWidget = new ContextWidget();
|
||||
|
||||
m_widget->layout()->addWidget( m_infobar );
|
||||
@ -124,6 +132,7 @@ ViewManager::~ViewManager()
|
||||
delete m_newReleasesWidget;
|
||||
delete m_welcomeWidget;
|
||||
delete m_recentPlaysWidget;
|
||||
delete m_inboxWidget;
|
||||
delete m_contextWidget;
|
||||
delete m_widget;
|
||||
}
|
||||
@ -426,6 +435,37 @@ ViewManager::showRecentPlaysPage()
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::ViewPage *
|
||||
ViewManager::showInboxPage()
|
||||
{
|
||||
if ( !m_inboxWidget )
|
||||
{
|
||||
TrackView* inboxView = new TrackView( m_widget );
|
||||
|
||||
PlaylistLargeItemDelegate* delegate =
|
||||
new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::/*Inbox*/LovedTracks,
|
||||
inboxView,
|
||||
inboxView->proxyModel() );
|
||||
connect( delegate, SIGNAL( updateIndex( QModelIndex ) ),
|
||||
inboxView, SLOT( update( QModelIndex ) ) );
|
||||
inboxView->setItemDelegate( delegate );
|
||||
|
||||
inboxView->setPlayableModel( m_inboxModel );
|
||||
inboxView->setEmptyTip( tr( "No listening suggestions here." ) );
|
||||
|
||||
inboxView->setGuid( "inbox" );
|
||||
|
||||
inboxView->proxyModel()->setStyle( PlayableProxyModel::Large );
|
||||
inboxView->setSortingEnabled( false );
|
||||
inboxView->setHeaderHidden( true );
|
||||
|
||||
m_inboxWidget = inboxView;
|
||||
}
|
||||
|
||||
return show( m_inboxWidget );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setFilter( const QString& filter )
|
||||
{
|
||||
@ -806,9 +846,21 @@ ViewManager::recentPlaysWidget() const
|
||||
return m_recentPlaysWidget;
|
||||
}
|
||||
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::inboxWidget() const
|
||||
{
|
||||
return m_inboxWidget;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::superCollectionView() const
|
||||
{
|
||||
return m_superCollectionView;
|
||||
}
|
||||
|
||||
InboxModel*
|
||||
ViewManager::inboxModel()
|
||||
{
|
||||
return m_inboxModel;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class NewReleasesWidget;
|
||||
class WelcomeWidget;
|
||||
class WhatsHotWidget;
|
||||
class QPushButton;
|
||||
class InboxModel;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@ -92,6 +93,9 @@ public:
|
||||
Tomahawk::ViewPage* newReleasesWidget() const;
|
||||
Tomahawk::ViewPage* recentPlaysWidget() const;
|
||||
Tomahawk::ViewPage* superCollectionView() const;
|
||||
Tomahawk::ViewPage* inboxWidget() const;
|
||||
|
||||
InboxModel* inboxModel();
|
||||
|
||||
/// Get the view page for the given item. Not pretty...
|
||||
Tomahawk::ViewPage* pageForPlaylist( const Tomahawk::playlist_ptr& pl ) const;
|
||||
@ -130,6 +134,7 @@ public slots:
|
||||
Tomahawk::ViewPage* showWhatsHotPage();
|
||||
Tomahawk::ViewPage* showNewReleasesPage();
|
||||
Tomahawk::ViewPage* showRecentPlaysPage();
|
||||
Tomahawk::ViewPage* showInboxPage();
|
||||
void showCurrentTrack();
|
||||
|
||||
// Returns the shown viewpage
|
||||
@ -181,6 +186,8 @@ private:
|
||||
WhatsHotWidget* m_whatsHotWidget;
|
||||
NewReleasesWidget* m_newReleasesWidget;
|
||||
Tomahawk::ViewPage* m_recentPlaysWidget;
|
||||
Tomahawk::ViewPage* m_inboxWidget;
|
||||
InboxModel* m_inboxModel;
|
||||
|
||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||
|
||||
|
97
src/libtomahawk/database/DatabaseCommand_ShareTrack.cpp
Normal file
97
src/libtomahawk/database/DatabaseCommand_ShareTrack.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/* === This file is part of Tomahawk Player - <http://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
|
||||
* 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_ShareTrack.h"
|
||||
|
||||
#include "Artist.h"
|
||||
#include "Database.h"
|
||||
#include "DatabaseImpl.h"
|
||||
#include "network/Servent.h"
|
||||
#include "ViewManager.h"
|
||||
#include "playlist/InboxModel.h"
|
||||
|
||||
DatabaseCommand_ShareTrack::DatabaseCommand_ShareTrack( QObject* parent )
|
||||
: DatabaseCommandLoggable( parent )
|
||||
{}
|
||||
|
||||
|
||||
DatabaseCommand_ShareTrack::DatabaseCommand_ShareTrack( const Tomahawk::query_ptr& query,
|
||||
const QString& recipientDbid,
|
||||
QObject* parent )
|
||||
: DatabaseCommandLoggable( parent )
|
||||
, m_query( query )
|
||||
, m_recipient( recipientDbid )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
|
||||
setArtist( query->artist() );
|
||||
setTrack( query->track() );
|
||||
}
|
||||
|
||||
|
||||
DatabaseCommand_ShareTrack::DatabaseCommand_ShareTrack( const Tomahawk::result_ptr& result,
|
||||
const QString& recipientDbid,
|
||||
QObject* parent )
|
||||
: DatabaseCommandLoggable( parent )
|
||||
, m_result( result )
|
||||
, m_recipient( recipientDbid )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
|
||||
setArtist( result->artist()->name() );
|
||||
setTrack( result->track() );
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseCommand_ShareTrack::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
Q_ASSERT( !source().isNull() );
|
||||
}
|
||||
|
||||
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 ( myDbid != m_recipient || sourceDbid == m_recipient )
|
||||
return;
|
||||
|
||||
//From here on, everything happens only on the recipient, and only if recipient!=source
|
||||
if ( !m_result.isNull() && m_query.isNull() )
|
||||
{
|
||||
m_query = m_result->toQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_query = Tomahawk::Query::get( m_artist, m_track, QString() );
|
||||
}
|
||||
|
||||
if ( m_query.isNull() )
|
||||
return;
|
||||
|
||||
QMetaObject::invokeMethod( ViewManager::instance()->inboxModel(),
|
||||
"appendQuery",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG( const Tomahawk::query_ptr&, m_query ) );
|
||||
}
|
79
src/libtomahawk/database/DatabaseCommand_ShareTrack.h
Normal file
79
src/libtomahawk/database/DatabaseCommand_ShareTrack.h
Normal file
@ -0,0 +1,79 @@
|
||||
/* === This file is part of Tomahawk Player - <http://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
|
||||
* 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_SHARETRACK_H
|
||||
#define DATABASECOMMAND_SHARETRACK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include "database/DatabaseCommandLoggable.h"
|
||||
#include "SourceList.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
class DatabaseCommand_ShareTrack : public DatabaseCommandLoggable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString artist READ artist WRITE setArtist )
|
||||
Q_PROPERTY( QString track READ track WRITE setTrack )
|
||||
Q_PROPERTY( QString recipient READ recipient WRITE setRecipient )
|
||||
|
||||
public:
|
||||
explicit DatabaseCommand_ShareTrack( QObject* parent = 0 );
|
||||
|
||||
explicit DatabaseCommand_ShareTrack( const Tomahawk::query_ptr& query,
|
||||
const QString& recipientDbid,
|
||||
QObject* parent = 0 );
|
||||
|
||||
explicit DatabaseCommand_ShareTrack( const Tomahawk::result_ptr& result,
|
||||
const QString& recipientDbid,
|
||||
QObject* parent = 0 );
|
||||
|
||||
//TODO: construct from result instead?
|
||||
|
||||
virtual QString commandname() const { return "sharetrack"; }
|
||||
|
||||
virtual void exec( DatabaseImpl* );
|
||||
virtual void postCommitHook();
|
||||
|
||||
virtual bool doesMutates() const { return false; }
|
||||
virtual bool singletonCmd() const { return false; }
|
||||
virtual bool localOnly() const { return false; }
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
QString artist() const { return m_artist; }
|
||||
void setArtist( const QString& s ) { m_artist = s; }
|
||||
|
||||
QString track() const { return m_track; }
|
||||
void setTrack( const QString& s ) { m_track = s; }
|
||||
|
||||
QString recipient() const { return m_recipient; }
|
||||
void setRecipient( const QString& s ) { m_recipient = s; }
|
||||
|
||||
private:
|
||||
Tomahawk::query_ptr m_query;
|
||||
Tomahawk::result_ptr m_result;
|
||||
|
||||
QString m_artist;
|
||||
QString m_track;
|
||||
QString m_recipient;
|
||||
};
|
||||
|
||||
#endif // DATABASECOMMAND_SHARETRACK_H
|
27
src/libtomahawk/playlist/InboxModel.cpp
Normal file
27
src/libtomahawk/playlist/InboxModel.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/* === This file is part of Tomahawk Player - <http://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
|
||||
* 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 "InboxModel.h"
|
||||
|
||||
InboxModel::InboxModel( QObject* parent )
|
||||
: PlaylistModel( parent )
|
||||
{
|
||||
}
|
||||
|
||||
InboxModel::~InboxModel()
|
||||
{}
|
39
src/libtomahawk/playlist/InboxModel.h
Normal file
39
src/libtomahawk/playlist/InboxModel.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* === This file is part of Tomahawk Player - <http://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
|
||||
* 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 INBOXMODEL_H
|
||||
#define INBOXMODEL_H
|
||||
|
||||
#include "PlaylistModel.h"
|
||||
#include "Typedefs.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
class DLLEXPORT InboxModel : public PlaylistModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InboxModel( QObject* parent = 0 );
|
||||
virtual ~InboxModel();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // INBOXMODEL_H
|
@ -41,7 +41,7 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DisplayMode
|
||||
{ LovedTracks, RecentlyPlayed, LatestAdditions };
|
||||
{ LovedTracks, RecentlyPlayed, LatestAdditions, Inbox };
|
||||
|
||||
PlaylistLargeItemDelegate( DisplayMode mode, TrackView* parent = 0, PlayableProxyModel* proxy = 0 );
|
||||
|
||||
|
@ -121,6 +121,7 @@ namespace TomahawkUtils
|
||||
SipPluginOnline,
|
||||
SipPluginOffline,
|
||||
ResolverBundle,
|
||||
Inbox,
|
||||
Invalid
|
||||
};
|
||||
|
||||
|
@ -711,6 +711,10 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
|
||||
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-all-songs.svg", size );
|
||||
break;
|
||||
|
||||
case Inbox:
|
||||
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/downloading.svg", size );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -326,6 +326,11 @@ SourcesModel::appendGroups()
|
||||
boost::bind( &ViewManager::newReleasesWidget, ViewManager::instance() ) );
|
||||
newReleases->setSortValue( 5 );
|
||||
|
||||
GenericPageItem* inbox = new GenericPageItem( this, browse, tr( "Inbox" ), ImageRegistry::instance()->icon( RESPATH "images/downloading.svg" ),
|
||||
boost::bind( &ViewManager::showInboxPage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::inboxWidget, ViewManager::instance() ) );
|
||||
inbox->setSortValue( 6 );
|
||||
|
||||
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 );
|
||||
|
||||
m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user