Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ec8ce622 authored by Michael Pyne's avatar Michael Pyne

Port most iterators to use foreach when feasible. Not only is it easier to

read but I think I even saw an instance of an end iterator being
inappropriately cached which is normally bad news.

It builds, I haven't tested if it runs yet. ;)

svn path=/trunk/KDE/kdemultimedia/juk/; revision=991102
parent 5424cb23
......@@ -64,11 +64,12 @@ QStringList MediaFiles::openDialog(QWidget *parent)
dialog->exec();
// Only local files included in this list.
QStringList selectedFiles = dialog->selectedFiles();
delete dialog;
return convertURLsToLocal(selectedFiles);
return selectedFiles;
}
QString MediaFiles::savePlaylistDialog(const QString &playlistName, QWidget *parent)
......@@ -141,13 +142,13 @@ QStringList MediaFiles::mimeTypes()
return l;
}
QStringList MediaFiles::convertURLsToLocal(const QStringList &urlList, QWidget *w)
QStringList MediaFiles::convertURLsToLocal(const KUrl::List &urlList, QWidget *w)
{
QStringList result;
KUrl localUrl;
for(QStringList::ConstIterator it = urlList.constBegin(); it != urlList.constEnd(); ++it) {
localUrl = KIO::NetAccess::mostLocalUrl(KUrl(*it), w);
foreach(const KUrl &url, urlList) {
localUrl = KIO::NetAccess::mostLocalUrl(url, w);
if(!localUrl.isLocalFile())
kDebug(65432) << localUrl << " is not a local file, skipping.\n";
......
......@@ -20,6 +20,8 @@ class QWidget;
class QString;
class QStringList;
#include <kurl.h>
/**
* A namespace for file JuK's file related functions. The goal is to hide
* all specific knowledge of mimetypes and file extensions here.
......@@ -86,7 +88,7 @@ namespace MediaFiles
* @param w KIO may need the widget to handle user interaction.
* @return list of all local files in urlList, converted to absolute paths.
*/
QStringList convertURLsToLocal(const QStringList &urlList, QWidget *w = 0);
QStringList convertURLsToLocal(const KUrl::List &urlList, QWidget *w = 0);
}
#endif
......
This diff is collapsed.
......@@ -364,18 +364,14 @@ void PlaylistCollection::addFolder()
const bool reload = m_importPlaylists != result.addPlaylists;
m_importPlaylists = result.addPlaylists;
for(QStringList::const_iterator it = result.addedDirs.constBegin();
it != result.addedDirs.constEnd(); it++)
{
m_dirLister.openUrl(KUrl::fromPath(*it), KDirLister::Keep);
m_folderList.append(*it);
foreach(const QString &dir, result.addedDirs) {
m_dirLister.openUrl(KUrl::fromPath(dir), KDirLister::Keep);
m_folderList.append(dir);
}
for(QStringList::const_iterator it = result.removedDirs.constBegin();
it != result.removedDirs.constEnd(); it++)
{
m_dirLister.stop(KUrl::fromPath(*it));
m_folderList.removeAll(*it);
foreach(const QString &dir, result.removedDirs) {
m_dirLister.stop(KUrl::fromPath(dir));
m_folderList.removeAll(dir);
}
if(reload)
......@@ -823,8 +819,8 @@ void PlaylistCollection::readConfig()
m_importPlaylists = config.readEntry("ImportPlaylists", true);
m_folderList = config.readEntry("DirectoryList", QStringList());
for(QStringList::ConstIterator it = m_folderList.constBegin(); it != m_folderList.constEnd(); ++it)
m_dirLister.openUrl(*it, KDirLister::Keep);
foreach(const QString &folder, m_folderList)
m_dirLister.openUrl(folder, KDirLister::Keep);
}
void PlaylistCollection::saveConfig()
......
......@@ -417,8 +417,8 @@ void TagEditor::updateCollection()
m_genreList = list->uniqueSet(CollectionList::Genres);
for(QStringList::ConstIterator it = m_genreList.constBegin(); it != m_genreList.constEnd(); ++it)
genreHash.insert(*it);
foreach(const QString &genre, m_genreList)
genreHash.insert(genre);
TagLib::StringList genres = TagLib::ID3v1::genreList();
......@@ -672,7 +672,7 @@ void TagEditor::save(const PlaylistItemList &list)
PlaylistItemList::ConstIterator end = list.end();
for(PlaylistItemList::ConstIterator it = list.begin(); it != end; /* Deliberatly missing */ ) {
for(PlaylistItemList::ConstIterator it = list.begin(); it != end; /* Deliberately missing */ ) {
// Process items before we being modifying tags, as the dynamic
// playlists will try to modify the file we edit if the tag changes
......@@ -740,8 +740,8 @@ void TagEditor::saveChangesPrompt()
QStringList files;
for(PlaylistItemList::Iterator it = m_items.begin(); it != m_items.end(); ++it)
files.append((*it)->file().absFilePath());
foreach(const PlaylistItem *item, m_items)
files.append(item->file().absFilePath());
if(KMessageBox::questionYesNoList(this,
i18n("Do you want to save your changes to:\n"),
......
......@@ -71,9 +71,9 @@ void UpcomingPlaylist::appendItems(const PlaylistItemList &itemList)
PlaylistItem *after = static_cast<PlaylistItem *>(lastItem());
for(PlaylistItemList::ConstIterator it = itemList.begin(); it != itemList.end(); ++it) {
after = createItem(*it, after);
m_playlistIndex.insert(after, (*it)->playlist());
foreach(PlaylistItem *playlistItem, itemList) {
after = createItem(playlistItem, after);
m_playlistIndex.insert(after, playlistItem->playlist());
}
dataChanged();
......@@ -120,8 +120,8 @@ void UpcomingPlaylist::addFiles(const QStringList &files, PlaylistItem *after)
CollectionList::instance()->addFiles(files, after);
PlaylistItemList l;
for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
FileHandle f(*it);
foreach(const QString &file, files) {
FileHandle f(file);
PlaylistItem *i = CollectionList::instance()->lookup(f.absFilePath());
if(i)
l.append(i);
......@@ -254,8 +254,8 @@ QDataStream &operator<<(QDataStream &s, const UpcomingPlaylist &p)
s << qint32(l.count());
for(PlaylistItemList::Iterator it = l.begin(); it != l.end(); ++it)
s << (*it)->file().absFilePath();
foreach(const PlaylistItem *playlistItem, l)
s << playlistItem->file().absFilePath();
return s;
}
......
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