Commit 5cf43763 authored by Scott Wheeler's avatar Scott Wheeler

Get rid of a few of the processEvent() hacks and replace them with one that's

aware of the time since the last call.  processEvents() still sucks in some
impressive ways but the more I looked into the possibility of making this
multi-threaded the more it was clear that it would have pretty bad effects
on both CPU and memory consumption.

svn path=/trunk/kdemultimedia/juk/; revision=318345
parent 5d891594
......@@ -125,7 +125,7 @@ void CollectionList::slotCheckCache()
for(QDictIterator<CollectionListItem>it(m_itemsDict); it.current(); ++it) {
if(!it.current()->checkCurrent())
invalidItems.append(*it);
kapp->processEvents();
processEvents();
}
clearItems(invalidItems);
......
......@@ -702,7 +702,6 @@ void Playlist::slotRefresh()
l = visibleItems();
KApplication::setOverrideCursor(Qt::waitCursor);
int j = 0;
for(PlaylistItemList::Iterator it = l.begin(); it != l.end(); ++it) {
(*it)->refreshFromDisk();
......@@ -713,9 +712,7 @@ void Playlist::slotRefresh()
delete (*it)->collectionItem();
}
if(j % 5 == 0)
kapp->processEvents();
j = j % 5 + 1;
processEvents();
}
KApplication::restoreOverrideCursor();
}
......@@ -751,13 +748,10 @@ void Playlist::slotGuessTagInfo(TagGuesser::Type type)
{
KApplication::setOverrideCursor(Qt::waitCursor);
PlaylistItemList items = selectedItems();
int j = 0;
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it) {
(*it)->guessTagInfo(type);
j = j % 5 + 1;
if(j % 5 == 0)
kapp->processEvents();
processEvents();
}
KApplication::restoreOverrideCursor();
}
......@@ -1325,6 +1319,8 @@ void Playlist::calculateColumnWeights()
PlaylistItem *Playlist::addFile(const QString &file, bool importPlaylists,
PlaylistItem *after)
{
processEvents();
const QFileInfo fileInfo = QDir::cleanDirPath(file);
if(!fileInfo.exists())
......@@ -1681,7 +1677,7 @@ void Playlist::slotInlineEditDone(QListViewItem *, const QString &, int column)
for(PlaylistItemList::ConstIterator it = l.begin(); it != l.end(); ++it) {
editTag(*it, text, column);
kapp->processEvents();
processEvents();
}
}
......@@ -1748,4 +1744,14 @@ QDataStream &operator>>(QDataStream &s, Playlist &p)
return s;
}
void processEvents()
{
static QTime time = QTime::currentTime();
if(time.elapsed() > 1000) {
time.restart();
kapp->processEvents();
}
}
#include "playlist.moc"
......@@ -590,6 +590,8 @@ private:
static PlaylistItem *m_playNextItem;
};
void processEvents();
QDataStream &operator<<(QDataStream &s, Playlist &p);
QDataStream &operator>>(QDataStream &s, Playlist &p);
......@@ -606,6 +608,7 @@ ItemType *Playlist::createItem(const FileHandle &file, QListViewItem *after,
setupItem(item);
// If a valid tag was not created, destroy the CollectionListItem.
if(!item->isValid()) {
kdError(65432) << "Playlist::createItem() -- A valid tag was not created for \""
<< file.absFilePath() << "\"" << endl;
......
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