Commit 7b2c349d authored by Scott Wheeler's avatar Scott Wheeler

Added a new method for creating new PlaylistItems that are copies of other

playlist items

svn path=/trunk/kdemultimedia/juk/; revision=220077
parent 5f3a5931
......@@ -182,11 +182,7 @@ void CollectionList::slotRefreshItem(const QString &file)
void CollectionList::slotCreateGroup()
{
PlaylistItemList items = selectedItems();
QValueList<QFileInfo> fileInfos;
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it)
fileInfos << *(*it)->data()->fileInfo();
emit signalRequestPlaylistCreation(fileInfos);
emit signalRequestPlaylistCreation(selectedItems());
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -93,7 +93,7 @@ protected:
signals:
void signalCollectionChanged();
void signalRequestPlaylistCreation(const QValueList<QFileInfo> &fileInfos);
void signalRequestPlaylistCreation(const PlaylistItemList &items);
private slots:
void slotRemoveItem(const QString &file);
......
......@@ -601,6 +601,19 @@ PlaylistItem *Playlist::createItem(const QFileInfo &file, QListViewItem *after)
return 0;
}
void Playlist::createItems(const PlaylistItemList &siblings)
{
PlaylistItem *previous = 0;
for(PlaylistItemList::ConstIterator it = siblings.begin(); it != siblings.end(); ++it) {
if(!m_members.insert(resolveSymLinks((*it)->absFilePath()))) {
previous = new PlaylistItem((*it)->collectionItem(), this, previous);
connect((*it), SIGNAL(destroyed()), (*it)->collectionItem(), SLOT(deleteLater()));
}
}
}
void Playlist::hideColumn(int c)
{
m_headerMenu->setItemChecked(c, false);
......
......@@ -98,6 +98,8 @@ public:
*/
virtual PlaylistItem *createItem(const QFileInfo &file, QListViewItem *after = 0);
void createItems(const PlaylistItemList &siblings);
QString fileName() const { return m_fileName; }
void setFileName(const QString &n) { m_fileName = n; }
......
......@@ -231,7 +231,7 @@ void PlaylistBox::duplicate(Item *item)
if(ok) {
Playlist *p = m_splitter->createPlaylist(name);
m_splitter->slotAddToPlaylist(item->playlist()->files(), p);
p->createItems(item->playlist()->items());
}
}
}
......
......@@ -137,8 +137,9 @@ PlaylistItem::PlaylistItem(CollectionListItem *item, Playlist *parent, QListView
setup(item, parent);
}
PlaylistItem::PlaylistItem(Playlist *parent) : QObject(parent), KListViewItem(parent),
m_collectionItem(0), m_data(0), m_playing(false)
PlaylistItem::PlaylistItem(CollectionList *parent) : QObject(parent), KListViewItem(parent),
m_collectionItem(static_cast<CollectionListItem *>(this)),
m_data(0), m_playing(false)
{
setDragEnabled(true);
}
......
......@@ -44,7 +44,6 @@ typedef QValueList<PlaylistItem *> PlaylistItemList;
class PlaylistItem : public QObject, public KListViewItem
{
friend class Playlist;
friend class PlaylistSplitter;
friend class CollectionList;
/**
......@@ -105,7 +104,7 @@ protected:
/**
* This is the constructor that shold be used by subclasses.
*/
PlaylistItem(Playlist *parent);
PlaylistItem(CollectionList *parent);
/**
* See the class documentation for an explanation of construction and deletion
......@@ -125,7 +124,7 @@ protected:
bool isValid() const;
virtual CollectionListItem *collectionItem() { return m_collectionItem; }
virtual CollectionListItem *collectionItem() const { return m_collectionItem; }
protected slots:
void slotRefreshImpl();
......
......@@ -408,8 +408,8 @@ void PlaylistSplitter::setupLayout()
m_collection = CollectionList::instance();
setupPlaylist(m_collection, true, "folder_sound");
connect(m_collection, SIGNAL(signalCollectionChanged()), m_editor, SLOT(slotUpdateCollection()));
connect(m_collection, SIGNAL(signalRequestPlaylistCreation(const QValueList<QFileInfo> &)),
this, SLOT(slotCreatePlaylist(const QValueList<QFileInfo> &)));
connect(m_collection, SIGNAL(signalRequestPlaylistCreation(const PlaylistItemList &)),
this, SLOT(slotCreatePlaylist(const PlaylistItemList &)));
// Create the search widget -- this must be done after the CollectionList is created.
......@@ -617,14 +617,9 @@ void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
// unsorted...
m_dynamicList->setSorting(m_dynamicList->columns() + 1);
PlaylistItem *previous = 0;
for(PlaylistList::ConstIterator it = l.begin(); it != l.end(); ++it) {
if(*it) {
PlaylistItemList items = (*it)->items();
for(PlaylistItemList::Iterator itemIt = items.begin(); itemIt != items.end(); ++itemIt)
previous = new PlaylistItem((*itemIt)->collectionItem(), m_dynamicList, previous);
}
if(*it)
m_dynamicList->createItems((*it)->items());
}
}
......@@ -647,16 +642,17 @@ void PlaylistSplitter::slotPlaylistItemRemoved(PlaylistItem *item)
m_nextPlaylistItem = 0;
}
void PlaylistSplitter::slotCreatePlaylist(const QValueList<QFileInfo> &fileInfos)
void PlaylistSplitter::slotCreatePlaylist(const PlaylistItemList &items)
{
if(items.isEmpty())
return;
Playlist *playlist = slotCreatePlaylist();
if(!playlist)
return;
QValueList<QFileInfo>::ConstIterator it = fileInfos.begin();
QValueList<QFileInfo>::ConstIterator end = fileInfos.end();
for(; it != end; ++it)
playlist->createItem(*it);
playlist->createItems(items);
}
void PlaylistSplitter::slotShowSearchResults(const QString &query, bool caseSensitive)
......
......@@ -293,7 +293,7 @@ private slots:
void slotScanDirectories() { open(m_directoryList); }
void slotSetNextItem(PlaylistItem *item = 0) { m_nextPlaylistItem = item; }
void slotDirChanged(const QString &dir) { slotAddToPlaylist(dir, m_collection); }
void slotCreatePlaylist(const QValueList<QFileInfo> &fileInfos);
void slotCreatePlaylist(const PlaylistItemList &items);
void slotShowSearchResults(const QString &query, bool caseSensitive = false);
void slotVisibleColumnsChanged();
......
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