Bug 260267 - calendar configuration: a lot of time fields not changable
Summary: calendar configuration: a lot of time fields not changable
Status: VERIFIED FIXED
Alias: None
Product: KOrganizer Mobile
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Windows CE Microsoft Windows CE
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-16 12:48 UTC by Ludwig Reiter
Modified: 2011-02-15 18:33 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
calendar config dialog: cursor in start time (20.68 KB, image/png)
2011-01-10 15:28 UTC, Ludwig Reiter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Reiter 2010-12-16 12:48:21 UTC
Version:           unspecified (using Devel) 
OS:                Windows CE

version: windows CE  2010-12-15 svn-1206816

in the calendar configure dialog a lot of time field like day start time and
office start time, office end time are not changable.


Reproducible: Always
Comment 1 Tobias Koenig 2011-01-04 06:43:31 UTC
Hej Ludwig,

what do you mean with 'not changeable'? Are the date/time input fields inactive or do they not respond to clicks? Can you provide a screenshot that illustrates the problem?

Ciao,
Tobias
Comment 2 Ludwig Reiter 2011-01-10 14:11:25 UTC
calendar config, first line
day starts at : 7:00
Click on the 7:00 
=> A cursor appears in the time. But I cannot change anything here.
(I will add an screenshot today.)
Comment 3 Ludwig Reiter 2011-01-10 15:28:40 UTC
Created attachment 55824 [details]
calendar config dialog: cursor in start time
Comment 4 Ludwig Reiter 2011-01-10 15:29:23 UTC
Added a screenshot.
Comment 5 Tobias Koenig 2011-01-12 10:23:38 UTC
commit f47b350036d750d984b2e7eee290de43502e156d
branch master
Author: Tobias Koenig <tokoe@kde.org>
Date:   Wed Jan 12 10:25:27 2011 +0100

    Use QML Clock in calendar config dialog
    
    Open the QML Clock like it's done in the 'New Appointment'
    dialog when changing a time.
    
    BUG: 260267

diff --git a/mobile/calendar/ConfigDialog.qml b/mobile/calendar/ConfigDialog.qml
index 99671ac..07ba08e 100644
--- a/mobile/calendar/ConfigDialog.qml
+++ b/mobile/calendar/ConfigDialog.qml
@@ -34,6 +34,30 @@ QML.Rectangle {
     configWidget.load();
   }
 
