~ubuntu-branches/ubuntu/wily/kipi-plugins/wily

« back to all changes in this revision

Viewing changes to calendar/calselect.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-12-13 12:14:45 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20101213121445-ukbi37gdnr50yzzi
Tags: 1.6.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    connect(ui.yearSpin, SIGNAL(valueChanged(int)),
59
59
            this, SLOT(yearChanged(int)));
60
60
 
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());
64
63
 
65
64
    KUrl::List urlList;
66
65
    KIPI::ImageCollection images = interface->currentSelection();
68
67
        urlList = images.images();
69
68
 
70
69
    QDate d;
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);
75
74
    MonthWidget *w;
85
84
            w->hide();
86
85
        mwVector_.insert(i, w);
87
86
    }
 
87
    ui.yearSpin->setRange(cal->year(cal->earliestValidDate()) + 1,
 
88
                          cal->year(cal->latestValidDate()) - 1);
 
89
    ui.yearSpin->setValue(currentYear);
88
90
}
89
91
 
90
92
void CalSelect::yearChanged(int year)
91
93
{
92
94
    int i, months;
93
95
    QDate d, oldD;
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);
97
100
 
98
 
    if ((KGlobal::locale()->calendar()->monthsInYear(oldD) != months) && !mwVector_.isEmpty())
 
101
    if ((cal->monthsInYear(oldD) != months) && !mwVector_.isEmpty())
99
102
    {
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();
103
106
 
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)
108
111
        {
109
112
            ui.monthBoxLayout->removeWidget(mwVector_.at(i));
110
113
        }