[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.5/kdepim/korganizer
From: Sergio Luis Martins <iamsergio () gmail ! com>
Date: 2010-07-31 20:24:39
Message-ID: 20100731202439.A0831AC783 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1157668 by smartins:
Renamed:
QHash<QString, bool> areWorkDays(...)
to:
QList<QDate> workDays(...)
Saner.
M +2 -2 kodaymatrix.cpp
M +11 -7 koglobals.cpp
M +2 -4 koglobals.h
M +8 -2 views/monthview/monthscene.cpp
--- branches/KDE/4.5/kdepim/korganizer/kodaymatrix.cpp #1157667:1157668
@@ -772,7 +772,7 @@
p.setPen( actcol );
QPen tmppen;
- const QHash<QString, bool> workDaysHash = KOGlobals::self()->areWorkDays( \
mDays[0], mDays[NUMDAYS-1] ); + const QList<QDate> workDays = \
KOGlobals::self()->workDays( mDays[0], mDays[NUMDAYS-1] ); for ( int i = 0; i < \
NUMDAYS; ++i ) { row = i / 7;
col = isRTL ? 6 - ( i - row * 7 ) : i - row * 7;
@@ -792,7 +792,7 @@
p.setPen( actcol );
}
- const bool holiday = !workDaysHash[mDays[i].toString()];
+ const bool holiday = !workDays.contains( mDays[i] );
QColor holidayColorShaded =
getShadedColor( KOPrefs::instance()->agendaHolidaysBackgroundColor() );
--- branches/KDE/4.5/kdepim/korganizer/koglobals.cpp #1157667:1157668
@@ -29,7 +29,6 @@
#include "reminderclient.h"
#include <kholidays/holidays.h>
-using namespace KHolidays;
#include <k3staticdeleter.h>
#include <kdebug.h>
@@ -46,6 +45,8 @@
#include <QPixmap>
#include <QIcon>
+using namespace KHolidays;
+
KOGlobals *KOGlobals::mSelf = 0;
static K3StaticDeleter<KOGlobals> koGlobalsDeleter;
@@ -115,14 +116,13 @@
bool KOGlobals::isWorkDay( const QDate &date ) const
{
- QHash<QString, bool> days = areWorkDays( date, date );
- return days[date.toString()];
+ return workDays( date, date ).contains( date );
}
-QHash<QString,bool> KOGlobals::areWorkDays( const QDate &startDate,
+QList<QDate> KOGlobals::workDays( const QDate &startDate,
const QDate &endDate ) const
{
- QHash<QString,bool> result;
+ QList<QDate> result;
const int mask( ~( KOPrefs::instance()->mWorkWeekMask ) );
@@ -130,17 +130,21 @@
for ( int i = 0; i < numDays; ++i ) {
const QDate date = startDate.addDays( i );
- result.insert( date.toString(), !( mask & ( 1 << ( date.dayOfWeek() - 1 ) ) ) );
+ if ( !( mask & ( 1 << ( date.dayOfWeek() - 1 ) ) ) ) {
+ result.append( date );
}
+ }
if ( mHolidays && KOPrefs::instance()->mExcludeHolidays ) {
const Holiday::List list = mHolidays->holidays( startDate, endDate );
for ( int i = 0; i < list.count(); ++i ) {
const Holiday &h = list.at( i );
const QString dateString = h.date().toString();
- result[dateString] = result[dateString] && h.dayType() != Holiday::NonWorkday;
+ if ( h.dayType() == Holiday::NonWorkday ) {
+ result.removeAll( h.date() );
}
}
+ }
return result;
}
--- branches/KDE/4.5/kdepim/korganizer/koglobals.h #1157667:1157668
@@ -61,11 +61,9 @@
/**
- Returns which days between @p start and @end are work days.
- The returned hash will have start.daysTo( end ) + 1 elements.
- They key is QDate::toString()
+ Returns a list containing work days between @p start and @end.
*/
- QHash<QString,bool> areWorkDays( const QDate &start, const QDate &end ) const;
+ QList<QDate> workDays( const QDate &start, const QDate &end ) const;
int getWorkWeekMask();
--- branches/KDE/4.5/kdepim/korganizer/views/monthview/monthscene.cpp \
#1157667:1157668 @@ -239,11 +239,17 @@
int columnWidth = mScene->columnWidth();
int rowHeight = mScene->rowHeight();
- for ( QDate d = mMonthView->actualStartDateTime().date(); d <= \
mMonthView->actualEndDateTime().date(); d = d.addDays( 1 ) ) { +
+ const QList<QDate> workDays = KOGlobals::self()->workDays( \
mMonthView->actualStartDateTime().date(), + \
mMonthView->actualEndDateTime().date() ); +
+ for ( QDate d = mMonthView->actualStartDateTime().date();
+ d <= mMonthView->actualEndDateTime().date();
+ d = d.addDays( 1 ) ) {
MonthCell *cell = mScene->mMonthCellMap[ d ];
QColor color;
- if ( KOGlobals::self()->isWorkDay( d ) ) {
+ if ( workDays.contains( d ) ) {
color = KOPrefs::instance()->monthGridWorkHoursBackgroundColor();
} else {
color = KOPrefs::instance()->monthGridBackgroundColor();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic