You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdemultimedia/juk/treeviewitemplaylist.cpp

94 lines
3.1 KiB

/***************************************************************************
begin : Mon Jun 21 2004
copyright : (C) 2004 by Michael Pyne
email : michael.pyne@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tdeapplication.h>
#include <kdebug.h>
#include <tdemessagebox.h>
#include <tdelocale.h>
#include <tqstringlist.h>
#include <tqlistview.h>
#include "collectionlist.h"
#include "treeviewitemplaylist.h"
#include "tag.h"
#include "playlistitem.h"
#include "playlistsearch.h"
#include "tagtransactionmanager.h"
TreeViewItemPlaylist::TreeViewItemPlaylist(PlaylistCollection *collection,
const PlaylistSearch &search,
const TQString &name) :
SearchPlaylist(collection, search, name, false)
{
PlaylistSearch::Component component = *(search.components().begin());
m_columnType = static_cast<PlaylistItem::ColumnType>(*(component.columns().begin()));
}
void TreeViewItemPlaylist::retag(const TQStringList &files, Playlist *)
{
CollectionList *collection = CollectionList::instance();
if(files.isEmpty())
return;
TQString changedTag = i18n("artist");
if(m_columnType == PlaylistItem::GenreColumn)
changedTag = i18n("genre");
else if(m_columnType == PlaylistItem::AlbumColumn)
changedTag = i18n("album");
if(KMessageBox::warningContinueCancelList(
this,
i18n("You are about to change the %1 on these files.").arg(changedTag),
files,
i18n("Changing Track Tags"),
KStdGuiItem::cont(),
"dragDropRetagWarn"
) == KMessageBox::Cancel)
{
return;
}
TQStringList::ConstIterator it;
for(it = files.begin(); it != files.end(); ++it) {
CollectionListItem *item = collection->lookup(*it);
if(!item)
continue;
Tag *tag = TagTransactionManager::duplicateTag(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;
}
TagTransactionManager::instance()->changeTagOnItem(item, tag);
}
}
#include "treeviewitemplaylist.moc"