2
This file is part of libkcal.
4
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA.
29
#include <QHBoxLayout>
30
#include <QGridLayout>
33
#include <QIntValidator>
37
#include <krestrictedline.h>
38
#include <categoryselectdialog.h>
40
#include "resourcekabc.h"
41
#include "resourcekabcconfig.h"
45
ResourceKABCConfig::ResourceKABCConfig( QWidget* parent )
46
: KRES::ConfigWidget( parent )
48
QGridLayout *topLayout = new QGridLayout( this );
49
topLayout->setSpacing( 6 );
50
topLayout->setMargin( 11 );
52
mAlarm = new QCheckBox(i18n("Set reminder"), this);
53
topLayout->addWidget(mAlarm, 0, 0, 1, 2);
55
mALabel = new QLabel(i18n("Reminder before (in days):"),this);
56
topLayout->addWidget(mALabel, 1, 0 );
57
mAlarmTimeEdit = new KLineEdit(this);
58
mAlarmTimeEdit->setValidator(new QIntValidator(mAlarmTimeEdit));
59
mAlarmTimeEdit->setText("0");
60
topLayout->addWidget(mAlarmTimeEdit, 1, 1 );
62
QFrame *line = new QFrame( this );
63
line->setFrameStyle( QFrame::Sunken | QFrame::HLine );
64
topLayout->addWidget( line, 2, 0, 1, 2 );
66
mUseCategories = new QCheckBox( i18n( "Filter by categories" ), this );
67
topLayout->addWidget( mUseCategories, 3, 0, 1, 2 );
69
KABPrefs *prefs = KABPrefs::instance();
70
mCategoryView = new KPIM::CategorySelectWidget(this,prefs);
71
mCategoryView->setCategories(prefs->customCategories());
72
mCategoryView->hideHeader();
73
mCategoryView->hideButton();
74
mCategoryView->setEnabled( false );
75
topLayout->addWidget( mCategoryView, 4, 0, 1, 2 );
77
connect( mUseCategories, SIGNAL( toggled( bool ) ),
78
mCategoryView, SLOT( setEnabled( bool ) ) );
81
mAlarmTimeEdit->setDisabled(true);
82
mALabel->setDisabled(true);
84
connect(mAlarm, SIGNAL(clicked()), SLOT(alarmClicked()));
90
void ResourceKABCConfig::loadSettings( KRES::Resource *resource )
92
ResourceKABC *res = static_cast<ResourceKABC *>( resource );
94
mAlarm->setChecked( res->alarm() );
96
mAlarmTimeEdit->setText( days.setNum(res->alarmDays()) );
98
mAlarmTimeEdit->setEnabled( res->alarm() );
99
mALabel->setEnabled( res->alarm() );
101
const QStringList categories = res->categories();
102
// mCategoryView->setSelected(categories);
103
mUseCategories->setChecked( res->useCategories() );
105
kDebug(5700) <<"ERROR: ResourceKABCConfig::loadSettings(): no ResourceKABC, cast failed";
109
void ResourceKABCConfig::saveSettings( KRES::Resource *resource )
111
ResourceKABC *res = static_cast<ResourceKABC *>( resource );
113
res->setAlarm( mAlarm->isChecked() );
114
res->setAlarmDays( mAlarmTimeEdit->text().toInt() );
117
QStringList categories;
118
QString categoriesStr;
119
// categories = mCategoryView->selectedCategories(categoriesStr);
120
res->setCategories( categories );
121
res->setUseCategories( mUseCategories->isChecked() );
123
kDebug(5700) <<"ERROR: ResourceKABCConfig::saveSettings(): no ResourceKABC, cast failed";
127
void ResourceKABCConfig::alarmClicked()
129
mAlarmTimeEdit->setDisabled(!mAlarm->isChecked());
130
mALabel->setDisabled(!mAlarm->isChecked());
133
#include "resourcekabcconfig.moc"