23 #include <Akonadi/Collection>
24 #include <Akonadi/EntityDisplayAttribute>
25 #include <akonadi/calendar/blockalarmsattribute.h>
27 #include <KCalCore/Event>
28 #include <KCalCore/Journal>
29 #include <KCalCore/Todo>
32 #include <KIconButton>
37 #include <QHBoxLayout>
39 #include <QVBoxLayout>
41 using namespace Akonadi;
42 using namespace CalendarSupport;
44 CollectionGeneralPage::CollectionGeneralPage(
QWidget *parent )
45 : CollectionPropertiesPage( parent )
47 setObjectName( QLatin1String(
"CalendarSupport::CollectionGeneralPage" ) );
48 setPageTitle( i18nc(
"@title:tab General settings for a folder.",
"General" ) );
50 QVBoxLayout *topLayout =
new QVBoxLayout(
this );
51 topLayout->setSpacing( KDialog::spacingHint() );
52 topLayout->setMargin( 0 );
54 QHBoxLayout *hbox =
new QHBoxLayout();
55 topLayout->addItem( hbox );
56 hbox->setSpacing( KDialog::spacingHint() );
58 QLabel *label =
new QLabel( i18nc(
"@label:textbox Name of the folder.",
"&Name:" ),
this );
59 hbox->addWidget( label );
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 );
71 hbox =
new QHBoxLayout();
72 topLayout->addItem( hbox );
73 hbox->setSpacing( KDialog::spacingHint() );
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 );
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 );
102 topLayout->addStretch( 100 );
111 mNameEdit->setEnabled( collection.rights() & Collection::CanChangeCollection );
113 const QString
displayName = collection.displayName();
115 mNameEdit->setText( displayName );
116 mBlockAlarmsCheckBox->setChecked( collection.hasAttribute<BlockAlarmsAttribute>() );
119 if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
120 iconName = collection.attribute<EntityDisplayAttribute>()->iconName();
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") );
136 mIconButton->setIcon( QLatin1String(
"folder") );
139 mIconButton->setIcon( iconName );
141 mIconCheckBox->setChecked( !iconName.isEmpty() );
147 if ( collection.hasAttribute<EntityDisplayAttribute>() &&
148 !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty() ) {
149 collection.attribute<EntityDisplayAttribute>()->setDisplayName( mNameEdit->text() );
151 collection.setName( mNameEdit->text() );
154 if ( mBlockAlarmsCheckBox->isChecked() ) {
155 if ( !collection.hasAttribute<BlockAlarmsAttribute>() ) {
156 collection.attribute<BlockAlarmsAttribute>( Collection::AddIfMissing );
159 collection.removeAttribute<BlockAlarmsAttribute>();
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() );
173 #include "collectiongeneralpage.moc"
void load(const Akonadi::Collection &collection)
void save(Akonadi::Collection &collection)
CALENDARSUPPORT_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &coll)