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

calendarsupport

  • sources
  • kde-4.12
  • kdepim
  • calendarsupport
collectiongeneralpage.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3  Author: Tobias Koenig <tokoe@kdab.com>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "collectiongeneralpage.h"
22 
23 #include <Akonadi/Collection>
24 #include <Akonadi/EntityDisplayAttribute>
25 #include <akonadi/calendar/blockalarmsattribute.h>
26 
27 #include <KCalCore/Event>
28 #include <KCalCore/Journal>
29 #include <KCalCore/Todo>
30 
31 #include <KDialog>
32 #include <KIconButton>
33 #include <KLineEdit>
34 #include <KLocale>
35 
36 #include <QCheckBox>
37 #include <QHBoxLayout>
38 #include <QLabel>
39 #include <QVBoxLayout>
40 
41 using namespace Akonadi;
42 using namespace CalendarSupport;
43 
44 CollectionGeneralPage::CollectionGeneralPage( QWidget *parent )
45  : CollectionPropertiesPage( parent )
46 {
47  setObjectName( QLatin1String( "CalendarSupport::CollectionGeneralPage" ) );
48  setPageTitle( i18nc( "@title:tab General settings for a folder.", "General" ) );
49 
50  QVBoxLayout *topLayout = new QVBoxLayout( this );
51  topLayout->setSpacing( KDialog::spacingHint() );
52  topLayout->setMargin( 0 );
53 
54  QHBoxLayout *hbox = new QHBoxLayout();
55  topLayout->addItem( hbox );
56  hbox->setSpacing( KDialog::spacingHint() );
57 
58  QLabel *label = new QLabel( i18nc( "@label:textbox Name of the folder.", "&Name:" ), this );
59  hbox->addWidget( label );
60 
61  mNameEdit = new KLineEdit( this );
62  mNameEdit->setToolTip(
63  i18nc( "@info:tooltip", "Set the folder name" ) );
64  mNameEdit->setWhatsThis(
65  i18nc( "@info:whatsthis",
66  "Enter a name here to set the name of this folder." ) );
67  label->setBuddy( mNameEdit );
68  hbox->addWidget( mNameEdit );
69 
70  // should replies to mails in this folder be kept in this same folder?
71  hbox = new QHBoxLayout();
72  topLayout->addItem( hbox );
73  hbox->setSpacing( KDialog::spacingHint() );
74 
75  mBlockAlarmsCheckBox = new QCheckBox( i18nc( "@option:check", "Block reminders locally" ), this );
76  mBlockAlarmsCheckBox->setToolTip(
77  i18nc( "@info:tooltip", "Ignore reminders from this calendar" ) );
78  mBlockAlarmsCheckBox->setWhatsThis(
79  i18nc( "@info:whatsthis",
80  "Check this box if you do not want to receive reminders from items "
81  "associated with this calendar." ) );
82  hbox->addWidget( mBlockAlarmsCheckBox );
83  hbox->addStretch( 1 );
84 
85 #ifndef KDEPIM_MOBILE_UI
86  hbox = new QHBoxLayout();
87  topLayout->addItem( hbox );
88  hbox->setSpacing( KDialog::spacingHint() );
89  mIconCheckBox = new QCheckBox( i18nc( "@option:check", "&Use custom icon:" ), this );
90  mIconCheckBox->setToolTip(
91  i18nc( "@info:tooltip", "Set a custom icon" ) );
92  mIconCheckBox->setWhatsThis(
93  i18nc( "@info:whatsthis",
94  "Check this box if you want to set a custom icon for this folder." ) );
95  mIconButton = new KIconButton( this );
96  mIconButton->setIconSize( 16 );
97  hbox->addWidget( mIconCheckBox );
98  hbox->addWidget( mIconButton );
99  hbox->addStretch();
100 #endif
101 
102  topLayout->addStretch( 100 ); // eat all superfluous space
103 }
104 
105 CollectionGeneralPage::~CollectionGeneralPage()
106 {
107 }
108 
109 void CollectionGeneralPage::load( const Akonadi::Collection &collection )
110 {
111  mNameEdit->setEnabled( collection.rights() & Collection::CanChangeCollection );
112 
113  const QString displayName = collection.displayName();
114 
115  mNameEdit->setText( displayName );
116  mBlockAlarmsCheckBox->setChecked( collection.hasAttribute<BlockAlarmsAttribute>() );
117 
118  QString iconName;
119  if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
120  iconName = collection.attribute<EntityDisplayAttribute>()->iconName();
121  }
122 
123 #ifndef KDEPIM_MOBILE_UI
124  if ( iconName.isEmpty() ) {
125  const QStringList mimeTypes = collection.contentMimeTypes();
126  if ( collection.contentMimeTypes().count() > 1 ||
127  collection.contentMimeTypes().contains( KCalCore::Event::eventMimeType() ) ) {
128  mIconButton->setIcon( QLatin1String("view-pim-calendar") );
129  } else if ( collection.contentMimeTypes().contains( KCalCore::Todo::todoMimeType() ) ) {
130  mIconButton->setIcon( QLatin1String("view-pim-tasks") );
131  } else if ( collection.contentMimeTypes().contains( KCalCore::Journal::journalMimeType() ) ) {
132  mIconButton->setIcon( QLatin1String("view-pim-journal") );
133  } else if ( mimeTypes.isEmpty() ) {
134  mIconButton->setIcon( QLatin1String("folder-grey") );
135  } else {
136  mIconButton->setIcon( QLatin1String("folder") );
137  }
138  } else {
139  mIconButton->setIcon( iconName );
140  }
141  mIconCheckBox->setChecked( !iconName.isEmpty() );
142 #endif
143 }
144 
145 void CollectionGeneralPage::save( Collection &collection )
146 {
147  if ( collection.hasAttribute<EntityDisplayAttribute>() &&
148  !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty() ) {
149  collection.attribute<EntityDisplayAttribute>()->setDisplayName( mNameEdit->text() );
150  } else {
151  collection.setName( mNameEdit->text() );
152  }
153 
154  if ( mBlockAlarmsCheckBox->isChecked() ) {
155  if ( !collection.hasAttribute<BlockAlarmsAttribute>() ) {
156  collection.attribute<BlockAlarmsAttribute>( Collection::AddIfMissing );
157  }
158  } else {
159  collection.removeAttribute<BlockAlarmsAttribute>();
160  }
161 
162 #ifndef KDEPIM_MOBILE_UI
163  if ( mIconCheckBox->isChecked() ) {
164  collection.attribute<EntityDisplayAttribute>( Collection::AddIfMissing )->
165  setIconName( mIconButton->icon() );
166  } else if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
167  collection.attribute<EntityDisplayAttribute>()->setIconName( QString() );
168  }
169 #endif
170 
171 }
172 
173 #include "collectiongeneralpage.moc"
CalendarSupport::CollectionGeneralPage::~CollectionGeneralPage
~CollectionGeneralPage()
Definition: collectiongeneralpage.cpp:105
CalendarSupport::CollectionGeneralPage::load
void load(const Akonadi::Collection &collection)
Definition: collectiongeneralpage.cpp:109
QWidget
CalendarSupport::CollectionGeneralPage::save
void save(Akonadi::Collection &collection)
Definition: collectiongeneralpage.cpp:145
collectiongeneralpage.h
CalendarSupport::displayName
CALENDARSUPPORT_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &coll)
Definition: utils.cpp:497
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

calendarsupport

Skip menu "calendarsupport"
  • Main Page
  • Namespace List
  • Namespace Members
  • 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

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