# HG changeset patch # User Chris Cannam # Date 1275496187 -3600 # Node ID 5f23d5b29aafe1e71e2aec57bb0c197ce14bded2 # Parent 273bd328b215bcfe662bc55c1ab5fb48deab383d * Add original tags to AudioFile diff -r 273bd328b215 -r 5f23d5b29aaf common/ComposerFileIndex.cpp --- a/common/ComposerFileIndex.cpp Fri May 28 16:22:37 2010 +0100 +++ b/common/ComposerFileIndex.cpp Wed Jun 02 17:29:47 2010 +0100 @@ -173,7 +173,8 @@ std::cerr << "Caught exception: \"" << e.what() << "\" while indexing " << Uri(fileUrl) << ", skipping" << std::endl; } - + + tx->commit(); delete tx; } diff -r 273bd328b215 -r 5f23d5b29aaf common/FeatureFileIndex.cpp --- a/common/FeatureFileIndex.cpp Fri May 28 16:22:37 2010 +0100 +++ b/common/FeatureFileIndex.cpp Wed Jun 02 17:29:47 2010 +0100 @@ -261,6 +261,7 @@ << Uri(fileUrl) << ", skipping" << std::endl; } + tx->commit(); delete tx; } diff -r 273bd328b215 -r 5f23d5b29aaf common/Objects.cpp --- a/common/Objects.cpp Fri May 28 16:22:37 2010 +0100 +++ b/common/Objects.cpp Wed Jun 02 17:29:47 2010 +0100 @@ -858,6 +858,25 @@ << ", uri = " << m_uri.toString().toStdString() << std::endl; } +AudioFile::~AudioFile() +{ + foreach (AudioFileTag *t, m_tags) delete t; +} + +void +AudioFile::setTags(QSet tt) +{ + foreach (AudioFileTag *t, m_tags) { + if (!tt.contains(t)) delete t; + } + m_tags = tt; +} + +void +AudioFile::addTag(AudioFileTag *t) +{ + m_tags.insert(t); +} } diff -r 273bd328b215 -r 5f23d5b29aaf common/Objects.h --- a/common/Objects.h Fri May 28 16:22:37 2010 +0100 +++ b/common/Objects.h Wed Jun 02 17:29:47 2010 +0100 @@ -580,7 +580,34 @@ static QMutex m_mutex; }; -// Separate AudioFile and Signal, to correspond with +class AudioFileTag : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged STORED true) + Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged STORED true) + +public: + AudioFileTag(QObject *parent = 0) : QObject(parent) { } + AudioFileTag(QString name, QString value, QObject *parent = 0) : + QObject(parent), m_name(name), m_value(value) { } + + QString name() const { return m_name; } + void setName(QString n) { m_name = n; emit nameChanged(m_name); } + + QString value() const { return m_value; } + void setValue(QString v) { m_value = v; emit valueChanged(m_value); } + +signals: + void nameChanged(QString); + void valueChanged(QString); + +private: + QString m_name; + QString m_value; +}; + +// Separate AudioFile and Signal, to correspond with MO class AudioFile : public QObject { @@ -588,10 +615,12 @@ Q_PROPERTY(QString hash READ hash WRITE setHash NOTIFY hashChanged STORED true) Q_PROPERTY(Dataquay::Uri uri READ uri WRITE setUri NOTIFY uriChanged STORED true) + Q_PROPERTY(QSet tags READ tags WRITE setTags NOTIFY tagsChanged STORED true) public: AudioFile(QObject *parent = 0); AudioFile(FileSource file, QObject *parent = 0); + ~AudioFile(); /// The URI is set automatically from the FileSource at construction Dataquay::Uri uri() const { return m_uri; } @@ -601,13 +630,20 @@ QString hash() const { return m_hash; } void setHash(QString hash) { m_hash = hash; emit hashChanged(hash); } + /// I take ownership of all tags + QSet tags() { return m_tags; } + void setTags(QSet t); + void addTag(AudioFileTag *t); + signals: void uriChanged(Dataquay::Uri); void hashChanged(QString); + void tagsChanged(QSet); private: Dataquay::Uri m_uri; QString m_hash; + QSet m_tags; }; class Signal : public QObject @@ -670,6 +706,7 @@ Q_DECLARE_METATYPE(ClassicalData::Work*); Q_DECLARE_METATYPE(ClassicalData::Movement*); Q_DECLARE_METATYPE(ClassicalData::Document*); +Q_DECLARE_METATYPE(ClassicalData::AudioFileTag*); Q_DECLARE_METATYPE(ClassicalData::AudioFile*); Q_DECLARE_METATYPE(ClassicalData::Signal*); Q_DECLARE_METATYPE(QSet); @@ -677,6 +714,7 @@ Q_DECLARE_METATYPE(QSet); Q_DECLARE_METATYPE(QSet); Q_DECLARE_METATYPE(QSet); +Q_DECLARE_METATYPE(QSet); Q_DECLARE_METATYPE(QSet); Q_DECLARE_METATYPE(QSet); Q_DECLARE_METATYPE(ClassicalData::Composer*); diff -r 273bd328b215 -r 5f23d5b29aaf common/TypeRegistrar.cpp --- a/common/TypeRegistrar.cpp Fri May 28 16:22:37 2010 +0100 +++ b/common/TypeRegistrar.cpp Wed Jun 02 17:29:47 2010 +0100 @@ -47,6 +47,10 @@ ("QSet"); qRegisterMetaType > ("QSet"); + qRegisterMetaType + ("ClassicalData::AudioFileTag*"); + qRegisterMetaType > + ("QSet"); qRegisterMetaType ("ClassicalData::AudioFile*"); qRegisterMetaType > @@ -76,6 +80,8 @@ ObjectBuilder::getInstance()->registerClass ("ClassicalData::Form*"); ObjectBuilder::getInstance()->registerClass + ("ClassicalData::AudioFileTag*"); + ObjectBuilder::getInstance()->registerClass ("ClassicalData::AudioFile*"); ContainerBuilder::getInstance()->registerContainer @@ -107,6 +113,11 @@ ContainerBuilder::SetKind); ContainerBuilder::getInstance()->registerContainer + > + ("ClassicalData::AudioFileTag*", "QSet", + ContainerBuilder::SetKind); + + ContainerBuilder::getInstance()->registerContainer > ("ClassicalData::AudioFile*", "QSet", ContainerBuilder::SetKind); @@ -193,6 +204,8 @@ mapping->addPropertyMapping("ClassicalData::Composition", "composer", store->expand("mo:composer")); mapping->addPropertyMapping("ClassicalData::Composition", "works", store->expand("mo:produced_work")); + mapping->addTypeMapping("ClassicalData::AudioFileTag", store->expand("classical:AudioFileTag")); + mapping->addTypeMapping("ClassicalData::AudioFile", store->expand("mo:AudioFile")); mapping->addPropertyMapping("ClassicalData::AudioFile", "hash", store->expand("foaf:sha1")); diff -r 273bd328b215 -r 5f23d5b29aaf testapp/testapp.pro --- a/testapp/testapp.pro Fri May 28 16:22:37 2010 +0100 +++ b/testapp/testapp.pro Wed Jun 02 17:29:47 2010 +0100 @@ -14,5 +14,5 @@ PRE_TARGETDEPS += ../common/libcommon.a -LIBS += ../common/libcommon.a -L../../svcore -lsvcore ../../../turbot/dataquay/libdataquay.a ../../../turbot/ext/libext.a +LIBS += ../common/libcommon.a -L../../svcore -lsvcore ../../../dataquay/libdataquay.a diff -r 273bd328b215 -r 5f23d5b29aaf utilities/composer/composer.pro --- a/utilities/composer/composer.pro Fri May 28 16:22:37 2010 +0100 +++ b/utilities/composer/composer.pro Wed Jun 02 17:29:47 2010 +0100 @@ -13,5 +13,5 @@ DEPENDPATH += ../../../svcore INCLUDEPATH += ../../../svcore -LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a +LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a diff -r 273bd328b215 -r 5f23d5b29aaf utilities/the-application/the-application.pro --- a/utilities/the-application/the-application.pro Fri May 28 16:22:37 2010 +0100 +++ b/utilities/the-application/the-application.pro Wed Jun 02 17:29:47 2010 +0100 @@ -10,5 +10,5 @@ INCLUDEPATH += ../../common ../../../svcore -LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a +LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a diff -r 273bd328b215 -r 5f23d5b29aaf utilities/track/track.cpp --- a/utilities/track/track.cpp Fri May 28 16:22:37 2010 +0100 +++ b/utilities/track/track.cpp Wed Jun 02 17:29:47 2010 +0100 @@ -463,7 +463,8 @@ // cerr << "Creating Signal..."; FileSource fs(track); Signal *tf = new Signal; - tf->addAvailableAs(new AudioFile(fs)); + AudioFile *af = new AudioFile(fs); + tf->addAvailableAs(af); // cerr << "done" << endl; // cerr << "hash = " << tf->hash() << endl; @@ -472,6 +473,13 @@ //!!! bad api!: getTrackData(fs, fingerprint, puid, title, maker, tags); + for (AudioFileReader::TagMap::const_iterator i = tags.begin(); + i != tags.end(); ++i) { + if (i->second != "") { + af->addTag(new AudioFileTag(i->first, i->second)); + } + } + cout << "fingerprint: " << fingerprint.toStdString() << ", puid: " << puid.toStdString() << endl; diff -r 273bd328b215 -r 5f23d5b29aaf utilities/track/track.pro --- a/utilities/track/track.pro Fri May 28 16:22:37 2010 +0100 +++ b/utilities/track/track.pro Wed Jun 02 17:29:47 2010 +0100 @@ -10,5 +10,5 @@ INCLUDEPATH += ../../common ../../../svcore -LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a +LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a diff -r 273bd328b215 -r 5f23d5b29aaf utilities/widgettest/widgettest.pro --- a/utilities/widgettest/widgettest.pro Fri May 28 16:22:37 2010 +0100 +++ b/utilities/widgettest/widgettest.pro Wed Jun 02 17:29:47 2010 +0100 @@ -10,7 +10,7 @@ DEPENDPATH += ../../../svcore INCLUDEPATH += ../../../svcore -LIBS += ../../widgets/libwidgets.a ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a +LIBS += ../../widgets/libwidgets.a ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a HEADERS += widgettest.h SOURCES += widgettest.cpp