+  QML.Connections {
+    target: configWidget
+    onShowClockWidget: {
+       clockWidget.expand()
+       clockWidget.okEnabled = false
+
+       // set the initial values
+       clockWidget.hours = hour;
+       clockWidget.minutes = minute;
+    }
+  }
+
+  QML.Connections {
+    target: clockWidget
+    onTimeChanged: {
+      configWidget.setNewTime( hour, minute );
+    }
+  }
+
+  KPIM.ClockDialog {
+    id: clockWidget
+    anchors.fill: parent
+  }
+
   KPIM.DecoratedFlickable {
     id: configWidgetBox
     anchors.fill: parent
diff --git a/mobile/calendar/configwidget.cpp b/mobile/calendar/configwidget.cpp
index aa1a9ea..e117de1 100644
--- a/mobile/calendar/configwidget.cpp
+++ b/mobile/calendar/configwidget.cpp
@@ -32,32 +32,32 @@ using namespace CalendarSupport;
 ConfigWidget::ConfigWidget( QWidget *parent )
   : QWidget( parent )
 {
-  Ui_ConfigWidget ui;
-  ui.setupUi( this );
-
-  ui.kcfg_DayBegins->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
-  ui.kcfg_DailyStartingHour->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
-  ui.kcfg_DailyEndingHour->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
-  ui.kcfg_DefaultAppointmentTime->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
-
-  ui.kcfg_AgendaViewColorUsage->addItem( i18n( "Category inside, calendar outside" ) );
-  ui.kcfg_AgendaViewColorUsage->addItem( i18n( "Calendar inside, category outside" ) );
-  ui.kcfg_AgendaViewColorUsage->addItem( i18n( "Only category" ) );
-  ui.kcfg_AgendaViewColorUsage->addItem( i18n( "Only calendar" ) );
-
-  ui.kcfg_MonthViewColorUsage->addItem( i18n( "Category inside, calendar outside" ) );
-  ui.kcfg_MonthViewColorUsage->addItem( i18n( "Calendar inside, category outside" ) );
-  ui.kcfg_MonthViewColorUsage->addItem( i18n( "Only category" ) );
-  ui.kcfg_MonthViewColorUsage->addItem( i18n( "Only calendar" ) );
-
-  mHolidayCombo = ui.kcfg_HolidayRegion;
-  mWorkDays << ui.workingPeriodMonday;
-  mWorkDays << ui.workingPeriodTuesday;
-  mWorkDays << ui.workingPeriodWednesday;
-  mWorkDays << ui.workingPeriodThursday;
-  mWorkDays << ui.workingPeriodFriday;
-  mWorkDays << ui.workingPeriodSaturday;
-  mWorkDays << ui.workingPeriodSunday;
+  mUi = new Ui_ConfigWidget;
+  mUi->setupUi( this );
+
+  mUi->kcfg_DayBegins->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
+  mUi->kcfg_DailyStartingHour->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
+  mUi->kcfg_DailyEndingHour->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
+  mUi->kcfg_DefaultAppointmentTime->setProperty( "kcfg_property", QByteArray( "dateTime" ) );
+
+  mUi->kcfg_AgendaViewColorUsage->addItem( i18n( "Category inside, calendar outside" ) );
+  mUi->kcfg_AgendaViewColorUsage->addItem( i18n( "Calendar inside, category outside" ) );
+  mUi->kcfg_AgendaViewColorUsage->addItem( i18n( "Only category" ) );
+  mUi->kcfg_AgendaViewColorUsage->addItem( i18n( "Only calendar" ) );
+
+  mUi->kcfg_MonthViewColorUsage->addItem( i18n( "Category inside, calendar outside" ) );
+  mUi->kcfg_MonthViewColorUsage->addItem( i18n( "Calendar inside, category outside" ) );
+  mUi->kcfg_MonthViewColorUsage->addItem( i18n( "Only category" ) );
+  mUi->kcfg_MonthViewColorUsage->addItem( i18n( "Only calendar" ) );
+
+  mHolidayCombo = mUi->kcfg_HolidayRegion;
+  mWorkDays << mUi->workingPeriodMonday;
+  mWorkDays << mUi->workingPeriodTuesday;
+  mWorkDays << mUi->workingPeriodWednesday;
+  mWorkDays << mUi->workingPeriodThursday;
+  mWorkDays << mUi->workingPeriodFriday;
+  mWorkDays << mUi->workingPeriodSaturday;
+  mWorkDays << mUi->workingPeriodSunday;
 
   mManager = new KConfigDialogManager( this, Settings::self() );
 
@@ -86,15 +86,30 @@ ConfigWidget::ConfigWidget( QWidget *parent )
     mHolidayCombo->addItem( it.key(), it.value() );
   }
 
+  mUi->kcfg_DayBegins->installEventFilter( this );
+  mUi->kcfg_DailyStartingHour->installEventFilter( this );
+  mUi->kcfg_DailyEndingHour->installEventFilter( this );
+  mUi->kcfg_DefaultAppointmentTime->installEventFilter( this );
+
+  connect( this, SIGNAL( dayBeginsFocus( QObject* ) ), SLOT( showClock( QObject* ) ) );
+  connect( this, SIGNAL( dailyStartingHourFocus( QObject* ) ), SLOT( showClock( QObject* ) ) );
+  connect( this, SIGNAL( dailyEndingHourFocus( QObject* ) ), SLOT( showClock( QObject* ) ) );
+  connect( this, SIGNAL( defaultAppointmentTimeFocus( QObject* ) ), SLOT( showClock( QObject* ) ) );
+
   // UI workarounds for Maemo5
 #ifdef Q_WS_MAEMO_5
-  ui.kcfg_DayBegins->setEditable( false );
-  ui.kcfg_DailyStartingHour->setEditable( false );
-  ui.kcfg_DailyEndingHour->setEditable( false );
-  ui.kcfg_DefaultAppointmentTime->setEditable( false );
+  mUi->kcfg_DayBegins->setEditable( false );
+  mUi->kcfg_DailyStartingHour->setEditable( false );
+  mUi->kcfg_DailyEndingHour->setEditable( false );
+  mUi->kcfg_DefaultAppointmentTime->setEditable( false );
 #endif
 }
 
