Skip to content

Commit b2947ee

Browse files
committed
Update property mapper and property editor
1 parent f909951 commit b2947ee

27 files changed

Lines changed: 772 additions & 245 deletions

src/plugins/coreplugin/internal/CorePlugin.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ namespace Core::Internal {
385385
(CoreInterface::propertyEditorManager()->*addMethod)(component);
386386
};
387387
f("MetadataPropertyEditor", &PropertyEditorManager::addNoneComponent);
388-
f("GlobalCentShiftPropertyEditor", &PropertyEditorManager::addNoneComponent);
389388
f("MasterControlPropertyEditor", &PropertyEditorManager::addNoneComponent);
390389
f("LoopPropertyEditor", &PropertyEditorManager::addNoneComponent);
391390

@@ -397,6 +396,11 @@ namespace Core::Internal {
397396

398397
f("LabelPropertyEditor", &PropertyEditorManager::addLabelComponent);
399398

399+
f("NotePropertyEditor", &PropertyEditorManager::addNoteComponent);
400+
f("NoteLyricPropertyEditor", &PropertyEditorManager::addNoteComponent);
401+
f("NotePitchPropertyEditor", &PropertyEditorManager::addNoteComponent);
402+
f("NoteTimePropertyEditor", &PropertyEditorManager::addNoteComponent);
403+
400404
f("TempoPropertyEditor", &PropertyEditorManager::addTempoComponent);
401405

402406
f("TrackPropertyEditor", &PropertyEditorManager::addTrackComponent);

src/plugins/coreplugin/project/propertymapper/ClipPropertyMapper_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Core {
3333
PropertyMetadata<dspx::Clip, &dspx::Clip::name, &dspx::Clip::setName, decltype(&dspx::Clip::nameChanged)>,
3434
PropertyMetadata<dspx::Clip, &dspx::Clip::type, nullptr, nullptr_t>,
3535
PropertyMetadata<dspx::Clip,
36-
[](const dspx::Clip *clip) { return clip->clipSequence()->track(); },
36+
[](const dspx::Clip *clip) { return clip->clipSequence() ? clip->clipSequence()->track() : nullptr; },
3737
[](dspx::Clip *clip, dspx::Track *track) { if (track) clip->clipSequence()->moveToAnotherClipSequence(clip, track->clips()); },
3838
decltype(&dspx::Clip::clipSequenceChanged)
3939
>,
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#include "NotePropertyMapper.h"
2+
#include "NotePropertyMapper_p.h"
3+
4+
#include <dspxmodel/SelectionModel.h>
5+
6+
namespace Core {
7+
8+
NotePropertyMapper::NotePropertyMapper(QObject *parent)
9+
: QObject(parent), d_ptr(new NotePropertyMapperPrivate) {
10+
Q_D(NotePropertyMapper);
11+
d->q_ptr = this;
12+
}
13+
14+
NotePropertyMapper::~NotePropertyMapper() = default;
15+
16+
dspx::SelectionModel *NotePropertyMapper::selectionModel() const {
17+
Q_D(const NotePropertyMapper);
18+
return d->selectionModel;
19+
}
20+
21+
void NotePropertyMapper::setSelectionModel(dspx::SelectionModel *selectionModel) {
22+
Q_D(NotePropertyMapper);
23+
if (d->selectionModel == selectionModel) {
24+
return;
25+
}
26+
d->setSelectionModel(selectionModel);
27+
Q_EMIT selectionModelChanged();
28+
}
29+
30+
QVariant NotePropertyMapper::centShift() const {
31+
Q_D(const NotePropertyMapper);
32+
return d->value<NotePropertyMapperPrivate::CentShiftProperty>();
33+
}
34+
35+
void NotePropertyMapper::setCentShift(const QVariant &centShift) {
36+
Q_D(NotePropertyMapper);
37+
d->setValue<NotePropertyMapperPrivate::CentShiftProperty>(centShift);
38+
}
39+
40+
QVariant NotePropertyMapper::keyNum() const {
41+
Q_D(const NotePropertyMapper);
42+
return d->value<NotePropertyMapperPrivate::KeyNumProperty>();
43+
}
44+
45+
void NotePropertyMapper::setKeyNum(const QVariant &keyNum) {
46+
Q_D(NotePropertyMapper);
47+
d->setValue<NotePropertyMapperPrivate::KeyNumProperty>(keyNum);
48+
}
49+
50+
QVariant NotePropertyMapper::language() const {
51+
Q_D(const NotePropertyMapper);
52+
return d->value<NotePropertyMapperPrivate::LanguageProperty>();
53+
}
54+
55+
void NotePropertyMapper::setLanguage(const QVariant &language) {
56+
Q_D(NotePropertyMapper);
57+
d->setValue<NotePropertyMapperPrivate::LanguageProperty>(language);
58+
}
59+
60+
QVariant NotePropertyMapper::length() const {
61+
Q_D(const NotePropertyMapper);
62+
return d->value<NotePropertyMapperPrivate::LengthProperty>();
63+
}
64+
65+
void NotePropertyMapper::setLength(const QVariant &length) {
66+
Q_D(NotePropertyMapper);
67+
d->setValue<NotePropertyMapperPrivate::LengthProperty>(length);
68+
}
69+
70+
QVariant NotePropertyMapper::lyric() const {
71+
Q_D(const NotePropertyMapper);
72+
return d->value<NotePropertyMapperPrivate::LyricProperty>();
73+
}
74+
75+
void NotePropertyMapper::setLyric(const QVariant &lyric) {
76+
Q_D(NotePropertyMapper);
77+
d->setValue<NotePropertyMapperPrivate::LyricProperty>(lyric);
78+
}
79+
80+
QVariant NotePropertyMapper::pos() const {
81+
Q_D(const NotePropertyMapper);
82+
return d->value<NotePropertyMapperPrivate::PosProperty>();
83+
}
84+
85+
void NotePropertyMapper::setPos(const QVariant &pos) {
86+
Q_D(NotePropertyMapper);
87+
d->setValue<NotePropertyMapperPrivate::PosProperty>(pos);
88+
}
89+
90+
QVariant NotePropertyMapper::pronunciationOriginal() const {
91+
Q_D(const NotePropertyMapper);
92+
return d->value<NotePropertyMapperPrivate::PronunciationOriginalProperty>();
93+
}
94+
95+
void NotePropertyMapper::setPronunciationOriginal(const QVariant &pronunciationOriginal) {
96+
Q_D(NotePropertyMapper);
97+
d->setValue<NotePropertyMapperPrivate::PronunciationOriginalProperty>(pronunciationOriginal);
98+
}
99+
100+
QVariant NotePropertyMapper::pronunciationEdited() const {
101+
Q_D(const NotePropertyMapper);
102+
return d->value<NotePropertyMapperPrivate::PronunciationEditedProperty>();
103+
}
104+
105+
void NotePropertyMapper::setPronunciationEdited(const QVariant &pronunciationEdited) {
106+
Q_D(NotePropertyMapper);
107+
d->setValue<NotePropertyMapperPrivate::PronunciationEditedProperty>(pronunciationEdited);
108+
}
109+
110+
QVariant NotePropertyMapper::singingClip() const {
111+
Q_D(const NotePropertyMapper);
112+
return d->value<NotePropertyMapperPrivate::SingingClipProperty>();
113+
}
114+
115+
void NotePropertyMapperPrivate::setSelectionModel(dspx::SelectionModel *selectionModel_) {
116+
if (selectionModel == selectionModel_) {
117+
return;
118+
}
119+
detachSelectionModel();
120+
selectionModel = selectionModel_;
121+
attachSelectionModel();
122+
refreshCache();
123+
}
124+
125+
void NotePropertyMapperPrivate::attachSelectionModel() {
126+
Q_Q(NotePropertyMapper);
127+
if (!selectionModel) {
128+
return;
129+
}
130+
noteSelectionModel = selectionModel->noteSelectionModel();
131+
if (!noteSelectionModel) {
132+
return;
133+
}
134+
QObject::connect(noteSelectionModel, &dspx::NoteSelectionModel::itemSelected, q, [this](dspx::Note *note, bool selected) {
135+
handleItemSelected(note, selected);
136+
});
137+
const auto existing = noteSelectionModel->selectedItems();
138+
for (auto *note : existing) {
139+
addItem(note);
140+
}
141+
refreshCache();
142+
}
143+
144+
void NotePropertyMapperPrivate::detachSelectionModel() {
145+
if (noteSelectionModel) {
146+
QObject::disconnect(noteSelectionModel, nullptr, q_ptr, nullptr);
147+
}
148+
clear();
149+
noteSelectionModel = nullptr;
150+
selectionModel = nullptr;
151+
}
152+
}
153+
154+
#include "moc_NotePropertyMapper.cpp"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#ifndef DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_H
2+
#define DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_H
3+
4+
#include <QObject>
5+
#include <QVariant>
6+
#include <QScopedPointer>
7+
#include <qqmlintegration.h>
8+
9+
namespace dspx {
10+
class SelectionModel;
11+
}
12+
13+
namespace Core {
14+
class NotePropertyMapperPrivate;
15+
16+
class NotePropertyMapper : public QObject {
17+
Q_OBJECT
18+
QML_ELEMENT
19+
Q_DECLARE_PRIVATE(NotePropertyMapper)
20+
21+
Q_PROPERTY(dspx::SelectionModel *selectionModel READ selectionModel WRITE setSelectionModel NOTIFY selectionModelChanged)
22+
Q_PROPERTY(QVariant centShift READ centShift WRITE setCentShift NOTIFY centShiftChanged)
23+
Q_PROPERTY(QVariant keyNum READ keyNum WRITE setKeyNum NOTIFY keyNumChanged)
24+
Q_PROPERTY(QVariant language READ language WRITE setLanguage NOTIFY languageChanged)
25+
Q_PROPERTY(QVariant length READ length WRITE setLength NOTIFY lengthChanged)
26+
Q_PROPERTY(QVariant lyric READ lyric WRITE setLyric NOTIFY lyricChanged)
27+
Q_PROPERTY(QVariant pos READ pos WRITE setPos NOTIFY posChanged)
28+
Q_PROPERTY(QVariant pronunciationOriginal READ pronunciationOriginal WRITE setPronunciationOriginal NOTIFY pronunciationOriginalChanged)
29+
Q_PROPERTY(QVariant pronunciationEdited READ pronunciationEdited WRITE setPronunciationEdited NOTIFY pronunciationEditedChanged)
30+
Q_PROPERTY(QVariant singingClip READ singingClip NOTIFY singingClipChanged)
31+
32+
public:
33+
explicit NotePropertyMapper(QObject *parent = nullptr);
34+
~NotePropertyMapper() override;
35+
36+
dspx::SelectionModel *selectionModel() const;
37+
void setSelectionModel(dspx::SelectionModel *selectionModel);
38+
39+
QVariant centShift() const;
40+
void setCentShift(const QVariant &centShift);
41+
42+
QVariant keyNum() const;
43+
void setKeyNum(const QVariant &keyNum);
44+
45+
QVariant language() const;
46+
void setLanguage(const QVariant &language);
47+
48+
QVariant length() const;
49+
void setLength(const QVariant &length);
50+
51+
QVariant lyric() const;
52+
void setLyric(const QVariant &lyric);
53+
54+
QVariant pos() const;
55+
void setPos(const QVariant &pos);
56+
57+
QVariant pronunciationOriginal() const;
58+
void setPronunciationOriginal(const QVariant &pronunciationOriginal);
59+
60+
QVariant pronunciationEdited() const;
61+
void setPronunciationEdited(const QVariant &pronunciationEdited);
62+
63+
QVariant singingClip() const;
64+
65+
Q_SIGNALS:
66+
void selectionModelChanged();
67+
void centShiftChanged();
68+
void keyNumChanged();
69+
void languageChanged();
70+
void lengthChanged();
71+
void lyricChanged();
72+
void posChanged();
73+
void pronunciationOriginalChanged();
74+
void pronunciationEditedChanged();
75+
void singingClipChanged();
76+
77+
private:
78+
QScopedPointer<NotePropertyMapperPrivate> d_ptr;
79+
};
80+
}
81+
82+
#endif // DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_H
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#ifndef DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_P_H
2+
#define DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_P_H
3+
4+
#include "NotePropertyMapper.h"
5+
6+
#include <dspxmodel/Note.h>
7+
#include <dspxmodel/NoteSequence.h>
8+
#include <dspxmodel/Pronunciation.h>
9+
#include <dspxmodel/SingingClip.h>
10+
#include <dspxmodel/NoteSelectionModel.h>
11+
#include <dspxmodel/SelectionModel.h>
12+
13+
#include <CorePlugin/private/PropertyMapperData_p.h>
14+
15+
namespace Core {
16+
class NotePropertyMapperPrivate : public PropertyMapperData<
17+
NotePropertyMapper,
18+
NotePropertyMapperPrivate,
19+
dspx::Note,
20+
PropertyMetadata<dspx::Note, &dspx::Note::centShift, &dspx::Note::setCentShift, decltype(&dspx::Note::centShiftChanged)>,
21+
PropertyMetadata<dspx::Note, &dspx::Note::keyNum, &dspx::Note::setKeyNum, decltype(&dspx::Note::keyNumChanged)>,
22+
PropertyMetadata<dspx::Note, &dspx::Note::language, &dspx::Note::setLanguage, decltype(&dspx::Note::languageChanged)>,
23+
PropertyMetadata<dspx::Note, &dspx::Note::length, &dspx::Note::setLength, decltype(&dspx::Note::lengthChanged)>,
24+
PropertyMetadata<dspx::Note, &dspx::Note::lyric, &dspx::Note::setLyric, decltype(&dspx::Note::lyricChanged)>,
25+
PropertyMetadata<dspx::Note, &dspx::Note::pos, &dspx::Note::setPos, decltype(&dspx::Note::posChanged)>,
26+
PropertyMetadata<dspx::Note, &dspx::Pronunciation::original, &dspx::Pronunciation::setOriginal, decltype(&dspx::Pronunciation::originalChanged), &dspx::Note::pronunciation>,
27+
PropertyMetadata<dspx::Note, &dspx::Pronunciation::edited, &dspx::Pronunciation::setEdited, decltype(&dspx::Pronunciation::editedChanged), &dspx::Note::pronunciation>,
28+
PropertyMetadata<dspx::Note,
29+
[](const dspx::Note *note) { return note->noteSequence() ? note->noteSequence()->singingClip() : nullptr; },
30+
nullptr,
31+
decltype(&dspx::Note::noteSequenceChanged)
32+
>
33+
> {
34+
Q_DECLARE_PUBLIC(NotePropertyMapper)
35+
public:
36+
NotePropertyMapperPrivate() : PropertyMapperData(
37+
{&dspx::Note::centShiftChanged},
38+
{&dspx::Note::keyNumChanged},
39+
{&dspx::Note::languageChanged},
40+
{&dspx::Note::lengthChanged},
41+
{&dspx::Note::lyricChanged},
42+
{&dspx::Note::posChanged},
43+
{&dspx::Pronunciation::originalChanged},
44+
{&dspx::Pronunciation::editedChanged},
45+
{&dspx::Note::noteSequenceChanged}
46+
) {}
47+
48+
dspx::SelectionModel *selectionModel = nullptr;
49+
dspx::NoteSelectionModel *noteSelectionModel = nullptr;
50+
51+
void setSelectionModel(dspx::SelectionModel *selectionModel_);
52+
void attachSelectionModel();
53+
void detachSelectionModel();
54+
55+
enum {
56+
CentShiftProperty = 0,
57+
KeyNumProperty = 1,
58+
LanguageProperty = 2,
59+
LengthProperty = 3,
60+
LyricProperty = 4,
61+
PosProperty = 5,
62+
PronunciationOriginalProperty = 6,
63+
PronunciationEditedProperty = 7,
64+
SingingClipProperty = 8
65+
};
66+
67+
template<int i>
68+
void notifyValueChange() {
69+
Q_Q(NotePropertyMapper);
70+
if constexpr (i == CentShiftProperty) {
71+
q->centShiftChanged();
72+
} else if constexpr (i == KeyNumProperty) {
73+
q->keyNumChanged();
74+
} else if constexpr (i == LanguageProperty) {
75+
q->languageChanged();
76+
} else if constexpr (i == LengthProperty) {
77+
q->lengthChanged();
78+
} else if constexpr (i == LyricProperty) {
79+
q->lyricChanged();
80+
} else if constexpr (i == PosProperty) {
81+
q->posChanged();
82+
} else if constexpr (i == PronunciationOriginalProperty) {
83+
q->pronunciationOriginalChanged();
84+
} else if constexpr (i == PronunciationEditedProperty) {
85+
q->pronunciationEditedChanged();
86+
} else if constexpr (i == SingingClipProperty) {
87+
q->singingClipChanged();
88+
}
89+
}
90+
};
91+
}
92+
93+
#endif // DIFFSCOPE_COREPLUGIN_NOTEPROPERTYMAPPER_P_H

0 commit comments

Comments
 (0)