• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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 
29 using namespace Akonadi;
30 
31 //@cond PRIVATE
32 
33 CollectionGeneralPropertiesPage::CollectionGeneralPropertiesPage( QWidget *parent )
34  : CollectionPropertiesPage( parent )
35 {
36  setObjectName( QLatin1String( "Akonadi::CollectionGeneralPropertiesPage" ) );
37 
38  setPageTitle( i18nc( "@title:tab general properties page", "General" ) );
39  ui.setupUi( this );
40 }
41 
42 void CollectionGeneralPropertiesPage::load(const Collection & collection)
43 {
44  QString displayName;
45  QString iconName;
46  if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
47  displayName = collection.attribute<EntityDisplayAttribute>()->displayName();
48  iconName = collection.attribute<EntityDisplayAttribute>()->iconName();
49  }
50 
51  if ( displayName.isEmpty() ) {
52  ui.nameEdit->setText( collection.name() );
53  } else {
54  ui.nameEdit->setText( displayName );
55  }
56 
57 #ifndef KDEPIM_MOBILE_UI
58  if ( iconName.isEmpty() ) {
59  ui.customIcon->setIcon( CollectionUtils::defaultIconName( collection ) );
60  } else {
61  ui.customIcon->setIcon( iconName );
62  }
63  ui.customIconCheckbox->setChecked( !iconName.isEmpty() );
64 #endif
65 
66  if ( collection.statistics().count() >= 0 ) {
67  ui.countLabel->setText( i18ncp( "@label", "One object", "%1 objects",
68  collection.statistics().count() ) );
69  ui.sizeLabel->setText( KGlobal::locale()->formatByteSize( collection.statistics().size() ) );
70  } else {
71  ui.statsBox->hide();
72  }
73 }
74 
75 void CollectionGeneralPropertiesPage::save(Collection & collection)
76 {
77  if ( collection.hasAttribute<EntityDisplayAttribute>() &&
78  !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty() ) {
79  collection.attribute<EntityDisplayAttribute>()->setDisplayName( ui.nameEdit->text() );
80  } else {
81  collection.setName( ui.nameEdit->text() );
82  }
83 
84 #ifndef KDEPIM_MOBILE_UI
85  if ( ui.customIconCheckbox->isChecked() ) {
86  collection.attribute<EntityDisplayAttribute>( Collection::AddIfMissing )->setIconName( ui.customIcon->icon() );
87  } else if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
88  collection.attribute<EntityDisplayAttribute>()->setIconName( QString() );
89  }
90 #endif
91 }
92 
93 //@endcond
94 
95 #include "moc_collectiongeneralpropertiespage_p.cpp"
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:33 by doxygen 1.8.3.1 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.10.5 API Reference

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