diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-02-07 14:21:23 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-02-07 14:21:23 +0000 |
| commit | 62f1800c82b5f637e1a6037229e66f1ce36dd8d5 (patch) | |
| tree | c8eaee05c6df848824b7b578c64ba323c432fc4d | |
| parent | 5a119002d992a47aeca66af31059d3769848d8c6 (diff) | |
| download | qmmp-62f1800c82b5f637e1a6037229e66f1ce36dd8d5.tar.gz qmmp-62f1800c82b5f637e1a6037229e66f1ce36dd8d5.tar.bz2 qmmp-62f1800c82b5f637e1a6037229e66f1ce36dd8d5.zip | |
removed TagUpdater class
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9696 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmpui/detailsdialog.cpp | 32 | ||||
| -rw-r--r-- | src/qmmpui/detailsdialog.h | 4 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 7 | ||||
| -rw-r--r-- | src/qmmpui/qmmpui.pro | 6 | ||||
| -rw-r--r-- | src/qmmpui/tagupdater.cpp | 49 | ||||
| -rw-r--r-- | src/qmmpui/tagupdater_p.h | 46 |
6 files changed, 38 insertions, 106 deletions
diff --git a/src/qmmpui/detailsdialog.cpp b/src/qmmpui/detailsdialog.cpp index e03e757a0..54b9b870c 100644 --- a/src/qmmpui/detailsdialog.cpp +++ b/src/qmmpui/detailsdialog.cpp @@ -46,10 +46,27 @@ DetailsDialog::DetailsDialog(const QList<PlayListTrack *> &tracks, QWidget *pare m_ui->prevButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowLeft)); updatePage(); on_tabWidget_currentChanged(0); + + for(PlayListTrack *t : qAsConst(m_tracks)) + t->beginUsage(); } DetailsDialog::~DetailsDialog() { + for(PlayListTrack *t : qAsConst(m_tracks)) + { + t->endUsage(); + if (!t->isUsed() && t->isSheduledForDeletion()) + { + delete t; + t = nullptr; + } + else + { + t->updateMetaData(); + } + } + if(m_metaDataModel) { delete m_metaDataModel; @@ -58,6 +75,11 @@ DetailsDialog::~DetailsDialog() delete m_ui; } +QStringList DetailsDialog::modifiedPaths() const +{ + return m_modifiedPaths.values(); +} + void DetailsDialog:: on_directoryButton_clicked() { QString dir_path; @@ -81,19 +103,25 @@ void DetailsDialog::on_buttonBox_clicked(QAbstractButton *button) { if(m_ui->buttonBox->standardButton(button) == QDialogButtonBox::Save) { - TagEditor *tagEditor = qobject_cast<TagEditor *>(m_ui->tabWidget->currentWidget()); + TagEditor *tagEditor = nullptr; CoverEditor *coverEditor = nullptr; CueEditor *cueEditor = nullptr; - if(tagEditor) + + if((tagEditor = qobject_cast<TagEditor *>(m_ui->tabWidget->currentWidget()))) + { tagEditor->save(); + m_modifiedPaths.insert(m_info.path()); + } else if((coverEditor = qobject_cast<CoverEditor *>(m_ui->tabWidget->currentWidget()))) { coverEditor->save(); + m_modifiedPaths.insert(m_info.path()); MetaDataManager::instance()->clearCoverCache(); } else if((cueEditor = qobject_cast<CueEditor *>(m_ui->tabWidget->currentWidget()))) { cueEditor->save(); + m_modifiedPaths.insert(m_info.path()); } } else diff --git a/src/qmmpui/detailsdialog.h b/src/qmmpui/detailsdialog.h index 7e04f89de..8ae97b512 100644 --- a/src/qmmpui/detailsdialog.h +++ b/src/qmmpui/detailsdialog.h @@ -22,6 +22,7 @@ #include <QDialog> #include <QList> +#include <QSet> #include <qmmp/qmmp.h> #include <qmmp/trackinfo.h> #include "qmmpui_export.h" @@ -54,6 +55,8 @@ public: */ ~DetailsDialog(); + QStringList modifiedPaths() const; + private slots: void on_buttonBox_clicked(QAbstractButton *button); void on_tabWidget_currentChanged(int index); @@ -72,6 +75,7 @@ private: QList<PlayListTrack *> m_tracks; TrackInfo m_info; int m_page = 0; + QSet<QString> m_modifiedPaths; }; #endif diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 60bf7226d..cac8b956c 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -33,7 +33,6 @@ #include "fileloader_p.h" #include "playstate_p.h" #include "detailsdialog.h" -#include "tagupdater_p.h" #include "qmmpuisettings.h" #include "playlistmodel.h" @@ -677,8 +676,7 @@ void PlayListModel::showDetails(QWidget *parent) { QDialog *d = new DetailsDialog(selected_tracks, parent); d->setAttribute(Qt::WA_DeleteOnClose, true); - TagUpdater *updater = new TagUpdater(d, selected_tracks); - connect(updater, SIGNAL(destroyed(QObject *)),SLOT(updateMetaData())); + connect(d, SIGNAL(destroyed(QObject *)),SLOT(updateMetaData())); d->show(); } } @@ -691,8 +689,7 @@ void PlayListModel::showDetailsForCurrent(QWidget *parent) l.append(m_current_track); QDialog *d = new DetailsDialog(l, parent); d->setAttribute(Qt::WA_DeleteOnClose, true); - TagUpdater *updater = new TagUpdater(d, l); - connect(updater, SIGNAL(destroyed(QObject *)),SLOT(updateMetaData())); + connect(d, SIGNAL(destroyed(QObject *)),SLOT(updateMetaData())); d->show(); } } diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index c8e4ca2f4..8dbf4b0f8 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -59,7 +59,6 @@ HEADERS += general.h \ playlistdownloader.h \ addurldialog_p.h \ qmmpuiplugincache_p.h \ - tagupdater_p.h \ playlistgroup.h \ playlisttrack.h \ playlistcontainer_p.h \ @@ -88,7 +87,6 @@ SOURCES += general.cpp \ fileloader.cpp \ mediaplayer.cpp \ detailsdialog.cpp \ - tageditor.cpp \ playlistmanager.cpp \ templateeditor.cpp \ uiloader.cpp \ @@ -102,7 +100,6 @@ SOURCES += general.cpp \ playlistdownloader.cpp \ addurldialog.cpp \ qmmpuiplugincache.cpp \ - tagupdater.cpp \ playlistgroup.cpp \ playlisttrack.cpp \ groupedcontainer.cpp \ @@ -118,7 +115,8 @@ SOURCES += general.cpp \ covereditor.cpp \ commandlinehandler.cpp \ generalfactory.cpp \ - cueeditor.cpp + cueeditor.cpp \ + tageditor.cpp FORMS += forms/detailsdialog.ui \ forms/tageditor.ui \ diff --git a/src/qmmpui/tagupdater.cpp b/src/qmmpui/tagupdater.cpp deleted file mode 100644 index fe8df89ea..000000000 --- a/src/qmmpui/tagupdater.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013-2021 by Ilya Kotov * - * forkotov02@ya.ru * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "tagupdater_p.h" - -TagUpdater::TagUpdater(QObject* o, const QList<PlayListTrack *> &tracks) : - m_observable(o), - m_tracks(tracks) -{ - for(PlayListTrack *t : qAsConst(m_tracks)) - t->beginUsage(); - connect(m_observable, SIGNAL(destroyed(QObject *)),SLOT(updateTags())); - connect(m_observable, SIGNAL(destroyed(QObject *)),SLOT(deleteLater())); -} - -void TagUpdater::updateTags() -{ - for(PlayListTrack *t : qAsConst(m_tracks)) - { - t->endUsage(); - if (!t->isUsed() && t->isSheduledForDeletion()) - { - delete t; - t = nullptr; - } - else - { - t->updateMetaData(); - } - } - m_tracks.clear(); -} diff --git a/src/qmmpui/tagupdater_p.h b/src/qmmpui/tagupdater_p.h deleted file mode 100644 index 396965808..000000000 --- a/src/qmmpui/tagupdater_p.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013 by Ilya Kotov * - * forkotov02@ya.ru * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef TAGUPDATER_P_H -#define TAGUPDATER_P_H - -#include <QObject> -#include "playlisttrack.h" - -/*! @internal - * @brief Helper class used for tags update after details dialog closing. - * - * @author Vladimir Kuznetsov <vovanec@gmail.com> - */ -class TagUpdater : public QObject -{ - Q_OBJECT - -public: - TagUpdater(QObject* o, const QList<PlayListTrack *> &tracks); - QObject* m_observable; - QList<PlayListTrack*> m_tracks; - -public slots: - void updateTags(); - -}; - -#endif // TAGUPDATER_P_H |
