Revision 48:5f23d5b29aaf

View differences:

common/ComposerFileIndex.cpp
173 173
        std::cerr << "Caught exception: \"" << e.what() << "\" while indexing "
174 174
                  << Uri(fileUrl) << ", skipping" << std::endl;
175 175
    }
176

  
176
    
177
    tx->commit();
177 178
    delete tx;
178 179
}
179 180

  
common/FeatureFileIndex.cpp
261 261
                  << Uri(fileUrl) << ", skipping" << std::endl;
262 262
    }
263 263

  
264
    tx->commit();
264 265
    delete tx;
265 266
}
266 267

  
common/Objects.cpp
858 858
              << ", uri = " << m_uri.toString().toStdString() << std::endl;
859 859
}
860 860

  
861
AudioFile::~AudioFile()
862
{
863
    foreach (AudioFileTag *t, m_tags) delete t;
864
}
865

  
866
void
867
AudioFile::setTags(QSet<AudioFileTag *> tt)
868
{
869
    foreach (AudioFileTag *t, m_tags) {
870
        if (!tt.contains(t)) delete t;
871
    }
872
    m_tags = tt;
873
}
874

  
875
void
876
AudioFile::addTag(AudioFileTag *t)
877
{
878
    m_tags.insert(t);
879
}
861 880

  
862 881
}
863 882

  
common/Objects.h
580 580
    static QMutex m_mutex;
581 581
};
582 582

  
583
// Separate AudioFile and Signal, to correspond with 
583
class AudioFileTag : public QObject
584
{
585
    Q_OBJECT
586

  
587
    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged STORED true)
588
    Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged STORED true)
589

  
590
public:
591
    AudioFileTag(QObject *parent = 0) : QObject(parent) { }
592
    AudioFileTag(QString name, QString value, QObject *parent = 0) :
593
        QObject(parent), m_name(name), m_value(value) { }
594

  
595
    QString name() const { return m_name; }
596
    void setName(QString n) { m_name = n; emit nameChanged(m_name); }
597

  
598
    QString value() const { return m_value; }
599
    void setValue(QString v) { m_value = v; emit valueChanged(m_value); }
600
    
601
signals:
602
    void nameChanged(QString);
603
    void valueChanged(QString);
604

  
605
private:
606
    QString m_name;
607
    QString m_value;
608
};
609
    
610
// Separate AudioFile and Signal, to correspond with MO
584 611

  
585 612
class AudioFile : public QObject
586 613
{
......
588 615

  
589 616
    Q_PROPERTY(QString hash READ hash WRITE setHash NOTIFY hashChanged STORED true)
590 617
    Q_PROPERTY(Dataquay::Uri uri READ uri WRITE setUri NOTIFY uriChanged STORED true)
618
    Q_PROPERTY(QSet<ClassicalData::AudioFileTag *> tags READ tags WRITE setTags NOTIFY tagsChanged STORED true)
591 619

  
592 620
public:
593 621
    AudioFile(QObject *parent = 0);
594 622
    AudioFile(FileSource file, QObject *parent = 0);
623
    ~AudioFile();
595 624

  
596 625
    /// The URI is set automatically from the FileSource at construction
597 626
    Dataquay::Uri uri() const { return m_uri; }
......
601 630
    QString hash() const { return m_hash; }
602 631
    void setHash(QString hash) { m_hash = hash; emit hashChanged(hash); }
603 632

  
633
    /// I take ownership of all tags
634
    QSet<AudioFileTag *> tags() { return m_tags; }
635
    void setTags(QSet<AudioFileTag *> t);
636
    void addTag(AudioFileTag *t);
637

  
604 638
signals:
605 639
    void uriChanged(Dataquay::Uri);
606 640
    void hashChanged(QString);
641
    void tagsChanged(QSet<AudioFileTag *>);
607 642

  
608 643
private:
609 644
    Dataquay::Uri m_uri;
610 645
    QString m_hash;
646
    QSet<AudioFileTag *> m_tags;
611 647
};
612 648

  
613 649
class Signal : public QObject
......
670 706
Q_DECLARE_METATYPE(ClassicalData::Work*);
671 707
Q_DECLARE_METATYPE(ClassicalData::Movement*);
672 708
Q_DECLARE_METATYPE(ClassicalData::Document*);
709
Q_DECLARE_METATYPE(ClassicalData::AudioFileTag*);
673 710
Q_DECLARE_METATYPE(ClassicalData::AudioFile*);
674 711
Q_DECLARE_METATYPE(ClassicalData::Signal*);
675 712
Q_DECLARE_METATYPE(QSet<QString>);
......
677 714
Q_DECLARE_METATYPE(QSet<ClassicalData::Work*>);
678 715
Q_DECLARE_METATYPE(QSet<ClassicalData::Movement*>);
679 716
Q_DECLARE_METATYPE(QSet<ClassicalData::Document*>);
717
Q_DECLARE_METATYPE(QSet<ClassicalData::AudioFileTag*>);
680 718
Q_DECLARE_METATYPE(QSet<ClassicalData::AudioFile*>);
681 719
Q_DECLARE_METATYPE(QSet<ClassicalData::Signal*>);
682 720
Q_DECLARE_METATYPE(ClassicalData::Composer*);
common/TypeRegistrar.cpp
47 47
	("QSet<QString>");
