MuseScore/libmscore/noteevent.cpp

70 lines
1.9 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2010-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "noteevent.h"
#include "xml.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// read
//---------------------------------------------------------
2013-01-11 18:10:18 +01:00
void NoteEvent::read(XmlReader& e)
2012-05-26 14:26:10 +02:00
{
2013-01-11 18:10:18 +01:00
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
2012-05-26 14:26:10 +02:00
if (tag == "pitch")
2013-01-11 18:10:18 +01:00
_pitch = e.readInt();
2012-05-26 14:26:10 +02:00
else if (tag == "ontime")
2013-01-11 18:10:18 +01:00
_ontime = e.readInt();
2012-05-26 14:26:10 +02:00
else if (tag == "len")
2013-01-11 18:10:18 +01:00
_len = e.readInt();
2012-05-26 14:26:10 +02:00
else
2013-01-11 18:10:18 +01:00
e.unknown();
2012-05-26 14:26:10 +02:00
}
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
void NoteEvent::write(Xml& xml) const
{
xml.stag("Event");
xml.tag("pitch", _pitch);
xml.tag("ontime", _ontime);
xml.tag("len", _len);
xml.etag();
}
2012-11-19 10:08:15 +01:00
//---------------------------------------------------------
// NoteEventList
//---------------------------------------------------------
NoteEventList::NoteEventList()
: QList<NoteEvent>()
{
}
2012-11-20 20:51:18 +01:00
//---------------------------------------------------------
// operator==
//---------------------------------------------------------
bool NoteEvent::operator==(const NoteEvent& e) const
{
return (e._pitch == _pitch) && (e._ontime == _ontime) && (e._len == _len);
}
2012-11-19 10:08:15 +01:00
2013-05-13 18:49:17 +02:00
}