[kde-doc-english] [kdepim-runtime] resources/google/calendar: Age limit option for items in Google Calendar

Dan Vrátil dvratil at redhat.com
Thu Mar 14 19:51:23 UTC 2013


Git commit e427b25088aab13d57792e8562dcc7cb97500ea9 by Dan Vrátil.
Committed on 14/03/2013 at 20:50.
Pushed by dvratil into branch 'master'.

Age limit option for items in Google Calendar

Fetch only events that occur after a specified date. The default
time span is three years. This filter does not take in account
recurrent events that have started before the set date (they
will be included nontheless).

FEATURE: 310173
FIXED-IN: 4.11
GUI:

M  +5    -0    resources/google/calendar/calendarresource.cpp
M  +2    -6    resources/google/calendar/settingsbase.kcfg
M  +25   -0    resources/google/calendar/settingsdialog.cpp
M  +4    -0    resources/google/calendar/settingsdialog.h

http://commits.kde.org/kdepim-runtime/e427b25088aab13d57792e8562dcc7cb97500ea9

diff --git a/resources/google/calendar/calendarresource.cpp b/resources/google/calendar/calendarresource.cpp
index 2ebf49d..cc8feec 100644
--- a/resources/google/calendar/calendarresource.cpp
+++ b/resources/google/calendar/calendarresource.cpp
@@ -134,6 +134,11 @@ void CalendarResource::retrieveItems( const Akonadi::Collection &collection )
         if ( !collection.remoteRevision().isEmpty() ) {
             fetchJob->setFetchOnlyUpdated( collection.remoteRevision().toULongLong() );
         }
+        if ( !Settings::self()->eventsSince().isEmpty() ) {
+            const QDate date = QDate::fromString( Settings::self()->eventsSince(), Qt::ISODate );
+            kDebug() << date << QDateTime(date) << QDateTime(date).toTime_t();
+            fetchJob->setTimeMin( QDateTime( date ).toTime_t() );
+        }
         job = fetchJob;
     } else if ( collection.contentMimeTypes().contains( KCalCore::Todo::todoMimeType() ) ) {
         TaskFetchJob *fetchJob = new TaskFetchJob( collection.remoteId(), account(), this );
diff --git a/resources/google/calendar/settingsbase.kcfg b/resources/google/calendar/settingsbase.kcfg
index 1bb10e4..f882d6b 100644
--- a/resources/google/calendar/settingsbase.kcfg
+++ b/resources/google/calendar/settingsbase.kcfg
@@ -16,12 +16,8 @@
       <default></default>
       <label>IDs of task lists in collection</label>
     </entry>
-    <entry name="RefreshInterval" type="Int">
-      <default>30</default>
-      <label>Refresh interval in minutes.</label>
-    </entry>
-    <entry name="RefreshEnabled" type="Bool">
-      <default>true</default>
+    <entry name="EventsSince" type="String">
+        <default></default>
     </entry>
   </group>
 </kcfg>
diff --git a/resources/google/calendar/settingsdialog.cpp b/resources/google/calendar/settingsdialog.cpp
index 34c04db..3a8f501 100644
--- a/resources/google/calendar/settingsdialog.cpp
+++ b/resources/google/calendar/settingsdialog.cpp
@@ -21,12 +21,14 @@
 #include <KDE/KLocalizedString>
 #include <KDE/KListWidget>
 #include <KDE/KPushButton>
+#include <KDE/KDateComboBox>
 
 #include <QtGui/QPixmap>
 #include <QtGui/QIcon>
 #include <QtGui/QListWidget>
 #include <QtGui/QGroupBox>
 #include <QtGui/QLayout>
+#include <QtGui/QLabel>
 #include <QtCore/QPointer>
 
 #include <LibKGAPI2/Account>
@@ -61,6 +63,25 @@ SettingsDialog::SettingsDialog( GoogleAccountManager *accountManager, WId window
     connect( m_reloadCalendarsBtn, SIGNAL(clicked(bool)),
              this, SLOT(slotReloadCalendars()) );
 
+    QHBoxLayout *hbox = new QHBoxLayout;
+    vbox->addLayout( hbox );
+
+    m_eventsLimitLabel = new QLabel( i18nc( "Followed by a date picker widget", "&Fetch only new events since" ), this );
+    hbox->addWidget( m_eventsLimitLabel );
+
+    m_eventsLimitCombo = new KDateComboBox( this );
+    m_eventsLimitLabel->setBuddy( m_eventsLimitCombo );
+    m_eventsLimitCombo->setMaximumDate( QDate::currentDate() );
+    m_eventsLimitCombo->setMinimumDate( QDate::fromString( QLatin1String( "2000-01-01" ), Qt::ISODate ) );
+    m_eventsLimitCombo->setOptions( KDateComboBox::EditDate | KDateComboBox::SelectDate |
+                                    KDateComboBox::DatePicker | KDateComboBox::WarnOnInvalid );
+    if( Settings::self()->eventsSince().isEmpty() ) {
+        const QString ds = QString::fromLatin1( "%1-01-01" ).arg( QString::number( QDate::currentDate().year() - 3 ) );
+        m_eventsLimitCombo->setDate( QDate::fromString( ds, Qt::ISODate ) );
+    } else {
+        m_eventsLimitCombo->setDate( QDate::fromString( Settings::self()->eventsSince(), Qt::ISODate ) );
+    }
+    hbox->addWidget( m_eventsLimitCombo );
 
     m_taskListsBox = new QGroupBox( i18n( "Tasklists" ), this );
     mainWidget()->layout()->addWidget( m_taskListsBox );
@@ -88,6 +109,7 @@ void SettingsDialog::saveSettings()
         Settings::self()->setAccount( QString() );
         Settings::self()->setCalendars( QStringList() );
         Settings::self()->setTaskLists( QStringList() );
+        Settings::self()->setEventsSince( QString() );
         Settings::self()->writeConfig();
         return;
     }
@@ -103,6 +125,9 @@ void SettingsDialog::saveSettings()
         }
     }
     Settings::self()->setCalendars( calendars );
+    if ( m_eventsLimitCombo->isValid() ) {
+        Settings::self()->setEventsSince( m_eventsLimitCombo->date().toString( Qt::ISODate ) );
+    }
 
     QStringList taskLists;
     for ( int i = 0; i < m_taskListsList->count(); i++ ) {
diff --git a/resources/google/calendar/settingsdialog.h b/resources/google/calendar/settingsdialog.h
index 7cdb1f0..574c35a 100644
--- a/resources/google/calendar/settingsdialog.h
+++ b/resources/google/calendar/settingsdialog.h
@@ -21,6 +21,8 @@
 #include "common/googlesettingsdialog.h"
 
 class KListWidget;
+class QLabel;
+class KDateComboBox;
 
 class SettingsDialog : public GoogleSettingsDialog
 {
@@ -43,6 +45,8 @@ class SettingsDialog : public GoogleSettingsDialog
     QGroupBox *m_calendarsBox;
     KListWidget *m_calendarsList;
     KPushButton *m_reloadCalendarsBtn;
+    QLabel *m_eventsLimitLabel;
+    KDateComboBox *m_eventsLimitCombo;
 
     QGroupBox *m_taskListsBox;
     KListWidget *m_taskListsList;


More information about the kde-doc-english mailing list