summaryrefslogtreecommitdiffstats
path: root/kontact/plugins/korganizer/kcmkorgsummary.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kontact/plugins/korganizer/kcmkorgsummary.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kontact/plugins/korganizer/kcmkorgsummary.cpp')
-rw-r--r--kontact/plugins/korganizer/kcmkorgsummary.cpp200
1 files changed, 200 insertions, 0 deletions
diff --git a/kontact/plugins/korganizer/kcmkorgsummary.cpp b/kontact/plugins/korganizer/kcmkorgsummary.cpp
new file mode 100644
index 000000000..9ab0b6838
--- /dev/null
+++ b/kontact/plugins/korganizer/kcmkorgsummary.cpp
@@ -0,0 +1,200 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qbuttongroup.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kaccelmanager.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include "kcmkorgsummary.h"
+
+#include <kdepimmacros.h>
+
+extern "C"
+{
+ KDE_EXPORT KCModule *create_korgsummary( QWidget *parent, const char * )
+ {
+ return new KCMKOrgSummary( parent, "kcmkorgsummary" );
+ }
+}
+
+KCMKOrgSummary::KCMKOrgSummary( QWidget *parent, const char *name )
+ : KCModule( parent, name )
+{
+ initGUI();
+
+ customDaysChanged( 1 );
+
+ connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) );
+ connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) );
+ connect( mTodoGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) );
+ connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( modified() ) );
+ connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( customDaysChanged( int ) ) );
+
+ KAcceleratorManager::manage( this );
+
+ load();
+
+ KAboutData *about = new KAboutData( I18N_NOOP( "kcmkorgsummary" ),
+ I18N_NOOP( "Schedule Configuration Dialog" ),
+ 0, 0, KAboutData::License_GPL,
+ I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) );
+
+ about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
+ setAboutData( about );
+}
+
+void KCMKOrgSummary::modified()
+{
+ emit changed( true );
+}
+
+void KCMKOrgSummary::buttonClicked( int id )
+{
+ mCustomDays->setEnabled( id == 4 );
+}
+
+void KCMKOrgSummary::customDaysChanged( int value )
+{
+ mCustomDays->setSuffix( i18n( " day", " days", value ) );
+}
+
+void KCMKOrgSummary::initGUI()
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
+
+ mCalendarGroup = new QButtonGroup( 0, Vertical, i18n( "Appointments" ), this );
+ QVBoxLayout *boxLayout = new QVBoxLayout( mCalendarGroup->layout(),
+ KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "How many days should the calendar show at once?" ), mCalendarGroup );
+ boxLayout->addWidget( label );
+
+ QRadioButton *button = new QRadioButton( i18n( "One day" ), mCalendarGroup );
+ boxLayout->addWidget( button );
+
+ button = new QRadioButton( i18n( "Five days" ), mCalendarGroup );
+ boxLayout->addWidget( button );
+
+ button = new QRadioButton( i18n( "One week" ), mCalendarGroup );
+ boxLayout->addWidget( button );
+
+ button = new QRadioButton( i18n( "One month" ), mCalendarGroup );
+ boxLayout->addWidget( button );
+
+ QHBoxLayout *hbox = new QHBoxLayout( boxLayout, KDialog::spacingHint() );
+
+ button = new QRadioButton( "", mCalendarGroup );
+ hbox->addWidget( button );
+
+ mCustomDays = new QSpinBox( 1, 365, 1, mCalendarGroup );
+ mCustomDays->setEnabled( false );
+ hbox->addWidget( mCustomDays );
+
+ hbox->addStretch( 1 );
+
+ layout->addWidget( mCalendarGroup );
+
+ mTodoGroup = new QButtonGroup( 2, Horizontal, i18n( "To-dos" ), this );
+ new QRadioButton( i18n( "Show all to-dos" ), mTodoGroup );
+ new QRadioButton( i18n( "Show today's to-dos only" ), mTodoGroup );
+
+ layout->addWidget( mTodoGroup );
+
+ layout->addStretch();
+}
+
+void KCMKOrgSummary::load()
+{
+ KConfig config( "kcmkorgsummaryrc" );
+
+ config.setGroup( "Calendar" );
+ int days = config.readNumEntry( "DaysToShow", 1 );
+ if ( days == 1 )
+ mCalendarGroup->setButton( 0 );
+ else if ( days == 5 )
+ mCalendarGroup->setButton( 1 );
+ else if ( days == 7 )
+ mCalendarGroup->setButton( 2 );
+ else if ( days == 31 )
+ mCalendarGroup->setButton( 3 );
+ else {
+ mCalendarGroup->setButton( 4 );
+ mCustomDays->setValue( days );
+ mCustomDays->setEnabled( true );
+ }
+
+ config.setGroup( "Todo" );
+ bool allTodos = config.readBoolEntry( "ShowAllTodos", false );
+
+ if ( allTodos )
+ mTodoGroup->setButton( 0 );
+ else
+ mTodoGroup->setButton( 1 );
+
+ emit changed( false );
+}
+
+void KCMKOrgSummary::save()
+{
+ KConfig config( "kcmkorgsummaryrc" );
+
+ config.setGroup( "Calendar" );
+
+ int days;
+ switch ( mCalendarGroup->selectedId() ) {
+ case 0: days = 1; break;
+ case 1: days = 5; break;
+ case 2: days = 7; break;
+ case 3: days = 31; break;
+ case 4:
+ default: days = mCustomDays->value(); break;
+ }
+ config.writeEntry( "DaysToShow", days );
+
+ config.setGroup( "Todo" );
+ config.writeEntry( "ShowAllTodos", mTodoGroup->selectedId() == 0 );
+
+ config.sync();
+
+ emit changed( false );
+}
+
+void KCMKOrgSummary::defaults()
+{
+ mCalendarGroup->setButton( 0 );
+ mTodoGroup->setButton( 1 );
+
+ emit changed( true );
+}
+
+#include "kcmkorgsummary.moc"