1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-20 06:25:02 +01:00

Don't ignore Folder (so we don't ignore playlists they contain and we don't end up with dangling pointers in playlists_by_id_)

(cherry picked from commit fb78321c16)
This commit is contained in:
Arnaud Bienner 2013-10-02 22:58:47 +02:00
parent 06e8160fd2
commit ce117da026
2 changed files with 19 additions and 12 deletions

View File

@ -65,22 +65,28 @@ void PlaylistListModel::AddRowMappings(const QModelIndex& begin,
for (int i=begin.row() ; i<=end.row() ; ++i) {
const QModelIndex index = begin.sibling(i, 0);
QStandardItem* item = itemFromIndex(index);
AddRowItem(item, parent_path);
}
}
switch (index.data(Role_Type).toInt()) {
case Type_Playlist: {
const int id = index.data(Role_PlaylistId).toInt();
playlists_by_id_[id] = item;
if (dropping_rows_) {
emit PlaylistPathChanged(id, parent_path);
}
break;
void PlaylistListModel::AddRowItem(QStandardItem* item, const QString& parent_path) {
switch (item->data(Role_Type).toInt()) {
case Type_Playlist: {
const int id = item->data(Role_PlaylistId).toInt();
playlists_by_id_[id] = item;
if (dropping_rows_) {
emit PlaylistPathChanged(id, parent_path);
}
case Type_Folder:
break;
break;
}
case Type_Folder:
for (int j=0; j<item->rowCount(); ++j) {
QStandardItem* child_item = item->child(j);
AddRowItem(child_item, parent_path);
}
break;
}
}

View File

@ -61,6 +61,7 @@ private slots:
private:
void AddRowMappings(const QModelIndex& begin, const QModelIndex& end);
void AddRowItem(QStandardItem* item, const QString& parent_path);
void UpdatePathsRecursive(const QModelIndex& parent);
private: