File indexing completed on 2025-01-05 04:01:16
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "mime_serializer.hpp" 0008 0009 #include "app/log/log.hpp" 0010 0011 #include "model/object.hpp" 0012 #include "json_mime.hpp" 0013 #include "io/svg/svg_mime.hpp" 0014 #include "model/document.hpp" 0015 #include "model/assets/assets.hpp" 0016 0017 0018 glaxnimate::io::Autoreg<glaxnimate::io::mime::JsonMime> glaxnimate::io::mime::JsonMime::autoreg; 0019 glaxnimate::io::Autoreg<glaxnimate::io::svg::SvgMime> glaxnimate::io::svg::SvgMime::autoreg; 0020 0021 0022 glaxnimate::io::mime::DeserializedData glaxnimate::io::mime::MimeSerializer::from_mime_data(const QMimeData& data) const 0023 { 0024 if ( !can_deserialize() ) 0025 return {}; 0026 0027 for ( const QString& mime : mime_types() ) 0028 if ( data.hasFormat(mime) ) 0029 return deserialize(data.data(mime)); 0030 0031 return {}; 0032 } 0033 0034 void glaxnimate::io::mime::MimeSerializer::message(const QString& message, app::log::Severity severity) const 0035 { 0036 app::log::Log(slug()).log(message, severity); 0037 } 0038 0039 0040 glaxnimate::io::mime::DeserializedData glaxnimate::io::mime::MimeSerializer::deserialize(const QByteArray&) const 0041 { 0042 return {}; 0043 } 0044 0045 glaxnimate::io::mime::DeserializedData::DeserializedData() = default; 0046 glaxnimate::io::mime::DeserializedData::DeserializedData(DeserializedData &&) = default; 0047 glaxnimate::io::mime::DeserializedData & glaxnimate::io::mime::DeserializedData::operator=(DeserializedData &&) = default; 0048 glaxnimate::io::mime::DeserializedData::~DeserializedData() = default; 0049 0050 bool glaxnimate::io::mime::DeserializedData::empty() const 0051 { 0052 return !document || main->shapes.empty(); 0053 } 0054 0055 0056 void glaxnimate::io::mime::DeserializedData::initialize_data() 0057 { 0058 document = std::make_unique<model::Document>(""); 0059 main = document->assets()->compositions->values.insert(std::make_unique<model::Composition>(document.get())); 0060 }