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

Clicking on a week number will select the correct month in month view.

CCBUG: 258866
parent 2e0e489c
......@@ -443,9 +443,8 @@ QPair<KDateTime,KDateTime> MonthView::actualDateRange( const KDateTime &start,
const KDateTime &,
const QDate &preferredMonth ) const
{
Q_UNUSED( preferredMonth );
KDateTime dayOne( start );
dayOne.setDate( QDate( start.date().year(), start.date().month(), 1 ) );
KDateTime dayOne = preferredMonth.isValid() ? KDateTime( preferredMonth ) : start;
dayOne.setDate( QDate( dayOne.date().year(), dayOne.date().month(), 1 ) );
const int weekdayCol = ( dayOne.date().dayOfWeek() + 7 - KGlobal::locale()->weekStartDay() ) % 7;
KDateTime actualStart = dayOne.addDays( -weekdayCol );
actualStart.setTime( QTime( 0, 0, 0, 0 ) );
......
......@@ -838,6 +838,7 @@ void CalendarView::changeIncidenceDisplay( const Akonadi::Item &item, int action
}
void CalendarView::updateView( const QDate &start, const QDate &end,
const QDate &preferredMonth,
const bool updateTodos )
{
const bool currentViewIsTodoView = mViewManager->currentView()->identifier() == "DefaultTodoView";
......@@ -848,7 +849,7 @@ void CalendarView::updateView( const QDate &start, const QDate &end,
}
if ( start.isValid() && end.isValid() && !( currentViewIsTodoView && !updateTodos ) ) {
mViewManager->updateView( start, end );
mViewManager->updateView( start, end, preferredMonth );
}
mDateNavigatorContainer->updateView();
......@@ -859,7 +860,7 @@ void CalendarView::updateView()
DateList tmpList = mDateNavigator->selectedDates();
// We assume that the navigator only selects consecutive days.
updateView( tmpList.first(), tmpList.last() );
updateView( tmpList.first(), tmpList.last(), QDate() /**preferredMonth*/ );
}
void CalendarView::updateUnmanagedViews()
......@@ -2166,7 +2167,7 @@ void CalendarView::showDates( const DateList &selectedDates, const QDate &prefer
mNavigatorBar->selectDates( selectedDates );
if ( mViewManager->currentView() ) {
updateView( selectedDates.first(), selectedDates.last(), false );
updateView( selectedDates.first(), selectedDates.last(), preferredMonth, false );
} else {
mViewManager->showAgendaView();
}
......
......@@ -465,7 +465,7 @@ class KORGANIZERPRIVATE_EXPORT CalendarView : public KOrg::CalendarViewBase,
void startMultiModify( const QString &text );
void endMultiModify();
void updateView( const QDate &start, const QDate &end, const bool updateTodos=true );
void updateView( const QDate &start, const QDate &end, const QDate &preferredMonth, const bool updateTodos=true );
void updateView();
void updateUnmanagedViews();
......
......@@ -277,10 +277,10 @@ void KOViewManager::updateView()
}
}
void KOViewManager::updateView( const QDate &start, const QDate &end )
void KOViewManager::updateView( const QDate &start, const QDate &end, const QDate &preferredMonth )
{
if ( mCurrentView && mCurrentView != mTodoView ) {
mCurrentView->setDateRange( KDateTime( start ), KDateTime( end ) );
mCurrentView->setDateRange( KDateTime( start ), KDateTime( end ), preferredMonth );
} else if ( mTodoView ) {
mTodoView->updateView();
}
......
......@@ -96,7 +96,7 @@ class KOViewManager : public QObject
void setDocumentId( const QString & );
void updateView();
void updateView( const QDate &start, const QDate &end );
void updateView( const QDate &start, const QDate &end, const QDate &preferredMonth );
void goMenu( bool enable );
void raiseCurrentView();
......
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