diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
commit | dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (patch) | |
tree | 99e72842fe687baea16376a147619b6048d7e441 /kmymoney2/widgets/kmymoneybriefschedule.cpp | |
download | kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.tar.gz kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.zip |
Added kmymoney
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/widgets/kmymoneybriefschedule.cpp')
-rw-r--r-- | kmymoney2/widgets/kmymoneybriefschedule.cpp | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/kmymoney2/widgets/kmymoneybriefschedule.cpp b/kmymoney2/widgets/kmymoneybriefschedule.cpp new file mode 100644 index 0000000..82776af --- /dev/null +++ b/kmymoney2/widgets/kmymoneybriefschedule.cpp @@ -0,0 +1,191 @@ +/*************************************************************************** + 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. * + * * + ***************************************************************************/ + +// ---------------------------------------------------------------------------- +// QT Includes + +#include <qlabel.h> +#include <qlineedit.h> +#include <qtextedit.h> +#include <qtoolbutton.h> + +// ---------------------------------------------------------------------------- +// KDE Includes + +#include <kglobal.h> +#include <klocale.h> +#include <kiconloader.h> +#include <kpushbutton.h> + +// ---------------------------------------------------------------------------- +// Project Includes + +#include <kmymoney/mymoneyscheduled.h> +#include "kmymoneybriefschedule.h" +#include "../kmymoneyutils.h" + +KMyMoneyBriefSchedule::KMyMoneyBriefSchedule(QWidget *parent, const char *name ) + : kScheduleBriefWidget(parent,name, WStyle_Customize | WStyle_NoBorder) +{ + KIconLoader *ic = KGlobal::iconLoader(); + m_nextButton->setPixmap(BarIcon(QString::fromLatin1("1rightarrow"))); + m_prevButton->setPixmap(BarIcon(QString::fromLatin1("1leftarrow"))); + + connect(m_prevButton, SIGNAL(clicked()), this, SLOT(slotPrevClicked())); + connect(m_nextButton, SIGNAL(clicked()), this, SLOT(slotNextClicked())); + connect(m_closeButton, SIGNAL(clicked()), this, SLOT(hide())); + connect(m_skipButton, SIGNAL(clicked()), this, SLOT(slotSkipClicked())); + connect(m_buttonEnter, SIGNAL(clicked()), this, SLOT(slotEnterClicked())); + + KGuiItem skipGuiItem( i18n("&Skip"), + QIconSet(ic->loadIcon("player_fwd", KIcon::Small, KIcon::SizeSmall)), + i18n("Skip this transaction"), + i18n("Use this button to skip this transaction")); + m_skipButton->setGuiItem(skipGuiItem); + + KGuiItem enterGuiItem( i18n("&Enter"), + QIconSet(ic->loadIcon("key_enter", KIcon::Small, KIcon::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(QValueList<MyMoneySchedule> list, const QDate& 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(QString::number(m_index+1)) + .arg(QString::number(m_scheduleList.count()))); + m_name->setText(sched.name()); + m_type->setText(KMyMoneyUtils::scheduleTypeToString(sched.type())); + m_account->setText(sched.account().name()); + QString 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(KGlobal::locale()->formatDate(m_date, true)) + .arg(amount.formatMoney(sched.account().fraction())) + .arg(QString::number(transactions)) + .arg(i18n(sched.occurenceToString())); + } else { + text = i18n("Payment on %1 for %2 occuring %4.") + .arg(KGlobal::locale()->formatDate(m_date, true)) + .arg(amount.formatMoney(sched.account().fraction())) + .arg(i18n(sched.occurenceToString())); + } + + if (m_date < QDate::currentDate()) + { + if (sched.isOverdue()) + { + QDate startD = (sched.lastPayment().isValid()) ? + sched.lastPayment() : + sched.startDate(); + + if (m_date.isValid()) + startD = m_date; + + int days = startD.daysTo(QDate::currentDate()); + int transactions = sched.paymentDates(startD, QDate::currentDate()).count(); + + text += "<br><font color=red>"; + text += i18n("%1 days overdue (%2 occurences).") + .arg(QString::number(days)) + .arg(QString::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" |