summaryrefslogtreecommitdiffstats
path: root/kmymoney2/plugins/ofximport/dialogs/konlinebankingstatus.cpp
blob: 8ca0aacec8432eb904fe9f7cc5154e4ffaee6905 (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
/***************************************************************************
                          konlinebankingstatus.cpp
                             -------------------
    begin                : Wed Apr 16 2008
    copyright            : (C) 2008 by Thomas Baumgart
    email                : [email protected]
 ***************************************************************************/

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

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif


// ----------------------------------------------------------------------------
// System Includes

// ----------------------------------------------------------------------------
// QT Includes

#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqradiobutton.h>
#include <tqspinbox.h>
#include <tqdatetimeedit.h>

// ----------------------------------------------------------------------------
// KDE Includes

#include <klocale.h>
#include <kled.h>
#include <kcombobox.h>

// ----------------------------------------------------------------------------
// Project Includes

#include "konlinebankingstatus.h"
#include <kmymoney/mymoneykeyvaluecontainer.h>
#include <kmymoney/mymoneyaccount.h>
#include <libofx/libofx.h>
#include "mymoneyofxconnector.h"

KOnlineBankingtqStatus::KOnlineBankingtqStatus(const MyMoneyAccount& acc, TQWidget *tqparent, const char *name) :
  KOnlineBankingStatusDecl(tqparent,name),
  m_appId(0)
{
  m_ledOnlinetqStatus->off();

  // Set up online banking settings if applicable
  MyMoneyKeyValueContainer settings = acc.onlineBankingSettings();
  m_textOnlinetqStatus->setText(i18n("Enabled & configured"));
  m_ledOnlinetqStatus->on();

  TQString account = settings.value("accountid");
  TQString bank = settings.value("bankname");
  TQString bankid = TQString("%1 %2").tqarg(settings.value("bankid")).tqarg(settings.value("branchid"));
  if ( bankid.length() > 1 )
    bank += TQString(" (%1)").tqarg(bankid);
  m_textBank->setText(bank);
  m_textOnlineAccount->setText(account);

  m_appId = new OfxAppVersion(m_applicationCombo, settings.value("appId"));
  m_headerVersion = new OfxHeaderVersion(m_headerVersionCombo, settings.value("kmmofx-headerVersion"));

  int numDays = 60;
  TQString snumDays = settings.value("kmmofx-numRequestDays");
  if (!snumDays.isEmpty())
    numDays = snumDays.toInt();
  m_numdaysSpin->setValue(numDays);
  m_todayRB->setChecked(settings.value("kmmofx-todayMinus").isEmpty() || settings.value("kmmofx-todayMinus").toInt() != 0);
  m_lastUpdateRB->setChecked(!settings.value("kmmofx-lastUpdate").isEmpty() && settings.value("kmmofx-lastUpdate").toInt() != 0);
  m_lastUpdateTXT->setText(acc.value("lastImportedTransactionDate"));
  m_pickDateRB->setChecked(!settings.value("kmmofx-pickDate").isEmpty() && settings.value("kmmofx-pickDate").toInt() != 0);
  TQString specificDate = settings.value("kmmofx-specificDate");
  if (!specificDate.isEmpty())
    m_specificDate->setDate(TQDate::fromString(specificDate));
  else
    m_specificDate->setDate(TQDate::tqcurrentDate());
  m_specificDate->setMaxValue(TQDate::tqcurrentDate());
  m_payeeidRB->setChecked(settings.value("kmmofx-preferPayeeid").isEmpty() || settings.value("kmmofx-preferPayeeid").toInt() != 0);
  m_nameRB->setChecked(!settings.value("kmmofx-preferName").isEmpty() && settings.value("kmmofx-preferName").toInt() != 0);
}

KOnlineBankingtqStatus::~KOnlineBankingtqStatus()
{
  delete m_appId;
}

const TQString& KOnlineBankingtqStatus::appId(void) const
{
  if(m_appId)
    return m_appId->appId();
  return TQString();
}

TQString KOnlineBankingtqStatus::headerVersion(void) const
{
  if(m_headerVersion)
    return m_headerVersion->headerVersion();
  return TQString();
}

#include "konlinebankingstatus.moc"