1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-28 01:59:24 +01:00

Invalidate the cached current row pixmap when the column headers are moved/resized and when the song's metadata changes.

This commit is contained in:
David Sansome 2010-06-02 13:51:16 +00:00
parent e891543f42
commit 24b22b1b17
2 changed files with 20 additions and 0 deletions

View File

@ -57,6 +57,8 @@ PlaylistView::PlaylistView(QWidget *parent)
connect(header(), SIGNAL(sectionResized(int,int,int)), SLOT(SaveGeometry()));
connect(header(), SIGNAL(sectionMoved(int,int,int)), SLOT(SaveGeometry()));
connect(header(), SIGNAL(sectionResized(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
connect(header(), SIGNAL(sectionMoved(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000);
inhibit_autoscroll_timer_->setSingleShot(true);
@ -93,6 +95,18 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
}
void PlaylistView::setModel(QAbstractItemModel *m) {
if (model()) {
disconnect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(InvalidateCachedCurrentPixmap()));
}
QTreeView::setModel(m);
connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(InvalidateCachedCurrentPixmap()));
}
void PlaylistView::LoadGeometry() {
QSettings settings;
settings.beginGroup(kSettingsGroup);
@ -229,6 +243,10 @@ void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option,
p.end();
}
void PlaylistView::InvalidateCachedCurrentPixmap() {
cached_current_row_ = QPixmap();
}
void PlaylistView::timerEvent(QTimerEvent* event) {
QTreeView::timerEvent(event);
if (event->timerId() == glow_timer_.timerId())

View File

@ -38,6 +38,7 @@ class PlaylistView : public QTreeView {
// QTreeView
void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
void keyPressEvent(QKeyEvent* event);
void setModel(QAbstractItemModel *model);
// QAbstractScrollArea
void contextMenuEvent(QContextMenuEvent* e);
@ -69,6 +70,7 @@ class PlaylistView : public QTreeView {
void GlowIntensityChanged();
void InhibitAutoscrollTimeout();
void MaybeAutoscroll();
void InvalidateCachedCurrentPixmap();
private:
void ReloadBarPixmaps();