Commit 6bda0915 authored by Scott Wheeler's avatar Scott Wheeler

Separate update() into dataChaged() and currentChanged() to avoid reshowing

everything in the status widget when the track changes.

svn path=/trunk/kdemultimedia/juk/; revision=321986
parent e2908bc7
......@@ -92,7 +92,7 @@ void CollectionList::clearItems(const PlaylistItemList &items)
clearItem(*it, false);
}
PlaylistInterface::update();
dataChanged();
}
////////////////////////////////////////////////////////////////////////////////
......@@ -238,7 +238,7 @@ void CollectionListItem::refresh()
data()->shortFileName = file().fileInfo().fileName().lower().local8Bit();
repaint();
playlist()->PlaylistInterface::update();
playlist()->dataChanged();
}
PlaylistItem *CollectionListItem::itemForPlaylist(const Playlist *playlist) const
......@@ -266,7 +266,7 @@ CollectionListItem::CollectionListItem(const FileHandle &file) :
if(file.tag()) {
refresh();
l->PlaylistInterface::update();
l->dataChanged();
// l->addWatched(m_path);
}
else
......
......@@ -32,7 +32,8 @@ public:
{
}
virtual void update() { m_parent->slotSetDirty(); }
virtual void updateData() { m_parent->slotSetDirty(); }
virtual void updateCurrent() {}
private:
DynamicPlaylist *m_parent;
......
......@@ -126,7 +126,7 @@ QDataStream &operator>>(QDataStream &s, HistoryPlaylist &p)
after->setDateTime(dateTime);
}
p.PlaylistInterface::update();
p.dataChanged();
return s;
}
......
......@@ -522,7 +522,7 @@ void Playlist::clearItem(PlaylistItem *item, bool emitChanged)
m_randomList.remove(item);
delete item;
if(emitChanged)
PlaylistInterface::update();
dataChanged();
}
void Playlist::clearItems(const PlaylistItemList &items)
......@@ -530,7 +530,7 @@ void Playlist::clearItems(const PlaylistItemList &items)
for(PlaylistItemList::ConstIterator it = items.begin(); it != items.end(); ++it)
clearItem(*it, false);
PlaylistInterface::update();
dataChanged();
}
QStringList Playlist::files()
......@@ -822,7 +822,7 @@ void Playlist::removeFromDisk(const PlaylistItemList &items)
}
}
PlaylistInterface::update();
dataChanged();
}
}
......@@ -976,7 +976,7 @@ void Playlist::read(QDataStream &s)
for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
after = createItem(FileHandle(*it), after, false);
PlaylistInterface::update();
dataChanged();
m_collection->setupPlaylist(this, "midi");
}
......@@ -1034,7 +1034,7 @@ void Playlist::addFiles(const QStringList &files, bool importPlaylists,
after = addFile(*it, importPlaylists, after);
slotWeightDirty();
PlaylistInterface::update();
dataChanged();
KApplication::restoreOverrideCursor();
}
......@@ -1240,7 +1240,7 @@ void Playlist::loadFile(const QString &fileName, const QFileInfo &fileInfo)
file.close();
PlaylistInterface::update();
dataChanged();
m_disableColumnWidthUpdates = false;
}
......
......@@ -630,7 +630,7 @@ ItemType *Playlist::createItem(const FileHandle &file, QListViewItem *after,
m_randomList.append(i);
if(emitChanged)
PlaylistInterface::update();
dataChanged();
return i;
}
......@@ -657,7 +657,7 @@ void Playlist::createItems(const QValueList<SiblingType *> &siblings)
}
}
PlaylistInterface::update();
dataChanged();
m_disableColumnWidthUpdates = false;
slotWeightDirty();
}
......
......@@ -512,7 +512,7 @@ void PlaylistBox::slotPlaylistChanged()
if(singlePlaylist) {
playlistStack()->raiseWidget(playlists.front());
PlaylistInterface::update(); // Update the status bar
dataChanged(); // Update the status bar
delete m_dynamicPlaylist;
m_dynamicPlaylist = 0;
......
......@@ -83,28 +83,28 @@ void PlaylistCollection::playFirst()
{
m_playing = true;
currentPlaylist()->playFirst();
update();
currentChanged();
}
void PlaylistCollection::playPrevious()
{
m_playing = true;
currentPlaylist()->playPrevious();
update();
currentChanged();
}
void PlaylistCollection::playNext()
{
m_playing = true;
currentPlaylist()->playNext();
update();
currentChanged();
}
void PlaylistCollection::stop()
{
m_playing = false;
currentPlaylist()->stop();
update();
currentChanged();
}
bool PlaylistCollection::playing() const
......@@ -403,7 +403,7 @@ void PlaylistCollection::raise(Playlist *playlist)
{
playlist->setSearchEnabled(m_searchEnabled);
m_playlistStack->raiseWidget(playlist);
update(); // Update the status bar
dataChanged();
}
void PlaylistCollection::setupPlaylist(Playlist *playlist, const QString &)
......
......@@ -18,13 +18,23 @@
// Watched implementation
////////////////////////////////////////////////////////////////////////////////
void Watched::update()
void Watched::currentChanged()
{
for(QValueList<PlaylistObserver *>::ConstIterator it = m_observers.begin();
it != m_observers.end();
++it)
{
(*it)->update();
(*it)->updateCurrent();
}
}
void Watched::dataChanged()
{
for(QValueList<PlaylistObserver *>::ConstIterator it = m_observers.begin();
it != m_observers.end();
++it)
{
(*it)->updateData();
}
}
......
......@@ -25,7 +25,8 @@ class Watched
public:
void addObserver(PlaylistObserver *observer);
void removeObserver(PlaylistObserver *observer);
virtual void update();
virtual void currentChanged();
virtual void dataChanged();
protected:
virtual ~Watched();
......@@ -58,7 +59,8 @@ class PlaylistObserver
{
public:
virtual ~PlaylistObserver();
virtual void update() = 0;
virtual void updateCurrent() = 0;
virtual void updateData() = 0;
void clearWatched() { m_playlist = 0; }
......
......@@ -74,7 +74,7 @@ void SearchPlaylist::updateItems()
clearItem(it.current(), false);
if(!oldItems.isEmpty() && newItems.isEmpty())
PlaylistInterface::update();
dataChanged();
createItems(newItems);
}
......
......@@ -89,7 +89,7 @@ StatusLabel::StatusLabel(PlaylistInterface *playlist, QWidget *parent, const cha
installEventFilter(this);
update();
updateData();
}
StatusLabel::~StatusLabel()
......@@ -97,7 +97,7 @@ StatusLabel::~StatusLabel()
}
void StatusLabel::update()
void StatusLabel::updateCurrent()
{
if(playlist()->playing()) {
FileHandle file = playlist()->currentFile();
......@@ -110,7 +110,13 @@ void StatusLabel::update()
m_trackLabel->setText(text);
m_playlistLabel->setText(playlist()->name().simplifyWhiteSpace());
}
else {
}
void StatusLabel::updateData()
{
updateCurrent();
if(!playlist()->playing()) {
setItemTotalTime(0);
setItemCurrentTime(0);
int days = playlist()->time() / (60 * 60 * 24);
......
......@@ -32,7 +32,8 @@ class StatusLabel : public QHBox, public PlaylistObserver
public:
StatusLabel(PlaylistInterface *playlist, QWidget *parent = 0, const char *name = 0);
virtual ~StatusLabel();
virtual void update();
virtual void updateCurrent();
virtual void updateData();
public slots:
/**
......
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