From c593f9fb752f038ff68df6d753085890798e5783 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 16 Jan 2021 16:05:06 +0000 Subject: refactoring git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9640 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/library/librarymodel.cpp | 35 ++++++++++------------------ 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/plugins/General/library/librarymodel.cpp') diff --git a/src/plugins/General/library/librarymodel.cpp b/src/plugins/General/library/librarymodel.cpp index d02e9ba27..a1c583149 100644 --- a/src/plugins/General/library/librarymodel.cpp +++ b/src/plugins/General/library/librarymodel.cpp @@ -91,15 +91,7 @@ QStringList LibraryModel::mimeTypes() const QMimeData *LibraryModel::mimeData(const QModelIndexList &indexes) const { - QList tracks; - - for(const QModelIndex &index : indexes) - { - if(index.isValid()) - { - tracks << getTracks(index); - } - } + QList tracks = getTracks(indexes); if(!tracks.isEmpty()) { @@ -308,20 +300,20 @@ void LibraryModel::refresh() void LibraryModel::add(const QModelIndexList &indexes) { - QList tracks; + PlayListManager::instance()->add(getTracks(indexes)); +} - for(const QModelIndex &index : indexes) - { - if(index.isValid()) - { - tracks << getTracks(index); - } - } +void LibraryModel::showInformation(const QModelIndexList &indexes, QWidget *parent) +{ + QList tracks = getTracks(indexes); - PlayListManager::instance()->add(tracks); + DetailsDialog *dialog = new DetailsDialog(tracks, parent); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + dialog->show(); + connect(dialog, &QObject::destroyed, [=]() { qDeleteAll(tracks); }); } -void LibraryModel::showInformation(const QModelIndexList &indexes, QWidget *parent) +QList LibraryModel::getTracks(const QModelIndexList &indexes) const { QList tracks; @@ -333,10 +325,7 @@ void LibraryModel::showInformation(const QModelIndexList &indexes, QWidget *pare } } - DetailsDialog *dialog = new DetailsDialog(tracks, parent); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - dialog->show(); - connect(dialog, &QObject::destroyed, [=]() { qDeleteAll(tracks); }); + return tracks; } QList LibraryModel::getTracks(const QModelIndex &index) const -- cgit v1.2.3-13-gbd6f