+ConfigWidget::~ConfigWidget()
+{
+  delete mUi;
+}
+
 void ConfigWidget::setPreferences( const EventViews::PrefsPtr &preferences )
 {
   mViewPrefs = preferences;
@@ -218,10 +233,50 @@ void ConfigWidget::saveToExternalSettings()
   mViewPrefs->writeConfig();
 }
 
+void ConfigWidget::showClock( QObject *object )
+{
+  setFocus();
+  mFocusedTimeWidget = qobject_cast<KPIM::KTimeEdit*>( object );
+  if ( !mFocusedTimeWidget )
+    return;
+
+  const QTime time = mFocusedTimeWidget->time();
+  emit showClockWidget( time.hour(), time.minute() );
+}
+
+void ConfigWidget::setNewTime( int hour, int minute )
+{
+  if ( mFocusedTimeWidget == 0 )
+    return;
+
+  mFocusedTimeWidget->setTime( QTime( hour, minute ) );
+}
+
+bool ConfigWidget::eventFilter( QObject *object, QEvent *event )
+{
+  if ( event->type() == QEvent::FocusIn ) {
+    if ( object == mUi->kcfg_DayBegins ) {
+      emit dayBeginsFocus( object );
+    } else if ( object == mUi->kcfg_DailyStartingHour ) {
+      emit dailyStartingHourFocus( object );
+    } else if ( object == mUi->kcfg_DailyEndingHour ) {
+      emit dailyEndingHourFocus( object );
+    } else if ( object == mUi->kcfg_DefaultAppointmentTime ) {
+      emit defaultAppointmentTimeFocus( object );
+    }
+
+    return true;
+  } else {
+    // standard event processing
+    return QObject::eventFilter( object, event );
+  }
+}
+
 DeclarativeConfigWidget::DeclarativeConfigWidget( QGraphicsItem *parent )
   : DeclarativeWidgetBase< ConfigWidget, MainView, &MainView::setConfigWidget>( parent )
 {
-  connect( this, SIGNAL(configChanged()), widget(), SIGNAL(configChanged()) );
+  connect( this, SIGNAL( configChanged() ), widget(), SIGNAL( configChanged() ) );
+  connect( widget(), SIGNAL( showClockWidget( int, int ) ), this, SIGNAL( showClockWidget( int, int ) ) );
 }
 
 DeclarativeConfigWidget::~DeclarativeConfigWidget()
@@ -239,4 +294,9 @@ void DeclarativeConfigWidget::save()
   emit configChanged();
 }
 
+void DeclarativeConfigWidget::setNewTime( int hour, int minute )
+{
+  widget()->setNewTime( hour, minute );
+}
+
 #include "configwidget.moc"
diff --git a/mobile/calendar/configwidget.h b/mobile/calendar/configwidget.h
index 2a7ec1f..ebbd4bc 100644
--- a/mobile/calendar/configwidget.h
+++ b/mobile/calendar/configwidget.h
@@ -32,6 +32,11 @@
 class KComboBox;
 class KConfigDialogManager;
 class QCheckBox;
+class Ui_ConfigWidget;
+
+namespace KPIM {
+class KTimeEdit;
+}
 
 class ConfigWidget : public QWidget
 {
@@ -39,6 +44,7 @@ class ConfigWidget : public QWidget
 
   public:
     explicit ConfigWidget( QWidget *parent = 0 );
+    ~ConfigWidget();
 
     void setPreferences( const EventViews::PrefsPtr &preferences );
 
@@ -46,17 +52,33 @@ class ConfigWidget : public QWidget
     void load();
     void save();
 
+    void setNewTime( int hour, int minute );
+
   Q_SIGNALS:
     void configChanged();
+    void showClockWidget( int hour, int minute );
+
+    void dayBeginsFocus( QObject *object );
+    void dailyStartingHourFocus( QObject *object );
+    void dailyEndingHourFocus( QObject *object );
+    void defaultAppointmentTimeFocus( QObject *object );
+
+  protected:
+    bool eventFilter( QObject *object, QEvent *event );
+
+  private Q_SLOTS:
+    void showClock( QObject *object );
 
   private:
     void loadFromExternalSettings();
     void saveToExternalSettings();
 
+    Ui_ConfigWidget *mUi;
     KConfigDialogManager *mManager;
     KComboBox *mHolidayCombo;
     QVector<QCheckBox*> mWorkDays;
     EventViews::PrefsPtr mViewPrefs;
+    KPIM::KTimeEdit *mFocusedTimeWidget;
 };
 
 class DeclarativeConfigWidget :
