Commit 356370d3 authored by Scott Wheeler's avatar Scott Wheeler

Switched PlaylistItemList from QPtrList<PlaylistItem> to

QValueList<PlaylistItem *> and added a typedef for PlaylistList.

svn path=/trunk/kdemultimedia/juk/; revision=218729
parent 3c655d4c
......@@ -184,8 +184,8 @@ void CollectionList::slotCreateGroup()
{
PlaylistItemList items = selectedItems();
QValueList<QFileInfo> fileInfos;
for(PlaylistItem *item = items.first(); item != 0; item = items.next())
fileInfos << *item->data()->fileInfo();
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it)
fileInfos << *(*it)->data()->fileInfo();
emit signalRequestPlaylistCreation(fileInfos);
}
......
......@@ -32,7 +32,6 @@
#include <qdir.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qptrlist.h>
#include <qheader.h>
#include <qcursor.h>
#include <qclipboard.h>
......@@ -257,8 +256,8 @@ void Playlist::refresh()
KApplication::setOverrideCursor(Qt::waitCursor);
int j = 0;
for(PlaylistItem *i = l.first(); i; i = l.next()) {
i->slotRefreshFromDisk();
for(PlaylistItemList::Iterator it = l.begin(); it != l.end(); ++it) {
(*it)->slotRefreshFromDisk();
if(j % 5 == 0)
kapp->processEvents();
j = j % 5 + 1;
......@@ -277,11 +276,9 @@ void Playlist::clearItem(PlaylistItem *item, bool emitChanged)
void Playlist::clearItems(const PlaylistItemList &items)
{
QPtrListIterator<PlaylistItem> it(items);
while(it.current()) {
clearItem(it.current(), false);
++it;
}
for(PlaylistItemList::ConstIterator it = items.begin(); it != items.end(); ++it)
clearItem(*it, false);
emit signalNumberOfItemsChanged(this);
}
......@@ -327,7 +324,7 @@ PlaylistItem *Playlist::nextItem(PlaylistItem *current, bool random)
srand(time(0));
i = current;
while(i == current)
i = items().at(rand() % count());
i = items()[rand() % count()];
}
else
i = 0;
......@@ -406,8 +403,8 @@ void Playlist::slotGuessTagInfo()
{
KApplication::setOverrideCursor(Qt::waitCursor);
PlaylistItemList items = selectedItems();
for(PlaylistItem *item = items.first(); item != 0; item = items.next())
item->guessTagInfo();
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it)
(*it)->guessTagInfo();
KApplication::restoreOverrideCursor();
}
......@@ -430,8 +427,8 @@ void Playlist::deleteFromDisk(const PlaylistItemList &items)
if(isVisible() && !items.isEmpty()) {
QStringList files;
for(QPtrListIterator<PlaylistItem> it(items); it.current(); ++it)
files.append(it.current()->fileName());
for(PlaylistItemList::ConstIterator it = items.begin(); it != items.end(); ++it)
files.append((*it)->fileName());
QString message;
......@@ -441,13 +438,13 @@ void Playlist::deleteFromDisk(const PlaylistItemList &items)
message = i18n("Do you really want to delete these %1 items from your disk?").arg(QString::number(files.count()));
if(KMessageBox::questionYesNoList(this, message, files) == KMessageBox::Yes) {
for(QPtrListIterator<PlaylistItem> it(items); it.current(); ++it) {
if(QFile::remove(it.current()->filePath())) {
emit signalAboutToRemove(it.current());
delete it.current();
for(PlaylistItemList::ConstIterator it = items.begin(); it != items.end(); ++it) {
if(QFile::remove((*it)->filePath())) {
emit signalAboutToRemove(*it);
delete *it;
}
else
KMessageBox::sorry(this, i18n("Could not delete ") + it.current()->fileName() + ".");
KMessageBox::sorry(this, i18n("Could not delete ") + (*it)->fileName() + ".");
}
}
......@@ -459,9 +456,9 @@ QDragObject *Playlist::dragObject(QWidget *parent)
{
PlaylistItemList items = selectedItems();
KURL::List urls;
for(PlaylistItem *i = items.first(); i; i = items.next()) {
for(PlaylistItemList::Iterator it = items.begin(); it != items.end(); ++it) {
KURL url;
url.setPath(i->absFilePath());
url.setPath((*it)->absFilePath());
urls.append(url);
}
......@@ -879,22 +876,26 @@ void Playlist::slotApplyModification(QListViewItem *item, const QString &text, i
QPtrList<QListViewItem> selectedSongs = KListView::selectedItems();
if (selectedSongs.count() > 1)
{
if (KMessageBox::warningYesNo(0, i18n("This will rename multiple files! Are you sure?"), QString::null,
KStdGuiItem::yes(), KStdGuiItem::no(), "DontWarnMultipleTags") == KMessageBox::No)
return;
if (KMessageBox::warningYesNo(0,
i18n("This will rename multiple files! Are you sure?"),
QString::null,
KStdGuiItem::yes(),
KStdGuiItem::no(),
"DontWarnMultipleTags") == KMessageBox::No)
{
return;
}
QPtrListIterator<QListViewItem> it(selectedSongs);
for(; it.current(); ++it)
applyTag((*it), text, column);
}
else
applyTag(item, text, column);
}
else
applyTag(item, text, column);
}
void Playlist::slotColumnOrderChanged(int, int from, int to)
{
// kdDebug() << "section: " << section << " from: " << from << " to: " << to << endl;
if(from == 0 || to == 0) {
if(m_playingItem) {
m_playingItem->setPixmap(m_leftColumn, QPixmap(0, 0));
......
......@@ -34,6 +34,8 @@ class KActionMenu;
class QEvent;
typedef QValueList<Playlist *> PlaylistList;
class Playlist : public KListView
{
Q_OBJECT
......@@ -134,7 +136,7 @@ public slots:
* Remove the currently selected items from the playlist and disk.
*/
void slotDeleteSelectedItems() { deleteFromDisk(selectedItems()); };
virtual void slotSetNext() { emit signalSetNext(selectedItems().getFirst()); }
virtual void slotSetNext() { emit signalSetNext(selectedItems().first()); }
/*
* The edit slots are required to use the canonical names so that they are
......
......@@ -27,7 +27,6 @@
#include <qdrawutil.h>
#include <qclipboard.h>
#include "playlist.h"
#include "playlistbox.h"
#include "collectionlist.h"
#include "playlistsplitter.h"
......@@ -129,9 +128,9 @@ void PlaylistBox::raise(Playlist *playlist)
ensureCurrentVisible();
}
QPtrList<Playlist> PlaylistBox::playlists() const
PlaylistList PlaylistBox::playlists() const
{
QPtrList<Playlist> l;
PlaylistList l;
// skip the collection m_list
......
......@@ -21,13 +21,12 @@
#include <klistbox.h>
#include <qwidgetstack.h>
#include <qptrlist.h>
#include <qptrdict.h>
#include <qmap.h>
#include "playlist.h"
#include "listboxpixmap.h"
class Playlist;
class PlaylistItem;
class PlaylistSplitter;
......@@ -51,7 +50,7 @@ public:
void sort();
void raise(Playlist *playlist);
QStringList names() const { return m_names; }
QPtrList<Playlist> playlists() const;
PlaylistList playlists() const;
// All of the methods use the selected item.
void save();
......
......@@ -22,7 +22,6 @@
#include <qfileinfo.h>
#include <qobject.h>
#include <qptrlist.h>
#include <qptrstack.h>
#include "tag.h"
......@@ -32,7 +31,7 @@ class Playlist;
class PlaylistItem;
class CollectionListItem;
typedef QPtrList<PlaylistItem> PlaylistItemList;
typedef QValueList<PlaylistItem *> PlaylistItemList;
/**
* Items for the Playlist and the baseclass for CollectionListItem.
......@@ -47,10 +46,6 @@ class PlaylistItem : public QObject, public KListViewItem
friend class Playlist;
friend class CollectionList;
/**
* Needs access to the destuctor, even though the destructor isn't used by QPtrList.
*/
friend class QPtrList<PlaylistItem>;
/**
* Needs access to the destuctor, even though the destructor isn't used by QPtrStack.
*/
......
......@@ -121,7 +121,7 @@ QString PlaylistSplitter::playNextFile(bool random, bool loopPlaylist)
i = static_cast<PlaylistItem *>(p->firstChild());
}
else {
i = playlistSelection().getFirst();
i = playlistSelection().first();
if(!i)
i = static_cast<PlaylistItem *>(visiblePlaylist()->firstChild());
}
......@@ -459,10 +459,10 @@ void PlaylistSplitter::saveConfig()
QDataStream s(&f);
QPtrList<Playlist> l = m_playlistBox->playlists();
PlaylistList l = m_playlistBox->playlists();
for(Playlist *p = l.first(); p; p = l.next())
s << *p;
for(PlaylistList::Iterator it = l.begin(); it != l.end(); it++)
s << *(*it);
f.close();
}
......
......@@ -83,7 +83,7 @@ public:
* Returns the name of the currently selected file and moves the playing
* indicator to that file.
*/
QString playSelectedFile() { return play(playlistSelection().getFirst()); }
QString playSelectedFile() { return play(playlistSelection().first()); }
/**
* Returns the name of the first item in the playlist and moves the playing
......@@ -230,7 +230,7 @@ signals:
private:
/**
* Returns a QPtrList of the selected PlaylistItems in the top playlist in
* Returns a PlaylistItemList of the selected PlaylistItems in the top playlist in
* the QWidgetStack of playlists.
*/
PlaylistItemList playlistSelection() const { return visiblePlaylist()->selectedItems(); }
......
......@@ -76,7 +76,7 @@ void TagEditor::slotRefresh()
// the most common case -- is to just process the first item. Then we
// check after that to see if there are other m_items and adjust accordingly.
PlaylistItem *item = m_items.getFirst();
PlaylistItem *item = m_items.first();
if(item) {
Tag *tag = item->tag();
......@@ -99,12 +99,12 @@ void TagEditor::slotRefresh()
// Start at the second item, since we've already processed the first.
QPtrListIterator<PlaylistItem> it(m_items);
PlaylistItemList::Iterator it = m_items.begin();
++it;
// If there is more than one item in the m_items that we're dealing with...
if(it.current()) {
if(it != m_items.end()) {
m_fileNameBox->clear();
m_fileNameBox->setEnabled(false);
......@@ -114,7 +114,7 @@ void TagEditor::slotRefresh()
m_bitrateBox->clear();
m_bitrateBox->setEnabled(false);
for(BoxMap::iterator boxIt = m_enableBoxes.begin(); boxIt != m_enableBoxes.end(); boxIt++) {
for(BoxMap::Iterator boxIt = m_enableBoxes.begin(); boxIt != m_enableBoxes.end(); boxIt++) {
(*boxIt)->setChecked(true);
(*boxIt)->show();
}
......@@ -135,7 +135,7 @@ void TagEditor::slotRefresh()
m_enableBoxes[m_commentBox]->setChecked(false);
}
else {
for(; it.current(); ++it) {
for(; it != m_items.end(); ++it) {
tag = (*it)->tag();
if(m_artistNameBox->currentText() != tag->artist() && m_enableBoxes.contains(m_artistNameBox)) {
m_artistNameBox->lineEdit()->clear();
......@@ -389,7 +389,7 @@ void TagEditor::save(const PlaylistItemList &list)
QStringList errorFiles;
for(QPtrListIterator<PlaylistItem> it(list); it.current(); ++it) {
for(PlaylistItemList::ConstIterator it = list.begin(); it != list.end(); ++it) {
PlaylistItem *item = *it;
QFileInfo newFile(item->dirPath() + QDir::separator() + m_fileNameBox->text());
......@@ -469,11 +469,9 @@ void TagEditor::saveChangesPrompt()
if(isVisible() && m_dataChanged && !m_items.isEmpty()) {
QStringList files;
PlaylistItem *item = m_items.first();
while(item) {
files.append(item->fileName());
item = m_items.next();
}
for(PlaylistItemList::Iterator it = m_items.begin(); it != m_items.end(); it++)
files.append((*it)->fileName());
if(KMessageBox::questionYesNoList(this,
i18n("Do you want to save your changes to:\n"),
......@@ -481,7 +479,8 @@ void TagEditor::saveChangesPrompt()
i18n("Save Changes"),
KStdGuiItem::yes(),
KStdGuiItem::no(),
"tagEditor_showSaveChangesBox") == KMessageBox::Yes) {
"tagEditor_showSaveChangesBox") == KMessageBox::Yes)
{
save(m_items);
}
}
......
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