Commit 4c6adfe7 authored by Scott Wheeler's avatar Scott Wheeler

Make the playing icon showup again; also removed yet another memory leak

introduced by the recent patch.

svn path=/trunk/kdemultimedia/juk/; revision=361760
parent c77f0b19
......@@ -593,10 +593,9 @@ void Playlist::updateLeftColumn()
int newLeftColumn = leftMostVisibleColumn();
if(m_leftColumn != newLeftColumn) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPixmap(newLeftColumn, UserIcon("playing"));
}
if(m_playingItem)
m_playingItem->listView()->triggerUpdate();
m_leftColumn = newLeftColumn;
}
}
......@@ -1186,10 +1185,9 @@ void Playlist::hideColumn(int c, bool updateSearch)
header()->setResizeEnabled(false, c);
if(c == m_leftColumn) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPixmap(leftMostVisibleColumn(), UserIcon("playing"));
}
if(m_playingItem)
m_playingItem->listView()->triggerUpdate();
m_leftColumn = leftMostVisibleColumn();
}
......@@ -1220,10 +1218,8 @@ void Playlist::showColumn(int c, bool updateSearch)
header()->moveSection(c, c); // Approximate old position
if(c == leftMostVisibleColumn()) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPixmap(leftMostVisibleColumn(), UserIcon("playing"));
}
if(m_playingItem)
m_playingItem->listView()->triggerUpdate();
m_leftColumn = leftMostVisibleColumn();
}
......@@ -1460,8 +1456,8 @@ void Playlist::setPlaying(PlaylistItem *item, bool addToHistory)
return;
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPlaying(false);
m_playingItem->listView()->triggerUpdate();
if(addToHistory) {
if(m_playingItem->playlist() == m_upcomingPlaylist)
......@@ -1479,11 +1475,11 @@ void Playlist::setPlaying(PlaylistItem *item, bool addToHistory)
return;
m_playingItem = item;
item->setPixmap(m_leftColumn, UserIcon("playing"));
item->setPlaying(true);
bool enableBack = !m_history.isEmpty();
action<KToolBarPopupAction>("back")->popupMenu()->setEnabled(enableBack);
item->listView()->triggerUpdate();
}
bool Playlist::playing() const
......@@ -1956,10 +1952,9 @@ void Playlist::slotInlineEditDone(QListViewItem *, const QString &, int column)
void Playlist::slotColumnOrderChanged(int, int from, int to)
{
if(from == 0 || to == 0) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPixmap(header()->mapToSection(0), UserIcon("playing"));
}
if(m_playingItem)
m_playingItem->listView()->triggerUpdate();
m_leftColumn = header()->mapToSection(0);
}
......
......@@ -241,6 +241,11 @@ public:
*/
void updateLeftColumn();
/**
* Returns the leftmost visible column of the listview.
*/
int leftColumn() const { return m_leftColumn; }
/**
* Sets the items in the list to be either visible based on the value of
* visible. This is useful for search operations and such.
......
......@@ -74,14 +74,20 @@ FileHandle PlaylistItem::file() const
return d->fileHandle;
}
QPixmap *PlaylistItem::pixmap(int column) const
const QPixmap *PlaylistItem::pixmap(int column) const
{
static QPixmap image(SmallIcon("image"));
static QPixmap playing(UserIcon("playing"));
int offset = playlist()->columnOffset();
if ((column - offset) == CoverColumn && d->fileHandle.coverInfo()->hasCover())
return new QPixmap(SmallIcon("image"));
if((column - offset) == CoverColumn && d->fileHandle.coverInfo()->hasCover())
return &image;
if(column == playlist()->leftColumn() && m_playing)
return &playing;
return 0;
return KListViewItem::pixmap(column);
}
QString PlaylistItem::text(int column) const
......
......@@ -69,7 +69,7 @@ public:
void setFile(const QString &file);
FileHandle file() const;
virtual QPixmap *pixmap(int column) const;
virtual const QPixmap *pixmap(int column) const;
virtual QString text(int column) const;
virtual void setText(int column, const QString &text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment