mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Merge branch 'stable'
Conflicts: src/libtomahawk/CMakeLists.txt src/libtomahawk/playlist/treemodel.cpp src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h src/tomahawkapp.cpp
This commit is contained in:
@@ -119,6 +119,7 @@ set( libGuiSources
|
|||||||
utils/dropjobnotifier.cpp
|
utils/dropjobnotifier.cpp
|
||||||
utils/proxystyle.cpp
|
utils/proxystyle.cpp
|
||||||
utils/tomahawkutilsgui.cpp
|
utils/tomahawkutilsgui.cpp
|
||||||
|
utils/closure.cpp
|
||||||
|
|
||||||
widgets/animatedcounterlabel.cpp
|
widgets/animatedcounterlabel.cpp
|
||||||
widgets/checkdirtree.cpp
|
widgets/checkdirtree.cpp
|
||||||
|
@@ -64,8 +64,6 @@ PlaylistUpdaterInterface::PlaylistUpdaterInterface( const playlist_ptr& pl )
|
|||||||
connect( m_timer, SIGNAL( timeout() ), this, SLOT( updateNow() ) );
|
connect( m_timer, SIGNAL( timeout() ), this, SLOT( updateNow() ) );
|
||||||
|
|
||||||
QTimer::singleShot( 0, this, SLOT( doSave() ) );
|
QTimer::singleShot( 0, this, SLOT( doSave() ) );
|
||||||
|
|
||||||
setAutoUpdate( m_autoUpdate );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistUpdaterInterface::PlaylistUpdaterInterface( const playlist_ptr& pl, int interval, bool autoUpdate )
|
PlaylistUpdaterInterface::PlaylistUpdaterInterface( const playlist_ptr& pl, int interval, bool autoUpdate )
|
||||||
|
@@ -55,8 +55,15 @@ XspfUpdater::~XspfUpdater()
|
|||||||
void
|
void
|
||||||
XspfUpdater::updateNow()
|
XspfUpdater::updateNow()
|
||||||
{
|
{
|
||||||
|
if ( m_url.isEmpty() )
|
||||||
|
{
|
||||||
|
qWarning() << "XspfUpdater not updating because we have an empty url...";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
XSPFLoader* l = new XSPFLoader( false, false );
|
XSPFLoader* l = new XSPFLoader( false, false );
|
||||||
l->setAutoResolveTracks( false );
|
l->setAutoResolveTracks( false );
|
||||||
|
l->setErrorTitle( playlist()->title() );
|
||||||
l->load( m_url );
|
l->load( m_url );
|
||||||
connect( l, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( playlistLoaded( QList<Tomahawk::query_ptr> ) ) );
|
connect( l, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( playlistLoaded( QList<Tomahawk::query_ptr> ) ) );
|
||||||
}
|
}
|
||||||
|
@@ -97,10 +97,13 @@ PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const
|
|||||||
if ( item->isPlaying() )
|
if ( item->isPlaying() )
|
||||||
{
|
{
|
||||||
option->palette.setColor( QPalette::Highlight, option->palette.color( QPalette::Mid ) );
|
option->palette.setColor( QPalette::Highlight, option->palette.color( QPalette::Mid ) );
|
||||||
option->state |= QStyle::State_Selected;
|
|
||||||
|
option->backgroundBrush = option->palette.color( QPalette::Mid );
|
||||||
|
option->palette.setColor( QPalette::Text, option->palette.color( QPalette::Text ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( option->state & QStyle::State_Selected )
|
if ( option->state & QStyle::State_Selected && !item->isPlaying() )
|
||||||
{
|
{
|
||||||
option->palette.setColor( QPalette::Text, option->palette.color( QPalette::HighlightedText ) );
|
option->palette.setColor( QPalette::Text, option->palette.color( QPalette::HighlightedText ) );
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "dynamic/widgets/LoadingSpinner.h"
|
#include "dynamic/widgets/LoadingSpinner.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include "utils/closure.h"
|
||||||
#include "dropjob.h"
|
#include "dropjob.h"
|
||||||
#include "artist.h"
|
#include "artist.h"
|
||||||
#include "album.h"
|
#include "album.h"
|
||||||
@@ -205,6 +206,41 @@ TrackView::onScrollTimeout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackView::startPlayingFromStart()
|
||||||
|
{
|
||||||
|
if ( m_proxyModel->rowCount() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QModelIndex index = m_proxyModel->index( 0, 0 );
|
||||||
|
startAutoPlay( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackView::autoPlayResolveFinished( const query_ptr& query, int row )
|
||||||
|
{
|
||||||
|
Q_ASSERT( !query.isNull() );
|
||||||
|
Q_ASSERT( row >= 0 );
|
||||||
|
|
||||||
|
if ( query.isNull() || row < 0 || query != m_autoPlaying )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QModelIndex index = m_proxyModel->index( row, 0 );
|
||||||
|
if ( query->playable() )
|
||||||
|
{
|
||||||
|
onItemActivated( index );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try the next one..
|
||||||
|
const QModelIndex sib = index.sibling( index.row() + 1, index.column() );
|
||||||
|
if ( sib.isValid() )
|
||||||
|
startAutoPlay( sib );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
|
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
|
||||||
{
|
{
|
||||||
@@ -227,15 +263,48 @@ TrackView::onItemActivated( const QModelIndex& index )
|
|||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tryToPlayItem( index );
|
||||||
|
emit itemActivated( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackView::startAutoPlay( const QModelIndex& index )
|
||||||
|
{
|
||||||
|
if ( tryToPlayItem( index ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// item isn't playable but still resolving
|
||||||
|
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
|
if ( item && !item->query().isNull() && !item->query()->resolvingFinished() )
|
||||||
|
{
|
||||||
|
m_autoPlaying = item->query(); // So we can kill it if user starts autoplaying this playlist again
|
||||||
|
NewClosure( item->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( autoPlayResolveFinished( Tomahawk::query_ptr, int ) ),
|
||||||
|
item->query(), index.row() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not playable at all, try next
|
||||||
|
const QModelIndex sib = index.sibling( index.row() + 1, index.column() );
|
||||||
|
if ( sib.isValid() )
|
||||||
|
startAutoPlay( sib );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TrackView::tryToPlayItem( const QModelIndex& index )
|
||||||
|
{
|
||||||
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
if ( item && !item->query().isNull() && item->query()->numResults() )
|
if ( item && !item->query().isNull() && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
tDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url();
|
||||||
m_proxyModel->setCurrentIndex( index );
|
m_proxyModel->setCurrentIndex( index );
|
||||||
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query()->results().first() );
|
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query()->results().first() );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit itemActivated( index );
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -66,6 +66,9 @@ public:
|
|||||||
bool updatesContextView() const { return m_updateContextView; }
|
bool updatesContextView() const { return m_updateContextView; }
|
||||||
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
||||||
|
|
||||||
|
// Starts playing from the beginning if resolved, or waits until a track is playable
|
||||||
|
void startPlayingFromStart();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void onItemActivated( const QModelIndex& index );
|
virtual void onItemActivated( const QModelIndex& index );
|
||||||
|
|
||||||
@@ -103,7 +106,11 @@ private slots:
|
|||||||
|
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
|
|
||||||
|
void autoPlayResolveFinished( const Tomahawk::query_ptr& query, int row );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void startAutoPlay( const QModelIndex& index );
|
||||||
|
bool tryToPlayItem( const QModelIndex& index );
|
||||||
void updateHoverIndex( const QPoint& pos );
|
void updateHoverIndex( const QPoint& pos );
|
||||||
|
|
||||||
QString m_guid;
|
QString m_guid;
|
||||||
@@ -122,6 +129,9 @@ private:
|
|||||||
|
|
||||||
QModelIndex m_hoveredIndex;
|
QModelIndex m_hoveredIndex;
|
||||||
QModelIndex m_contextMenuIndex;
|
QModelIndex m_contextMenuIndex;
|
||||||
|
|
||||||
|
Tomahawk::query_ptr m_autoPlaying;
|
||||||
|
|
||||||
Tomahawk::ContextMenu* m_contextMenu;
|
Tomahawk::ContextMenu* m_contextMenu;
|
||||||
|
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2012, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -623,7 +624,7 @@ TreeModel::addAlbums( const artist_ptr& artist, const QModelIndex& parent, bool
|
|||||||
requestData.caller = m_infoId;
|
requestData.caller = m_infoId;
|
||||||
requestData.customData["row"] = parent.row();
|
requestData.customData["row"] = parent.row();
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
||||||
requestData.customData["refetch"] = QVariant( autoRefetch );
|
requestData.customData["refetch"] = autoRefetch;
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;
|
requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
}
|
}
|
||||||
@@ -661,8 +662,8 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent, bool au
|
|||||||
m_receivedInfoData.removeAll( artistInfo );
|
m_receivedInfoData.removeAll( artistInfo );
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
requestData.caller = m_infoId;
|
requestData.caller = m_infoId;
|
||||||
requestData.customData["rows"] = QVariant( rows );
|
requestData.customData["rows"] = rows;
|
||||||
requestData.customData["refetch"] = QVariant( autoRefetch );
|
requestData.customData["refetch"] = autoRefetch;
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumSongs;
|
requestData.type = Tomahawk::InfoSystem::InfoAlbumSongs;
|
||||||
requestData.timeoutMillis = 0;
|
requestData.timeoutMillis = 0;
|
||||||
@@ -887,7 +888,7 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
|||||||
|
|
||||||
QModelIndex idx = index( requestData.customData[ "row" ].toInt(), 0, QModelIndex() );
|
QModelIndex idx = index( requestData.customData[ "row" ].toInt(), 0, QModelIndex() );
|
||||||
|
|
||||||
if ( requestData.customData[ "refetch" ].toInt() > 0 && !al.count() )
|
if ( requestData.customData[ "refetch" ].toBool() && !al.count() )
|
||||||
{
|
{
|
||||||
setMode( DatabaseMode );
|
setMode( DatabaseMode );
|
||||||
|
|
||||||
@@ -941,7 +942,13 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
|||||||
}
|
}
|
||||||
else if ( m_receivedInfoData.count() == 2 /* FIXME */ )
|
else if ( m_receivedInfoData.count() == 2 /* FIXME */ )
|
||||||
{
|
{
|
||||||
if ( requestData.customData[ "refetch" ].toInt() > 0 )
|
// If the second load got no data, but the first load did, don't do anything
|
||||||
|
QList< QVariant > rows = requestData.customData[ "rows" ].toList();
|
||||||
|
QModelIndex idx = index( rows.first().toUInt(), 0, index( rows.at( 1 ).toUInt(), 0, QModelIndex() ) );
|
||||||
|
if ( rowCount( idx ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( requestData.customData[ "refetch" ].toBool() )
|
||||||
{
|
{
|
||||||
setMode( DatabaseMode );
|
setMode( DatabaseMode );
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
|||||||
, m_ready( false )
|
, m_ready( false )
|
||||||
, m_stopped( true )
|
, m_stopped( true )
|
||||||
, m_configSent( false )
|
, m_configSent( false )
|
||||||
|
, m_deleting( false )
|
||||||
, m_error( Tomahawk::ExternalResolver::NoError )
|
, m_error( Tomahawk::ExternalResolver::NoError )
|
||||||
{
|
{
|
||||||
tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
|
tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
|
||||||
@@ -62,9 +63,10 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
|||||||
ScriptResolver::~ScriptResolver()
|
ScriptResolver::~ScriptResolver()
|
||||||
{
|
{
|
||||||
disconnect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
|
disconnect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
|
||||||
|
m_deleting = true;
|
||||||
|
|
||||||
m_proc.kill();
|
m_proc.kill();
|
||||||
m_proc.waitForFinished();
|
m_proc.waitForFinished(); // might call handleMsg
|
||||||
|
|
||||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||||
|
|
||||||
@@ -208,6 +210,10 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
|||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO << msg.size() << QString::fromAscii( msg );
|
// qDebug() << Q_FUNC_INFO << msg.size() << QString::fromAscii( msg );
|
||||||
|
|
||||||
|
// Might be called from waitForFinished() in ~ScriptResolver, no database in that case, abort.
|
||||||
|
if ( m_deleting )
|
||||||
|
return;
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QVariant v = m_parser.parse( msg, &ok );
|
QVariant v = m_parser.parse( msg, &ok );
|
||||||
if ( !ok || v.type() != QVariant::Map )
|
if ( !ok || v.type() != QVariant::Map )
|
||||||
|
@@ -85,7 +85,7 @@ private:
|
|||||||
quint32 m_msgsize;
|
quint32 m_msgsize;
|
||||||
QByteArray m_msg;
|
QByteArray m_msg;
|
||||||
|
|
||||||
bool m_ready, m_stopped, m_configSent;
|
bool m_ready, m_stopped, m_configSent, m_deleting;
|
||||||
ExternalResolver::ErrorState m_error;
|
ExternalResolver::ErrorState m_error;
|
||||||
|
|
||||||
QJson::Parser m_parser;
|
QJson::Parser m_parser;
|
||||||
|
89
src/libtomahawk/utils/closure.cpp
Normal file
89
src/libtomahawk/utils/closure.cpp
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2011, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine 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.
|
||||||
|
|
||||||
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "closure.h"
|
||||||
|
|
||||||
|
namespace _detail {
|
||||||
|
|
||||||
|
Closure::Closure(QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const ClosureArgumentWrapper* val0,
|
||||||
|
const ClosureArgumentWrapper* val1,
|
||||||
|
const ClosureArgumentWrapper* val2,
|
||||||
|
const ClosureArgumentWrapper* val3)
|
||||||
|
: QObject(receiver),
|
||||||
|
callback_(NULL),
|
||||||
|
val0_(val0),
|
||||||
|
val1_(val1),
|
||||||
|
val2_(val2),
|
||||||
|
val3_(val3) {
|
||||||
|
const QMetaObject* meta_receiver = receiver->metaObject();
|
||||||
|
|
||||||
|
QByteArray normalised_slot = QMetaObject::normalizedSignature(slot + 1);
|
||||||
|
const int index = meta_receiver->indexOfSlot(normalised_slot.constData());
|
||||||
|
Q_ASSERT(index != -1);
|
||||||
|
slot_ = meta_receiver->method(index);
|
||||||
|
|
||||||
|
Connect(sender, signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
Closure::Closure(QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
std::tr1::function<void()> callback)
|
||||||
|
: callback_(callback) {
|
||||||
|
Connect(sender, signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
Closure::~Closure() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Closure::Connect(QObject* sender, const char* signal) {
|
||||||
|
bool success = connect(sender, signal, SLOT(Invoked()));
|
||||||
|
Q_ASSERT(success);
|
||||||
|
success = connect(sender, SIGNAL(destroyed()), SLOT(Cleanup()));
|
||||||
|
Q_ASSERT(success);
|
||||||
|
Q_UNUSED(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Closure::Invoked() {
|
||||||
|
if (callback_) {
|
||||||
|
callback_();
|
||||||
|
} else {
|
||||||
|
slot_.invoke(
|
||||||
|
parent(),
|
||||||
|
val0_ ? val0_->arg() : QGenericArgument(),
|
||||||
|
val1_ ? val1_->arg() : QGenericArgument(),
|
||||||
|
val2_ ? val2_->arg() : QGenericArgument(),
|
||||||
|
val3_ ? val3_->arg() : QGenericArgument());
|
||||||
|
}
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Closure::Cleanup() {
|
||||||
|
disconnect();
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace _detail
|
||||||
|
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender, const char* signal,
|
||||||
|
QObject* receiver, const char* slot) {
|
||||||
|
return new _detail::Closure(sender, signal, receiver, slot);
|
||||||
|
}
|
225
src/libtomahawk/utils/closure.h
Normal file
225
src/libtomahawk/utils/closure.h
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2011, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine 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.
|
||||||
|
|
||||||
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLOSURE_H
|
||||||
|
#define CLOSURE_H
|
||||||
|
|
||||||
|
#include <tr1/functional>
|
||||||
|
|
||||||
|
#include <QMetaMethod>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
namespace _detail {
|
||||||
|
|
||||||
|
class ClosureArgumentWrapper {
|
||||||
|
public:
|
||||||
|
virtual ~ClosureArgumentWrapper() {}
|
||||||
|
|
||||||
|
virtual QGenericArgument arg() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class ClosureArgument : public ClosureArgumentWrapper {
|
||||||
|
public:
|
||||||
|
explicit ClosureArgument(const T& data) : data_(data) {}
|
||||||
|
|
||||||
|
virtual QGenericArgument arg() const {
|
||||||
|
return Q_ARG(T, data_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T data_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Closure : public QObject, boost::noncopyable {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Closure(QObject* sender, const char* signal,
|
||||||
|
QObject* receiver, const char* slot,
|
||||||
|
const ClosureArgumentWrapper* val0 = 0,
|
||||||
|
const ClosureArgumentWrapper* val1 = 0,
|
||||||
|
const ClosureArgumentWrapper* val2 = 0,
|
||||||
|
const ClosureArgumentWrapper* val3 = 0);
|
||||||
|
|
||||||
|
Closure(QObject* sender, const char* signal,
|
||||||
|
std::tr1::function<void()> callback);
|
||||||
|
|
||||||
|
virtual ~Closure();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void Invoked();
|
||||||
|
void Cleanup();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Connect(QObject* sender, const char* signal);
|
||||||
|
|
||||||
|
QMetaMethod slot_;
|
||||||
|
std::tr1::function<void()> callback_;
|
||||||
|
|
||||||
|
boost::scoped_ptr<const ClosureArgumentWrapper> val0_;
|
||||||
|
boost::scoped_ptr<const ClosureArgumentWrapper> val1_;
|
||||||
|
boost::scoped_ptr<const ClosureArgumentWrapper> val2_;
|
||||||
|
boost::scoped_ptr<const ClosureArgumentWrapper> val3_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SharedPointerWrapper {
|
||||||
|
public:
|
||||||
|
virtual ~SharedPointerWrapper() {}
|
||||||
|
virtual QObject* data() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class SharedPointer : public SharedPointerWrapper {
|
||||||
|
public:
|
||||||
|
explicit SharedPointer(QSharedPointer<T> ptr)
|
||||||
|
: ptr_(ptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* data() const {
|
||||||
|
return ptr_.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<T> ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// For use with a QSharedPointer as a sender.
|
||||||
|
class SharedClosure : public Closure {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SharedClosure(SharedPointerWrapper* sender, const char* signal,
|
||||||
|
QObject* receiver, const char* slot,
|
||||||
|
const ClosureArgumentWrapper* val0 = 0,
|
||||||
|
const ClosureArgumentWrapper* val1 = 0,
|
||||||
|
const ClosureArgumentWrapper* val2 = 0,
|
||||||
|
const ClosureArgumentWrapper* val3 = 0)
|
||||||
|
: Closure(sender->data(), signal,
|
||||||
|
receiver, slot,
|
||||||
|
val0, val1, val2, val3),
|
||||||
|
shared_sender_(sender) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::scoped_ptr<SharedPointerWrapper> shared_sender_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace _detail
|
||||||
|
|
||||||
|
#define C_ARG(type, data) new _detail::ClosureArgument<type>(data)
|
||||||
|
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T& val0) {
|
||||||
|
return new _detail::Closure(
|
||||||
|
sender, signal, receiver, slot,
|
||||||
|
C_ARG(T, val0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T0, typename T1>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T0& val0,
|
||||||
|
const T1& val1) {
|
||||||
|
return new _detail::Closure(
|
||||||
|
sender, signal, receiver, slot,
|
||||||
|
C_ARG(T0, val0), C_ARG(T1, val1));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T0, typename T1, typename T2>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T0& val0,
|
||||||
|
const T1& val1,
|
||||||
|
const T2& val2) {
|
||||||
|
return new _detail::Closure(
|
||||||
|
sender, signal, receiver, slot,
|
||||||
|
C_ARG(T0, val0), C_ARG(T1, val1), C_ARG(T2, val2));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T0, typename T1, typename T2, typename T3>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QObject* sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T0& val0,
|
||||||
|
const T1& val1,
|
||||||
|
const T2& val2,
|
||||||
|
const T3& val3) {
|
||||||
|
return new _detail::Closure(
|
||||||
|
sender, signal, receiver, slot,
|
||||||
|
C_ARG(T0, val0), C_ARG(T1, val1), C_ARG(T2, val2), C_ARG(T3, val3));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename TP>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QSharedPointer<TP> sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot) {
|
||||||
|
return new _detail::SharedClosure(
|
||||||
|
new _detail::SharedPointer<TP>(sender), signal, receiver, slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename TP, typename T0>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QSharedPointer<TP> sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T0& val0) {
|
||||||
|
return new _detail::SharedClosure(
|
||||||
|
new _detail::SharedPointer<TP>(sender), signal, receiver, slot,
|
||||||
|
C_ARG(T0, val0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename TP, typename T0, typename T1>
|
||||||
|
_detail::Closure* NewClosure(
|
||||||
|
QSharedPointer<TP> sender,
|
||||||
|
const char* signal,
|
||||||
|
QObject* receiver,
|
||||||
|
const char* slot,
|
||||||
|
const T0& val0,
|
||||||
|
const T1& val1) {
|
||||||
|
return new _detail::SharedClosure(
|
||||||
|
new _detail::SharedPointer<TP>(sender), signal, receiver, slot,
|
||||||
|
C_ARG(T0, val0), C_ARG(T1, val1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CLOSURE_H
|
@@ -123,7 +123,11 @@ XSPFLoader::reportError()
|
|||||||
{
|
{
|
||||||
emit error( FetchError );
|
emit error( FetchError );
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( errorToString( FetchError) ) );
|
const QString errorMsg = errorToString( FetchError);
|
||||||
|
if ( !m_errorTitle.isEmpty() )
|
||||||
|
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "%1: %2" ).arg( m_errorTitle ).arg( errorMsg ) ) );
|
||||||
|
else
|
||||||
|
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( errorMsg ) );
|
||||||
#endif
|
#endif
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,7 @@ public:
|
|||||||
void setOverrideTitle( const QString& newTitle );
|
void setOverrideTitle( const QString& newTitle );
|
||||||
void setAutoResolveTracks( bool autoResolve ) { m_autoResolve = autoResolve; }
|
void setAutoResolveTracks( bool autoResolve ) { m_autoResolve = autoResolve; }
|
||||||
void setAutoDelete( bool autoDelete ) { m_autoDelete = autoDelete; }
|
void setAutoDelete( bool autoDelete ) { m_autoDelete = autoDelete; }
|
||||||
|
void setErrorTitle( const QString& error ) { m_errorTitle = error; }
|
||||||
|
|
||||||
static QString errorToString( XSPFErrorCode error );
|
static QString errorToString( XSPFErrorCode error );
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ private:
|
|||||||
bool m_autoCreate, m_autoUpdate, m_autoResolve, m_autoDelete;
|
bool m_autoCreate, m_autoUpdate, m_autoResolve, m_autoDelete;
|
||||||
QString m_NS,m_overrideTitle;
|
QString m_NS,m_overrideTitle;
|
||||||
QList< Tomahawk::query_ptr > m_entries;
|
QList< Tomahawk::query_ptr > m_entries;
|
||||||
QString m_title, m_info, m_creator;
|
QString m_title, m_info, m_creator, m_errorTitle;
|
||||||
|
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
QByteArray m_body;
|
QByteArray m_body;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -232,7 +233,7 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
|
|||||||
artistInfo["artist"] = m_album->artist()->name();
|
artistInfo["artist"] = m_album->artist()->name();
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
requestData.customData["refetch"] = QVariant( autoRefetch );
|
requestData.customData["refetch"] = autoRefetch;
|
||||||
requestData.caller = m_infoId;
|
requestData.caller = m_infoId;
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;
|
requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;
|
||||||
@@ -309,7 +310,7 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
|
|||||||
tDebug() << "Adding" << al.count() << "albums";
|
tDebug() << "Adding" << al.count() << "albums";
|
||||||
gotAlbums( al );
|
gotAlbums( al );
|
||||||
}
|
}
|
||||||
else if ( requestData.customData[ "refetch" ].toInt() > 0 )
|
else if ( requestData.customData[ "refetch" ].toBool() )
|
||||||
{
|
{
|
||||||
tDebug() << "Auto refetching";
|
tDebug() << "Auto refetching";
|
||||||
m_buttonAlbums->setChecked( false );
|
m_buttonAlbums->setChecked( false );
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
#include "playlist/dynamic/GeneratorInterface.h"
|
#include "playlist/dynamic/GeneratorInterface.h"
|
||||||
|
#include "playlist/playlistview.h"
|
||||||
#include "categoryitems.h"
|
#include "categoryitems.h"
|
||||||
#include "sourceitem.h"
|
#include "sourceitem.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
@@ -136,6 +137,17 @@ PlaylistItem::activate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistItem::doubleClicked()
|
||||||
|
{
|
||||||
|
ViewPage* p = ViewManager::instance()->currentPage();
|
||||||
|
if ( PlaylistView* view = dynamic_cast< PlaylistView* >( p ) )
|
||||||
|
{
|
||||||
|
view->startPlayingFromStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistItem::setLoaded( bool loaded )
|
PlaylistItem::setLoaded( bool loaded )
|
||||||
{
|
{
|
||||||
|
@@ -31,7 +31,6 @@ public:
|
|||||||
virtual QString text() const;
|
virtual QString text() const;
|
||||||
virtual Tomahawk::playlist_ptr playlist() const;
|
virtual Tomahawk::playlist_ptr playlist() const;
|
||||||
virtual Qt::ItemFlags flags() const;
|
virtual Qt::ItemFlags flags() const;
|
||||||
virtual void activate();
|
|
||||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||||
virtual DropTypes supportedDropTypes( const QMimeData* data ) const;
|
virtual DropTypes supportedDropTypes( const QMimeData* data ) const;
|
||||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
|
||||||
@@ -43,6 +42,10 @@ public:
|
|||||||
|
|
||||||
virtual SourceTreeItem* activateCurrent();
|
virtual SourceTreeItem* activateCurrent();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void activate();
|
||||||
|
virtual void doubleClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setLoaded( bool loaded );
|
void setLoaded( bool loaded );
|
||||||
|
|
||||||
|
@@ -78,6 +78,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void activate() {}
|
virtual void activate() {}
|
||||||
|
virtual void doubleClicked() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updated();
|
void updated();
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
||||||
: QStyledItemDelegate( parent )
|
: QStyledItemDelegate( parent )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
|
, m_lastClicked( -1 )
|
||||||
{
|
{
|
||||||
m_dropTypeMap.insert( 0, SourceTreeItem::DropTypeThisTrack );
|
m_dropTypeMap.insert( 0, SourceTreeItem::DropTypeThisTrack );
|
||||||
m_dropTypeMap.insert( 1, SourceTreeItem::DropTypeThisAlbum );
|
m_dropTypeMap.insert( 1, SourceTreeItem::DropTypeThisAlbum );
|
||||||
@@ -632,7 +633,27 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
|
|||||||
// a mouse press event. Since we want to swallow click events when they are on headphones other action items, here wemake sure we only
|
// a mouse press event. Since we want to swallow click events when they are on headphones other action items, here wemake sure we only
|
||||||
// emit if we really want to
|
// emit if we really want to
|
||||||
if ( event->type() == QEvent::MouseButtonRelease )
|
if ( event->type() == QEvent::MouseButtonRelease )
|
||||||
|
{
|
||||||
|
if ( m_lastClicked == -1 )
|
||||||
|
{
|
||||||
|
m_lastClicked = QDateTime::currentMSecsSinceEpoch();
|
||||||
emit clicked( index );
|
emit clicked( index );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qint64 elapsed = QDateTime::currentMSecsSinceEpoch() - m_lastClicked;
|
||||||
|
if ( elapsed < QApplication::doubleClickInterval() )
|
||||||
|
{
|
||||||
|
m_lastClicked = -1;
|
||||||
|
emit doubleClicked( index );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
m_lastClicked = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
emit clicked( index );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return QStyledItemDelegate::editorEvent ( event, model, option, index );
|
return QStyledItemDelegate::editorEvent ( event, model, option, index );
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked( const QModelIndex& idx );
|
void clicked( const QModelIndex& idx );
|
||||||
|
void doubleClicked( const QModelIndex& idx );
|
||||||
void latchOn( const Tomahawk::source_ptr& idx );
|
void latchOn( const Tomahawk::source_ptr& idx );
|
||||||
void latchOff( const Tomahawk::source_ptr& idx );
|
void latchOff( const Tomahawk::source_ptr& idx );
|
||||||
void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime );
|
void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime );
|
||||||
@@ -73,6 +74,7 @@ private:
|
|||||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||||
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
||||||
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
|
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
|
||||||
|
qint64 m_lastClicked;
|
||||||
|
|
||||||
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
||||||
QMap< int, QString > m_dropTypeTextMap;
|
QMap< int, QString > m_dropTypeTextMap;
|
||||||
|
@@ -79,6 +79,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
sortByColumn( 0, Qt::AscendingOrder );
|
sortByColumn( 0, Qt::AscendingOrder );
|
||||||
setVerticalScrollMode( QTreeView::ScrollPerPixel );
|
setVerticalScrollMode( QTreeView::ScrollPerPixel );
|
||||||
setMouseTracking( true );
|
setMouseTracking( true );
|
||||||
|
setEditTriggers( NoEditTriggers );
|
||||||
|
|
||||||
// TODO animation conflicts with the expanding-playlists-when-collection-is-null
|
// TODO animation conflicts with the expanding-playlists-when-collection-is-null
|
||||||
// so investigate
|
// so investigate
|
||||||
@@ -89,6 +90,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
|
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
|
||||||
connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) );
|
connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) );
|
||||||
connect( m_delegate, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( m_delegate, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
|
connect( m_delegate, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemDoubleClicked( QModelIndex ) ) );
|
||||||
|
|
||||||
setItemDelegate( m_delegate );
|
setItemDelegate( m_delegate );
|
||||||
|
|
||||||
@@ -231,6 +233,17 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::onItemDoubleClicked( const QModelIndex& idx )
|
||||||
|
{
|
||||||
|
if ( !selectionModel()->selectedIndexes().contains( idx ) )
|
||||||
|
onItemActivated( idx );
|
||||||
|
|
||||||
|
SourceTreeItem* item = itemFromIndex< SourceTreeItem >( idx );
|
||||||
|
item->doubleClicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::onItemExpanded( const QModelIndex& idx )
|
SourceTreeView::onItemExpanded( const QModelIndex& idx )
|
||||||
{
|
{
|
||||||
|
@@ -67,6 +67,7 @@ private slots:
|
|||||||
void selectRequest( const QPersistentModelIndex& idx );
|
void selectRequest( const QPersistentModelIndex& idx );
|
||||||
void expandRequest( const QPersistentModelIndex& idx );
|
void expandRequest( const QPersistentModelIndex& idx );
|
||||||
void toggleExpandRequest( const QPersistentModelIndex& idx );
|
void toggleExpandRequest( const QPersistentModelIndex& idx );
|
||||||
|
void onItemDoubleClicked( const QModelIndex& idx );
|
||||||
|
|
||||||
void loadPlaylist();
|
void loadPlaylist();
|
||||||
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||||
|
@@ -575,9 +575,14 @@ void QxtHttpSessionManager::processEvents()
|
|||||||
*/
|
*/
|
||||||
void QxtHttpSessionManager::chunkReadyRead(int requestID)
|
void QxtHttpSessionManager::chunkReadyRead(int requestID)
|
||||||
{
|
{
|
||||||
|
if (!connector()) return;
|
||||||
|
|
||||||
const QSharedPointer<QIODevice>& dataSource = connector()->getRequestDataSource( requestID );
|
const QSharedPointer<QIODevice>& dataSource = connector()->getRequestDataSource( requestID );
|
||||||
if (!dataSource->bytesAvailable()) return;
|
if (!dataSource->bytesAvailable()) return;
|
||||||
|
|
||||||
QIODevice* device = connector()->getRequestConnection(requestID);
|
QIODevice* device = connector()->getRequestConnection(requestID);
|
||||||
|
if (!device) return;
|
||||||
|
|
||||||
if (!device->bytesToWrite() || qxt_d().connectionState[device].readyRead == false)
|
if (!device->bytesToWrite() || qxt_d().connectionState[device].readyRead == false)
|
||||||
{
|
{
|
||||||
qxt_d().connectionState[device].readyRead = true;
|
qxt_d().connectionState[device].readyRead = true;
|
||||||
@@ -590,6 +595,9 @@ void QxtHttpSessionManager::chunkReadyRead(int requestID)
|
|||||||
*/
|
*/
|
||||||
void QxtHttpSessionManager::sendNextChunk(int requestID)
|
void QxtHttpSessionManager::sendNextChunk(int requestID)
|
||||||
{
|
{
|
||||||
|
if ( !connector() )
|
||||||
|
return;
|
||||||
|
|
||||||
const QSharedPointer<QIODevice>& dataSource = connector()->getRequestDataSource( requestID );
|
const QSharedPointer<QIODevice>& dataSource = connector()->getRequestDataSource( requestID );
|
||||||
QIODevice* device = connector()->getRequestConnection(requestID);
|
QIODevice* device = connector()->getRequestConnection(requestID);
|
||||||
QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device];
|
QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device];
|
||||||
|
Reference in New Issue
Block a user