Commit 344c07b7 authored by Scott Wheeler's avatar Scott Wheeler

An optimization for a couple of important cases in determining the set of

selected files.

svn path=/trunk/kdemultimedia/juk/; revision=242586
parent 0a0996ca
......@@ -26,7 +26,7 @@ class GenreListList : public QValueList<GenreList>
{
public:
GenreListList();
virtual ~GenreListList();
~GenreListList();
static GenreList ID3v1List();
static GenreListList lists();
......
......@@ -193,7 +193,9 @@ int Playlist::m_leftColumn = 0;
Playlist::Playlist(QWidget *parent, const QString &name) :
KListView(parent, name.latin1()),
m_playlistName(name),
m_rmbMenu(0)
m_rmbMenu(0),
m_selectedCount(0),
m_lastSelected(0)
{
setup();
......@@ -313,9 +315,23 @@ PlaylistItemList Playlist::visibleItems() const
PlaylistItemList Playlist::selectedItems() const
{
PlaylistItemList list;
for(PlaylistItem *i = static_cast<PlaylistItem *>(firstChild()); i; i = static_cast<PlaylistItem *>(i->itemBelow()))
if(i->isSelected())
list.append(i);
switch(m_selectedCount) {
case 0:
break;
case 1:
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);
}
break;
}
return list;
}
......@@ -431,6 +447,16 @@ void Playlist::setItemsVisible(const PlaylistItemList &items, bool visible) // s
(*it)->setVisible(visible);
}
void Playlist::markItemSelected(PlaylistItem *item, bool selected)
{
if(selected && !item->isSelected()) {
m_selectedCount++;
m_lastSelected = item;
}
else if(!selected && item->isSelected())
m_selectedCount--;
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......
......@@ -213,6 +213,8 @@ public:
*/
void emitCountChanged() { emit signalCountChanged(this); }
void markItemSelected(PlaylistItem *item, bool selected);
virtual int columnOffset() const { return 0; }
virtual bool readOnly() const { return false; }
......@@ -459,6 +461,9 @@ private:
int m_rmbPasteID;
int m_rmbEditID;
int m_selectedCount;
PlaylistItem *m_lastSelected;
static PlaylistItem *m_playingItem;
static int m_leftColumn;
......
......@@ -78,6 +78,12 @@ bool PlaylistItem::isWritable() const
return m_data->fileInfo()->isWritable();
}
void PlaylistItem::setSelected(bool selected)
{
static_cast<Playlist *>(listView())->markItemSelected(this, selected);
KListViewItem::setSelected(selected);
}
void PlaylistItem::guessTagInfo(TagGuesser::Type type)
{
switch(type) {
......
......@@ -85,6 +85,8 @@ public:
bool isWritable() const;
void setPlaying(bool playing = true) { m_playing = playing; }
virtual void setSelected(bool selected);
void guessTagInfo(TagGuesser::Type type);
void renameFile();
......
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