fixed crash when enabling grouping by date and having dates like

30 December 2008 (is "Week 1" (of 2009 , but for 2008 too))
28 December 2008 (is "Week 52" (of 2008) )

Thanks to Darío Andrés for the patch!

BUG: 179019

svn path=/trunk/KDE/kdebase/apps/; revision=903432
This commit is contained in:
Peter Penz 2008-12-30 14:48:18 +00:00
parent 5194a032ac
commit 3fc700f042

View file

@ -208,8 +208,18 @@ QVariant DolphinModel::displayRoleData(const QModelIndex& index) const
const QDate modifiedDate = modifiedTime.date();
const int daysDistance = modifiedDate.daysTo(currentDate);
const int currentWeek = currentDate.weekNumber();
const int modifiedWeek = modifiedDate.weekNumber();
int yearForCurrentWeek = 0;
int currentWeek = currentDate.weekNumber(&yearForCurrentWeek);
if (yearForCurrentWeek == currentDate.year() + 1) {
currentWeek = 53;
}
int yearForModifiedWeek = 0;
int modifiedWeek = modifiedDate.weekNumber(&yearForModifiedWeek);
if (yearForModifiedWeek == modifiedDate.year() + 1) {
modifiedWeek = 53;
}
if (currentDate.year() == modifiedDate.year() &&
currentDate.month() == modifiedDate.month()) {
@ -231,6 +241,7 @@ QVariant DolphinModel::displayRoleData(const QModelIndex& index) const
retString = i18nc("@title:group Date", "Three Weeks Ago");
break;
case 4:
case 5:
retString = i18nc("@title:group Date", "Earlier this Month");
break;
default: