Fix some bugs in yearTo selection & fill in GenerateDialog
This commit is contained in:
parent
0a1b9819c7
commit
76808fe700
|
@ -46,12 +46,12 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
|||
_monthTo = new QComboBox(this);
|
||||
gridLayout->addWidget(_monthTo, 1, 2);
|
||||
|
||||
QPushButton* ok = new QPushButton(_("OK"), this);
|
||||
_ok = new QPushButton(_("OK"), this);
|
||||
QPushButton* cancel = new QPushButton(_("Cancel"), this);
|
||||
gridLayout->addWidget(ok, 3, 1);
|
||||
gridLayout->addWidget(_ok, 3, 1);
|
||||
gridLayout->addWidget(cancel, 3, 2);
|
||||
|
||||
connect(ok, SIGNAL(clicked()), this, SLOT(OnOK()));
|
||||
connect(_ok, SIGNAL(clicked()), this, SLOT(OnOK()));
|
||||
connect(cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
||||
|
||||
connect(_yearTo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnYearToChange(int)));
|
||||
|
@ -59,10 +59,8 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
|||
|
||||
_ops = _kiss->GetAllOperations();
|
||||
|
||||
_yearFrom->addItem("");
|
||||
_monthFrom->addItem("");
|
||||
|
||||
for(i=1, it = _ops.begin(); it != _ops.end(); it++, i++)
|
||||
/* From */
|
||||
for(i=0, it = _ops.begin(); it != _ops.end(); it++, i++)
|
||||
{
|
||||
_yearFrom->addItem(QString::number(it->first));
|
||||
if (year == it->first)
|
||||
|
@ -91,7 +89,8 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
|||
_yearFrom->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
for(i=curDate.year()-10; i<=curDate.year()+10; i++)
|
||||
/* To */
|
||||
for(i=year-10; i<=year+10; i++)
|
||||
_yearTo->addItem(QString::number(i));
|
||||
|
||||
if (year == -1)
|
||||
|
@ -101,10 +100,14 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
|||
}
|
||||
else
|
||||
{
|
||||
toSelect = 10;
|
||||
if (month == 11)
|
||||
{
|
||||
year++;
|
||||
toSelect++;
|
||||
}
|
||||
|
||||
_yearTo->setCurrentIndex(year-(curDate.year()-10));
|
||||
_yearTo->setCurrentIndex(toSelect);
|
||||
|
||||
if (month == -1)
|
||||
_monthTo->setCurrentIndex(0);
|
||||
|
@ -158,6 +161,7 @@ void GenerateDialog::OnYearToChange(int index)
|
|||
|
||||
year = _yearTo->currentText().toInt();
|
||||
|
||||
/* Avoid adding an existing month */
|
||||
for (i=0; i<12; i++)
|
||||
{
|
||||
ok = 1;
|
||||
|
@ -174,6 +178,13 @@ void GenerateDialog::OnYearToChange(int index)
|
|||
|
||||
_monthTo->setCurrentIndex(0);
|
||||
|
||||
if (_monthTo->count() == 0)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("All months for this year has already been generated"));
|
||||
_ok->setEnabled(false);
|
||||
}
|
||||
else
|
||||
_ok->setEnabled(true);
|
||||
layout();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ private:
|
|||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
QComboBox* _yearFrom, *_monthFrom, *_yearTo, *_monthTo;
|
||||
QPushButton* _ok;
|
||||
std::map<int, std::vector<int> > _ops;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user