48 48
    qRegisterMetaType<QSet<Dataquay::Uri> >
49 49
	("QSet<Dataquay::Uri>");
50
    qRegisterMetaType<AudioFileTag *>
51
	("ClassicalData::AudioFileTag*");
52
    qRegisterMetaType<QSet<AudioFileTag *> >
53
	("QSet<ClassicalData::AudioFileTag*>");
50 54
    qRegisterMetaType<AudioFile *>
51 55
	("ClassicalData::AudioFile*");
52 56
    qRegisterMetaType<QSet<AudioFile *> >
......
76 80
    ObjectBuilder::getInstance()->registerClass
77 81
	<Form, QObject>("ClassicalData::Form*");
78 82
    ObjectBuilder::getInstance()->registerClass
83
	<AudioFileTag>("ClassicalData::AudioFileTag*");
84
    ObjectBuilder::getInstance()->registerClass
79 85
	<AudioFile>("ClassicalData::AudioFile*");
80 86

  
81 87
    ContainerBuilder::getInstance()->registerContainer
......
107 113
	 ContainerBuilder::SetKind);
108 114

  
109 115
    ContainerBuilder::getInstance()->registerContainer
116
	<AudioFileTag*, QSet<AudioFileTag*> >
117
	("ClassicalData::AudioFileTag*", "QSet<ClassicalData::AudioFileTag*>",
118
	 ContainerBuilder::SetKind);
119

  
120
    ContainerBuilder::getInstance()->registerContainer
110 121
	<AudioFile*, QSet<AudioFile*> >
111 122
	("ClassicalData::AudioFile*", "QSet<ClassicalData::AudioFile*>",
112 123
	 ContainerBuilder::SetKind);
......
193 204
	mapping->addPropertyMapping("ClassicalData::Composition", "composer", store->expand("mo:composer"));
194 205
	mapping->addPropertyMapping("ClassicalData::Composition", "works", store->expand("mo:produced_work"));
195 206

  
207
	mapping->addTypeMapping("ClassicalData::AudioFileTag", store->expand("classical:AudioFileTag"));
208

  
196 209
	mapping->addTypeMapping("ClassicalData::AudioFile", store->expand("mo:AudioFile"));
197 210
	mapping->addPropertyMapping("ClassicalData::AudioFile", "hash", store->expand("foaf:sha1"));
198 211

  
testapp/testapp.pro
14 14

  
15 15
PRE_TARGETDEPS += ../common/libcommon.a
16 16

  
17
LIBS += ../common/libcommon.a -L../../svcore -lsvcore ../../../turbot/dataquay/libdataquay.a ../../../turbot/ext/libext.a
17
LIBS += ../common/libcommon.a -L../../svcore -lsvcore ../../../dataquay/libdataquay.a 
18 18

  
utilities/composer/composer.pro
13 13
DEPENDPATH += ../../../svcore
14 14
INCLUDEPATH += ../../../svcore
15 15

  
16
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a
16
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a
17 17

  
utilities/the-application/the-application.pro
10 10

  
11 11
INCLUDEPATH += ../../common ../../../svcore
12 12

  
13
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a
13
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a
14 14

  
utilities/track/track.cpp
463 463
//    cerr << "Creating Signal...";
464 464
    FileSource fs(track);
465 465
    Signal *tf = new Signal;
466
    tf->addAvailableAs(new AudioFile(fs));
466
    AudioFile *af = new AudioFile(fs);
467
    tf->addAvailableAs(af);
467 468
//    cerr << "done" << endl;
468 469
//    cerr << "hash = " << tf->hash() << endl;
469 470

  
......
472 473
    //!!! bad api!:
473 474
    getTrackData(fs, fingerprint, puid, title, maker, tags);
474 475

  
476
    for (AudioFileReader::TagMap::const_iterator i = tags.begin();
477
         i != tags.end(); ++i) {
478
        if (i->second != "") {
479
            af->addTag(new AudioFileTag(i->first, i->second));
480
        }
481
    }
482

  
475 483
    cout << "fingerprint: " << fingerprint.toStdString() << ", puid: "
476 484
         << puid.toStdString() << endl;
477 485

  
utilities/track/track.pro
10 10

  
11 11
INCLUDEPATH += ../../common ../../../svcore
12 12

  
13
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a
13
LIBS += ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a 
14 14

  
utilities/widgettest/widgettest.pro
10 10
DEPENDPATH += ../../../svcore
11 11
INCLUDEPATH += ../../../svcore
12 12

  
13
LIBS += ../../widgets/libwidgets.a ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../turbot/dataquay/libdataquay.a ../../../../turbot/ext/libext.a
13
LIBS += ../../widgets/libwidgets.a ../../common/libcommon.a -L../../../svcore -lsvcore ../../../../dataquay/libdataquay.a
14 14

  
15 15
HEADERS += widgettest.h
16 16
SOURCES += widgettest.cpp

Also available in: Unified diff