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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/***************************************************************************
kmymoneybriefschedule.cpp - description
-------------------
begin : Sun Jul 6 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. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// ----------------------------------------------------------------------------
// QT Includes
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqtextedit.h>
#include <tqtoolbutton.h>
// ----------------------------------------------------------------------------
// KDE Includes
#include <tdeglobal.h>
#include <tdelocale.h>
#include <kiconloader.h>
#include <kpushbutton.h>
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/mymoneyscheduled.h>
#include "kmymoneybriefschedule.h"
#include "../kmymoneyutils.h"
KMyMoneyBriefSchedule::KMyMoneyBriefSchedule(TQWidget *parent, const char *name )
: kScheduleBriefWidget(parent,name, WStyle_Customize | WStyle_NoBorder)
{
TDEIconLoader *ic = TDEGlobal::iconLoader();
m_nextButton->setPixmap(BarIcon(TQString::fromLatin1("1rightarrow")));
m_prevButton->setPixmap(BarIcon(TQString::fromLatin1("1leftarrow")));
connect(m_prevButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotPrevClicked()));
connect(m_nextButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotNextClicked()));
connect(m_closeButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(hide()));
connect(m_skipButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSkipClicked()));
connect(m_buttonEnter, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotEnterClicked()));
KGuiItem skipGuiItem( i18n("&Skip"),
TQIconSet(ic->loadIcon("media-seek-forward", TDEIcon::Small, TDEIcon::SizeSmall)),
i18n("Skip this transaction"),
i18n("Use this button to skip this transaction"));
m_skipButton->setGuiItem(skipGuiItem);
KGuiItem enterGuiItem( i18n("&Enter"),
TQIconSet(ic->loadIcon("key_enter", TDEIcon::Small, TDEIcon::SizeSmall)),
i18n("Record this transaction into the register"),
i18n("Use this button to record this transaction"));
m_buttonEnter->setGuiItem(enterGuiItem);
}
KMyMoneyBriefSchedule::~KMyMoneyBriefSchedule()
{
}
void KMyMoneyBriefSchedule::setSchedules(TQValueList<MyMoneySchedule> list, const TQDate& date)
{
m_scheduleList = list;
m_date = date;
m_index = 0;
if (list.count() >= 1)
{
loadSchedule();
}
}
void KMyMoneyBriefSchedule::loadSchedule()
{
try
{
if (m_index < m_scheduleList.count())
{
MyMoneySchedule sched = m_scheduleList[m_index];
m_indexLabel->setText(i18n("%1 of %2")
.arg(TQString::number(m_index+1))
.arg(TQString::number(m_scheduleList.count())));
m_name->setText(sched.name());
m_type->setText(KMyMoneyUtils::scheduleTypeToString(sched.type()));
m_account->setText(sched.account().name());
TQString text;
MyMoneyMoney amount = sched.transaction().splitByAccount(sched.account().id()).value();
amount = amount.abs();
if (sched.willEnd())
{
int transactions = sched.paymentDates(m_date, sched.endDate()).count()-1;
text = i18n("Payment on %1 for %2 with %3 transactions remaining occuring %4.")
.arg(TDEGlobal::locale()->formatDate(m_date, true))
.arg(amount.formatMoney(sched.account().fraction()))
.arg(TQString::number(transactions))
.arg(i18n(sched.occurenceToString().utf8()));
} else {
text = i18n("Payment on %1 for %2 occuring %4.")
.arg(TDEGlobal::locale()->formatDate(m_date, true))
.arg(amount.formatMoney(sched.account().fraction()))
.arg(i18n(sched.occurenceToString().utf8()));
}
if (m_date < TQDate::currentDate())
{
if (sched.isOverdue())
{
TQDate startD = (sched.lastPayment().isValid()) ?
sched.lastPayment() :
sched.startDate();
if (m_date.isValid())
startD = m_date;
int days = startD.daysTo(TQDate::currentDate());
int transactions = sched.paymentDates(startD, TQDate::currentDate()).count();
text += "<br><font color=red>";
text += i18n("%1 days overdue (%2 occurences).")
.arg(TQString::number(days))
.arg(TQString::number(transactions));
text += "</color>";
}
}
m_details->setText(text);
m_prevButton->setEnabled(true);
m_nextButton->setEnabled(true);
m_skipButton->setEnabled(sched.occurencePeriod() != MyMoneySchedule::OCCUR_ONCE);
if (m_index == 0)
m_prevButton->setEnabled(false);
if (m_index == (m_scheduleList.count()-1))
m_nextButton->setEnabled(false);
}
}
catch (MyMoneyException *e)
{
delete e;
}
}
void KMyMoneyBriefSchedule::slotPrevClicked()
{
if (m_index >= 1)
{
--m_index;
loadSchedule();
}
}
void KMyMoneyBriefSchedule::slotNextClicked()
{
if (m_index < (m_scheduleList.count()-1))
{
m_index++;
loadSchedule();
}
}
void KMyMoneyBriefSchedule::slotEnterClicked()
{
hide();
emit enterClicked(m_scheduleList[m_index], m_date);
}
void KMyMoneyBriefSchedule::slotSkipClicked()
{
hide();
emit skipClicked(m_scheduleList[m_index], m_date);
}
#include "kmymoneybriefschedule.moc"
|