@@ -76,8 +98,11 @@ public QGraphicsProxyWidget
     void load();
     void save();
 
+    void setNewTime( int hour, int minute );
+
   Q_SIGNALS:
     void configChanged();
+    void showClockWidget( int hour, int minute );
 };
 
 #endif
diff --git a/mobile/calendar/mainview.cpp b/mobile/calendar/mainview.cpp
index 43ba8e4..2d86f4a 100644
--- a/mobile/calendar/mainview.cpp
+++ b/mobile/calendar/mainview.cpp
@@ -25,6 +25,7 @@
 #include "agendaviewitem.h"
 #include "calendaradaptor.h"
 #include "calendarinterface.h"
+#include "calendar/clockhelper.h"
 #include "calendar/incidenceview.h"
 #include "calendar/kcalitembrowseritem.h"
 #include "configwidget.h"
@@ -136,6 +137,7 @@ void MainView::doDelayedInit()
   qmlRegisterType<EventViews::MonthViewItem>( "org.kde.calendarviews", 4, 5, "MonthView" );
   qmlRegisterType<EventViews::TimelineViewItem>( "org.kde.calendarviews", 4, 5, "TimelineView" );
   qmlRegisterType<Qt::QmlDateEdit>( "org.qt", 4, 7, "QmlDateEdit" );
+  qmlRegisterType<ClockHelper>( "ClockHelper", 4, 5, "ClockHelper" );
   qmlRegisterUncreatableType<EventsGuiStateManager>( "org.kde.akonadi.events", 4, 5, "EventsGuiStateManager", QLatin1String( "This type is only exported for its enums" ) );
 
   m_calendar = new CalendarSupport::Calendar( entityTreeModel(), itemModel(), KSystemTimeZones::local() );
Comment 6 Ludwig Reiter 2011-01-18 12:33:27 UTC
test of description
version 2011-01-16 git-4d1bc61


Open calendar config.
Change day start time. okay
Try to change day end time. 
=> clock dialog wrong initialized. Textfield shows 9 o'clock should show 17 o'clock.

Not fixed.
Comment 7 Tobias Koenig 2011-01-18 14:59:27 UTC
Hej Ludwig,

can you give a step-by-step description please what exactly you are doing?
Because I can't reproduce it here with latest snapshot packages. The clock is intialized correctly and the selected date is shown in the date fields of the configuration dialog.

Ciao,
Tobias
Comment 8 Ludwig Reiter 2011-01-19 10:52:53 UTC
I did give a step-by-step instructions. See comment #6.
Okay. Once more...

Test:
1. Open calendar touch.
2. Choose Actions->Calendar->Calendar configuration
3. Scroll to day starts at/day ends at.
=> Time fields shows 8:00 start time, 17:00 end time.
4. Click on the 8:00 time field.
=> The time selection dialog opens(8:00 in clock, 8, 0 in fields on the right side)
5. Change it to 9:00
6. Press Okay. 
=> Config Dialog 9:00 starttime, 17:00 endtime.
7. Click on 17:00 time.
=> time selection dialog opens once more. Time of the clock 17:00, but the right fields show 9 and 0. (Error)
They should show 17 and 0.
Comment 9 Tobias Koenig 2011-01-19 15:43:09 UTC
Hej Ludwig,

I can't reproduce it here with (git-fc4ca32) (2011-01-17).
After clicking on the end time button, the clock dialog is opened and both, the analog clock and the text fields both show the right time.

Ciao,
Tobias
Comment 10 Ludwig Reiter 2011-01-21 12:54:00 UTC
Test with Calendar Touch (Windows CE) 2011-01-20 git-d974996

I can reproduce the problem here.
Comment 11 Ludwig Reiter 2011-01-21 13:05:24 UTC
Note in the text the time change 8:00->9:00 must be done with the digital text field to reproduce.
Comment 12 Tobias Koenig 2011-01-31 10:52:24 UTC
Hej,

by introducing the new time selection dialog this bug report does not apply anymore.

Ciao,
Tobias