summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/knewbudgetdlg.cpp
blob: d584623ed3510c711ed69aaba686a09d43a2a6d6 (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
/***************************************************************************
                          knewbudgetdlg.cpp
                             -------------------
    begin                : Wed Jan 18 2006
    copyright            : (C) 2000-2004 by Darren Gould
    email                : darren_gould@gmx.de
 ***************************************************************************/

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

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

#include <kpushbutton.h>
#include <tdelistview.h>
#include <kiconloader.h>
#include <kguiitem.h>
#include <klocale.h>
#include <kmessagebox.h>

// ----------------------------------------------------------------------------
// Project Includes
#include "knewbudgetdlg.h"

const int KNewBudgetDlg::m_icFutureYears = 5;
const int KNewBudgetDlg::m_icPastYears = 2;

KNewBudgetDlg::KNewBudgetDlg(TQWidget* parent, const char *name) :
  KNewBudgetDlgDecl(parent, name)
{
  TQStringList slYear;
  TQDate dToday = TQDate::currentDate();
  int iYear = dToday.year();

  for (int i=0; i<=m_icFutureYears; i++)
    m_cbYear->insertItem( TQString::number(iYear++) );

  iYear = dToday.year();
  for (int i=0; i<=m_icFutureYears; i++)
    m_cbYear->insertItem( TQString::number(--iYear) );
}

KNewBudgetDlg::~KNewBudgetDlg()
{
}

void KNewBudgetDlg::m_pbCancel_clicked()
{
  reject();
}

void KNewBudgetDlg::m_pbOk_clicked()
{
  // force focus change to update all data
  m_pbOk->setFocus();

  if (m_leBudgetName->displayText().isEmpty())
  {
    KMessageBox::information(this, i18n("Please specify a budget name"));
    m_leBudgetName->setFocus();
    return;
  }

  m_year = m_cbYear->currentText();
  m_name = m_leBudgetName->displayText();

  accept();
}


#include "knewbudgetdlg.moc"