• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • plugins
  • specialdates
kcmsdsummary.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5  Copyright (c) 2004-2006,2009 Allen Winter <winter@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "kcmsdsummary.h"
27 
28 #include <KAboutData>
29 #include <KAcceleratorManager>
30 #include <KComponentData>
31 
32 extern "C"
33 {
34  KDE_EXPORT KCModule *create_sdsummary( QWidget *parent, const char * )
35  {
36  KComponentData inst( "kcmsdsummary" );
37  return new KCMSDSummary( inst, parent );
38  }
39 }
40 
41 KCMSDSummary::KCMSDSummary( const KComponentData &inst, QWidget *parent )
42  : KCModule( inst, parent )
43 {
44  setupUi( this );
45 
46  customDaysChanged( 7 );
47 
48  connect( mDateTodayButton, SIGNAL(clicked(bool)), SLOT(modified()) );
49  connect( mDateMonthButton, SIGNAL(clicked(bool)), SLOT(modified()) );
50  connect( mDateRangeButton, SIGNAL(clicked(bool)), SLOT(modified()) );
51 
52  connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(modified()) );
53  connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(customDaysChanged(int)) );
54 
55  connect( mShowBirthdaysFromCalBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
56  connect( mShowAnniversariesFromCalBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
57  connect( mShowHolidaysFromCalBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
58  connect( mShowSpecialsFromCalBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
59 
60  connect( mShowBirthdaysFromKABBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
61  connect( mShowAnniversariesFromKABBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
62 
63  connect( mShowMineOnly, SIGNAL(stateChanged(int)), SLOT(modified()) );
64 
65  KAcceleratorManager::manage( this );
66 
67  load();
68 }
69 
70 void KCMSDSummary::modified()
71 {
72  emit changed( true );
73 }
74 
75 void KCMSDSummary::buttonClicked( int id )
76 {
77  mCustomDays->setEnabled( id == 2 );
78 }
79 
80 void KCMSDSummary::customDaysChanged( int value )
81 {
82  mCustomDays->setSuffix( i18np( " day", " days", value ) );
83 }
84 
85 void KCMSDSummary::load()
86 {
87  KConfig config( QLatin1String("kcmsdsummaryrc") );
88 
89  KConfigGroup group = config.group( "Days" );
90  int days = group.readEntry( "DaysToShow", 7 );
91  if ( days == 1 ) {
92  mDateTodayButton->setChecked( true );
93  } else if ( days == 31 ) {
94  mDateMonthButton->setChecked( true );
95  } else {
96  mDateRangeButton->setChecked( true );
97  mCustomDays->setValue( days );
98  mCustomDays->setEnabled( true );
99  }
100 
101  group = config.group( "Show" );
102 
103  mShowBirthdaysFromKABBox->setChecked( group.readEntry( "BirthdaysFromContacts", true ) );
104  mShowBirthdaysFromCalBox->setChecked( group.readEntry( "BirthdaysFromCalendar", true ) );
105 
106  mShowAnniversariesFromKABBox->setChecked( group.readEntry( "AnniversariesFromContacts", true ) );
107  mShowAnniversariesFromCalBox->setChecked( group.readEntry( "AnniversariesFromCalendar", true ) );
108 
109  mShowHolidaysFromCalBox->setChecked( group.readEntry( "HolidaysFromCalendar", true ) );
110 
111  mShowSpecialsFromCalBox->setChecked( group.readEntry( "SpecialsFromCalendar", true ) );
112 
113  group = config.group( "Groupware" );
114  mShowMineOnly->setChecked( group.readEntry( "ShowMineOnly", false ) );
115 
116  emit changed( false );
117 }
118 
119 void KCMSDSummary::save()
120 {
121  KConfig config( QLatin1String("kcmsdsummaryrc") );
122 
123  KConfigGroup group = config.group( "Days" );
124 
125  int days;
126  if ( mDateTodayButton->isChecked() ) {
127  days = 1;
128  } else if ( mDateMonthButton->isChecked() ) {
129  days = 31;
130  } else {
131  days = mCustomDays->value();
132  }
133  group.writeEntry( "DaysToShow", days );
134 
135  group = config.group( "Show" );
136 
137  group.writeEntry( "BirthdaysFromContacts", mShowBirthdaysFromKABBox->isChecked() );
138  group.writeEntry( "BirthdaysFromCalendar", mShowBirthdaysFromCalBox->isChecked() );
139 
140  group.writeEntry( "AnniversariesFromContacts", mShowAnniversariesFromKABBox->isChecked() );
141  group.writeEntry( "AnniversariesFromCalendar", mShowAnniversariesFromCalBox->isChecked() );
142 
143  group.writeEntry( "HolidaysFromCalendar", mShowHolidaysFromCalBox->isChecked() );
144 
145  group.writeEntry( "SpecialsFromCalendar", mShowSpecialsFromCalBox->isChecked() );
146 
147  group = config.group( "Groupware" );
148  group.writeEntry( "ShowMineOnly", mShowMineOnly->isChecked() );
149 
150  group.sync();
151  emit changed( false );
152 }
153 
154 void KCMSDSummary::defaults()
155 {
156  mDateRangeButton->setChecked( true );
157  mCustomDays->setValue( 7 );
158  mCustomDays->setEnabled( true );
159 
160  mShowBirthdaysFromKABBox->setChecked( true );
161  mShowBirthdaysFromCalBox->setChecked( true );
162  mShowAnniversariesFromKABBox->setChecked( true );
163  mShowAnniversariesFromCalBox->setChecked( true );
164  mShowHolidaysFromCalBox->setChecked( true );
165  mShowSpecialsFromCalBox->setChecked( true );
166 
167  mShowMineOnly->setChecked( false );
168 
169  emit changed( true );
170 }
171 
172 const KAboutData *KCMSDSummary::aboutData() const
173 {
174  KAboutData *about = new KAboutData(
175  I18N_NOOP( "kcmsdsummary" ), 0,
176  ki18n( "Upcoming Special Dates Configuration Dialog" ),
177  0, KLocalizedString(), KAboutData::License_GPL,
178  ki18n( "Copyright © 2004 Tobias Koenig\n"
179  "Copyright © 2004–2010 Allen Winter" ) );
180 
181  about->addAuthor( ki18n( "Allen Winter" ), KLocalizedString(), "winter@kde.org" );
182  about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
183 
184  return about;
185 }
186 
QWidget
KCMSDSummary::load
virtual void load()
Definition: kcmsdsummary.cpp:85
KCMSDSummary::KCMSDSummary
KCMSDSummary(const KComponentData &inst, QWidget *parent=0)
Definition: kcmsdsummary.cpp:41
create_sdsummary
KCModule * create_sdsummary(QWidget *parent, const char *)
Definition: kcmsdsummary.cpp:34
KCMSDSummary::defaults
virtual void defaults()
Definition: kcmsdsummary.cpp:154
KCMSDSummary
Definition: kcmsdsummary.h:32
QLatin1String
kcmsdsummary.h
KCMSDSummary::aboutData
virtual const KAboutData * aboutData() const
Definition: kcmsdsummary.cpp:172
KCModule
KCMSDSummary::save
virtual void save()
Definition: kcmsdsummary.cpp:119
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal