Commit 69387386 authored by Scott Wheeler's avatar Scott Wheeler

Use the newly discovered QListViewItemIterator::IteratorFlag to drive the

various item list methods.  Don't know if this improves performance at all
but it removes a little code and makes things conceptually cleaner.

svn path=/trunk/kdemultimedia/juk/; revision=250434
parent ebab3143
......@@ -327,34 +327,15 @@ QStringList Playlist::files()
PlaylistItemList Playlist::items()
{
PlaylistItemList list;
for(QListViewItemIterator it(this); it.current(); ++it)
list.append(static_cast<PlaylistItem *>(it.current()));
return list;
return items(QListViewItemIterator::IteratorFlag(0));
}
PlaylistItemList Playlist::visibleItems() const
PlaylistItemList Playlist::visibleItems()
{
PlaylistItemList list;
PlaylistItem *i = static_cast<PlaylistItem *>(firstChild());
for(; i; i = static_cast<PlaylistItem *>(i->itemBelow())) {
// This check should be removed at some point since those items should
// all be already visible at the time of writing there's a bug that
// leaves some invisible items in the list
if(i->isVisible())
list.append(i);
else
kdDebug(65432) << "File shouldn't be in the list" << i->fileName() << endl;
}
return list;
return items(QListViewItemIterator::Visible);
}
PlaylistItemList Playlist::selectedItems() const
PlaylistItemList Playlist::selectedItems()
{
PlaylistItemList list;
......@@ -365,13 +346,7 @@ PlaylistItemList Playlist::selectedItems() const
list.append(m_lastSelected);
break;
default:
for(PlaylistItem *i = static_cast<PlaylistItem *>(firstChild());
i;
i = static_cast<PlaylistItem *>(i->itemBelow()))
{
if(i->isSelected())
list.append(i);
}
list = items(QListViewItemIterator::Selected);
break;
}
......@@ -1010,6 +985,16 @@ int Playlist::leftMostVisibleColumn() const
return header()->mapToSection(i);
}
PlaylistItemList Playlist::items(QListViewItemIterator::IteratorFlag flags)
{
PlaylistItemList list;
for(QListViewItemIterator it(this, flags); it.current(); ++it)
list.append(static_cast<PlaylistItem *>(it.current()));
return list;
}
void Playlist::calculateColumnWeights()
{
if(m_disableColumnWidthUpdates)
......
......@@ -110,12 +110,12 @@ public:
/**
* Returns a list of all of the items in the playlist.
*/
PlaylistItemList visibleItems() const;
PlaylistItemList visibleItems();
/**
* Returns a list of the currently selected items.
*/
PlaylistItemList selectedItems() const;
PlaylistItemList selectedItems();
/**
* Returns a list of the last 10 played items.
......@@ -478,6 +478,16 @@ private:
*/
int leftMostVisibleColumn() const;
/**
* This method is used internally to provide the backend to the other item
* lists.
*
* \see items()
* \see visibleItems()
* \see selectedItems()
*/
PlaylistItemList items(QListViewItemIterator::IteratorFlag flags);
/**
* Build the column "weights" for the weighted width mode.
*/
......
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