Commit c4dd89e6 authored by Sergio Martins's avatar Sergio Martins
Browse files

EventViews::showDates() and setDateRange() now have an optional "preferredMonth" parameter.

For month-like views, this hint will be used to choose the correct month when the date range crosses months.

CCBUG: 258866
parent 34ac5278
......@@ -1384,8 +1384,9 @@ QDate AgendaView::endDate() const
return d->mSelectedDates.last();
}
void AgendaView::showDates( const QDate &start, const QDate &end )
void AgendaView::showDates( const QDate &start, const QDate &end, const QDate &preferredMonth )
{
Q_UNUSED( preferredMonth );
if ( !d->mSelectedDates.isEmpty() &&
d->mSelectedDates.first() == start &&
d->mSelectedDates.last() == end ) {
......
......@@ -155,7 +155,7 @@ class EVENTVIEWS_EXPORT AgendaView : public EventView
public slots:
virtual void updateView();
virtual void updateConfig();
virtual void showDates( const QDate &start, const QDate &end );
virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
void clearSelection();
......
......@@ -272,20 +272,14 @@ bool EventView::hasConfigurationDialog() const
return false;
}
void EventView::setDateRange( const KDateTime &start, const KDateTime &end )
void EventView::setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth )
{
Q_D( EventView );
#if 0
//AKONADI_PORT the old code called showDates() (below), which triggers a repaint,
//which the old code relies on
if ( d->startDateTime == start && d->endDateTime == end ) {
return;
}
#endif
d->startDateTime = start;
d->endDateTime = end;
showDates( start.date(), end.date() );
const QPair<KDateTime,KDateTime> adjusted = actualDateRange( start, end );
showDates( start.date(), end.date(), preferredMonth );
const QPair<KDateTime,KDateTime> adjusted = actualDateRange( start, end, preferredMonth );
d->actualStartDateTime = adjusted.first;
d->actualEndDateTime = adjusted.second;
}
......@@ -465,8 +459,10 @@ void EventView::doSaveConfig( KConfigGroup & )
}
QPair<KDateTime,KDateTime> EventView::actualDateRange( const KDateTime &start,
const KDateTime &end ) const
const KDateTime &end,
const QDate &preferredMonth ) const
{
Q_UNUSED( preferredMonth );
return qMakePair( start, end );
}
......
......@@ -115,7 +115,7 @@ class EVENTVIEWS_EXPORT EventView : public QWidget
/**
* Destructor. Views will do view-specific cleanups here.
*/
virtual ~EventView();
~EventView();
enum {
// This value is passed to QColor's lighter(int factor) for selected events
......@@ -241,7 +241,13 @@ class EVENTVIEWS_EXPORT EventView : public QWidget
*/
virtual EventView *viewAt( const QPoint &p );
virtual void setDateRange( const KDateTime &start, const KDateTime &end );
/*
* @param preferredMonth Used by month orientated views. Contains the month to show when the week crosses months.
* It's a QDate instead of uint so it can be easily feed to KCalendarSystem's
functions.
* */
virtual void setDateRange( const KDateTime &start, const KDateTime &end,
const QDate &preferredMonth = QDate() );
KDateTime startDateTime() const;
KDateTime endDateTime() const;
......@@ -475,17 +481,22 @@ class EVENTVIEWS_EXPORT EventView : public QWidget
/**
@deprecated
*/
virtual void showDates( const QDate &start, const QDate &end ) = 0;
virtual void showDates( const QDate &start, const QDate &end,
const QDate &preferredMonth = QDate() ) = 0;
/**
* from the requested date range (passed via setDateRange()), calculates the
* adjusted date range actually displayed by the view, depending on the
* view's supported range (e.g., a month view always displays one month)
* The default implementation returns the range unmodified
*
* @param preferredMonth Used by month orientated views. Contains the month to show when the week crosses months.
* It's a QDate instead of uint so it can be easily feed to KCalendarSystem's
* functions.
*/
virtual QPair<KDateTime,KDateTime> actualDateRange( const KDateTime &start,
const KDateTime &end ) const;
const KDateTime &end,
const QDate &preferredMonth = QDate() ) const;
/*
virtual void incidencesAdded( const Akonadi::Item::List &incidences );
virtual void incidencesAboutToBeRemoved( const Akonadi::Item::List &incidences );
......
......@@ -319,8 +319,9 @@ void ListView::updateView()
kDebug() << "not implemented yet";
}
void ListView::showDates( const QDate &start, const QDate &end )
void ListView::showDates( const QDate &start, const QDate &end, const QDate &preferredMonth )
{
Q_UNUSED( preferredMonth );
clear();
d->mStartDate = start;
......
......@@ -83,7 +83,7 @@ class EVENTVIEWS_EXPORT ListView : public EventView
public slots:
virtual void updateView();
virtual void showDates( const QDate &start, const QDate &end );
virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
void clearSelection();
......
......@@ -325,9 +325,9 @@ QDateTime MonthView::selectionEnd() const
return selectionStart();
}
void MonthView::setDateRange( const KDateTime &start, const KDateTime &end )
void MonthView::setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth )
{
EventView::setDateRange( start, end );
EventView::setDateRange( start, end, preferredMonth );
// d->calendarSearch->setStartDate( actualStartDateTime() );
// d->calendarSearch->setEndDate( actualEndDateTime() );
setChanges( changes() | DatesChanged );
......@@ -431,15 +431,19 @@ void MonthView::moveFwdMonth()
d->moveStartDate( 0, 1 );
}
void MonthView::showDates( const QDate &start, const QDate &end )
void MonthView::showDates( const QDate &start, const QDate &end, const QDate &preferedMonth )
{
Q_UNUSED( start );
Q_UNUSED( end );
Q_UNUSED( preferedMonth );
d->triggerDelayedReload( DatesChanged );
}
QPair<KDateTime,KDateTime> MonthView::actualDateRange( const KDateTime &start,
const KDateTime & ) const {
const KDateTime &,
const QDate &preferredMonth ) const
{
Q_UNUSED( preferredMonth );
KDateTime dayOne( start );
dayOne.setDate( QDate( start.date().year(), start.date().month(), 1 ) );
const int weekdayCol = ( dayOne.date().dayOfWeek() + 7 - KGlobal::locale()->weekStartDay() ) % 7;
......
......@@ -62,7 +62,7 @@ class EVENTVIEWS_EXPORT MonthView : public EventView
virtual QDateTime selectionEnd() const;
virtual void setDateRange( const KDateTime &start, const KDateTime &end );
virtual void setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth = QDate() );
virtual bool eventDurationHint( QDateTime &startDt, QDateTime &endDt, bool &allDay ) const;
......@@ -114,7 +114,8 @@ class EVENTVIEWS_EXPORT MonthView : public EventView
///* reimp */void incidencesAboutToBeRemoved( const Akonadi::Item::List &incidences );
///* reimp */void incidencesChanged( const Akonadi::Item::List &incidences );
/* reimp */QPair<KDateTime,KDateTime> actualDateRange( const KDateTime &start,
const KDateTime &end ) const;
const KDateTime &end,
const QDate &preferredMonth = QDate() ) const;
// Compute and update the whole view
void reloadIncidences();
......@@ -123,7 +124,7 @@ class EVENTVIEWS_EXPORT MonthView : public EventView
/**
* @deprecated
*/
void showDates( const QDate &start, const QDate &end );
void showDates( const QDate &start, const QDate &end, const QDate &preferedMonth = QDate() );
private:
MonthViewPrivate * const d;
......
......@@ -384,8 +384,9 @@ int MultiAgendaView::currentDateCount() const
return 0;
}
void MultiAgendaView::showDates( const QDate &start, const QDate &end )
void MultiAgendaView::showDates( const QDate &start, const QDate &end, const QDate &preferredMonth )
{
Q_UNUSED( preferredMonth );
d->mStartDate = start;
d->mEndDate = end;
slotResizeScrollView();
......
......@@ -69,7 +69,7 @@ class EVENTVIEWS_EXPORT MultiAgendaView : public EventView
void customCollectionsChanged( ConfigDialogInterface *dlg );
void showDates( const QDate &start, const QDate &end );
void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
void updateView();
void updateConfig();
......
......@@ -273,8 +273,9 @@ int TimelineView::currentDateCount() const
}
/*virtual*/
void TimelineView::showDates( const QDate &start, const QDate &end )
void TimelineView::showDates( const QDate &start, const QDate &end, const QDate &preferredMonth )
{
Q_UNUSED( preferredMonth );
Q_ASSERT_X( calendar(), "showDates()", "set a CalendarSupport::Calendar" );
Q_ASSERT_X( start.isValid(), "showDates()", "start date must be valid" );
Q_ASSERT_X( end.isValid(), "showDates()", "end date must be valid" );
......
......@@ -49,7 +49,7 @@ class EVENTVIEWS_EXPORT TimelineView : public EventView
virtual int currentDateCount() const;
// ensure start and end are valid before calling this.
virtual void showDates( const QDate &, const QDate & );
virtual void showDates( const QDate &, const QDate &, const QDate &preferredMonth = QDate() );
// FIXME: we already have startDateTime() in the base class
// why aren't we using it.
......
......@@ -127,16 +127,12 @@ bool BaseView::hasConfigurationDialog() const
return false;
}
void BaseView::setDateRange( const KDateTime& start, const KDateTime& end )
void BaseView::setDateRange( const KDateTime& start, const KDateTime& end, const QDate &preferredMonth )
{
#if 0 //AKONADI_PORT the old code called showDates() (below), which triggers a repaint, which the old code relies on
if ( d->startDateTime == start && d->endDateTime == end )
return;
#endif
d->startDateTime = start;
d->endDateTime = end;
showDates( start.date(), end.date() );
const QPair<KDateTime,KDateTime> adjusted = actualDateRange( start, end );
showDates( start.date(), end.date(), preferredMonth );
const QPair<KDateTime,KDateTime> adjusted = actualDateRange( start, end, preferredMonth );
d->actualStartDateTime = adjusted.first;
d->actualEndDateTime = adjusted.second;
}
......@@ -233,8 +229,10 @@ void BaseView::calendarReset()
{
}
QPair<KDateTime,KDateTime> BaseView::actualDateRange( const KDateTime& start, const KDateTime& end ) const
QPair<KDateTime,KDateTime> BaseView::actualDateRange( const KDateTime& start, const KDateTime& end,
const QDate &preferredMonth ) const
{
Q_UNUSED( preferredMonth );
return qMakePair( start, end );
}
......
......@@ -201,7 +201,7 @@ class KORGANIZER_INTERFACES_EXPORT BaseView : public QWidget
@param start Start of date range.
@param end End of date range.
*/
virtual void setDateRange( const KDateTime &start, const KDateTime &end );
virtual void setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth = QDate() );
KDateTime startDateTime() const;
KDateTime endDateTime() const;
......@@ -387,14 +387,14 @@ class KORGANIZER_INTERFACES_EXPORT BaseView : public QWidget
/**
@deprecated
*/
virtual void showDates( const QDate& start, const QDate& end ) = 0;
virtual void showDates( const QDate& start, const QDate& end, const QDate &preferredMonth = QDate() ) = 0;
/**
* from the requested date range (passed via setDateRange()), calculates the adjusted date range actually displayed by the view, depending
* on the view's supported range (e.g., a month view always displays one month)
* The default implementation returns the range unmodified
*/
virtual QPair<KDateTime,KDateTime> actualDateRange( const KDateTime& start, const KDateTime& end ) const;
virtual QPair<KDateTime,KDateTime> actualDateRange( const KDateTime& start, const KDateTime& end, const QDate &preferredMonth = QDate() ) const;
protected Q_SLOTS:
virtual void calendarReset();
......
......@@ -234,7 +234,7 @@ void KOAgendaView::updateConfig()
d->mAgendaView->updateConfig();
}
void KOAgendaView::showDates( const QDate &start, const QDate &end )
void KOAgendaView::showDates( const QDate &start, const QDate &end, const QDate & )
{
d->mAgendaView->showDates( start, end );
}
......@@ -342,7 +342,7 @@ void KOAgendaView::setChanges( EventViews::EventView::Changes changes )
d->mAgendaView->setChanges( c | d->mAgendaView->changes() );
}
void KOAgendaView::setDateRange( const KDateTime &start, const KDateTime &end )
void KOAgendaView::setDateRange( const KDateTime &start, const KDateTime &end, const QDate & )
{
d->mAgendaView->setDateRange( start, end );
}
......
......@@ -86,12 +86,12 @@ class KOAgendaView : public KOEventView
void setChanges( EventViews::EventView::Changes changes );
/** reimpl */
void setDateRange( const KDateTime &start, const KDateTime &end );
void setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth = QDate() );
public slots:
virtual void updateView();
virtual void updateConfig();
virtual void showDates( const QDate &start, const QDate &end );
virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
void changeIncidenceDisplayAdded( const Akonadi::Item &incidence );
......
......@@ -137,7 +137,7 @@ void KOJournalView::flushView()
emit flushEntries();
}
void KOJournalView::showDates( const QDate &start, const QDate &end )
void KOJournalView::showDates( const QDate &start, const QDate &end, const QDate & )
{
clearEntries();
if ( end<start ) {
......
......@@ -66,7 +66,7 @@ class KOJournalView : public KOrg::BaseView
void updateView();
void flushView();
void showDates( const QDate &start, const QDate &end );
void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
void showIncidences( const Akonadi::Item::List &incidences, const QDate &date );
void changeIncidenceDisplay( const Akonadi::Item &incidence, int );
......
......@@ -168,7 +168,7 @@ void KOListView::updateView()
mListView->updateView();
}
void KOListView::showDates( const QDate &start, const QDate &end )
void KOListView::showDates( const QDate &start, const QDate &end, const QDate & )
{
mListView->showDates( start, end );
}
......
......@@ -80,7 +80,7 @@ class KOListView : public KOEventView
public slots:
virtual void updateView();
virtual void showDates( const QDate &start, const QDate &end );
virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
void clearSelection();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment