58
58
connect(ui.yearSpin, SIGNAL(valueChanged(int)),
59
59
this, SLOT(yearChanged(int)));
61
ui.yearSpin->setRange(KGlobal::locale()->calendar()->earliestValidDate().year() + 1,
62
KGlobal::locale()->calendar()->latestValidDate().year() - 1);
63
ui.yearSpin->setValue(KGlobal::locale()->calendar()->year(QDate::currentDate()));
61
const KCalendarSystem *cal = KGlobal::locale()->calendar();
62
int currentYear = cal->year(QDate::currentDate());
65
64
KUrl::List urlList;
66
65
KIPI::ImageCollection images = interface->currentSelection();
68
67
urlList = images.images();
71
KGlobal::locale()->calendar()->setYMD(d, ui.yearSpin->value(), 1, 1);
72
int months = KGlobal::locale()->calendar()->monthsInYear(d);
70
cal->setYMD(d, currentYear, 1, 1);
71
int months = cal->monthsInYear(d);
73
72
// span the monthWidgets over 2 rows. inRow should usually be 6 or 7 (for 12 or 13 months)
74
73
int inRow = (months / 2) + ((months % 2) != 0);
86
85
mwVector_.insert(i, w);
87
ui.yearSpin->setRange(cal->year(cal->earliestValidDate()) + 1,
88
cal->year(cal->latestValidDate()) - 1);
89
ui.yearSpin->setValue(currentYear);
90
92
void CalSelect::yearChanged(int year)
94
KGlobal::locale()->calendar()->setYMD(d, year, 1, 1);
95
KGlobal::locale()->calendar()->setYMD(oldD, CalSettings::instance()->year(), 1, 1);
96
months = KGlobal::locale()->calendar()->monthsInYear(d);
96
const KCalendarSystem *cal = KGlobal::locale()->calendar();
97
cal->setYMD(d, year, 1, 1);
98
cal->setYMD(oldD, CalSettings::instance()->year(), 1, 1);
99
months = cal->monthsInYear(d);
98
if ((KGlobal::locale()->calendar()->monthsInYear(oldD) != months) && !mwVector_.isEmpty())
101
if ((cal->monthsInYear(oldD) != months) && !mwVector_.isEmpty())
100
103
// hide the last months that are not present on the current year
101
for (i=months; (i<KGlobal::locale()->calendar()->monthsInYear(oldD)) && (i<mwVector_.count()); ++i)
104
for (i=months; (i<cal->monthsInYear(oldD)) && (i<mwVector_.count()); ++i)
102
105
mwVector_.at(i)->hide();
104
107
// span the monthWidgets over 2 rows. inRow should usually be 6 or 7 (for 12 or 13 months)
105
108
int inRow = (months / 2) + ((months % 2) != 0);
106
109
// remove all the monthWidgets, then readd the needed ones
107
for (i=0; i<KGlobal::locale()->calendar()->monthsInYear(oldD); ++i)
110
for (i=0; i<cal->monthsInYear(oldD); ++i)
109
112
ui.monthBoxLayout->removeWidget(mwVector_.at(i));