diff --git a/src/historytimecategorymodel.cpp b/src/historytimecategorymodel.cpp index a5284d957f90f92abceaed82d0058bac06eea7a7..b94189251e17ad568dd38691d4551bbd51f99375 100644 --- a/src/historytimecategorymodel.cpp +++ b/src/historytimecategorymodel.cpp @@ -44,25 +44,24 @@ d_ptr(new HistoryTimeCategoryModelPrivate) d_ptr->m_lCategories << QDate::currentDate().addDays(-4).toString("dddd");//4 d_ptr->m_lCategories << QDate::currentDate().addDays(-5).toString("dddd");//5 d_ptr->m_lCategories << QDate::currentDate().addDays(-6).toString("dddd");//6 - d_ptr->m_lCategories << tr("Last week") ;//7 + d_ptr->m_lCategories << tr("A week ago") ;//7 d_ptr->m_lCategories << tr("Two weeks ago") ;//8 d_ptr->m_lCategories << tr("Three weeks ago") ;//9 - d_ptr->m_lCategories << tr("Four weeks ago") ;//10 - d_ptr->m_lCategories << tr("Last month") ;//11 - d_ptr->m_lCategories << tr("Two months ago") ;//12 - d_ptr->m_lCategories << tr("Three months ago") ;//13 - d_ptr->m_lCategories << tr("Four months ago") ;//14 - d_ptr->m_lCategories << tr("Five months ago") ;//15 - d_ptr->m_lCategories << tr("Six months ago") ;//16 - d_ptr->m_lCategories << tr("Seven months ago") ;//17 - d_ptr->m_lCategories << tr("Eight months ago") ;//18 - d_ptr->m_lCategories << tr("Nine months ago") ;//19 - d_ptr->m_lCategories << tr("Ten months ago") ;//20 - d_ptr->m_lCategories << tr("Eleven months ago") ;//21 - d_ptr->m_lCategories << tr("Twelve months ago") ;//22 - d_ptr->m_lCategories << tr("Last year") ;//23 - d_ptr->m_lCategories << tr("Very long time ago") ;//24 - d_ptr->m_lCategories << tr("Never") ;//25 + d_ptr->m_lCategories << tr("A month ago") ;//10 + d_ptr->m_lCategories << tr("Two months ago") ;//11 + d_ptr->m_lCategories << tr("Three months ago") ;//12 + d_ptr->m_lCategories << tr("Four months ago") ;//13 + d_ptr->m_lCategories << tr("Five months ago") ;//14 + d_ptr->m_lCategories << tr("Six months ago") ;//15 + d_ptr->m_lCategories << tr("Seven months ago") ;//16 + d_ptr->m_lCategories << tr("Eight months ago") ;//17 + d_ptr->m_lCategories << tr("Nine months ago") ;//18 + d_ptr->m_lCategories << tr("Ten months ago") ;//19 + d_ptr->m_lCategories << tr("Eleven months ago") ;//20 + d_ptr->m_lCategories << tr("Twelve months ago") ;//21 + d_ptr->m_lCategories << tr("A year ago") ;//22 + d_ptr->m_lCategories << tr("Very long time ago") ;//23 + d_ptr->m_lCategories << tr("Never") ;//24 } HistoryTimeCategoryModel::~HistoryTimeCategoryModel() @@ -133,7 +132,7 @@ HistoryTimeCategoryModel::HistoryConst HistoryTimeCategoryModel::timeToHistoryCo /* * Struct tm description of fields used below: - * tm_mday int day of the month 1-31 + * tm_yday int days since January 1 1-31 * tm_mon int months since January 0-11 * tm_year int years since 1900 * tm_wday int days since Sunday 0-6 @@ -146,22 +145,27 @@ HistoryTimeCategoryModel::HistoryConst HistoryTimeCategoryModel::timeToHistoryCo int diffYears = localCurrentTime.tm_year - localPastTime.tm_year; int diffMonths = localCurrentTime.tm_mon - localPastTime.tm_mon; - int diffDays = localCurrentTime.tm_mday - localPastTime.tm_mday; + int diffDays = localCurrentTime.tm_yday - localPastTime.tm_yday; - //Check for past days, stopping at Monday - if (diffYears == 0 && diffMonths == 0 && diffDays < 7 && localPastTime.tm_wday <= localCurrentTime.tm_wday) { + if (diffYears == 1 && diffMonths < 0) { + diffMonths += 12; + diffYears = 0; + } + + //Check for past 6 days + if (diffYears == 0 && diffDays < 7) { return (HistoryTimeCategoryModel::HistoryConst)(diffDays); //Today to Six_days_ago } //Check for last month - else if (diffYears == 0 && diffMonths == 0) { - return (HistoryTimeCategoryModel::HistoryConst)(diffDays / 7 + ((int)HistoryTimeCategoryModel::HistoryConst::Last_week)); //Last_week to Three_weeks_ago + else if (diffYears == 0 && diffMonths <= 1 && (diffDays / 7 <= 4)) { + return (HistoryTimeCategoryModel::HistoryConst)(diffDays / 7 + ((int)HistoryTimeCategoryModel::HistoryConst::A_week_ago) - 1); //A_week_ago to Three_weeks_ago } //Check for last year else if (diffYears == 0 && diffMonths > 0) { - return (HistoryTimeCategoryModel::HistoryConst)(diffMonths + ((int)HistoryTimeCategoryModel::HistoryConst::Last_month) - 1); //Last_month to Twelve_months ago + return (HistoryTimeCategoryModel::HistoryConst)(diffMonths + ((int)HistoryTimeCategoryModel::HistoryConst::A_month_ago) - 1); //A_month_ago to Twelve_months ago } else if (diffYears == 1) - return HistoryConst::Last_year; + return HistoryConst::A_year_ago; //Every other senario return HistoryTimeCategoryModel::HistoryConst::Very_long_time_ago; diff --git a/src/historytimecategorymodel.h b/src/historytimecategorymodel.h index a34298699d2f758a34796b8f78d316143df549d9..dedc04ee1daf6ecbf3e22b26da8a4b56fe71d79b 100644 --- a/src/historytimecategorymodel.h +++ b/src/historytimecategorymodel.h @@ -38,25 +38,24 @@ public: Four_days_ago = 4 , Five_days_ago = 5 , Six_days_ago = 6 , - Last_week = 7 , + A_week_ago = 7 , Two_weeks_ago = 8 , Three_weeks_ago = 9 , - Four_weeks_ago = 10 , - Last_month = 11 , - Two_months_ago = 12 , - Three_months_ago = 13 , - Four_months_ago = 14 , - Five_months_ago = 15 , - Six_months_ago = 16 , - Seven_months_ago = 17 , - Eight_months_ago = 18 , - Nine_months_ago = 19 , - Ten_months_ago = 20 , - Eleven_months_ago = 21 , - Twelve_months_ago = 22 , - Last_year = 23 , - Very_long_time_ago= 24 , - Never = 25 , + A_month_ago = 10 , + Two_months_ago = 11 , + Three_months_ago = 12 , + Four_months_ago = 13 , + Five_months_ago = 14 , + Six_months_ago = 15 , + Seven_months_ago = 16 , + Eight_months_ago = 17 , + Nine_months_ago = 18 , + Ten_months_ago = 19 , + Eleven_months_ago = 20 , + Twelve_months_ago = 21 , + A_year_ago = 22 , + Very_long_time_ago= 23 , + Never = 24 , }; Q_ENUMS(HistoryConst) diff --git a/translations/lrc_en.ts b/translations/lrc_en.ts index 388914b08358498ef0abd3b72fdeef335bd2db74..17941eb934ba477f895ca448178bf2207e854510 100644 --- a/translations/lrc_en.ts +++ b/translations/lrc_en.ts @@ -203,7 +203,7 @@ <context> <name>CallModel</name> <message> - <location filename="../src/callmodel.cpp" line="848"/> + <location filename="../src/callmodel.cpp" line="856"/> <source>Calls</source> <translation type="unfinished"></translation> </message> @@ -211,7 +211,7 @@ <context> <name>CallModelPrivate</name> <message> - <location filename="../src/callmodel.cpp" line="520"/> + <location filename="../src/callmodel.cpp" line="528"/> <source>Invalid account</source> <translation type="unfinished"></translation> </message> @@ -363,11 +363,6 @@ <source>Yesterday</source> <translation type="unfinished"></translation> </message> - <message> - <location filename="../src/historytimecategorymodel.cpp" line="47"/> - <source>Last week</source> - <translation type="unfinished"></translation> - </message> <message> <location filename="../src/historytimecategorymodel.cpp" line="48"/> <source>Two weeks ago</source> @@ -379,82 +374,82 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="50"/> - <source>Four weeks ago</source> + <location filename="../src/historytimecategorymodel.cpp" line="47"/> + <source>A week ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="51"/> - <source>Last month</source> + <location filename="../src/historytimecategorymodel.cpp" line="50"/> + <source>A month ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="52"/> + <location filename="../src/historytimecategorymodel.cpp" line="51"/> <source>Two months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="53"/> + <location filename="../src/historytimecategorymodel.cpp" line="52"/> <source>Three months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="54"/> + <location filename="../src/historytimecategorymodel.cpp" line="53"/> <source>Four months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="55"/> + <location filename="../src/historytimecategorymodel.cpp" line="54"/> <source>Five months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="56"/> + <location filename="../src/historytimecategorymodel.cpp" line="55"/> <source>Six months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="57"/> + <location filename="../src/historytimecategorymodel.cpp" line="56"/> <source>Seven months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="58"/> + <location filename="../src/historytimecategorymodel.cpp" line="57"/> <source>Eight months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="59"/> + <location filename="../src/historytimecategorymodel.cpp" line="58"/> <source>Nine months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="60"/> + <location filename="../src/historytimecategorymodel.cpp" line="59"/> <source>Ten months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="61"/> + <location filename="../src/historytimecategorymodel.cpp" line="60"/> <source>Eleven months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="62"/> + <location filename="../src/historytimecategorymodel.cpp" line="61"/> <source>Twelve months ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="63"/> - <source>Last year</source> + <location filename="../src/historytimecategorymodel.cpp" line="62"/> + <source>A year ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="64"/> + <location filename="../src/historytimecategorymodel.cpp" line="63"/> <source>Very long time ago</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/historytimecategorymodel.cpp" line="65"/> + <location filename="../src/historytimecategorymodel.cpp" line="64"/> <source>Never</source> <translation type="unfinished"></translation> </message> @@ -1305,7 +1300,7 @@ <context> <name>RecentModel</name> <message> - <location filename="../src/recentmodel.cpp" line="341"/> + <location filename="../src/recentmodel.cpp" line="344"/> <source>Recent persons</source> <translation type="unfinished"></translation> </message>