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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 
31 using namespace Akonadi;
32 
33 //@cond PRIVATE
34 
35 CollectionGeneralPropertiesPage::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 
44 void 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 
77 void 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::CollectionStatistics::count
qint64 count() const
Returns the number of items in this collection or -1 if this information is not available.
Definition: collectionstatistics.cpp:67
QWidget
Akonadi::Collection::name
QString name() const
Returns the i18n'ed name of the collection.
Definition: collection.cpp:81
Akonadi::EntityDisplayAttribute::displayName
QString displayName() const
Returns the name that should be used for display.
Definition: entitydisplayattribute.cpp:52
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::CollectionPropertiesPage
A single page in a collection properties dialog.
Definition: collectionpropertiespage.h:99
Akonadi::Collection::setName
void setName(const QString &name)
Sets the i18n'ed name of the collection.
Definition: collection.cpp:93
Akonadi::Entity::attribute
Attribute * attribute(const QByteArray &name) const
Returns the attribute of the given type name if available, 0 otherwise.
Definition: entity.cpp:167
QObject::setObjectName
void setObjectName(const QString &name)
QString::isEmpty
bool isEmpty() const
QString
QLatin1String
Akonadi::Entity::hasAttribute
bool hasAttribute(const QByteArray &name) const
Returns true if the entity has an attribute of the given type name, false otherwise.
Definition: entity.cpp:148
Akonadi::Entity::AddIfMissing
Creates the attribute if it is missing.
Definition: entity.h:205
Akonadi::Collection::statistics
CollectionStatistics statistics() const
Returns the collection statistics of the collection.
Definition: collection.cpp:238
Akonadi::EntityDisplayAttribute
Attribute that stores the properties that are used to display an entity.
Definition: entitydisplayattribute.h:39
Akonadi::CollectionStatistics::size
qint64 size() const
Returns the total size of the items in this collection or -1 if this information is not available...
Definition: collectionstatistics.cpp:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:02 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

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