35 #include <KCalendarSystem>
41 mHorizontalCount( 1 ), mVerticalCount( 1 ),
42 mIgnoreNavigatorUpdates( false )
45 mNavigatorView->setWhatsThis(
46 i18n(
"<qt><p>Select the dates you want to "
47 "display in KOrganizer's main view here. Hold the "
48 "mouse button to select more than one day.</p>"
49 "<p>Press the top buttons to browse to the next "
50 "/ previous months or years.</p>"
51 "<p>Each line shows a week. The number in the left "
52 "column is the number of the week in the year. "
53 "Press it to select the whole week.</p>"
61 qDeleteAll( mExtraViews );
67 SLOT(handleDatesSelectedSignal(KCalCore::DateList)) );
82 SLOT(handleWeekClickedSignal(QDate,QDate)) );
162 const QDate &preferredMonth )
164 if ( !dateList.isEmpty() ) {
165 QDate start( dateList.first() );
166 QDate end( dateList.last() );
167 QDate navfirst( mNavigatorView->
startDate() );
170 if ( !mExtraViews.isEmpty() ) {
171 navlast = mExtraViews.last()->endDate();
172 navsecond = mExtraViews.first()->startDate();
174 navlast = mNavigatorView->
endDate();
175 navsecond = navfirst;
182 const bool changingMonth =
183 ( preferredMonth.isValid() &&
184 calSys->month( mNavigatorView->
month() ) != calSys->month( preferredMonth ) );
186 if ( start < navfirst ||
188 ( end > navlast && start >= navsecond ) ||
191 if ( preferredMonth.isValid() ) {
198 if ( !mIgnoreNavigatorUpdates ) {
211 QDate baseDate = start;
212 if ( !mIgnoreNavigatorUpdates ) {
218 if ( !mIgnoreNavigatorUpdates ) {
227 kDebug() <<
"DateNavigatorContainer::resizeEvent()";
228 kDebug() <<
" CURRENT SIZE:" << size();
230 kDebug() <<
" SIZEHINT:" <<
sizeHint();
231 kDebug() <<
" MINIMUM SIZE:" << minimumSize();
238 QSize minSize = mNavigatorView->minimumSizeHint();
242 int verticalCount = size().height() / minSize.height();
243 int horizontalCount = size().width() / minSize.width();
245 if ( horizontalCount != mHorizontalCount || verticalCount != mVerticalCount ) {
246 int count = horizontalCount * verticalCount;
251 while ( count > ( mExtraViews.count() + 1 ) ) {
253 mExtraViews.append( n );
258 while ( count < ( mExtraViews.count() + 1 ) ) {
259 delete ( mExtraViews.last() );
260 mExtraViews.removeLast();
263 mHorizontalCount = horizontalCount;
264 mVerticalCount = verticalCount;
274 int height = size().height() / verticalCount;
275 int width = size().width() / horizontalCount;
278 if ( horizontalCount > 1 ) {
284 mNavigatorView->setGeometry( ( ( (
KOGlobals::self()->reverseLayout() ) ?
285 ( horizontalCount - 1 ) : 0 ) * width ),
287 for (
int i = 0; i < mExtraViews.count(); ++i ) {
288 int x = ( i + 1 ) % horizontalCount;
289 int y = ( i + 1 ) / horizontalCount;
296 if ( x + 1 == horizontalCount ) {
303 ( horizontalCount - 1 - x ) : x ) * width ),
304 y * height, width, height );
311 return mNavigatorView->minimumSizeHint();
316 return mNavigatorView->sizeHint();
321 bool highlightJournals )
const {
323 mNavigatorView->
setHighlightMode( highlightEvents, highlightTodos, highlightJournals );
335 const QPair<QDate,QDate> p = dateLimits( 1 );
344 const QPair<QDate,QDate> p = dateLimits( -1 );
351 QPair<QDate,QDate> DateNavigatorContainer::dateLimits(
int offset )
const
354 QDate firstMonth, lastMonth;
355 if ( mExtraViews.isEmpty() ) {
356 lastMonth = mNavigatorView->
month();
358 lastMonth = mExtraViews.last()->month();
361 firstMonth = calSys->addMonths( mNavigatorView->
month(), offset );
362 lastMonth = calSys->addMonths( lastMonth, offset );
367 return qMakePair( firstMonthBoundary.first, lastMonthBoundary.second );
372 if ( navigatorIndex == 0 ) {
373 return mNavigatorView->
month();
376 if ( navigatorIndex <= mExtraViews.count() && navigatorIndex >= 0 ) {
377 return mExtraViews[navigatorIndex-1]->month();
383 void DateNavigatorContainer::handleDatesSelectedSignal(
const KCalCore::DateList &dateList )
385 Q_ASSERT( sender() );
390 const QDate firstDate = dateList.first();
392 navigator = navigator ? navigator : qobject_cast<
KDateNavigator*>( sender() );
397 void DateNavigatorContainer::handleWeekClickedSignal(
const QDate &week,
const QDate & )
399 Q_ASSERT( sender() );
401 navigator = navigator ? navigator : qobject_cast<
KDateNavigator*>( sender() );
406 KDateNavigator *DateNavigatorContainer::firstNavigatorForDate(
const QDate &date )
const
409 if ( date.isValid() ) {
412 if ( date >= limits.first && date <= limits.second ) {
414 navigator = mNavigatorView;
419 if ( date >= limits.first && date <= limits.second ) {
431 #include "datenavigatorcontainer.moc"
void selectDates(const KCalCore::DateList &)
DateNavigatorContainer(QWidget *parent=0)
QDate monthOfNavigator(int navigatorIndex=0) const
Returns the month of the specified KDateNavigator.
void resizeEvent(QResizeEvent *)
static QPair< QDate, QDate > matrixLimits(const QDate &month)
returns the first and last date of the 6*7 matrix that displays month
void datesSelected(const KCalCore::DateList &, const QDate &preferredMonth)
NavigatorBar * navigatorBar() const
void setHighlightMode(bool highlightEvents, bool highlightTodos, bool highlightJournals) const
void incidenceDropped(const Akonadi::Item &, const QDate &)
KCalCore::DateList selectedDates() const
void newEventSignal(const QDate &)
void setCalendar(const Akonadi::ETMCalendar::Ptr &)
Associate date navigator with a calendar.
void incidenceDroppedMove(const Akonadi::Item &, const QDate &)
void newJournalSignal(const QDate &)
void nextMonthClicked(const QDate ¤tMonth, const QDate &selectionLowerLimit, const QDate &selectionUpperLimit)
~DateNavigatorContainer()
void connectNavigatorView(KDateNavigator *v)
void prevMonthClicked(const QDate ¤tMonth, const QDate &selectionLowerLimit, const QDate &selectionUpperLimit)
Signals that the previous month button has been clicked.
void setBaseDate(const QDate &)
QSize minimumSizeHint() const
void yearSelected(int year)
void weekClicked(const QDate &week, const QDate &preferredMonth)
void monthSelected(int month)
const KCalendarSystem * calendarSystem() const
static KOGlobals * self()
QDate month() const
Returns the current displayed month.
void showButtons(bool left, bool right)
void selectDates(const KCalCore::DateList &, const QDate &preferredMonth=QDate())
preferredMonth is useful when the datelist crosses months, if different from -1, it has the month tha...
void setHighlightMode(bool highlightEvents, bool highlightTodos, bool highlightJournals) const
void setBaseDates(const QDate &start)
void newTodoSignal(const QDate &)
void resizeAllContents()
Resizes all the child elements after the size of the widget changed.
void setCalendar(const Akonadi::ETMCalendar::Ptr &)
Associate date navigator with a calendar.