Commit 2790a724 authored by Kacper Kasper's avatar Kacper Kasper Committed by Michael Pyne

Fix upcoming playlist crashes.

Also ensures items added to the upcoming playlist are ordered correctly
and fixes the "Add to Play Queue" GUI action.

Differential Revision: https://phabricator.kde.org/D7553
parent d726a580
......@@ -332,7 +332,6 @@ Playlist::Playlist(PlaylistCollection *collection, const QString &name,
QTreeWidget(collection->playlistStack()),
m_collection(collection),
m_fetcher(new WebImageFetcher(this)),
m_selectedCount(0),
m_allowDuplicates(true),
m_applySharedSettings(true),
m_columnWidthModeChanged(false),
......@@ -340,7 +339,6 @@ Playlist::Playlist(PlaylistCollection *collection, const QString &name,
m_time(0),
m_widthsDirty(true),
m_searchEnabled(true),
m_lastSelected(0),
m_playlistName(name),
m_rmbMenu(0),
m_toolTip(0),
......@@ -355,7 +353,6 @@ Playlist::Playlist(PlaylistCollection *collection, const PlaylistItemList &items
QTreeWidget(collection->playlistStack()),
m_collection(collection),
m_fetcher(new WebImageFetcher(this)),
m_selectedCount(0),
m_allowDuplicates(true),
m_applySharedSettings(true),
m_columnWidthModeChanged(false),
......@@ -363,7 +360,6 @@ Playlist::Playlist(PlaylistCollection *collection, const PlaylistItemList &items
m_time(0),
m_widthsDirty(true),
m_searchEnabled(true),
m_lastSelected(0),
m_playlistName(name),
m_rmbMenu(0),
m_toolTip(0),
......@@ -379,7 +375,6 @@ Playlist::Playlist(PlaylistCollection *collection, const QFileInfo &playlistFile
QTreeWidget(collection->playlistStack()),
m_collection(collection),
m_fetcher(new WebImageFetcher(this)),
m_selectedCount(0),
m_allowDuplicates(true),
m_applySharedSettings(true),
m_columnWidthModeChanged(false),
......@@ -387,7 +382,6 @@ Playlist::Playlist(PlaylistCollection *collection, const QFileInfo &playlistFile
m_time(0),
m_widthsDirty(true),
m_searchEnabled(true),
m_lastSelected(0),
m_fileName(playlistFile.canonicalFilePath()),
m_rmbMenu(0),
m_toolTip(0),
......@@ -402,7 +396,6 @@ Playlist::Playlist(PlaylistCollection *collection, bool delaySetup, int extraCol
QTreeWidget(collection->playlistStack()),
m_collection(collection),
m_fetcher(new WebImageFetcher(this)),
m_selectedCount(0),
m_allowDuplicates(true),
m_applySharedSettings(true),
m_columnWidthModeChanged(false),
......@@ -410,7 +403,6 @@ Playlist::Playlist(PlaylistCollection *collection, bool delaySetup, int extraCol
m_time(0),
m_widthsDirty(true),
m_searchEnabled(true),
m_lastSelected(0),
m_rmbMenu(0),
m_toolTip(0),
m_blockDataChanged(false)
......@@ -640,20 +632,7 @@ PlaylistItemList Playlist::visibleItems()
PlaylistItemList Playlist::selectedItems()
{
PlaylistItemList list;
switch(m_selectedCount) {
case 0:
break;
// case 1:
// list.append(m_lastSelected);
// break;
default:
list = items(QTreeWidgetItemIterator::Selected | QTreeWidgetItemIterator::NotHidden);
break;
}
return list;
return items(QTreeWidgetItemIterator::Selected | QTreeWidgetItemIterator::NotHidden);
}
PlaylistItem *Playlist::firstChild() const
......@@ -707,16 +686,6 @@ void Playlist::setSearchEnabled(bool enabled)
setItemsVisible(items(), true);
}
void Playlist::markItemSelected(PlaylistItem *item, bool selected)
{
if(selected && !item->isSelected()) {
m_selectedCount++;
m_lastSelected = item;
}
else if(!selected && item->isSelected())
m_selectedCount--;
}
void Playlist::synchronizePlayingItems(const PlaylistList &sources, bool setMaster)
{
foreach(const Playlist *p, sources) {
......@@ -1322,7 +1291,7 @@ void Playlist::insertItem(QTreeWidgetItem *item)
// you need to use the PlaylistItem from here.
m_addTime.append(static_cast<PlaylistItem *>(item));
QTreeWidget::addTopLevelItem(item);
QTreeWidget::insertTopLevelItem(0, item);
}
void Playlist::takeItem(QTreeWidgetItem *item)
......@@ -1331,7 +1300,7 @@ void Playlist::takeItem(QTreeWidgetItem *item)
m_subtractTime.append(static_cast<PlaylistItem *>(item));
int index = indexOfTopLevelItem(item);
delete takeTopLevelItem(index);
QTreeWidget::takeTopLevelItem(index);
}
void Playlist::addColumn(const QString &label, int)
......
......@@ -278,11 +278,6 @@ public:
*/
void setSearchEnabled(bool searchEnabled);
/**
* Marks \a item as either selected or deselected based.
*/
void markItemSelected(PlaylistItem *item, bool selected);
/**
* Subclasses of Playlist which add new columns will set this value to
* specify how many of those columns exist. This allows the Playlist
......@@ -660,7 +655,6 @@ private:
int m_currentColumn;
QAction *m_rmbEdit;
int m_selectedCount;
bool m_allowDuplicates;
bool m_applySharedSettings;
......@@ -685,8 +679,6 @@ private:
bool m_searchEnabled;
PlaylistItem *m_lastSelected;
/**
* Used to store the text for inline editing before it is changed so that
* we can know if something actually changed and as such if we need to save
......
......@@ -185,12 +185,6 @@ void PlaylistItem::setPlaying(bool playing, bool master)
treeWidget()->viewport()->update();
}
void PlaylistItem::setSelected(bool selected)
{
playlist()->markItemSelected(this, selected);
QTreeWidgetItem::setSelected(selected);
}
void PlaylistItem::guessTagInfo(TagGuesser::Type type)
{
switch(type) {
......
......@@ -102,7 +102,6 @@ public:
void setPlaying(bool playing = true, bool master = true);
virtual void setSelected(bool selected);
void guessTagInfo(TagGuesser::Type type);
Playlist *playlist() const;
......
......@@ -140,7 +140,6 @@ void PlaylistSplitter::slotFocusCurrentPlaylist()
playlist->setSelectionMode(QTreeWidget::SingleSelection);
playlist->markItemSelected(item, true);
playlist->setCurrentItem(item);
playlist->setSelectionMode(QTreeWidget::ExtendedSelection);
......
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