File indexing completed on 2025-09-28 04:46:11
0001 /* 0002 SPDX-FileCopyrightText: 2000-2003 Michael Edwardes <mte@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2000-2003 Javier Campos Morales <javi_c@users.sourceforge.net> 0004 SPDX-FileCopyrightText: 2000-2003 Felix Rodriguez <frodriguez@users.sourceforge.net> 0005 SPDX-FileCopyrightText: 2000-2003 John C <thetacoturtle@users.sourceforge.net> 0006 SPDX-FileCopyrightText: 2000-2003 Thomas Baumgart <ipwizard@users.sourceforge.net> 0007 SPDX-FileCopyrightText: 2000-2003 Kevin Tambascio <ktambascio@users.sourceforge.net> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef MYMONEYQIFWRITER_H 0012 #define MYMONEYQIFWRITER_H 0013 0014 // ---------------------------------------------------------------------------- 0015 // QT Headers 0016 0017 #include <QObject> 0018 #include <QDateTime> 0019 #include <QTextStream> 0020 0021 // ---------------------------------------------------------------------------- 0022 // KDE Headers 0023 0024 // ---------------------------------------------------------------------------- 0025 // Project Headers 0026 0027 #include "mymoneyqifprofile.h" 0028 0029 class MyMoneyTransaction; 0030 class MyMoneySplit; 0031 0032 /** 0033 * @author Thomas Baumgart 0034 */ 0035 0036 /** 0037 * This class represents the QIF writer. All conversion between the 0038 * internal representation of accounts, transactions is handled in this 0039 * object. The conversion is controlled using a MyMoneyQifProfile to allow 0040 * the user to control the conversion. 0041 */ 0042 class MyMoneyQifWriter : public QObject 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 MyMoneyQifWriter(); 0048 ~MyMoneyQifWriter(); 0049 0050 /** 0051 * This method is used to start the conversion. The parameters control 0052 * the destination of the data and the parts that will be exported. 0053 * Individual errors will be reported using message boxes. 0054 * 0055 * @param filename The name of the output file with full path information 0056 * @param profile The name of the profile to be used for conversion 0057 * @param accountId The id of the account that will be exported 0058 * @param accountData If true, the transactions will be exported 0059 * @param categoryData If true, the categories will be exported as well 0060 * @param startDate Transactions before this date will not be exported 0061 * @param endDate Transactions after this date will not be exported 0062 */ 0063 void write(const QString &filename, const QString &profile, 0064 const QString &accountId, const bool accountData, 0065 const bool categoryData, 0066 const QDate &startDate, const QDate &endDate); 0067 0068 private: 0069 0070 /** 0071 * This method writes the entries necessary for an account. First 0072 * the leadin, and then the transactions that are in the account 0073 * specified by @p accountId in the range from @p startDate to @p 0074 * endDate. 0075 * 0076 * @param s reference to textstream 0077 * @param accountId id of the account to be written 0078 * @param startDate date from which entries are written 0079 * @param endDate date until which entries are written 0080 */ 0081 void writeAccountEntry(QTextStream &s, const QString &accountId, const QDate &startDate, const QDate &endDate); 0082 0083 /** 0084 * This method writes the category entries to the stream 0085 * @p s. It writes the leadin and uses writeCategoryEntries() 0086 * to write the entries and emits signalProgess() where needed. 0087 * 0088 * @param s reference to textstream 0089 */ 0090 void writeCategoryEntries(QTextStream &s); 0091 0092 /** 0093 * This method writes the category entry for account with 0094 * the ID @p accountId to the stream @p s. All subaccounts 0095 * are processed as well. 0096 * 0097 * @param s reference to textstream 0098 * @param accountId id of the account to be written 0099 * @param leadIn constant text that will be prepended to the account's name 0100 */ 0101 void writeCategoryEntry(QTextStream &s, const QString &accountId, const QString &leadIn); 0102 0103 void writeTransactionEntry(QTextStream &s, const MyMoneyTransaction &t, const QString &accountId); 0104 void writeSplitEntry(QTextStream &s, const MyMoneySplit &t); 0105 void extractInvestmentEntries(QTextStream &s, const QString &accountId, const QDate &startDate, const QDate &endDate); 0106 void writeInvestmentEntry(QTextStream &stream, const MyMoneyTransaction &t, const int count); 0107 0108 Q_SIGNALS: 0109 /** 0110 * This signal is emitted while the operation progresses. 0111 * When the operation starts, the signal is emitted with 0112 * @p current being 0 and @p max having the maximum value. 0113 * 0114 * During the operation, the signal is emitted with @p current 0115 * containing the current value on the way to the maximum value. 0116 * @p max will be 0 in this case. 0117 * 0118 * When the operation is finished, the signal is emitted with 0119 * @p current and @p max set to -1 to identify the end of the 0120 * operation. 0121 * 0122 * @param current see above 0123 * @param max see above 0124 */ 0125 void signalProgress(int current, int max); 0126 0127 private: 0128 MyMoneyQifProfile m_qifProfile; 0129 0130 }; 0131 0132 #endif