Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4839a25f authored by Michael Pyne's avatar Michael Pyne

Fix a bug with renaming files that is exposed by the History list. When

renaming a file, the map of file names to collection list items wasn't updated,
which caused duplicate entries to appear when the History list added an entry
when you play the newly-renamed file.

Although disabling the KDirWatch doesn't appear to be actually necessary to fix
the bug, I'm leaving that part in because I think that once 85534 is fixed it
will expose the bug again.

svn path=/trunk/kdemultimedia/juk/; revision=332434
parent 0fdc1c20
......@@ -354,6 +354,17 @@ PlaylistItem *CollectionListItem::itemForPlaylist(const Playlist *playlist) cons
return 0;
}
void CollectionListItem::updateCollectionDict(const QString &oldPath, const QString &newPath)
{
CollectionList *collection = CollectionList::instance();
if(!collection)
return;
collection->removeFromDict(oldPath);
collection->addToDict(newPath, this);
}
////////////////////////////////////////////////////////////////////////////////
// CollectionListItem protected methods
////////////////////////////////////////////////////////////////////////////////
......
......@@ -163,6 +163,7 @@ class CollectionListItem : public PlaylistItem
public:
virtual void refresh();
PlaylistItem *itemForPlaylist(const Playlist *playlist) const;
void updateCollectionDict(const QString &oldPath, const QString &newPath);
protected:
CollectionListItem(const FileHandle &file);
......
......@@ -714,24 +714,14 @@ void Playlist::slotRefresh()
void Playlist::slotRenameFile()
{
#if 0
// TODO: find a less dirty hack for signaling disabling of the file
// renamer that doesn't involve going through these layers of indirection.
JuK *mainWindow = dynamic_cast<JuK *>(kapp->mainWidget());
Q_ASSERT(mainWindow);
if(mainWindow)
mainWindow->setDirWatchEnabled(false);
#endif
FileRenamer renamer;
PlaylistItemList items = selectedItems();
if(items.isEmpty())
return;
emit signalEnableDirWatch(false);
if(items.count() == 1)
renamer.rename(items[0]);
else
......@@ -739,10 +729,7 @@ void Playlist::slotRenameFile()
dataChanged();
#if 0
if(mainWindow)
mainWindow->setDirWatchEnabled(true);
#endif
emit signalEnableDirWatch(true);
}
void Playlist::slotGuessTagInfo(TagGuesser::Type type)
......
......@@ -423,6 +423,8 @@ signals:
*/
void signalAboutToRemove(PlaylistItem *item);
void signalEnableDirWatch(bool enable);
private:
void setup();
......
......@@ -677,6 +677,8 @@ void PlaylistBox::Item::init()
connect(m_playlist, SIGNAL(signalNameChanged(const QString &)),
this, SLOT(slotSetName(const QString &)));
connect(m_playlist, SIGNAL(destroyed()), this, SLOT(deleteLater()));
connect(m_playlist, SIGNAL(signalEnableDirWatch(bool)),
list->object(), SLOT(slotEnableDirWatch(bool)));
}
if(m_playlist == CollectionList::instance()) {
......
......@@ -459,6 +459,14 @@ bool PlaylistCollection::containsPlaylistFile(const QString &file) const
return m_playlistFiles.contains(file);
}
void PlaylistCollection::enableDirWatch(bool enable)
{
if(enable)
m_dirWatch.startScan(false);
else
m_dirWatch.stopScan();
}
QString PlaylistCollection::playlistNameDialog(const QString &caption,
const QString &suggest,
bool forceUnique) const
......
......@@ -108,6 +108,8 @@ protected:
bool importPlaylists() const;
bool containsPlaylistFile(const QString &file) const;
void enableDirWatch(bool enable);
QString playlistNameDialog(const QString &caption = i18n("Create New Playlist"),
const QString &suggest = QString::null,
bool forceUnique = true) const;
......@@ -180,6 +182,7 @@ private slots:
void slotSetSearchEnabled(bool enable) { m_collection->setSearchEnabled(enable); }
void slotSetHistoryPlaylistEnabled(bool enable) {m_collection->setHistoryPlaylistEnabled(enable); }
void slotEnableDirWatch(bool enable) { m_collection->enableDirWatch(enable); }
signals:
void signalSelectedItemsChanged();
......
......@@ -40,6 +40,7 @@ PlaylistItem::~PlaylistItem()
void PlaylistItem::setFile(const FileHandle &file)
{
m_collectionItem->updateCollectionDict(d->fileHandle.absFilePath(), file.absFilePath());
d->fileHandle = file;
refresh();
}
......
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