[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-baseapps] dolphin/src/kitemviews: Use a consistent way to group files by "Date"
From:       Frank Reininghaus <frank78ac () googlemail ! com>
Date:       2013-03-03 17:27:48
Message-ID: 20130303172748.005DBA604F () git ! kde ! org
[Download RAW message or body]

Git commit d7845775624999742f793a16e04531d50f4b450c by Frank Reininghaus, on behalf \
of Daniel Kreuter. Committed on 03/03/2013 at 18:20.
Pushed by freininghaus into branch 'master'.

Use a consistent way to group files by "Date"

Before this change, files were grouped by calendar weeks if they were
modified in the current month and ignoring the "first week day setting",
but by the actual distance measured in multiples of seven days if the
were modified last month.

This not only fixes the "ignores first week day" bug, but also the
problem that the inconsistencies in the algorithm could lead to a broken
grouping in the first days of a month (see screenshot in the review
request).

BUG: 181337
FIXED-IN: 4.11
REVIEW: 108667

M  +3    -20   dolphin/src/kitemviews/kfileitemmodel.cpp

http://commits.kde.org/kde-baseapps/d7845775624999742f793a16e04531d50f4b450c

diff --git a/dolphin/src/kitemviews/kfileitemmodel.cpp \
b/dolphin/src/kitemviews/kfileitemmodel.cpp index 2d11e87..688826e 100644
--- a/dolphin/src/kitemviews/kfileitemmodel.cpp
+++ b/dolphin/src/kitemviews/kfileitemmodel.cpp
@@ -1664,12 +1664,6 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() \
const  
     const QDate currentDate = KDateTime::currentLocalDateTime().date();
 
-    int yearForCurrentWeek = 0;
-    int currentWeek = currentDate.weekNumber(&yearForCurrentWeek);
-    if (yearForCurrentWeek == currentDate.year() + 1) {
-        currentWeek = 53;
-    }
-
     QDate previousModifiedDate;
     QString groupValue;
     for (int i = 0; i <= maxIndex; ++i) {
@@ -1687,20 +1681,9 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() \
const  
         const int daysDistance = modifiedDate.daysTo(currentDate);
 
-        int yearForModifiedWeek = 0;
-        int modifiedWeek = modifiedDate.weekNumber(&yearForModifiedWeek);
-        if (yearForModifiedWeek == modifiedDate.year() + 1) {
-            modifiedWeek = 53;
-        }
-
         QString newGroupValue;
         if (currentDate.year() == modifiedDate.year() && currentDate.month() == \
                modifiedDate.month()) {
-            if (modifiedWeek > currentWeek) {
-                // Usecase: modified date = 2010-01-01, current date = 2010-01-22
-                //          modified week = 53,         current week = 3
-                modifiedWeek = 0;
-            }
-            switch (currentWeek - modifiedWeek) {
+            switch (daysDistance / 7) {
             case 0:
                 switch (daysDistance) {
                 case 0:  newGroupValue = i18nc("@title:group Date", "Today"); break;
@@ -1709,7 +1692,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() \
const  }
                 break;
             case 1:
-                newGroupValue = i18nc("@title:group Date", "Last Week");
+                newGroupValue = i18nc("@title:group Date", "One Week Ago");
                 break;
             case 2:
                 newGroupValue = i18nc("@title:group Date", "Two Weeks Ago");
@@ -1732,7 +1715,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() \
const  } else if (daysDistance <= 7) {
                     newGroupValue = modifiedTime.toString(i18nc("@title:group The \
week day name: %A, %B is full month name in current locale, and %Y is full year \
number", "%A (%B, %Y)"));  } else if (daysDistance <= 7 * 2) {
-                    newGroupValue = modifiedTime.toString(i18nc("@title:group Date: \
%B is full month name in current locale, and %Y is full year number", "Last Week (%B, \
%Y)")); +                    newGroupValue = \
modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current \
locale, and %Y is full year number", "One Week Ago (%B, %Y)"));  } else if \
(daysDistance <= 7 * 3) {  newGroupValue = modifiedTime.toString(i18nc("@title:group \
Date: %B is full month name in current locale, and %Y is full year number", "Two \
Weeks Ago (%B, %Y)"));  } else if (daysDistance <= 7 * 4) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic