• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
collectiongeneralpropertiespage.cpp
1/*
2 Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#include "collectiongeneralpropertiespage_p.h"
21
22#include "collection.h"
23#include "entitydisplayattribute.h"
24#include "collectionstatistics.h"
25#include "collectionutils_p.h"
26
27#include <klocale.h>
28#include <klocalizedstring.h>
29#include <kglobal.h>
30
31using namespace Akonadi;
32
33//@cond PRIVATE
34
35CollectionGeneralPropertiesPage::CollectionGeneralPropertiesPage(QWidget *parent)
36 : CollectionPropertiesPage(parent)
37{
38 setObjectName(QLatin1String("Akonadi::CollectionGeneralPropertiesPage"));
39
40 setPageTitle(i18nc("@title:tab general properties page", "General"));
41 ui.setupUi(this);
42}
43
44void CollectionGeneralPropertiesPage::load(const Collection &collection)
45{
46 QString displayName;
47 QString iconName;
48 if (collection.hasAttribute<EntityDisplayAttribute>()) {
49 displayName = collection.attribute<EntityDisplayAttribute>()->displayName();
50 iconName = collection.attribute<EntityDisplayAttribute>()->iconName();
51 }
52
53 if (displayName.isEmpty()) {
54 ui.nameEdit->setText(collection.name());
55 } else {
56 ui.nameEdit->setText(displayName);
57 }
58
59#ifndef KDEPIM_MOBILE_UI
60 if (iconName.isEmpty()) {
61 ui.customIcon->setIcon(CollectionUtils::defaultIconName(collection));
62 } else {
63 ui.customIcon->setIcon(iconName);
64 }
65 ui.customIconCheckbox->setChecked(!iconName.isEmpty());
66#endif
67
68 if (collection.statistics().count() >= 0) {
69 ui.countLabel->setText(i18ncp("@label", "One object", "%1 objects",
70 collection.statistics().count()));
71 ui.sizeLabel->setText(KGlobal::locale()->formatByteSize(collection.statistics().size()));
72 } else {
73 ui.statsBox->hide();
74 }
75}
76
77void CollectionGeneralPropertiesPage::save(Collection &collection)
78{
79 if (collection.hasAttribute<EntityDisplayAttribute>() &&
80 !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty()) {
81 collection.attribute<EntityDisplayAttribute>()->setDisplayName(ui.nameEdit->text());
82 } else {
83 collection.setName(ui.nameEdit->text());
84 }
85
86#ifndef KDEPIM_MOBILE_UI
87 if (ui.customIconCheckbox->isChecked()) {
88 collection.attribute<EntityDisplayAttribute>(Collection::AddIfMissing)->setIconName(ui.customIcon->icon());
89 } else if (collection.hasAttribute<EntityDisplayAttribute>()) {
90 collection.attribute<EntityDisplayAttribute>()->setIconName(QString());
91 }
92#endif
93}
94
95//@endcond
96
97#include "moc_collectiongeneralpropertiespage_p.cpp"
Akonadi::CollectionPropertiesPage
A single page in a collection properties dialog.
Definition: collectionpropertiespage.h:100
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:76
Akonadi::EntityDisplayAttribute
Attribute that stores the properties that are used to display an entity.
Definition: entitydisplayattribute.h:40
Akonadi::EntityDisplayAttribute::displayName
QString displayName() const
Returns the name that should be used for display.
Definition: entitydisplayattribute.cpp:52
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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