Commit 52a5fbe0 authored by Michael Pyne's avatar Michael Pyne

* Implement drag-and-drop retagging of songs while using the tree view...

* Implement drag-and-drop retagging of songs while using the tree view playlist mode, fixing bug 62307.
* In the process, I've found many instances where updating a tag sometimes wouldn't update a search playlist, and so I've fixed all those bugs I could find.

Drag-and-drop retagging only works dragging songs onto the Artist, Album, or Genre subitems, however I still find it pretty useful.

CCMAIL:62307-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=322682
parent 8cf0995f
......@@ -49,6 +49,7 @@ juk_SOURCES = \
tagguesserconfigdlgwidget.ui \
trackpickerdialog.cpp \
trackpickerdialogbase.ui \
treeviewitemplaylist.cpp \
viewmode.cpp
tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp
......
......@@ -242,8 +242,10 @@ void CollectionListItem::refresh()
}
data()->shortFileName = file().fileInfo().fileName().lower().local8Bit();
repaint();
playlist()->dataChanged();
CollectionList::instance()->dataChanged();
emit CollectionList::instance()->signalCollectionChanged();
repaint();
}
PlaylistItem *CollectionListItem::itemForPlaylist(const Playlist *playlist) const
......
......@@ -98,6 +98,12 @@ void DynamicPlaylist::showEvent(QShowEvent *e)
Playlist::showEvent(e);
}
void DynamicPlaylist::paintEvent(QPaintEvent *e)
{
checkUpdateItems();
Playlist::paintEvent(e);
}
void DynamicPlaylist::updateItems()
{
PlaylistItemList siblings;
......
......@@ -65,6 +65,8 @@ protected:
*/
virtual void showEvent(QShowEvent *e);
virtual void paintEvent(QPaintEvent *e);
/**
* Updates the items (unconditionally). This should be reimplemented in
* subclasses to refresh the items in the dynamic list (i.e. running a
......
......@@ -711,6 +711,8 @@ void Playlist::slotRenameFile()
else
renamer.rename(items);
dataChanged();
#if 0
if(mainWindow)
mainWindow->setDirWatchEnabled(true);
......@@ -726,6 +728,7 @@ void Playlist::slotGuessTagInfo(TagGuesser::Type type)
processEvents();
}
dataChanged();
KApplication::restoreOverrideCursor();
}
......@@ -904,6 +907,7 @@ void Playlist::contentsDropEvent(QDropEvent *e)
else
decode(e, moveAfter);
dataChanged();
KListView::contentsDropEvent(e);
}
......@@ -1703,6 +1707,10 @@ void Playlist::slotInlineEditDone(QListViewItem *, const QString &, int column)
editTag(*it, text, column);
processEvents();
}
CollectionList::instance()->dataChanged();
dataChanged();
update();
}
void Playlist::slotColumnOrderChanged(int, int from, int to)
......
......@@ -30,6 +30,7 @@
#include "dynamicplaylist.h"
#include "viewmode.h"
#include "searchplaylist.h"
#include "treeviewitemplaylist.h"
#include "actioncollection.h"
#include "cache.h"
#include "k3bexporter.h"
......@@ -309,10 +310,19 @@ void PlaylistBox::decode(QMimeSource *s, Item *item)
if(KURLDrag::decode(s, urls) && !urls.isEmpty()) {
QStringList files;
for(KURL::List::Iterator it = urls.begin(); it != urls.end(); it++)
files.append((*it).path());
if(item) {
TreeViewItemPlaylist *playlistItem;
playlistItem = dynamic_cast<TreeViewItemPlaylist *>(item->playlist());
if(playlistItem) {
playlistItem->retag(files, currentPlaylist());
currentPlaylist()->update();
return;
}
}
if(item && item->playlist())
item->playlist()->addFiles(files, true);
else {
......
......@@ -527,6 +527,13 @@ void TagEditor::save(const PlaylistItemList &list)
QStringList errorFiles;
for(PlaylistItemList::ConstIterator it = list.begin(); it != list.end(); ++it) {
// Process items before we being modifying tags, as the dynamic
// playlists will try to modify the file we edit if the tag changes
// due to our alterations here.
kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
PlaylistItem *item = *it;
QFileInfo newFile(item->file().fileInfo().dirPath() + QDir::separator() +
......@@ -597,11 +604,10 @@ void TagEditor::save(const PlaylistItemList &list)
item->file().tag()->save();
item->refresh();
item->playlist()->update();
}
else if(item)
errorFiles.append(item->file().absFilePath());
kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
}
if(!errorFiles.isEmpty())
......@@ -610,6 +616,7 @@ void TagEditor::save(const PlaylistItemList &list)
i18n("Could Not Write to:\n") + errorFiles.join("\n"));
m_dataChanged = false;
CollectionList::instance()->dataChanged();
KApplication::restoreOverrideCursor();
}
}
......
#include <kapplication.h>
#include <kdebug.h>
#include <qstringlist.h>
#include <qlistview.h>
#include "collectionlist.h"
#include "treeviewitemplaylist.h"
#include "tag.h"
#include "playlistitem.h"
#include "playlistsearch.h"
TreeViewItemPlaylist::TreeViewItemPlaylist(PlaylistCollection *collection,
const PlaylistSearch &search,
const QString &name,
bool setupPlaylist) :
SearchPlaylist(collection, search, name, setupPlaylist)
{
PlaylistSearch::Component component = *(search.components().begin());
m_columnType = static_cast<PlaylistItem::ColumnType>(*(component.columns().begin()));
}
void TreeViewItemPlaylist::retag(const QStringList &files, Playlist *donorPlaylist)
{
CollectionList *collection = CollectionList::instance();
if(files.isEmpty())
return;
QStringList::ConstIterator it;
for(it = files.begin(); it != files.end(); ++it) {
CollectionListItem *item = collection->lookup(*it);
if(!item)
continue;
Tag *tag = item->file().tag();
switch(m_columnType) {
case PlaylistItem::ArtistColumn:
tag->setArtist(name());
break;
case PlaylistItem::AlbumColumn:
tag->setAlbum(name());
break;
case PlaylistItem::GenreColumn:
tag->setGenre(name());
break;
default:
kdDebug() << "Unhandled column type editing " << *it << endl;
}
tag->save();
item->refresh();
DynamicPlaylist *dynPlaylist = dynamic_cast<DynamicPlaylist *>(donorPlaylist);
if(dynPlaylist) {
dynPlaylist->slotSetDirty();
static_cast<QWidget*>(dynPlaylist)->update();
}
else {
PlaylistItem *donorItem = item->itemForPlaylist(donorPlaylist);
if(donorItem)
donorItem->repaint();
}
kapp->processEvents();
}
dataChanged();
}
#include "treeviewitemplaylist.moc"
#ifndef TREEVIEWITEMPLAYLIST_H
#define TREEVIEWITEMPLAYLIST_H
#include "searchplaylist.h"
#include "playlistitem.h"
class QStringList;
class TreeViewItemPlaylist : public SearchPlaylist
{
Q_OBJECT
public:
TreeViewItemPlaylist(PlaylistCollection *collection,
const PlaylistSearch &search = PlaylistSearch(),
const QString &name = QString::null,
bool setupPlaylist = true);
void retag(const QStringList &files, Playlist *donorPlaylist);
signals:
void signalTagsChanged();
private:
PlaylistItem::ColumnType m_columnType;
};
#endif // TREEVIEWITEMPLAYLIST_H
......@@ -22,6 +22,7 @@
#include "viewmode.h"
#include "playlistbox.h"
#include "searchplaylist.h"
#include "treeviewitemplaylist.h"
#include "collectionlist.h"
////////////////////////////////////////////////////////////////////////////////
......@@ -306,7 +307,7 @@ void TreeViewMode::setupCategory(const QString &searchCategory, const QStringLis
playlists.append(collection);
PlaylistSearch s(playlists, components, PlaylistSearch::MatchAny, false);
SearchPlaylist *p = new SearchPlaylist(playlistBox(), s, *it, false);
TreeViewItemPlaylist *p = new TreeViewItemPlaylist(playlistBox(), s, *it, false);
playlistBox()->setupPlaylist(p, "midi", m_searchCategories[searchCategory]);
processEvents();
......
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