rewrote void loading

This commit is contained in:
itsmattkc
2019-02-16 14:02:26 -08:00
parent ba2331e40d
commit 3d0a65c70d
3 changed files with 22 additions and 21 deletions
+19 -19
View File
@@ -52,26 +52,26 @@ Effect *VoidEffect::copy(Clip *c) {
void VoidEffect::load(QXmlStreamReader &stream) {
QString tag = stream.name().toString();
qint64 start_index = stream.characterOffset();
qint64 end_index = start_index;
while (!stream.atEnd() && !(stream.name() == tag && stream.isEndElement())) {
end_index = stream.characterOffset();
stream.readNext();
}
qint64 passage_length = end_index - start_index;
if (passage_length > 0) {
// store xml data verbatim
QFile* device = static_cast<QFile*>(stream.device());
QFile passage_get(device->fileName());
if (passage_get.open(QFile::ReadOnly)) {
passage_get.seek(start_index);
bytes = passage_get.read(passage_length);
int passage_end = bytes.lastIndexOf('>')+1;
bytes.remove(passage_end, bytes.size()-passage_end);
passage_get.close();
}
}
QXmlStreamWriter writer(&bytes);
// copy XML from reader to writer
while (!stream.atEnd() && !(stream.name() == tag && stream.isEndElement())) {
stream.readNext();
if (stream.isStartElement()) {
writer.writeStartElement(stream.name().toString());
}
if (stream.isEndElement()) {
writer.writeEndElement();
}
if (stream.isCharacters()) {
writer.writeCharacters(stream.text().toString());
}
for (int i=0;i<stream.attributes().size();i++) {
writer.writeAttribute(stream.attributes().at(i));
}
}
}
void VoidEffect::save(QXmlStreamWriter &stream) {