summaryrefslogtreecommitdiffstats
path: root/kmymoney2/converter/mymoneyqifwriter.h
blob: 13981619ec08719f2af4325a2b34f6c840876d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/***************************************************************************
                          mymoneyqifwriter.h  -  description
                             -------------------
    begin                : Sun Jan 5 2003
    copyright            : (C) 2000-2003 by Michael Edwardes
    email                : mte@users.sourceforge.net
                           Javier Campos Morales <javi_c@users.sourceforge.net>
                           Felix Rodriguez <frodriguez@users.sourceforge.net>
                           John C <thetacoturtle@users.sourceforge.net>
                           Thomas Baumgart <ipwizard@users.sourceforge.net>
                           Kevin Tambascio <ktambascio@users.sourceforge.net>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef MYMONEYTQIFWRITER_H
#define MYMONEYTQIFWRITER_H

// ----------------------------------------------------------------------------
// QT Headers

#include <tqobject.h>
#include <tqdatetime.h>

// ----------------------------------------------------------------------------
// KDE Headers

// ----------------------------------------------------------------------------
// Project Headers

class MyMoneyTransaction;
class MyMoneySplit;
#include "mymoneyqifprofile.h"

/**
  * @author Thomas Baumgart
  */

/**
  * This class represents the TQIF writer. All conversion between the
  * internal representation of accounts, transactions is handled in this
  * object. The conversion is controlled using a MyMoneyQifProfile to allow
  * the user to control the conversion.
  */
class MyMoneyQifWriter : public TQObject
{
  Q_OBJECT
  TQ_OBJECT

public:
  MyMoneyQifWriter();
  ~MyMoneyQifWriter();

  /**
    * This method is used to start the conversion. The parameters control
    * the destination of the data and the parts that will be exported.
    * Individual errors will be reported using message boxes.
    *
    * @param filename The name of the output file with full path information
    * @param profile The name of the profile to be used for conversion
    * @param accountId The id of the account that will be exported
    * @param accountData If true, the transactions will be exported
    * @param categoryData If true, the categories will be exported as well
    * @param startDate Transations before this date will not be exported
    * @param endDate Transactions after this date will not be exported
    */
  void write(const TQString& filename, const TQString& profile,
             const TQString& accountId, const bool accountData,
             const bool categoryData,
             const TQDate& startDate, const TQDate& endDate);

private:
  /**
    * This method writes the entries necessary for an account. First
    * the leadin, and then the transactions that are in the account
    * specified by @p accountId in the range from @p startDate to @p
    * endDate.
    *
    * @param s reference to textstream
    * @param accountId id of the account to be written
    * @param startDate date from which entries are written
    * @param endDate date until which entries are written
    */
  void writeAccountEntry(TQTextStream& s, const TQString& accountId, const TQDate& startDate, const TQDate& endDate);

  /**
    * This method writes the category entries to the stream
    * @p s. It writes the leadin and uses writeCategoryEntries()
    * to write the entries and emits signalProgess() where needed.
    *
    * @param s reference to textstream
    */
  void writeCategoryEntries(TQTextStream& s);

  /**
    * This method writes the category entry for account with
    * the ID @p accountId to the stream @p s. All subaccounts
    * are processed as well.
    *
    * @param s reference to textstream
    * @param accountId id of the account to be written
    * @param leadIn constant text that will be prepended to the account's name
    */
  void writeCategoryEntry(TQTextStream& s, const TQString& accountId, const TQString& leadIn);

  void writeTransactionEntry(TQTextStream &s, const MyMoneyTransaction& t, const TQString& accountId);
  void writeSplitEntry(TQTextStream &s, const MyMoneySplit& t);

signals:
  /**
    * This signal is emitted while the operation progresses.
    * When the operation starts, the signal is emitted with
    * @p current being 0 and @p max having the maximum value.
    *
    * During the operation, the signal is emitted with @p current
    * containing the current value on the way to the maximum value.
    * @p max will be 0 in this case.
    *
    * When the operation is finished, the signal is emitted with
    * @p current and @p max set to -1 to identify the end of the
    * operation.
    *
    * @param current see above
    * @param max see above
    */
  void signalProgress(int current, int max);

private:
  MyMoneyQifProfile m_qifProfile;
};

#endif