aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-01-16 16:05:06 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-01-16 16:05:06 +0000
commitc593f9fb752f038ff68df6d753085890798e5783 (patch)
treeef657b68408a8c818bf08836e62ab731ed035e28 /src/plugins/General
parent886f9be488970798b2725ad2e9ddf26b5cadee07 (diff)
downloadqmmp-c593f9fb752f038ff68df6d753085890798e5783.tar.gz
qmmp-c593f9fb752f038ff68df6d753085890798e5783.tar.bz2
qmmp-c593f9fb752f038ff68df6d753085890798e5783.zip
refactoring
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9640 90c681e8-e032-0410-971d-27865f9a5e38
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());
}