From 3fc700f0421f801c4c89c075155009ce67667f10 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 30 Dec 2008 14:48:18 +0000 Subject: 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) ) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Darío Andrés for the patch! BUG: 179019 svn path=/trunk/KDE/kdebase/apps/; revision=903432 --- src/dolphinmodel.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/dolphinmodel.cpp') diff --git a/src/dolphinmodel.cpp b/src/dolphinmodel.cpp index 1cd5ad663..76bd86264 100644 --- a/src/dolphinmodel.cpp +++ b/src/dolphinmodel.cpp @@ -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: -- cgit v1.3