Bug 250256 - Window focuses on current date after finished edit event.
Summary: Window focuses on current date after finished edit event.
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: monthview (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-05 11:47 UTC by Fest
Modified: 2010-12-27 11:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fest 2010-09-05 11:47:57 UTC
Version:           unspecified (using KDE 4.5.0) 
OS:                Linux

It's pretty annoying when you want to create few events in upcoming months. After every event main window focus back on current date, and you need to scroll back to next month. 

Reproducible: Always

Steps to Reproduce:
1. Scroll down to next month.
2. Create event.
3. Click ok and close new event.

Actual Results:  
Window focus back to current date.

Expected Results:  
Window focus stays on date you're editing now.
Comment 1 Sergio Martins 2010-12-27 11:11:07 UTC
commit 257e6304b501b04c575051f8af7f960c355e881f
branch master
Author: Sergio Martins <iamsergio@gmail.com>
Date:   Mon Dec 27 02:01:22 2010 +0000

    When wheel scrolling in monthview, month view changed the displayed date range and didn't notify the application about it.
    
    BUG: 250256

diff --git a/calendarviews/eventviews/month/monthview.cpp b/calendarviews/eventviews/month/monthview.cpp
index afcd554..7d1e7c1 100644
--- a/calendarviews/eventviews/month/monthview.cpp
+++ b/calendarviews/eventviews/month/monthview.cpp
@@ -106,7 +106,29 @@ void MonthViewPrivate::moveStartDate( int weeks, int months )
   end = end.addDays( weeks * 7 );
   start = start.addMonths( months );
   end = end.addMonths( months );
+
+#ifndef KDEPIM_MOBILE_UI
+  KCalCore::DateList dateList;
+  QDate d = start.date();
+  while ( d <= end.date() ) {
+    dateList.append( d );
+    d = d.addDays( 1 );
+  }
+
+  /**
+   * If we call q->setDateRange( start, end ); directly,
+   * it will change the selected dates in month view,
+   * but the application won't know about it.
+   * The correct way is to emit datesSelected()
+   * #250256
+   * */
+  emit q->datesSelected( dateList );
+#else
+  // korg-mobile doesn't use korg's date navigator.
+  // Before creating a solution with no #ifndef, we must first extract the remaining views from
+  // korg, and review the API.
   q->setDateRange( start, end );
+#endif
 }
 
 /*
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3b6d6c2..415c0b3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -210,6 +210,9 @@ CalendarView::CalendarView( QWidget *parent )
   connect( mDateNavigatorContainer, SIGNAL(datesSelected(const KCalCore::DateList &)),
            mDateNavigator, SLOT(selectDates(const KCalCore::DateList &)) );
 
+  connect( mViewManager, SIGNAL(datesSelected(KCalCore::DateList)),
+           mDateNavigator, SLOT(selectDates(KCalCore::DateList)) );
+
   connect( mDateNavigatorContainer, SIGNAL(incidenceDropped(Akonadi::Item,QDate)),
            SLOT(addIncidenceOn(Akonadi::Item,QDate)) );
   connect( mDateNavigatorContainer, SIGNAL(incidenceDroppedMove(Akonadi::Item,QDate)),
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index a6ba6f2..d7840ba 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -294,6 +294,11 @@ void KOViewManager::connectView( KOrg::BaseView *view )
     return;
   }
 
+  if ( view->isEventView() ) {
+    connect( view, SIGNAL(datesSelected(KCalCore::DateList)),
+                   SIGNAL(datesSelected(KCalCore::DateList)) );
+  }
+
   // selecting an incidence
   connect( view, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
            mMainView, SLOT(processMainViewSelection(Akonadi::Item,QDate)) );
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index c00211f..6308499 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -136,6 +136,7 @@ class KOViewManager : public QObject
 
   signals:
     void configChanged();
+    void datesSelected(const KCalCore::DateList & );
 
   public slots:
     void showWhatsNextView();