Skip to content

Commit

Permalink
fix #15011
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 17, 2013
1 parent 7e8e83b commit f223bec
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 73 deletions.
1 change: 1 addition & 0 deletions all.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include <QAtomicInt>
#include <QStaticText>
#include <QErrorMessage>

#include <QPainterPath>
#include <QBitmap>
Expand Down
71 changes: 0 additions & 71 deletions libmscore/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,77 +66,6 @@

namespace Ms {

//---------------------------------------------------------
// cmdPaste
//---------------------------------------------------------

void Score::cmdPaste(MuseScoreView* view)
{
const QMimeData* ms = QApplication::clipboard()->mimeData();
if (ms == 0) {
qDebug("no application mime data");
return;
}
if (selection().isSingle() && ms->hasFormat(mimeSymbolFormat)) {
QByteArray data(ms->data(mimeSymbolFormat));
XmlReader e(data);
QPointF dragOffset;
Fraction duration(1, 4);
Element::ElementType type = Element::readType(e, &dragOffset, &duration);
if (type != Element::INVALID) {
Element* el = Element::create(type, this);
if (el) {
el->read(e);
addRefresh(selection().element()->abbox()); // layout() ?!
DropData ddata;
ddata.view = view;
ddata.element = el;
ddata.duration = duration;
selection().element()->drop(ddata);
if (selection().element())
addRefresh(selection().element()->abbox());
}
}
else
qDebug("cannot read type");
}
else if ((selection().state() == SEL_RANGE || selection().state() == SEL_LIST)
&& ms->hasFormat(mimeStaffListFormat)) {
ChordRest* cr = 0;
if (selection().state() == SEL_RANGE) {
cr = selection().firstChordRest();
}
else if (selection().isSingle()) {
Element* e = selection().element();
if (e->type() != Element::NOTE && e->type() != Element::REST) {
qDebug("cannot paste to %s", e->name());
return;
}
if (e->type() == Element::NOTE)
e = static_cast<Note*>(e)->chord();
cr = static_cast<ChordRest*>(e);
}
if (cr == 0) {
qDebug("no destination for paste");
return;
}

QByteArray data(ms->data(mimeStaffListFormat));
qDebug("paste <%s>", data.data());
XmlReader e(data);
pasteStaff(e, cr);
}
else if (ms->hasFormat(mimeSymbolListFormat) && selection().isSingle()) {
qDebug("cannot paste symbol list to element");
}
else {
qDebug("cannot paste selState %d staffList %d",
selection().state(), ms->hasFormat(mimeStaffListFormat));
foreach(const QString& s, ms->formats())
qDebug(" format %s", qPrintable(s));
}
}

//---------------------------------------------------------
// pasteStaff
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ class Score : public QObject {
int addCustomKeySig(KeySig*);
KeySig* customKeySig(int) const;
KeySig* keySigFactory(const KeySigEvent&);
void cmdPaste(MuseScoreView*);
Element* selectMove(const QString& cmd);
Element* move(const QString& cmd);
void cmdEnterRest(const TDuration& d);
Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ QString localeName;
bool useFactorySettings = false;
QString styleName;
QString revision;
QErrorMessage* errorMessage;

extern void initStaffTypes();
extern bool savePositions(Score*, const QString& name);
Expand Down Expand Up @@ -4822,6 +4823,7 @@ int main(int argc, char* av[])
if (!mscore->restoreSession((preferences.sessionStart == LAST_SESSION) && (files == 0)) || files)
loadScores(argv);
}
errorMessage = new QErrorMessage(mscore);
mscore->loadPlugins();
mscore->writeSessionFile(false);

Expand Down
67 changes: 66 additions & 1 deletion mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

namespace Ms {

extern QErrorMessage* errorMessage;

#if 0
// a useful enum for scale steps (could be moved to libmscore/pitchspelling.h)
enum {
Expand Down Expand Up @@ -2289,7 +2291,70 @@ void ScoreView::editPaste()
void ScoreView::normalPaste()
{
_score->startCmd();
_score->cmdPaste(this);

const QMimeData* ms = QApplication::clipboard()->mimeData();
if (ms == 0) {
qDebug("no application mime data");
return;
}
if (_score->selection().isSingle() && ms->hasFormat(mimeSymbolFormat)) {
QByteArray data(ms->data(mimeSymbolFormat));
XmlReader e(data);
QPointF dragOffset;
Fraction duration(1, 4);
Element::ElementType type = Element::readType(e, &dragOffset, &duration);
if (type != Element::INVALID) {
Element* el = Element::create(type, _score);
if (el) {
el->read(e);
_score->addRefresh(_score->selection().element()->abbox()); // layout() ?!
DropData ddata;
ddata.view = this;
ddata.element = el;
ddata.duration = duration;
_score->selection().element()->drop(ddata);
if (_score->selection().element())
_score->addRefresh(_score->selection().element()->abbox());
}
}
else
qDebug("cannot read type");
}
else if ((_score->selection().state() == SEL_RANGE || _score->selection().state() == SEL_LIST)
&& ms->hasFormat(mimeStaffListFormat)) {
ChordRest* cr = 0;
if (_score->selection().state() == SEL_RANGE)
cr = _score->selection().firstChordRest();
else if (_score->selection().isSingle()) {
Element* e = _score->selection().element();
if (e->type() != Element::NOTE && e->type() != Element::REST) {
qDebug("cannot paste to %s", e->name());
return;
}
if (e->type() == Element::NOTE)
e = static_cast<Note*>(e)->chord();
cr = static_cast<ChordRest*>(e);
}
if (cr == 0)
errorMessage->showMessage(tr("no destination to paste"), "pasteDestination");
else if (cr->tuplet())
errorMessage->showMessage(tr("cannot paste into tuplet"), "pasteTuplet");
else {
QByteArray data(ms->data(mimeStaffListFormat));
qDebug("paste <%s>", data.data());
XmlReader e(data);
_score->pasteStaff(e, cr);
}
}
else if (ms->hasFormat(mimeSymbolListFormat) && _score->selection().isSingle())
errorMessage->showMessage(tr("cannot paste symbol list to element"), "pasteSymbollist");
else {
qDebug("cannot paste selState %d staffList %d",
_score->selection().state(), ms->hasFormat(mimeStaffListFormat));
foreach(const QString& s, ms->formats())
qDebug(" format %s", qPrintable(s));
}

_score->endCmd();
mscore->endCmd();
}
Expand Down

0 comments on commit f223bec

Please sign in to comment.