mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
* Set remote playlists to readonly.
* Disable context menu entries for readonly playlists. * Don't allow dropping items on readonly playlists. * VCard work on Jabber client.
This commit is contained in:
@@ -425,7 +425,7 @@ Jabber_p::handleRosterPresence( const RosterItem& item, const std::string& resou
|
||||
return;
|
||||
}
|
||||
|
||||
// "coming online " event
|
||||
// "coming online" event
|
||||
if( presenceMeansOnline( presence ) &&
|
||||
( !m_peers.contains( fulljid ) ||
|
||||
!presenceMeansOnline( m_peers.value( fulljid ) )
|
||||
@@ -478,6 +478,20 @@ Jabber_p::handleNonrosterPresence( const Presence& presence )
|
||||
/// END ROSTER STUFF
|
||||
|
||||
|
||||
void
|
||||
Jabber_p::handleVCard( const JID& jid, const VCard* vcard )
|
||||
{
|
||||
qDebug() << "VCARD RECEIVED!" << jid.bare().c_str();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber_p::handleVCardResult( VCardContext context, const JID& jid, StanzaError se )
|
||||
{
|
||||
qDebug() << "VCARD RESULT RECEIVED!" << jid.bare().c_str();
|
||||
}
|
||||
|
||||
|
||||
/// DISCO STUFF
|
||||
void
|
||||
Jabber_p::handleDiscoInfo( const JID& from, const Disco::Info& info, int context)
|
||||
@@ -525,8 +539,3 @@ bool Jabber_p::presenceMeansOnline( Presence::PresenceType p )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -41,6 +41,9 @@
|
||||
#include <gloox/error.h>
|
||||
#include <gloox/presence.h>
|
||||
#include <gloox/rosteritem.h>
|
||||
#include <gloox/vcard.h>
|
||||
#include <gloox/vcardhandler.h>
|
||||
#include <gloox/vcardmanager.h>
|
||||
|
||||
#if defined( WIN32 ) || defined( _WIN32 )
|
||||
# include <windows.h>
|
||||
@@ -51,6 +54,7 @@ class Jabber_p :
|
||||
public gloox::ConnectionListener,
|
||||
public gloox::RosterListener,
|
||||
public gloox::MessageHandler,
|
||||
public gloox::VCardHandler,
|
||||
gloox::LogHandler
|
||||
//public gloox::DiscoHandler,
|
||||
{
|
||||
@@ -91,6 +95,9 @@ public:
|
||||
virtual void handleNonrosterPresence( const gloox::Presence& presence );
|
||||
/// END ROSTER STUFF
|
||||
|
||||
virtual void handleVCard( const gloox::JID& jid, const gloox::VCard* vcard );
|
||||
virtual void handleVCardResult( gloox::VCardHandler::VCardContext context, const gloox::JID& jid, gloox::StanzaError se );
|
||||
|
||||
/// DISCO STUFF
|
||||
virtual void handleDiscoInfo( const gloox::JID& from, const gloox::Disco::Info& info, int context);
|
||||
virtual void handleDiscoItems( const gloox::JID& /*iq*/, const gloox::Disco::Items&, int /*context*/ );
|
||||
@@ -115,7 +122,6 @@ public slots:
|
||||
void broadcastMsg( const QString &msg );
|
||||
|
||||
private slots:
|
||||
|
||||
void doJabberRecv();
|
||||
|
||||
private:
|
||||
@@ -125,6 +131,7 @@ private:
|
||||
gloox::JID m_jid;
|
||||
QMap<gloox::Presence::PresenceType, QString> m_presences;
|
||||
QMap<QString, gloox::Presence::PresenceType> m_peers;
|
||||
QSharedPointer<gloox::VCardManager> m_vcardManager;
|
||||
QTimer m_timer; // for recv()
|
||||
};
|
||||
|
||||
|
@@ -67,7 +67,7 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
||||
disconnect( collection.data(), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ),
|
||||
this, SLOT( onTracksAddingFinished( Tomahawk::collection_ptr ) ) );
|
||||
|
||||
QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
||||
// QList<PlItem*> plitems = m_collectionIndex.values( collection );
|
||||
QList< QPair< int, int > > rows;
|
||||
QList< QPair< int, int > > sortrows;
|
||||
QPair< int, int > row;
|
||||
@@ -113,11 +113,15 @@ CollectionFlatModel::removeCollection( const collection_ptr& collection )
|
||||
|
||||
qDebug() << "Removing rows:" << row.first << row.second;
|
||||
emit beginRemoveRows( QModelIndex(), row.first, row.second );
|
||||
for ( int i = row.second; i >= row.first; i-- )
|
||||
{
|
||||
PlItem* item = itemFromIndex( index( i, 0, QModelIndex() ) );
|
||||
delete item;
|
||||
}
|
||||
emit endRemoveRows();
|
||||
}
|
||||
|
||||
qDeleteAll( plitems );
|
||||
m_collectionIndex.remove( collection );
|
||||
// m_collectionIndex.remove( collection );
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +154,7 @@ CollectionFlatModel::onTracksAdded( const QList<QVariant>& tracks, const collect
|
||||
|
||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
|
||||
m_collectionIndex.insertMulti( collection, plitem );
|
||||
// m_collectionIndex.insertMulti( collection, plitem );
|
||||
}
|
||||
|
||||
m_collectionRows.insertMulti( collection, crows );
|
||||
@@ -183,7 +187,7 @@ CollectionFlatModel::onSourceOffline( const Tomahawk::source_ptr& src )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( m_collectionIndex.contains( src->collection() ) )
|
||||
if ( m_collectionRows.contains( src->collection() ) )
|
||||
{
|
||||
removeCollection( src->collection() );
|
||||
}
|
||||
|
@@ -50,7 +50,6 @@ private slots:
|
||||
void onSourceOffline( const Tomahawk::source_ptr& src );
|
||||
|
||||
private:
|
||||
QMap< Tomahawk::collection_ptr, PlItem* > m_collectionIndex;
|
||||
QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
|
||||
};
|
||||
|
||||
|
@@ -38,6 +38,9 @@ void
|
||||
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
PlItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( !item )
|
||||
return;
|
||||
|
||||
if ( item->query()->results().count() )
|
||||
painter->setOpacity( item->query()->results().at( 0 )->score() );
|
||||
else
|
||||
|
@@ -59,6 +59,8 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
|
||||
m_playlist = playlist;
|
||||
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
|
||||
|
||||
setReadOnly( !m_playlist->author()->isLocal() );
|
||||
|
||||
PlItem* plitem;
|
||||
QList<plentry_ptr> entries = playlist->entries();
|
||||
int c = rowCount( QModelIndex() );
|
||||
@@ -110,7 +112,7 @@ PlaylistModel::onRevisionLoaded( Tomahawk::PlaylistRevision revision )
|
||||
bool
|
||||
PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
|
||||
{
|
||||
if ( action == Qt::IgnoreAction )
|
||||
if ( action == Qt::IgnoreAction || isReadOnly() )
|
||||
return true;
|
||||
|
||||
if ( !data->hasFormat( "application/tomahawk.query.list" ) && !data->hasFormat( "application/tomahawk.plentry.list" ) )
|
||||
@@ -210,6 +212,9 @@ PlaylistModel::playlistEntries() const
|
||||
void
|
||||
PlaylistModel::removeIndex( const QModelIndex& index )
|
||||
{
|
||||
if ( isReadOnly() )
|
||||
return;
|
||||
|
||||
TrackModel::removeIndex( index );
|
||||
|
||||
m_waitForUpdate = true;
|
||||
|
@@ -12,7 +12,9 @@ PlaylistView::PlaylistView( QWidget* parent )
|
||||
: TrackView( parent )
|
||||
{
|
||||
setProxyModel( new PlaylistProxyModel( this ) );
|
||||
setupMenus();
|
||||
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +27,20 @@ PlaylistView::~PlaylistView()
|
||||
void
|
||||
PlaylistView::setupMenus()
|
||||
{
|
||||
m_itemMenu.clear();
|
||||
|
||||
m_playItemAction = m_itemMenu.addAction( tr( "&Play" ) );
|
||||
m_itemMenu.addSeparator();
|
||||
m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
||||
m_itemMenu.addSeparator();
|
||||
m_deleteItemAction = m_itemMenu.addAction( tr( "&Delete Item" ) );
|
||||
|
||||
if ( model() )
|
||||
m_deleteItemAction->setEnabled( !model()->isReadOnly() );
|
||||
|
||||
connect( m_playItemAction, SIGNAL( triggered() ), SLOT( playItem() ) );
|
||||
connect( m_addItemsToPlaylistAction, SIGNAL( triggered() ), SLOT( addItemsToPlaylist() ) );
|
||||
connect( m_deleteItemAction, SIGNAL( triggered() ), SLOT( deleteItem() ) );
|
||||
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +48,7 @@ void
|
||||
PlaylistView::onCustomContextMenu( const QPoint& pos )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
setupMenus();
|
||||
|
||||
QModelIndex idx = indexAt( pos );
|
||||
idx = idx.sibling( idx.row(), 0 );
|
||||
@@ -81,7 +86,7 @@ PlaylistView::playItem()
|
||||
|
||||
|
||||
void
|
||||
PlaylistView::addItemToPlaylist()
|
||||
PlaylistView::addItemsToPlaylist()
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ private slots:
|
||||
void onCustomContextMenu( const QPoint& pos );
|
||||
|
||||
void playItem();
|
||||
void addItemToPlaylist();
|
||||
void addItemsToPlaylist();
|
||||
void deleteItem();
|
||||
|
||||
private:
|
||||
|
@@ -11,6 +11,7 @@ using namespace Tomahawk;
|
||||
|
||||
TrackModel::TrackModel( QObject* parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, m_readOnly( true )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@ public:
|
||||
virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
|
||||
virtual QModelIndex parent( const QModelIndex& child ) const;
|
||||
|
||||
virtual bool isReadOnly() const { return m_readOnly; }
|
||||
|
||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||
|
||||
virtual int rowCount( const QModelIndex& parent ) const;
|
||||
@@ -52,8 +54,12 @@ public slots:
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
||||
virtual void setShuffled( bool shuffled ) {}
|
||||
|
||||
protected:
|
||||
virtual void setReadOnly( bool b ) { m_readOnly = b; }
|
||||
|
||||
private:
|
||||
QPersistentModelIndex m_currentIndex;
|
||||
bool m_readOnly;
|
||||
};
|
||||
|
||||
#endif // TRACKMODEL_H
|
||||
|
@@ -208,6 +208,12 @@ TrackView::dragMoveEvent( QDragMoveEvent* event )
|
||||
{
|
||||
QTreeView::dragMoveEvent( event );
|
||||
|
||||
if ( model()->isReadOnly() )
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event->mimeData()->hasFormat( "application/tomahawk.query.list" ) || event->mimeData()->hasFormat( "application/tomahawk.plentry.list" ) )
|
||||
{
|
||||
setDirtyRegion( m_dropRect );
|
||||
|
@@ -31,7 +31,8 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
setDropIndicatorShown( false );
|
||||
setAllColumnsShowFocus( false );
|
||||
|
||||
setupMenus();
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
||||
|
||||
m_model = new SourcesModel( this );
|
||||
setModel( m_model );
|
||||
@@ -50,15 +51,30 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
void
|
||||
SourceTreeView::setupMenus()
|
||||
{
|
||||
m_playlistMenu.clear();
|
||||
|
||||
m_loadPlaylistAction = m_playlistMenu.addAction( tr( "&Load Playlist" ) );
|
||||
m_playlistMenu.addSeparator();
|
||||
m_deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete Playlist" ) );
|
||||
|
||||
bool readonly = true;
|
||||
int type = SourcesModel::indexType( m_contextMenuIndex );
|
||||
if ( type == 1 )
|
||||
{
|
||||
playlist_ptr playlist = SourcesModel::indexToPlaylist( m_contextMenuIndex );
|
||||
if ( !playlist.isNull() )
|
||||
{
|
||||
readonly = !playlist->author()->isLocal();
|
||||
}
|
||||
}
|
||||
|
||||
if ( readonly )
|
||||
{
|
||||
m_deletePlaylistAction->setEnabled( !readonly );
|
||||
}
|
||||
|
||||
connect( m_loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
||||
connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
||||
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +178,8 @@ SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
||||
if ( !idx.isValid() )
|
||||
return;
|
||||
|
||||
setupMenus();
|
||||
|
||||
if ( SourcesModel::indexType( idx ) )
|
||||
{
|
||||
m_playlistMenu.exec( mapToGlobal( pos ) );
|
||||
|
Reference in New Issue
Block a user