Skip to content

Commit

Permalink
fix #33896
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 23, 2014
1 parent d5b29fd commit 5382ede
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 28 deletions.
14 changes: 0 additions & 14 deletions libmscore/score.cpp
Expand Up @@ -1916,20 +1916,6 @@ TimeSigMap* Score::sigmap() const
return rootScore()->_sigmap;
}

//---------------------------------------------------------
// metaTags
//---------------------------------------------------------

const QMap<QString, QString>& Score::metaTags() const
{
return _metaTags;
}

QMap<QString, QString>& Score::metaTags()
{
return _metaTags;
}

//---------------------------------------------------------
// metaTag
//---------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions libmscore/score.h
Expand Up @@ -891,8 +891,10 @@ class Score : public QObject {
QByteArray readToBuffer();
void writeSegments(Xml& xml, int strack, int etrack, Segment* first, Segment* last, bool, bool, bool);

const QMap<QString, QString>& metaTags() const;
QMap<QString, QString>& metaTags();
const QMap<QString, QString>& metaTags() const { return _metaTags; }
QMap<QString, QString>& metaTags() { return _metaTags; }
void setMetaTags(const QMap<QString,QString>& t) { _metaTags = t; }

Q_INVOKABLE QString metaTag(const QString& s) const;
Q_INVOKABLE void setMetaTag(const QString& tag, const QString& val);

Expand Down
11 changes: 11 additions & 0 deletions libmscore/undo.cpp
Expand Up @@ -3853,4 +3853,15 @@ void ChangeLayoutMode::flip()
score->setLayoutAll(true);
}

//---------------------------------------------------------
// ChangeMetaTags::flip
//---------------------------------------------------------

void ChangeMetaTags::flip()
{
QMap<QString,QString> t = score->metaTags();
score->setMetaTags(metaTags);
metaTags = t;
}

}
15 changes: 15 additions & 0 deletions libmscore/undo.h
Expand Up @@ -1442,6 +1442,21 @@ class ChangeLayoutMode : public UndoCommand {
UNDO_NAME("ChangeLayoutMode")
};

//---------------------------------------------------------
// ChangeMetaTags
//---------------------------------------------------------

class ChangeMetaTags : public UndoCommand {
Score* score;
QMap<QString,QString> metaTags;

void flip();

public:
ChangeMetaTags(Score* s, const QMap<QString,QString>& m) : score(s), metaTags(m) {}
UNDO_NAME("ChangeMetaTags")
};


} // namespace Ms
#endif
Expand Down
26 changes: 14 additions & 12 deletions mscore/metaedit.cpp
Expand Up @@ -34,6 +34,7 @@ MetaEditDialog::MetaEditDialog(Score* s, QWidget* parent)
setupUi(this);
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
score = s;
dirty = false;

level->setValue(score->mscVersion());
version->setText(score->mscoreVersion());
Expand All @@ -43,10 +44,10 @@ MetaEditDialog::MetaEditDialog(Score* s, QWidget* parent)
QMapIterator<QString, QString> i(s->metaTags());
while (i.hasNext()) {
i.next();
// xml.tag(QString("metaTag name=\"%1\"").arg(i.key()), i.value());
QLabel* label = new QLabel;
label->setText(i.key());
QLineEdit* text = new QLineEdit(i.value(), 0);
connect(text, SIGNAL(textChanged(const QString&)), SLOT(setDirty()));
grid->addWidget(label, idx, 0);
grid->addWidget(text, idx, 1);
++idx;
Expand All @@ -72,6 +73,7 @@ void MetaEditDialog::newClicked()
grid->addWidget(label, idx, 0);
grid->addWidget(text, idx, 1);
}
dirty = true;
}

//---------------------------------------------------------
Expand All @@ -80,17 +82,17 @@ void MetaEditDialog::newClicked()

void MetaEditDialog::accept()
{
int idx = grid->rowCount();

QMap<QString, QString>& m(score->metaTags());
m.clear();

for (int i = 0; i < idx; ++i) {
QLayoutItem* labelItem = grid->itemAtPosition(i, 0);
QLayoutItem* dataItem = grid->itemAtPosition(i, 1);
QLabel* label = static_cast<QLabel*>(labelItem->widget());
QLineEdit* le = static_cast<QLineEdit*>(dataItem->widget());
m.insert(label->text(), le->text());
if (dirty) {
int idx = grid->rowCount();
QMap<QString, QString> m;
for (int i = 0; i < idx; ++i) {
QLayoutItem* labelItem = grid->itemAtPosition(i, 0);
QLayoutItem* dataItem = grid->itemAtPosition(i, 1);
QLabel* label = static_cast<QLabel*>(labelItem->widget());
QLineEdit* le = static_cast<QLineEdit*>(dataItem->widget());
m.insert(label->text(), le->text());
}
score->undo(new ChangeMetaTags(score, m));
}
QDialog::accept();
}
Expand Down
3 changes: 3 additions & 0 deletions mscore/metaedit.h
Expand Up @@ -36,8 +36,11 @@ class MetaEditDialog : public QDialog, public Ui::MetaEditDialog {

Score* score;

bool dirty;

private slots:
void newClicked();
void setDirty() { dirty = true; }

public slots:
virtual void accept();
Expand Down

0 comments on commit 5382ede

Please sign in to comment.