32 #include <KCalendarSystem>
34 #include <KLocalizedString>
47 return mSelectedDates;
52 return mSelectedDates.count();
57 if ( dateList.count() > 0 ) {
58 mSelectedDates = dateList;
68 kDebug() <<
"an invalid date was passed as a parameter!";
71 mSelectedDates.clear();
72 mSelectedDates.append( d );
79 count = qMin( count, static_cast<int>( MAX_SELECTABLE_DAYS ) );
84 const QDate &preferredMonth )
86 KCalCore::DateList dates;
89 for ( i = 0; i < count; ++i ) {
93 mSelectedDates = dates;
99 int dateCount = mSelectedDates.count();
100 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
101 if ( weekStart && dateCount == 7 ) {
116 const int weekStart = KGlobal::locale()->weekStartDay();
120 if ( weekStart != 1 && dayOfWeek < weekStart ) {
121 firstDate = firstDate.
addDays( -7 );
134 const int weekStart = KGlobal::locale()->weekStartDay();
138 if ( weekStart != 1 && dayOfWeek < weekStart ) {
139 currentDate = currentDate.
addDays( -7 );
142 mSelectedDates.clear();
145 for (
int i = 0; i < 7; ++i ) {
146 if ( ( 1 << ( ( i + weekStart + 6 ) % 7 ) ) & (mask) ) {
147 mSelectedDates.append( currentDate.
addDays( i ) );
158 int dateCount = mSelectedDates.count();
160 if ( dateCount == 7 ) {
162 }
else if ( dateCount == 5 ) {
171 QDate firstSelected = mSelectedDates.first();
179 const QDate &selectionLowerLimit,
180 const QDate &selectionUpperLimit )
182 shiftMonth( currentMonth,
190 QDate firstSelected = mSelectedDates.first();
191 const int weekDay = firstSelected.
dayOfWeek();
199 QDate firstSelected = mSelectedDates.first();
200 const int weekDay = firstSelected.
dayOfWeek();
207 void DateNavigator::shiftMonth(
const QDate ¤tMonth,
208 const QDate &selectionLowerLimit,
209 const QDate &selectionUpperLimit,
214 QDate firstSelected = mSelectedDates.first();
215 const int weekDay = firstSelected.
dayOfWeek();
216 firstSelected = calSys->
addMonths( firstSelected, offset );
223 calSys->addMonths( currentMonth, offset ) : firstSelected;
228 if ( selectionLowerLimit.
isValid() &&
229 firstSelected < selectionLowerLimit ) {
230 firstSelected = selectionLowerLimit;
231 }
else if ( selectionUpperLimit.
isValid() &&
232 firstSelected > selectionUpperLimit ) {
233 firstSelected = selectionUpperLimit.
addDays( -6 );
240 const QDate &selectionLowerLimit,
241 const QDate &selectionUpperLimit )
243 shiftMonth( currentMonth,
251 QDate firstSelected = mSelectedDates.first();
283 QDate firstSelected =
QDate( mSelectedDates.first().year(), month, 1 );
285 int day = calSys->
day( firstSelected );
286 calSys->setDate( firstSelected, calSys->
year( firstSelected ), month, 1 );
287 int days = calSys->daysInMonth( firstSelected );
293 QDate requestedMonth;
294 calSys->
setDate( firstSelected, calSys->
year( firstSelected ), month, day );
295 calSys->setDate( requestedMonth, calSys->
year( firstSelected ), month, 1 );
302 QDate firstSelected = mSelectedDates.first();
306 const int weekDay = firstSelected.
dayOfWeek();
void selectDate(const QDate &)
void selectMonth(int month)
void selectPreviousYear()
void selectWeekByDay(int weekDay, const QDate &, const QDate &preferredMonth=QDate())
QDate addMonths(int nmonths) const
void selectDates(const KCalCore::DateList &, const QDate &preferredMonth=QDate())
KCalCore::DateList selectedDates()
void selectPreviousWeek()
void selectPreviousMonth(const QDate ¤tMonth=QDate(), const QDate &selectionLowerLimit=QDate(), const QDate &selectionUpperLimit=QDate())
void selectNextMonth(const QDate ¤tMonth=QDate(), const QDate &selectionLowerLimit=QDate(), const QDate &selectionUpperLimit=QDate())
const KCalendarSystem * calendarSystem() const
static KOGlobals * self()
DateNavigator(QObject *parent=0)
bool setDate(int year, int month, int day)
void emitSelected(const QDate &preferredMonth=QDate())
void datesSelected(const KCalCore::DateList &, const QDate &preferredMonth)
void selectYear(int year)
QDate addDays(int ndays) const