mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 13:17:34 +02:00
Allow playlist updaters to put custom questions in playlist delete dialogs
This commit is contained in:
@@ -37,7 +37,9 @@
|
|||||||
#include "PlaylistPlaylistInterface.h"
|
#include "PlaylistPlaylistInterface.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Closure.h"
|
||||||
#include "PlaylistUpdaterInterface.h"
|
#include "PlaylistUpdaterInterface.h"
|
||||||
|
#include "widgets/SourceTreePopupDialog.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -311,6 +313,84 @@ Playlist::removeUpdater( PlaylistUpdaterInterface* updater )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Playlist::hasCustomDeleter() const
|
||||||
|
{
|
||||||
|
foreach ( PlaylistUpdaterInterface* updater, m_updaters )
|
||||||
|
{
|
||||||
|
if ( !updater->deleteQuestions().isEmpty() )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Playlist::customDelete( const QPoint& leftCenter )
|
||||||
|
{
|
||||||
|
if ( !hasCustomDeleter() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Tomahawk::PlaylistDeleteQuestions questions;
|
||||||
|
foreach ( PlaylistUpdaterInterface* updater, m_updaters )
|
||||||
|
{
|
||||||
|
if ( updater->deleteQuestions().isEmpty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
questions.append( updater->deleteQuestions() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT( !questions.isEmpty() );
|
||||||
|
SourceTreePopupDialog* dialog = new SourceTreePopupDialog;
|
||||||
|
NewClosure( dialog, SIGNAL( result( bool ) ), this, SLOT( onDeleteResult( SourceTreePopupDialog* ) ), dialog );
|
||||||
|
|
||||||
|
dialog->setMainText( tr( "Would you like to delete the playlist <b>\"%2\"</b>?", "e.g. Would you like to delete the playlist named Foobar?" )
|
||||||
|
.arg( title() ) );
|
||||||
|
dialog->setOkButtonText( tr( "Delete" ) );
|
||||||
|
dialog->setExtraQuestions( questions );
|
||||||
|
|
||||||
|
dialog->move( leftCenter.x() - dialog->offset(), leftCenter.y() - dialog->sizeHint().height() / 2. );
|
||||||
|
dialog->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Playlist::onDeleteResult( SourceTreePopupDialog* dialog )
|
||||||
|
{
|
||||||
|
dialog->deleteLater();
|
||||||
|
|
||||||
|
const bool ret = dialog->resultValue();
|
||||||
|
|
||||||
|
if ( !ret )
|
||||||
|
return;
|
||||||
|
|
||||||
|
playlist_ptr p = m_weakSelf.toStrongRef();
|
||||||
|
if ( p.isNull() )
|
||||||
|
{
|
||||||
|
qWarning() << "Got null m_weakSelf weak ref in Playlsit::onDeleteResult!!";
|
||||||
|
Q_ASSERT( false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QMap< int, bool > questionResults = dialog->questionResults();
|
||||||
|
foreach ( PlaylistUpdaterInterface* updater, m_updaters )
|
||||||
|
{
|
||||||
|
updater->setQuestionResults( questionResults );
|
||||||
|
}
|
||||||
|
|
||||||
|
dynplaylist_ptr dynpl = p.dynamicCast< DynamicPlaylist >();
|
||||||
|
if ( !dynpl.isNull() )
|
||||||
|
{
|
||||||
|
DynamicPlaylist::remove( dynpl );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remove( p );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::loadRevision( const QString& rev )
|
Playlist::loadRevision( const QString& rev )
|
||||||
{
|
{
|
||||||
|
@@ -195,6 +195,18 @@ public:
|
|||||||
void removeUpdater( PlaylistUpdaterInterface* updater );
|
void removeUpdater( PlaylistUpdaterInterface* updater );
|
||||||
QList<PlaylistUpdaterInterface*> updaters() const { return m_updaters; }
|
QList<PlaylistUpdaterInterface*> updaters() const { return m_updaters; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some updaters might have custom deleters in order to perform more actions that require
|
||||||
|
* user prompting on delete.
|
||||||
|
*/
|
||||||
|
bool hasCustomDeleter() const;
|
||||||
|
/**
|
||||||
|
* If this playlist has a custom deleter, let it do the deleting itself.
|
||||||
|
*
|
||||||
|
* If it needs user prompting, use the \param customDeleter as the right-most center point.
|
||||||
|
*/
|
||||||
|
void customDelete( const QPoint& rightCenter );
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -284,6 +296,7 @@ private slots:
|
|||||||
void onResultsFound( const QList<Tomahawk::result_ptr>& results );
|
void onResultsFound( const QList<Tomahawk::result_ptr>& results );
|
||||||
void onResolvingFinished();
|
void onResolvingFinished();
|
||||||
|
|
||||||
|
void onDeleteResult( SourceTreePopupDialog* );
|
||||||
private:
|
private:
|
||||||
Playlist();
|
Playlist();
|
||||||
void init();
|
void init();
|
||||||
|
@@ -98,6 +98,9 @@ namespace Tomahawk
|
|||||||
typedef QMultiHash< QString, SerializedUpdater > SerializedUpdaters;
|
typedef QMultiHash< QString, SerializedUpdater > SerializedUpdaters;
|
||||||
typedef QList< SerializedUpdater > SerializedUpdaterList;
|
typedef QList< SerializedUpdater > SerializedUpdaterList;
|
||||||
|
|
||||||
|
// Yes/no questions with an associated enum value
|
||||||
|
typedef QPair< QString, int > PlaylistDeleteQuestion;
|
||||||
|
typedef QList< PlaylistDeleteQuestion > PlaylistDeleteQuestions;
|
||||||
|
|
||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
|
@@ -131,35 +131,18 @@ SpotifyPlaylistUpdater::remove( bool askToDeletePlaylist )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyPlaylistUpdater::aboutToDelete()
|
SpotifyPlaylistUpdater::unsyncOrDelete( bool toDelete )
|
||||||
{
|
{
|
||||||
if ( QThread::currentThread() != QApplication::instance()->thread() )
|
if ( QThread::currentThread() != QApplication::instance()->thread() )
|
||||||
QMetaObject::invokeMethod( const_cast<SpotifyPlaylistUpdater*>(this), "aboutToDelete", Qt::BlockingQueuedConnection );
|
QMetaObject::invokeMethod( const_cast<SpotifyPlaylistUpdater*>(this), "unsyncOrDelete", Qt::BlockingQueuedConnection, Q_ARG( bool, toDelete ) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_subscribed )
|
if ( m_subscribed )
|
||||||
{
|
{
|
||||||
m_spotify.data()->setSubscribedForPlaylist( playlist(), false );
|
m_spotify.data()->setSubscribedForPlaylist( playlist(), false );
|
||||||
}
|
}
|
||||||
else if ( m_sync )
|
else if ( m_sync && toDelete )
|
||||||
{
|
{
|
||||||
checkDeleteDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SpotifyPlaylistUpdater::checkDeleteDialog() const
|
|
||||||
{
|
|
||||||
// Ask if we should delete the playlist on the spotify side as well
|
|
||||||
QMessageBox askDelete( QMessageBox::Question, tr( "Delete in Spotify?" ), tr( "Would you like to delete the corresponding Spotify playlist as well?" ), QMessageBox::Yes | QMessageBox::No, 0 );
|
|
||||||
int ret = askDelete.exec();
|
|
||||||
if ( ret == QMessageBox::Yes )
|
|
||||||
{
|
|
||||||
if ( m_spotify.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// User wants to delete it!
|
// User wants to delete it!
|
||||||
QVariantMap msg;
|
QVariantMap msg;
|
||||||
msg[ "_msgtype" ] = "deletePlaylist";
|
msg[ "_msgtype" ] = "deletePlaylist";
|
||||||
@@ -167,6 +150,7 @@ SpotifyPlaylistUpdater::checkDeleteDialog() const
|
|||||||
m_spotify.data()->sendMessage( msg );
|
m_spotify.data()->sendMessage( msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -293,6 +277,25 @@ SpotifyPlaylistUpdater::canSubscribe() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistDeleteQuestions
|
||||||
|
SpotifyPlaylistUpdater::deleteQuestions() const
|
||||||
|
{
|
||||||
|
// 1234 is our magic key
|
||||||
|
if ( m_sync && !m_subscribed )
|
||||||
|
return Tomahawk::PlaylistDeleteQuestions() << qMakePair<QString, int>( tr( "Delete associated Spotify playlist?" ), 1234 );
|
||||||
|
else
|
||||||
|
return Tomahawk::PlaylistDeleteQuestions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyPlaylistUpdater::setQuestionResults( const QMap< int, bool > results )
|
||||||
|
{
|
||||||
|
const bool toDelete = results.value( 1234, false );
|
||||||
|
unsyncOrDelete( toDelete );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyPlaylistUpdater::spotifyTracksAdded( const QVariantList& tracks, const QString& startPosId, const QString& newRev, const QString& oldRev )
|
SpotifyPlaylistUpdater::spotifyTracksAdded( const QVariantList& tracks, const QString& startPosId, const QString& newRev, const QString& oldRev )
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "playlist/PlaylistUpdaterInterface.h"
|
#include "playlist/PlaylistUpdaterInterface.h"
|
||||||
#include "utils/Closure.h"
|
#include "utils/Closure.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -63,6 +64,9 @@ public:
|
|||||||
void setCanSubscribe( bool canSub );
|
void setCanSubscribe( bool canSub );
|
||||||
QString spotifyId() const { return m_spotifyId; }
|
QString spotifyId() const { return m_spotifyId; }
|
||||||
|
|
||||||
|
virtual Tomahawk::PlaylistDeleteQuestions deleteQuestions() const;
|
||||||
|
virtual void setQuestionResults( const QMap< int, bool > results );
|
||||||
|
|
||||||
void remove( bool askToDeletePlaylist = true );
|
void remove( bool askToDeletePlaylist = true );
|
||||||
public slots:
|
public slots:
|
||||||
/// Spotify callbacks when we are directly instructed from the resolver
|
/// Spotify callbacks when we are directly instructed from the resolver
|
||||||
@@ -76,15 +80,13 @@ public slots:
|
|||||||
void tomahawkTracksMoved( const QList<Tomahawk::plentry_ptr>& ,int );
|
void tomahawkTracksMoved( const QList<Tomahawk::plentry_ptr>& ,int );
|
||||||
void tomahawkPlaylistRenamed( const QString&, const QString& );
|
void tomahawkPlaylistRenamed( const QString&, const QString& );
|
||||||
|
|
||||||
void aboutToDelete();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// SpotifyResolver message handlers, all take msgtype, msg as argument
|
// SpotifyResolver message handlers, all take msgtype, msg as argument
|
||||||
void onTracksInsertedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
void onTracksInsertedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
||||||
void onTracksRemovedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
void onTracksRemovedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
||||||
void onTracksMovedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
void onTracksMovedReturn( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
|
||||||
|
|
||||||
void checkDeleteDialog() const;
|
void unsyncOrDelete( bool toDelete );
|
||||||
|
|
||||||
void playlistRevisionLoaded();
|
void playlistRevisionLoaded();
|
||||||
private:
|
private:
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
@@ -84,6 +85,11 @@ public:
|
|||||||
virtual bool subscribed() const { return false; }
|
virtual bool subscribed() const { return false; }
|
||||||
virtual void setSubscribed( bool ) {}
|
virtual void setSubscribed( bool ) {}
|
||||||
|
|
||||||
|
// The int data value associated with each question must be unique across *all* playlist updaters,
|
||||||
|
// as setQuestionResults is called with all questions from all updaters.
|
||||||
|
virtual PlaylistDeleteQuestions deleteQuestions() const { return PlaylistDeleteQuestions(); }
|
||||||
|
virtual void setQuestionResults( const QMap< int, bool > results ) {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
@@ -18,22 +18,25 @@
|
|||||||
|
|
||||||
#include "SourceTreePopupDialog.h"
|
#include "SourceTreePopupDialog.h"
|
||||||
|
|
||||||
#include "sourcetree/SourceTreeView.h"
|
|
||||||
|
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#ifdef QT_MAC_USE_COCOA
|
#ifdef QT_MAC_USE_COCOA
|
||||||
#include "SourceTreePopupDialog_mac.h"
|
#include "SourceTreePopupDialog_mac.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SourceTreePopupDialog::SourceTreePopupDialog( SourceTreeView* parent )
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
SourceTreePopupDialog::SourceTreePopupDialog()
|
||||||
: QWidget( 0 )
|
: QWidget( 0 )
|
||||||
|
, m_layout( 0 )
|
||||||
, m_result( false )
|
, m_result( false )
|
||||||
, m_label( 0 )
|
, m_label( 0 )
|
||||||
, m_buttons( 0 )
|
, m_buttons( 0 )
|
||||||
@@ -54,10 +57,12 @@ SourceTreePopupDialog::SourceTreePopupDialog( SourceTreeView* parent )
|
|||||||
connect( m_buttons, SIGNAL( accepted() ), this, SLOT( onAccepted() ) );
|
connect( m_buttons, SIGNAL( accepted() ), this, SLOT( onAccepted() ) );
|
||||||
connect( m_buttons, SIGNAL( rejected() ), this, SLOT( onRejected() ) );
|
connect( m_buttons, SIGNAL( rejected() ), this, SLOT( onRejected() ) );
|
||||||
|
|
||||||
setLayout( new QVBoxLayout );
|
m_layout = new QVBoxLayout;
|
||||||
|
setLayout( m_layout );
|
||||||
|
|
||||||
layout()->addWidget( m_label );
|
layout()->addWidget( m_label );
|
||||||
layout()->addWidget( m_buttons );
|
layout()->addWidget( m_buttons );
|
||||||
|
setContentsMargins( contentsMargins().left() + 2, contentsMargins().top(), contentsMargins().right(), contentsMargins().bottom() );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
m_buttons->button( QDialogButtonBox::Ok )->setStyleSheet(
|
m_buttons->button( QDialogButtonBox::Ok )->setStyleSheet(
|
||||||
@@ -95,6 +100,30 @@ SourceTreePopupDialog::setOkButtonText( const QString& text )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreePopupDialog::setExtraQuestions( const Tomahawk::PlaylistDeleteQuestions& questions )
|
||||||
|
{
|
||||||
|
m_questions = questions;
|
||||||
|
|
||||||
|
int idx = m_layout->indexOf( m_label ) + 1;
|
||||||
|
foreach ( const Tomahawk::PlaylistDeleteQuestion& question, m_questions )
|
||||||
|
{
|
||||||
|
QCheckBox* cb = new QCheckBox( question.first, this );
|
||||||
|
cb->setLayoutDirection( Qt::RightToLeft );
|
||||||
|
cb->setProperty( "data", question.second );
|
||||||
|
|
||||||
|
QHBoxLayout* h = new QHBoxLayout;
|
||||||
|
h->addStretch( 1 );
|
||||||
|
h->addWidget( cb );
|
||||||
|
// m_layout->insertLayout( h, cb, 0 );
|
||||||
|
m_layout->insertLayout( idx, h, 0 );
|
||||||
|
|
||||||
|
m_questionCheckboxes << cb;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreePopupDialog::paintEvent( QPaintEvent* event )
|
SourceTreePopupDialog::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
@@ -163,6 +192,7 @@ SourceTreePopupDialog::onAccepted()
|
|||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
m_result = true;
|
m_result = true;
|
||||||
|
calculateResults();
|
||||||
emit result( m_result );
|
emit result( m_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,5 +202,19 @@ SourceTreePopupDialog::onRejected()
|
|||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
m_result = false;
|
m_result = false;
|
||||||
|
calculateResults();
|
||||||
emit result( m_result );
|
emit result( m_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreePopupDialog::calculateResults()
|
||||||
|
{
|
||||||
|
foreach ( const QCheckBox* b, m_questionCheckboxes )
|
||||||
|
{
|
||||||
|
if ( b->property( "data" ).toInt() != 0 )
|
||||||
|
{
|
||||||
|
m_questionResults[ b->property( "data" ).toInt() ] = ( b->checkState() == Qt::Checked );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -20,15 +20,18 @@
|
|||||||
#define SOURCETREE_POPUP_DIALOG
|
#define SOURCETREE_POPUP_DIALOG
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
class QVBoxLayout;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QFocusEvent;
|
class QFocusEvent;
|
||||||
class SourceTreeView;
|
class QCheckBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place me at offset() to the left of the right edge of the sourcetree.
|
* Place me at offset() to the left of the right edge of the sourcetree.
|
||||||
@@ -37,14 +40,16 @@ class DLLEXPORT SourceTreePopupDialog : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SourceTreePopupDialog( SourceTreeView* parent );
|
explicit SourceTreePopupDialog();
|
||||||
|
|
||||||
int offset() const { return 16; }
|
int offset() const { return 16; }
|
||||||
|
|
||||||
void setMainText( const QString& text );
|
void setMainText( const QString& text );
|
||||||
void setOkButtonText( const QString& text );
|
void setOkButtonText( const QString& text );
|
||||||
|
void setExtraQuestions( const Tomahawk::PlaylistDeleteQuestions& questions );
|
||||||
|
|
||||||
bool resultValue() const { return m_result; }
|
bool resultValue() const { return m_result; }
|
||||||
|
QMap< int, bool > questionResults() const { return m_questionResults; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void result( bool accepted );
|
void result( bool accepted );
|
||||||
@@ -59,11 +64,22 @@ private slots:
|
|||||||
void onRejected();
|
void onRejected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void calculateResults();
|
||||||
|
|
||||||
|
QVBoxLayout* m_layout;
|
||||||
|
QList< QCheckBox* > m_questionCheckboxes;
|
||||||
|
|
||||||
QString m_text;
|
QString m_text;
|
||||||
bool m_result;
|
bool m_result;
|
||||||
|
Tomahawk::PlaylistDeleteQuestions m_questions;
|
||||||
|
QMap< int, bool > m_questionResults;
|
||||||
|
|
||||||
QLabel* m_label;
|
QLabel* m_label;
|
||||||
QDialogButtonBox* m_buttons;
|
QDialogButtonBox* m_buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE( SourceTreePopupDialog* )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
@@ -364,9 +364,19 @@ SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
|||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||||
|
playlist_ptr playlist = item->playlist();
|
||||||
|
|
||||||
|
const QPoint rightCenter = viewport()->mapToGlobal( visualRect( idx ).topRight() + QPoint( 0, visualRect( idx ).height() / 2 ) );
|
||||||
|
if ( playlist->hasCustomDeleter() )
|
||||||
|
{
|
||||||
|
playlist->customDelete( rightCenter );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ( m_popupDialog.isNull() )
|
if ( m_popupDialog.isNull() )
|
||||||
{
|
{
|
||||||
m_popupDialog = QWeakPointer< SourceTreePopupDialog >( new SourceTreePopupDialog( this ) );
|
m_popupDialog = QWeakPointer< SourceTreePopupDialog >( new SourceTreePopupDialog() );
|
||||||
connect( m_popupDialog.data(), SIGNAL( result( bool ) ), this, SLOT( onDeletePlaylistResult( bool ) ) );
|
connect( m_popupDialog.data(), SIGNAL( result( bool ) ), this, SLOT( onDeletePlaylistResult( bool ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,12 +385,12 @@ SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
|||||||
m_popupDialog.data()->setOkButtonText( tr( "Delete" ) );
|
m_popupDialog.data()->setOkButtonText( tr( "Delete" ) );
|
||||||
m_popupDialog.data()->setProperty( "idx", QVariant::fromValue< QModelIndex >( idx ) );
|
m_popupDialog.data()->setProperty( "idx", QVariant::fromValue< QModelIndex >( idx ) );
|
||||||
|
|
||||||
qDebug() << "POPUP HAS HEIGHT:" << m_popupDialog.data()->sizeHint().height();
|
|
||||||
const QPoint rightCenter = viewport()->mapToGlobal( visualRect( idx ).topRight() + QPoint( 0, visualRect( idx ).height() / 2 ) );
|
|
||||||
m_popupDialog.data()->move( rightCenter.x() - m_popupDialog.data()->offset(), rightCenter.y() - m_popupDialog.data()->sizeHint().height() / 2. );
|
m_popupDialog.data()->move( rightCenter.x() - m_popupDialog.data()->offset(), rightCenter.y() - m_popupDialog.data()->sizeHint().height() / 2. );
|
||||||
m_popupDialog.data()->show();
|
m_popupDialog.data()->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreeView::onDeletePlaylistResult( bool result )
|
SourceTreeView::onDeletePlaylistResult( bool result )
|
||||||
|
Reference in New Issue
Block a user