File indexing completed on 2024-05-12 05:10:13
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef TELLICO_XMLEXPORTER_H 0026 #define TELLICO_XMLEXPORTER_H 0027 0028 #include "exporter.h" 0029 #include "../utils/stringset.h" 0030 0031 namespace Tellico { 0032 class Filter; 0033 } 0034 0035 class QDomDocument; 0036 class QDomElement; 0037 class QCheckBox; 0038 0039 namespace Tellico { 0040 namespace Export { 0041 0042 /** 0043 * @author Robby Stephenson 0044 */ 0045 class TellicoXMLExporter : public Exporter { 0046 Q_OBJECT 0047 0048 public: 0049 TellicoXMLExporter(Data::CollPtr coll); 0050 ~TellicoXMLExporter(); 0051 0052 virtual bool exec() Q_DECL_OVERRIDE; 0053 virtual QString formatString() const Q_DECL_OVERRIDE; 0054 virtual QString fileFilter() const Q_DECL_OVERRIDE; 0055 0056 QString text() const; 0057 QDomDocument exportXML() const; 0058 0059 void setIncludeImages(bool b) { m_includeImages = b; } 0060 void setIncludeGroups(bool b) { m_includeGroups = b; } 0061 0062 virtual QWidget* widget(QWidget*) Q_DECL_OVERRIDE; 0063 virtual void readOptions(KSharedConfigPtr cfg) Q_DECL_OVERRIDE; 0064 virtual void saveOptions(KSharedConfigPtr cfg) Q_DECL_OVERRIDE; 0065 0066 /** 0067 * An integer indicating format version. 0068 */ 0069 static const unsigned syntaxVersion; 0070 0071 private: 0072 void exportCollectionXML(QDomDocument& doc, QDomElement& parent, int format) const; 0073 void exportFieldXML(QDomDocument& doc, QDomElement& parent, Data::FieldPtr field) const; 0074 void exportEntryXML(QDomDocument& doc, QDomElement& parent, Data::EntryPtr entry, int format) const; 0075 void exportImageXML(QDomDocument& doc, QDomElement& parent, const QString& imageID) const; 0076 void exportGroupXML(QDomDocument& doc, QDomElement& parent) const; 0077 void exportFilterXML(QDomDocument& doc, QDomElement& parent, FilterPtr filter) const; 0078 void exportBorrowerXML(QDomDocument& doc, QDomElement& parent, Data::BorrowerPtr borrower) const; 0079 0080 Data::EntryList sortEntries(const Data::EntryList& entries) const; 0081 bool version12Needed() const; 0082 0083 // keep track of which images were written, since some entries could have same image 0084 mutable StringSet m_images; 0085 bool m_includeImages : 1; 0086 bool m_includeGroups : 1; 0087 0088 QWidget* m_widget; 0089 QCheckBox* m_checkIncludeImages; 0090 }; 0091 0092 } // end namespace 0093 } // end namespace 0094 #endif