aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/library/librarymodel.cpp35
-rw-r--r--src/plugins/General/library/librarymodel.h3
-rw-r--r--src/plugins/General/library/librarywidget.cpp2
3 files changed, 15 insertions, 25 deletions
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<PlayListTrack *> tracks;
-
- for(const QModelIndex &index : indexes)
- {
- if(index.isValid())
- {
- tracks << getTracks(index);
- }
- }
+ QList<PlayListTrack *> tracks = getTracks(indexes);
if(!tracks.isEmpty())
{
@@ -308,20 +300,20 @@ void LibraryModel::refresh()
void LibraryModel::add(const QModelIndexList &indexes)
{
- QList<PlayListTrack *> 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<PlayListTrack *> 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<PlayListTrack *> LibraryModel::getTracks(const QModelIndexList &indexes) const
{
QList<PlayListTrack *> 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<PlayListTrack *> LibraryModel::getTracks(const QModelIndex &index) const
diff --git a/src/plugins/General/library/librarymodel.h b/src/plugins/General/library/librarymodel.h
index 5ba99d936..885b1af15 100644
--- a/src/plugins/General/library/librarymodel.h
+++ b/src/plugins/General/library/librarymodel.h
@@ -52,9 +52,10 @@ public:
void setFilter(const QString &filter);
void refresh();
void add(const QModelIndexList &indexes);
- void showInformation(const QModelIndexList &indexes, QWidget *parent);
+ void showInformation(const QModelIndexList &indexes, QWidget *parent = nullptr);
private:
+ QList<PlayListTrack *> getTracks(const QModelIndexList &indexes) const;
QList<PlayListTrack *> getTracks(const QModelIndex &index) const;
PlayListTrack *createTrack(const QSqlQuery &query) const;
diff --git a/src/plugins/General/library/librarywidget.cpp b/src/plugins/General/library/librarywidget.cpp
index eea4ce983..8d3ddca85 100644
--- a/src/plugins/General/library/librarywidget.cpp
+++ b/src/plugins/General/library/librarywidget.cpp
@@ -86,5 +86,5 @@ void LibraryWidget::addSelected()
void LibraryWidget::showInformation()
{
- m_model->showInformation(m_ui->treeView->selectionModel()->selectedIndexes(), this);
+ m_model->showInformation(m_ui->treeView->selectionModel()->selectedIndexes());
}