mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 03:45:56 +01:00
Update the moodbar column on the correct model
This commit is contained in:
parent
ba2f4ddedc
commit
836a2b0c89
@ -23,10 +23,12 @@
|
|||||||
#include "core/closure.h"
|
#include "core/closure.h"
|
||||||
#include "core/qhash_qurl.h"
|
#include "core/qhash_qurl.h"
|
||||||
#include "playlist/playlist.h"
|
#include "playlist/playlist.h"
|
||||||
|
#include "playlist/playlistview.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
MoodbarItemDelegate::Data::Data()
|
MoodbarItemDelegate::Data::Data()
|
||||||
@ -34,9 +36,11 @@ MoodbarItemDelegate::Data::Data()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MoodbarItemDelegate::MoodbarItemDelegate(Application* app, QObject* parent)
|
MoodbarItemDelegate::MoodbarItemDelegate(Application* app, PlaylistView* view,
|
||||||
|
QObject* parent)
|
||||||
: QItemDelegate(parent),
|
: QItemDelegate(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
|
view_(view),
|
||||||
style_(MoodbarRenderer::Style_Normal)
|
style_(MoodbarRenderer::Style_Normal)
|
||||||
{
|
{
|
||||||
connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()));
|
connect(app_, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()));
|
||||||
@ -244,12 +248,19 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl& url, QFutureWatcher<QImage>* w
|
|||||||
|
|
||||||
data->pixmap_ = QPixmap::fromImage(image);
|
data->pixmap_ = QPixmap::fromImage(image);
|
||||||
data->state_ = Data::State_Loaded;
|
data->state_ = Data::State_Loaded;
|
||||||
|
|
||||||
|
Playlist* playlist = view_->playlist();
|
||||||
|
const QSortFilterProxyModel* filter = playlist->proxy();
|
||||||
|
|
||||||
// Update all the indices with the new pixmap.
|
// Update all the indices with the new pixmap.
|
||||||
foreach (const QPersistentModelIndex& index, data->indexes_) {
|
foreach (const QPersistentModelIndex& index, data->indexes_) {
|
||||||
if (index.isValid() && index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() == url) {
|
if (index.isValid() && index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() == url) {
|
||||||
const_cast<Playlist*>(reinterpret_cast<const Playlist*>(index.model()))
|
Q_ASSERT(index.model() == filter);
|
||||||
->MoodbarUpdated(index);
|
QModelIndex source_index(filter->mapToSource(index));
|
||||||
|
|
||||||
|
Q_ASSERT(source_index.model() == playlist);
|
||||||
|
|
||||||
|
playlist->MoodbarUpdated(source_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class MoodbarPipeline;
|
class MoodbarPipeline;
|
||||||
|
class PlaylistView;
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ class MoodbarItemDelegate : public QItemDelegate {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MoodbarItemDelegate(Application* app, QObject* parent = 0);
|
MoodbarItemDelegate(Application* app, PlaylistView* view, QObject* parent = 0);
|
||||||
|
|
||||||
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||||
const QModelIndex& index) const;
|
const QModelIndex& index) const;
|
||||||
@ -79,6 +80,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Application* app_;
|
Application* app_;
|
||||||
|
PlaylistView* view_;
|
||||||
QCache<QUrl, Data> data_;
|
QCache<QUrl, Data> data_;
|
||||||
|
|
||||||
MoodbarRenderer::MoodbarStyle style_;
|
MoodbarRenderer::MoodbarStyle style_;
|
||||||
|
@ -205,7 +205,7 @@ void PlaylistView::SetItemDelegates(LibraryBackend* backend) {
|
|||||||
setItemDelegateForColumn(Playlist::Column_LastPlayed, new LastPlayedItemDelegate(this));
|
setItemDelegateForColumn(Playlist::Column_LastPlayed, new LastPlayedItemDelegate(this));
|
||||||
|
|
||||||
#ifdef HAVE_MOODBAR
|
#ifdef HAVE_MOODBAR
|
||||||
setItemDelegateForColumn(Playlist::Column_Mood, new MoodbarItemDelegate(app_, this));
|
setItemDelegateForColumn(Playlist::Column_Mood, new MoodbarItemDelegate(app_, this, this));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (app_ && app_->player()) {
|
if (app_ && app_->player()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user