File indexing completed on 2024-05-12 16:41:58
0001 /* 0002 SPDX-FileCopyrightText: 2004 Thomas Baumgart <ipwizard@users.sourceforge.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef MYMONEYTEMPLATE_H 0007 #define MYMONEYTEMPLATE_H 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QDomDocument> 0013 #include <QDomNode> 0014 #include <QUrl> 0015 #include <QMap> 0016 0017 class QTreeWidgetItem; 0018 class QSaveFile; 0019 0020 // ---------------------------------------------------------------------------- 0021 // KDE Includes 0022 0023 // ---------------------------------------------------------------------------- 0024 // Project Includes 0025 0026 /** 0027 * @author Thomas Baumgart 0028 */ 0029 0030 /** 0031 * This class represents an account template handler. It is capable 0032 * to read an XML formatted account template file and import it into 0033 * the current engine. Also, it can save the current account structure 0034 * of the engine to an XML formatted template file. 0035 */ 0036 class MyMoneyAccount; 0037 class MyMoneyTemplate 0038 { 0039 public: 0040 MyMoneyTemplate(); 0041 explicit MyMoneyTemplate(const QUrl &url); 0042 ~MyMoneyTemplate(); 0043 0044 bool loadTemplate(const QUrl &url); 0045 bool saveTemplate(const QUrl &url); 0046 bool importTemplate(void(*callback)(int, int, const QString&)); 0047 bool exportTemplate(void(*callback)(int, int, const QString&)); 0048 0049 const QString& title() const; 0050 const QString& shortDescription() const; 0051 const QString& longDescription() const; 0052 0053 void setTitle(const QString &s); 0054 void setShortDescription(const QString &s); 0055 void setLongDescription(const QString &s); 0056 0057 void hierarchy(QMap<QString, QTreeWidgetItem*>& list); 0058 0059 protected: 0060 bool loadDescription(); 0061 bool createAccounts(MyMoneyAccount& parent, QDomNode account); 0062 bool setFlags(MyMoneyAccount& acc, QDomNode flags); 0063 bool saveToLocalFile(QSaveFile* qfile); 0064 bool addAccountStructure(QDomElement& parent, const MyMoneyAccount& acc); 0065 bool hierarchy(QMap<QString, QTreeWidgetItem*>& list, const QString& parent, QDomNode account); 0066 0067 /** 0068 * This method is used to update the progress information. It 0069 * checks if an appropriate function is known and calls it. 0070 * 0071 * For a parameter description see KMyMoneyView::progressCallback(). 0072 */ 0073 void signalProgress(int current, int total, const QString& = ""); 0074 0075 private: 0076 QDomDocument m_doc; 0077 QDomNode m_accounts; 0078 QString m_title; 0079 QString m_shortDesc; 0080 QString m_longDesc; 0081 QUrl m_source; 0082 void (*m_progressCallback)(int, int, const QString&); 0083 int m_accountsRead; 0084 QMap<QString,QString> m_vatAccountMap; 0085 }; 0086 0087 #endif