summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qashmoney/transferdialog.cpp
blob: 7a12fbf5e09923a70250ac772bf386378ec13d1e (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
#include "transferdialog.h"
#include "datepicker.h"
#include "calculator.h"


extern Preferences *preferences;
extern Account *account;

TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE )
  {
    dateedited = FALSE;
    setCaption ( "Transfer" );

    fromaccountlabel = new QLabel ( "From account:", this );
    QFont f = this->font();
    f.setWeight ( QFont::Bold );
    fromaccountlabel->setFont ( f );
    fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this );

    toaccountlabel = new QLabel ( "To Account:", this );
    toaccountlabel->setFont ( f );
    toaccount = new QLabel ( account->getAccountName ( toaccountid ), this );

    datelabel = new QLabel ( "Date", this );

    datebox = new QHBox ( this );
    datebox->setSpacing ( 2 );
    date = new QLineEdit ( datebox );
    date->setAlignment ( Qt::AlignRight );
    date->setDisabled ( TRUE );
    datebutton = new QPushButton ( datebox );
    datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
    connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );

    amounttlabel = new QLabel ( "Amount", this );

    amountbox = new QHBox ( this );
    amountbox->setSpacing ( 2 );
    amount = new QLineEdit ( amountbox );
    amount->setAlignment ( Qt::AlignRight );
    calculatorbutton = new QPushButton( amountbox );
    calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
    connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );

    clearedcheckbox = new QCheckBox ( "Cleared", this );

    layout = new QVBoxLayout ( this, 4, 2 );
    layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
    layout->addWidget ( fromaccount, Qt::AlignLeft );
    layout->addWidget ( toaccountlabel, Qt::AlignLeft );
    layout->addWidget ( toaccount, Qt::AlignLeft );
    layout->addSpacing ( 5 );
    layout->addWidget ( datelabel, Qt::AlignLeft );
    layout->addWidget ( datebox, Qt::AlignLeft );
    layout->addWidget ( amounttlabel, Qt::AlignLeft );
    layout->addWidget ( amountbox, Qt::AlignLeft );
    layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
  }

bool TransferDialog::getDateEdited ()
  {
    return dateedited;
  }

void TransferDialog::showCalendar ()
  {
    QDate newDate = QDate::currentDate ();
    DatePicker *dp = new DatePicker ( newDate );
    if ( dp->exec () == QDialog::Accepted )
      {
	// Set date integers
	year = dp->getYear();
	month = dp->getMonth();
	day = dp->getDay();

	// Set dateedited to TRUE
	// This tells the accountdisplay object that the user edited an account
	// and did change the date
	dateedited = TRUE;

	// Display date with our selected format
	date->setText ( preferences->getDate ( year, month, day ) );
      }
  }

int TransferDialog::getDay ()
  {
    return day;
  }

int TransferDialog::getMonth ()
  {
    return month;
  }

int TransferDialog::getYear ()
  {
    return year;
  }

void TransferDialog::showCalculator ()
  {
    Calculator *calculator = new Calculator ( this );
    if ( calculator->exec () == QDialog::Accepted )
      amount->setText ( calculator->display->text() );
  }