diff --git a/plugins/impex/sai/kis_sai_converter.cpp b/plugins/impex/sai/kis_sai_converter.cpp index 7d4c4e6a46..2652e47ffa 100644 --- a/plugins/impex/sai/kis_sai_converter.cpp +++ b/plugins/impex/sai/kis_sai_converter.cpp @@ -1,63 +1,101 @@ /* * Copyright (c) 2019 Wolthera van Hövell tot Westerflier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "sai.hpp" #include #include #include #include #include #include #include #include #include "kis_sai_converter.h" +class SaiLayerVisitor : public sai::VirtualFileVisitor +{ +public: + SaiLayerVisitor(KisImageSP image) + : m_image(image) + , FolderDepth(0) + { + } + ~SaiLayerVisitor() override + { + } + bool VisitFolderBegin(sai::VirtualFileEntry& Entry) override + { + qDebug() << "begin folder" + << Entry.GetSize() << Entry.GetTimeStamp() << Entry.GetName(); + ++FolderDepth; + return true; + } + bool VisitFolderEnd(sai::VirtualFileEntry& /*Entry*/) override + { + qDebug() << "end folder"; + --FolderDepth; + return true; + } + bool VisitFile(sai::VirtualFileEntry& Entry) override + { + qDebug() << Entry.GetSize() << Entry.GetTimeStamp() << Entry.GetName(); + return true; + } +private: + KisImageSP m_image; + std::uint32_t FolderDepth; + +}; KisSaiConverter::KisSaiConverter(KisDocument *doc) : QObject(0), m_doc(doc) { } KisImportExportErrorCode KisSaiConverter::buildImage(const QString &filename) { sai::Document saiFile(QFile::encodeName(filename)); if (!saiFile.IsOpen()) { dbgFile << "Could not open the file, either it does not exist, either it is not a Sai file :" << filename; return ImportExportCodes::FileFormatIncorrect; } std::tuple size = saiFile.GetCanvasSize(); m_image = new KisImage(m_doc->createUndoStore(), int(std::get<0>(size)), int(std::get<1>(size)), KoColorSpaceRegistry::instance()->rgb8(), "file"); + + SaiLayerVisitor visitor(m_image); + saiFile.IterateFileSystem(visitor); + return ImportExportCodes::OK; } KisImageSP KisSaiConverter::image() { return m_image; } diff --git a/plugins/impex/sai/kis_sai_converter.h b/plugins/impex/sai/kis_sai_converter.h index 4900c7b328..9f69449cc7 100644 --- a/plugins/impex/sai/kis_sai_converter.h +++ b/plugins/impex/sai/kis_sai_converter.h @@ -1,48 +1,49 @@ /* * Copyright (c) 2019 Wolthera van Hövell tot Westerflier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_SAI_CONVERTER_H #define KIS_SAI_CONVERTER_H + #include #include "kis_types.h" #include "kis_global.h" #include "kis_annotation.h" #include #include "kis_image.h" class KisDocument; class KisImage; class KisSaiConverter : public QObject { Q_OBJECT public: explicit KisSaiConverter(KisDocument *doc); KisImportExportErrorCode buildImage(const QString &filename); KisImageSP image(); private: KisDocument *m_doc; KisImageSP m_image; }; #endif // KIS_SAI_CONVERTER_H