~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to kresources/birthdays/resourcekabcconfig.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of libkcal.
3
 
 
4
 
    Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
 
 
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.
10
 
 
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.
15
 
 
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.
20
 
*/
21
 
 
22
 
#include <typeinfo>
23
 
 
24
 
 
25
 
#include <QLayout>
26
 
//Added by qt3to4:
27
 
#include <QLabel>
28
 
#include <QFrame>
29
 
#include <QHBoxLayout>
30
 
#include <QGridLayout>
31
 
#include <QBoxLayout>
32
 
#include <QCheckBox>
33
 
#include <QIntValidator>
34
 
 
35
 
#include <kdebug.h>
36
 
#include <klocale.h>
37
 
#include <krestrictedline.h>
38
 
#include <categoryselectdialog.h>
39
 
 
40
 
#include "resourcekabc.h"
41
 
#include "resourcekabcconfig.h"
42
 
 
43
 
using namespace KCal;
44
 
 
45
 
ResourceKABCConfig::ResourceKABCConfig( QWidget* parent )
46
 
    : KRES::ConfigWidget( parent )
47
 
{
48
 
  QGridLayout *topLayout = new QGridLayout( this );
49
 
  topLayout->setSpacing( 6 );
50
 
  topLayout->setMargin( 11 );
51
 
 
52
 
  mAlarm = new QCheckBox(i18n("Set reminder"), this);
53
 
  topLayout->addWidget(mAlarm, 0, 0, 1, 2);
54
 
 
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 );
61
 
 
62
 
  QFrame *line = new QFrame( this );
63
 
  line->setFrameStyle( QFrame::Sunken | QFrame::HLine );
64
 
  topLayout->addWidget( line, 2, 0, 1, 2 );
65
 
 
66
 
  mUseCategories = new QCheckBox( i18n( "Filter by categories" ), this );
67
 
  topLayout->addWidget( mUseCategories, 3, 0, 1, 2 );
68
 
/*
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 );
76
 
 
77
 
  connect( mUseCategories, SIGNAL( toggled( bool ) ),
78
 
           mCategoryView, SLOT( setEnabled( bool ) ) );
79
 
*/
80
 
 
81
 
  mAlarmTimeEdit->setDisabled(true);
82
 
  mALabel->setDisabled(true);
83
 
 
84
 
  connect(mAlarm, SIGNAL(clicked()), SLOT(alarmClicked()));
85
 
 
86
 
  setReadOnly( true );
87
 
 
88
 
}
89
 
 
90
 
void ResourceKABCConfig::loadSettings( KRES::Resource *resource )
91
 
{
92
 
  ResourceKABC *res = static_cast<ResourceKABC *>( resource );
93
 
  if ( res ) {
94
 
    mAlarm->setChecked( res->alarm() );
95
 
    QString days;
96
 
    mAlarmTimeEdit->setText( days.setNum(res->alarmDays()) );
97
 
 
98
 
    mAlarmTimeEdit->setEnabled( res->alarm() );
99
 
    mALabel->setEnabled( res->alarm() );
100
 
 
101
 
    const QStringList categories = res->categories();
102
 
//    mCategoryView->setSelected(categories);
103
 
    mUseCategories->setChecked( res->useCategories() );
104
 
  } else {
105
 
    kDebug(5700) <<"ERROR: ResourceKABCConfig::loadSettings(): no ResourceKABC, cast failed";
106
 
  }
107
 
}
108
 
 
109
 
void ResourceKABCConfig::saveSettings( KRES::Resource *resource )
110
 
{
111
 
  ResourceKABC *res = static_cast<ResourceKABC *>( resource );
112
 
  if ( res ) {
113
 
    res->setAlarm( mAlarm->isChecked() );
114
 
    res->setAlarmDays( mAlarmTimeEdit->text().toInt() );
115
 
    setReadOnly( true );
116
 
 
117
 
    QStringList categories;
118
 
    QString categoriesStr;
119
 
//    categories = mCategoryView->selectedCategories(categoriesStr);
120
 
    res->setCategories( categories );
121
 
    res->setUseCategories( mUseCategories->isChecked() );
122
 
  } else {
123
 
    kDebug(5700) <<"ERROR: ResourceKABCConfig::saveSettings(): no ResourceKABC, cast failed";
124
 
  }
125
 
}
126
 
 
127
 
void ResourceKABCConfig::alarmClicked()
128
 
{
129
 
  mAlarmTimeEdit->setDisabled(!mAlarm->isChecked());
130
 
  mALabel->setDisabled(!mAlarm->isChecked());
131
 
}
132
 
 
133
 
#include "resourcekabcconfig.moc"