Commit b44e56d5 authored by Scott Wheeler's avatar Scott Wheeler

Make it so that the left most column always displays the playing indicator.

svn path=/trunk/kdemultimedia/juk/; revision=213088
parent 9c5dcd3a
......@@ -52,13 +52,15 @@
////////////////////////////////////////////////////////////////////////////////
Playlist::Playlist(QWidget *parent, const QString &name) : KListView(parent, name.latin1()),
m_playlistName(name)
m_playlistName(name), m_playingItem(0), m_leftColumn(0)
{
setup();
}
Playlist::Playlist(const QFileInfo &playlistFile, QWidget *parent, const char *name) : KListView(parent, name),
m_playlistFileName(playlistFile.absFilePath())
m_playlistFileName(playlistFile.absFilePath()),
m_playingItem(0), m_leftColumn(0)
{
setup();
......@@ -542,6 +544,20 @@ void Playlist::setup()
setAcceptDrops(true);
m_allowDuplicates = false;
connect(header(), SIGNAL(indexChange(int, int, int)), this, SLOT(slotColumnOrderChanged(int, int, int)));
}
void Playlist::setPlaying(PlaylistItem *item, bool playing)
{
if(playing) {
m_playingItem = item;
item->setPixmap(m_leftColumn, QPixmap(UserIcon("playing")));
}
else {
m_playingItem = 0;
item->setPixmap(m_leftColumn, QPixmap(0, 0));
}
}
////////////////////////////////////////////////////////////////////////////////
......@@ -661,6 +677,20 @@ void Playlist::slotApplyModification(QListViewItem *item, const QString &text, i
applyTag(item, text, column);
}
void Playlist::slotColumnOrderChanged(int, int from, int to)
{
// kdDebug() << "section: " << section << " from: " << from << " to: " << to << endl;
if(from == 0 || to == 0) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
m_playingItem->setPixmap(header()->mapToSection(0), QPixmap(UserIcon("playing")));
}
m_leftColumn = header()->mapToSection(0);
}
}
////////////////////////////////////////////////////////////////////////////////
// helper functions
////////////////////////////////////////////////////////////////////////////////
......
......@@ -120,6 +120,8 @@ public:
KActionMenu *columnVisibleAction() const { return m_columnVisibleAction; }
void setPlaying(PlaylistItem *item, bool playing = true);
public slots:
/**
* Remove the currently selected items from the playlist and disk.
......@@ -197,6 +199,7 @@ private slots:
void slotShowRMBMenu(QListViewItem *item, const QPoint &point, int column);
void slotApplyModification(QListViewItem *item, const QString &text, int column);
void slotRenameTag();
void slotColumnOrderChanged(int, int from, int to);
private:
int m_currentColumn;
......@@ -218,6 +221,9 @@ private:
int m_rmbPasteID;
int m_rmbEditID;
PlaylistItem *m_playingItem;
int m_leftColumn;
};
QDataStream &operator<<(QDataStream &s, const Playlist &p);
......
......@@ -149,10 +149,13 @@ void PlaylistSplitter::stop()
{
m_nextPlaylistItem = 0;
if(m_playingItem) {
m_playingItem->setPixmap(0, 0);
m_playingItem = 0;
}
if(!m_playingItem)
return;
Playlist *p = static_cast<Playlist *>(m_playingItem->listView());
p->setPlaying(m_playingItem, false);
m_playingItem = 0;
}
QString PlaylistSplitter::playingArtist() const
......@@ -561,7 +564,10 @@ QString PlaylistSplitter::play(PlaylistItem *item)
if(!item)
return QString::null;
item->setPixmap(0, QPixmap(UserIcon("playing")));
Playlist *p = static_cast<Playlist *>(item->listView());
p->setPlaying(item, true);
m_playingItem = item;
return item->absFilePath();
......
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