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