• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

collectiongeneralpropertiespage.cpp

00001 /*
00002     Copyright (c) 2008 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "collectiongeneralpropertiespage.h"
00021 
00022 #include "collection.h"
00023 #include "entitydisplayattribute.h"
00024 #include "collectionstatistics.h"
00025 #include "collectionutils_p.h"
00026 
00027 #include <klocale.h>
00028 
00029 using namespace Akonadi;
00030 
00031 //@cond PRIVATE
00032 
00033 CollectionGeneralPropertiesPage::CollectionGeneralPropertiesPage(QWidget * parent) :
00034     CollectionPropertiesPage( parent )
00035 {
00036   setPageTitle( i18nc( "@title:tab general properties page", "General" ) );
00037   ui.setupUi( this );
00038 }
00039 
00040 void CollectionGeneralPropertiesPage::load(const Collection & collection)
00041 {
00042   QString displayName;
00043   QString iconName;
00044   if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
00045     displayName = collection.attribute<EntityDisplayAttribute>()->displayName();
00046     iconName = collection.attribute<EntityDisplayAttribute>()->iconName();
00047   }
00048 
00049   if ( displayName.isEmpty() )
00050     ui.nameEdit->setText( collection.name() );
00051   else
00052     ui.nameEdit->setText( displayName );
00053 
00054   if ( iconName.isEmpty() )
00055     ui.customIcon->setIcon( CollectionUtils::defaultIconName( collection ) );
00056   else
00057     ui.customIcon->setIcon( iconName );
00058   ui.customIconCheckbox->setChecked( !iconName.isEmpty() );
00059 
00060   if ( collection.statistics().count() >= 0 ) {
00061     ui.countLabel->setText( i18ncp( "@label", "One object", "%1 objects",
00062                             collection.statistics().count() ) );
00063   } else {
00064     ui.statsBox->hide();
00065   }
00066 }
00067 
00068 void CollectionGeneralPropertiesPage::save(Collection & collection)
00069 {
00070   if ( collection.hasAttribute<EntityDisplayAttribute>() &&
00071        !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty() )
00072     collection.attribute<EntityDisplayAttribute>()->setDisplayName( ui.nameEdit->text() );
00073   else
00074     collection.setName( ui.nameEdit->text() );
00075 
00076   if ( ui.customIconCheckbox->isChecked() )
00077     collection.attribute<EntityDisplayAttribute>( Collection::AddIfMissing )->setIconName( ui.customIcon->icon() );
00078   else if ( collection.hasAttribute<EntityDisplayAttribute>() )
00079     collection.attribute<EntityDisplayAttribute>()->setIconName( QString() );
00080 }
00081 
00082 //@endcond
00083 
00084 #include "collectiongeneralpropertiespage.moc"

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal