aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/decoderfactory.h2
-rw-r--r--lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp3
-rw-r--r--lib/qmmp/Input/ffmpeg/decoderffmpegfactory.h2
-rw-r--r--lib/qmmp/Input/flac/decoderflacfactory.cpp3
-rw-r--r--lib/qmmp/Input/flac/decoderflacfactory.h2
-rw-r--r--lib/qmmp/Input/mad/decodermadfactory.cpp3
-rw-r--r--lib/qmmp/Input/mad/decodermadfactory.h2
-rw-r--r--lib/qmmp/Input/mad/detailsdialog.cpp2
-rw-r--r--lib/qmmp/Input/mpc/decodermpcfactory.cpp3
-rw-r--r--lib/qmmp/Input/mpc/decodermpcfactory.h2
-rw-r--r--lib/qmmp/Input/vorbis/decodervorbisfactory.cpp3
-rw-r--r--lib/qmmp/Input/vorbis/decodervorbisfactory.h2
-rw-r--r--src/mediafile.cpp14
-rw-r--r--src/mediafile.h18
-rw-r--r--src/playlistmodel.cpp63
-rw-r--r--src/playlistmodel.h18
16 files changed, 118 insertions, 24 deletions
diff --git a/lib/decoderfactory.h b/lib/decoderfactory.h
index cfd0e5166..d67d1b564 100644
--- a/lib/decoderfactory.h
+++ b/lib/decoderfactory.h
@@ -53,7 +53,7 @@ public:
virtual const DecoderProperties properties() const = 0;
virtual Decoder *create(QObject *, QIODevice *, Output *) = 0;
virtual FileTag *createTag(const QString &source) = 0;
- virtual void showDetails(QWidget *parent, const QString &path) = 0;
+ virtual QObject* showDetails(QWidget *parent, const QString &path) = 0;
virtual void showSettings(QWidget *parent) = 0;
virtual void showAbout(QWidget *parent) = 0;
virtual QTranslator *createTranslator(QObject *parent) = 0;
diff --git a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
index 09d878990..789635a15 100644
--- a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
+++ b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.cpp
@@ -64,10 +64,11 @@ FileTag *DecoderFFmpegFactory::createTag(const QString &source)
return ftag;
}
-void DecoderFFmpegFactory::showDetails(QWidget *parent, const QString &path)
+QObject* DecoderFFmpegFactory::showDetails(QWidget *parent, const QString &path)
{
DetailsDialog *d = new DetailsDialog(parent, path);
d -> show();
+ return d;
}
void DecoderFFmpegFactory::showSettings(QWidget *)
diff --git a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.h b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.h
index 7acc9f204..16b6de1dd 100644
--- a/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.h
+++ b/lib/qmmp/Input/ffmpeg/decoderffmpegfactory.h
@@ -45,7 +45,7 @@ public:
const DecoderProperties properties() const;
Decoder *create(QObject *, QIODevice *, Output *);
FileTag *createTag(const QString &source);
- void showDetails(QWidget *parent, const QString &path);
+ QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/lib/qmmp/Input/flac/decoderflacfactory.cpp b/lib/qmmp/Input/flac/decoderflacfactory.cpp
index cf8643ce4..5abb60b39 100644
--- a/lib/qmmp/Input/flac/decoderflacfactory.cpp
+++ b/lib/qmmp/Input/flac/decoderflacfactory.cpp
@@ -67,10 +67,11 @@ FileTag *DecoderFLACFactory::createTag(const QString &source)
return ftag;
}
-void DecoderFLACFactory::showDetails(QWidget *parent, const QString &path)
+QObject* DecoderFLACFactory::showDetails(QWidget *parent, const QString &path)
{
DetailsDialog *d = new DetailsDialog(parent, path);
d -> show();
+ return d;
}
void DecoderFLACFactory::showSettings(QWidget *)
diff --git a/lib/qmmp/Input/flac/decoderflacfactory.h b/lib/qmmp/Input/flac/decoderflacfactory.h
index 59b6a8656..586bc3b33 100644
--- a/lib/qmmp/Input/flac/decoderflacfactory.h
+++ b/lib/qmmp/Input/flac/decoderflacfactory.h
@@ -45,7 +45,7 @@ public:
const DecoderProperties properties() const;
Decoder *create(QObject *, QIODevice *, Output *);
FileTag *createTag(const QString &source);
- void showDetails(QWidget *parent, const QString &path);
+ QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/lib/qmmp/Input/mad/decodermadfactory.cpp b/lib/qmmp/Input/mad/decodermadfactory.cpp
index f86f6972b..1c863d6e0 100644
--- a/lib/qmmp/Input/mad/decodermadfactory.cpp
+++ b/lib/qmmp/Input/mad/decodermadfactory.cpp
@@ -155,10 +155,11 @@ FileTag *DecoderMADFactory::createTag(const QString &source)
return ftag;
}
-void DecoderMADFactory::showDetails(QWidget *parent, const QString &path)
+QObject* DecoderMADFactory::showDetails(QWidget *parent, const QString &path)
{
DetailsDialog *d = new DetailsDialog(parent, path);
d -> show();
+ return d;
}
void DecoderMADFactory::showSettings(QWidget *parent)
diff --git a/lib/qmmp/Input/mad/decodermadfactory.h b/lib/qmmp/Input/mad/decodermadfactory.h
index fa1e7972f..2c7da8e47 100644
--- a/lib/qmmp/Input/mad/decodermadfactory.h
+++ b/lib/qmmp/Input/mad/decodermadfactory.h
@@ -44,7 +44,7 @@ public:
const DecoderProperties properties() const;
Decoder *create(QObject *, QIODevice *, Output *);
FileTag *createTag(const QString &source);
- void showDetails(QWidget *parent, const QString &path);
+ QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/lib/qmmp/Input/mad/detailsdialog.cpp b/lib/qmmp/Input/mad/detailsdialog.cpp
index 21ebf2524..8e28dda66 100644
--- a/lib/qmmp/Input/mad/detailsdialog.cpp
+++ b/lib/qmmp/Input/mad/detailsdialog.cpp
@@ -187,7 +187,7 @@ void DetailsDialog::saveID3v1Tag()
f.ID3v1Tag(TRUE)->setTitle(TagLib::String(m_codec_v1->fromUnicode(ui.titleLineEdit_v1->text()).constData(), type));
f.ID3v1Tag()->setArtist(TagLib::String(m_codec_v1->fromUnicode(ui.artistLineEdit_v1->text()).constData(), type));
f.ID3v1Tag()->setAlbum(TagLib::String(m_codec_v1->fromUnicode(ui.albumLineEdit_v1->text()).constData(), type));
- f.ID3v1Tag()->setComment(TagLib::String(m_codec_v1->fromUnicode(ui.commentLineEdit_v2->text()).constData(), type));
+ f.ID3v1Tag()->setComment(TagLib::String(m_codec_v1->fromUnicode(ui.commentLineEdit_v1->text()).constData(), type));
f.ID3v1Tag()->setGenre(TagLib::String(m_codec_v1->fromUnicode(ui.genreLineEdit_v1->text()).constData(), type));
f.ID3v1Tag()->setYear(ui.yearLineEdit_v1->text().toUInt());
f.ID3v1Tag()->setTrack(ui.trackLineEdit_v1->text().toUInt());
diff --git a/lib/qmmp/Input/mpc/decodermpcfactory.cpp b/lib/qmmp/Input/mpc/decodermpcfactory.cpp
index 7e15174e5..f2874a08d 100644
--- a/lib/qmmp/Input/mpc/decodermpcfactory.cpp
+++ b/lib/qmmp/Input/mpc/decodermpcfactory.cpp
@@ -67,10 +67,11 @@ FileTag *DecoderMPCFactory::createTag(const QString &source)
return ftag;
}
-void DecoderMPCFactory::showDetails(QWidget *parent, const QString &path)
+QObject* DecoderMPCFactory::showDetails(QWidget *parent, const QString &path)
{
DetailsDialog *d = new DetailsDialog(parent, path);
d -> show();
+ return d;
}
void DecoderMPCFactory::showSettings(QWidget *)
diff --git a/lib/qmmp/Input/mpc/decodermpcfactory.h b/lib/qmmp/Input/mpc/decodermpcfactory.h
index eb8858cdf..0f8dda55f 100644
--- a/lib/qmmp/Input/mpc/decodermpcfactory.h
+++ b/lib/qmmp/Input/mpc/decodermpcfactory.h
@@ -45,7 +45,7 @@ public:
const DecoderProperties properties() const;
Decoder *create(QObject *, QIODevice *, Output *);
FileTag *createTag(const QString &source);
- void showDetails(QWidget *parent, const QString &path);
+ QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp b/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
index d09154d61..c3b31ec52 100644
--- a/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
+++ b/lib/qmmp/Input/vorbis/decodervorbisfactory.cpp
@@ -72,10 +72,11 @@ FileTag *DecoderVorbisFactory::createTag(const QString &source)
return ftag;
}
-void DecoderVorbisFactory::showDetails(QWidget *parent, const QString &path)
+QObject* DecoderVorbisFactory::showDetails(QWidget *parent, const QString &path)
{
DetailsDialog *d = new DetailsDialog(parent, path);
d -> show();
+ return d;
}
void DecoderVorbisFactory::showSettings(QWidget *)
diff --git a/lib/qmmp/Input/vorbis/decodervorbisfactory.h b/lib/qmmp/Input/vorbis/decodervorbisfactory.h
index f4d3eb9c6..6830fc102 100644
--- a/lib/qmmp/Input/vorbis/decodervorbisfactory.h
+++ b/lib/qmmp/Input/vorbis/decodervorbisfactory.h
@@ -45,7 +45,7 @@ public:
const DecoderProperties properties() const;
Decoder *create(QObject *, QIODevice *, Output *);
FileTag *createTag(const QString &source);
- void showDetails(QWidget *parent, const QString &path);
+ QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
diff --git a/src/mediafile.cpp b/src/mediafile.cpp
index d6ccc6668..24b6ce174 100644
--- a/src/mediafile.cpp
+++ b/src/mediafile.cpp
@@ -24,7 +24,7 @@
#include "mediafile.h"
-MediaFile::MediaFile(QString path)
+MediaFile::MediaFile(const QString& path) : m_flag(FREE)
{
m_selected = FALSE;
m_current = FALSE;
@@ -114,7 +114,6 @@ void MediaFile::updateTags()
{
if (m_path.startsWith("http://"))
return;
-
if (m_tag)
{
delete m_tag;
@@ -150,3 +149,14 @@ void MediaFile::changeTitle(const QString &newtitle)
m_title = newtitle;
}
+void MediaFile::setFlag(FLAGS f)
+{
+ m_flag = f;
+}
+
+
+MediaFile::FLAGS MediaFile::flag() const
+{
+ return m_flag;
+}
+
diff --git a/src/mediafile.h b/src/mediafile.h
index 799d508c1..7adab6603 100644
--- a/src/mediafile.h
+++ b/src/mediafile.h
@@ -31,12 +31,20 @@ class FileTag;
class MediaFile
{
public:
- MediaFile()
+ /*!
+ * Current state of media file.
+ * FREE - instance is free and may be deleted
+ * EDITING - instance is currently busy in some kind of operation(tags editing etc.)
+ * and can't be deleted at the moment. Set flag SCHEDULED_FOR_DELETION for it
+ * instead of delete operator call.
+ */
+ enum FLAGS{FREE = 0,EDITING,SCHEDULED_FOR_DELETION};
+
+ MediaFile() : m_flag(FREE)
{};
- MediaFile(QString);
+ MediaFile(const QString&);
~MediaFile();
- //MediaFile &operator=(const MediaFile &other);
const QString path()const;
const QString title()const;
@@ -50,7 +58,8 @@ public:
void updateTags(const FileTag*);
void updateTags();
void changeTitle(const QString&);
-
+ FLAGS flag()const;
+ void setFlag(FLAGS);
private:
void readMetadata();
@@ -62,6 +71,7 @@ private:
bool m_current;
bool m_use_meta;
QString m_format;
+ FLAGS m_flag;
};
diff --git a/src/playlistmodel.cpp b/src/playlistmodel.cpp
index f88f59268..196608438 100644
--- a/src/playlistmodel.cpp
+++ b/src/playlistmodel.cpp
@@ -43,6 +43,28 @@
#define INVALID_ROW -1
+TagUpdater::TagUpdater(QObject* o,MediaFile* f):m_observable(o),m_file(f)
+{
+ m_file->setFlag(MediaFile::EDITING);
+ connect (m_observable, SIGNAL(destroyed (QObject * )),SLOT(updateTag()));
+ connect (m_observable, SIGNAL(destroyed (QObject * )),SLOT(deleteLater()));
+}
+
+void TagUpdater::updateTag()
+{
+ if(m_file->flag() == MediaFile::SCHEDULED_FOR_DELETION)
+ {
+ delete m_file;
+ m_file = NULL;
+ }
+ else
+ {
+ m_file->updateTags();
+ m_file->setFlag(MediaFile::FREE);
+ }
+}
+
+
PlayListModel::PlayListModel ( QObject *parent )
: QObject ( parent ) , m_selection()
{
@@ -60,8 +82,6 @@ PlayListModel::PlayListModel ( QObject *parent )
registerPlaylistFormat( new XSPFPlaylistFormat);
#endif
loadExternalPlaylistFormats();
-
- //qRegisterMetaType<MediaFile*>("MediaFileStar");
}
PlayListModel::~PlayListModel()
@@ -145,7 +165,6 @@ void PlayListModel::clear()
{
if (!l.isNull())
{
- qWarning("void PlayListModel::clear()");
l->finish();
l->wait();
}
@@ -155,7 +174,18 @@ void PlayListModel::clear()
m_current = 0;
while ( !m_files.isEmpty() )
- delete m_files.takeFirst();
+ {
+ MediaFile* mf = m_files.takeFirst();
+
+ if(mf->flag() == MediaFile::FREE)
+ {
+ delete mf;
+ }
+ else if(mf->flag() == MediaFile::EDITING)
+ {
+ mf->setFlag(MediaFile::SCHEDULED_FOR_DELETION);
+ }
+ }
m_total_length = 0;
m_play_state->resetState();
@@ -225,7 +255,14 @@ void PlayListModel::removeSelection(bool inverted)
m_total_length -= f->length();
if (m_total_length < 0)
m_total_length = 0;
- delete f;
+
+ if(f->flag() == MediaFile::FREE)
+ {
+ delete f;
+ f = NULL;
+ }
+ else if(f->flag() == MediaFile::EDITING)
+ f->setFlag(MediaFile::SCHEDULED_FOR_DELETION);
select_after_delete = i;
@@ -271,7 +308,15 @@ void PlayListModel::showDetails()
{
DecoderFactory *fact = Decoder::findByPath ( m_files.at ( i )->path() );
if ( fact )
- fact->showDetails ( 0, m_files.at ( i )->path() );
+ {
+ QObject* o = fact->showDetails ( 0, m_files.at ( i )->path() );
+ if(o)
+ {
+ TagUpdater *updater = new TagUpdater(o,m_files.at(i));
+ m_editing_files.append(m_files.at(i));
+ connect (updater, SIGNAL(destroyed (QObject * )),SIGNAL(listChanged()));
+ }
+ }
return;
}
@@ -846,3 +891,9 @@ void PlayListModel::preparePlayState()
+
+
+
+
+
+
diff --git a/src/playlistmodel.h b/src/playlistmodel.h
index 1a14bd723..40849b7e8 100644
--- a/src/playlistmodel.h
+++ b/src/playlistmodel.h
@@ -63,6 +63,22 @@ struct SimpleSelection
QList<int>m_selected_rows;
};
+/*!
+ * Helper class used for tags update after details dialog closing.
+ * @author Vladimir Kuznetsov <vovanec@gmail.com>
+ */
+class TagUpdater : public QObject
+{
+Q_OBJECT
+ QObject* m_observable;
+ MediaFile* m_file;
+public:
+ TagUpdater(QObject* o,MediaFile* f);
+protected slots:
+ void updateTag();
+};
+
+
class PlayListModel : public QObject
{
Q_OBJECT
@@ -288,7 +304,9 @@ private:
void removeSelection(bool inverted = false);
private:
+
QList <MediaFile*> m_files;
+ QList <MediaFile*> m_editing_files;
MediaFile* m_currentItem;
int m_current;