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_p.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 setObjectName( QLatin1String( "Akonadi::CollectionGeneralPropertiesPage" ) ); 00037 00038 setPageTitle( i18nc( "@title:tab general properties page", "General" ) ); 00039 ui.setupUi( this ); 00040 } 00041 00042 void CollectionGeneralPropertiesPage::load(const Collection & collection) 00043 { 00044 QString displayName; 00045 QString iconName; 00046 if ( collection.hasAttribute<EntityDisplayAttribute>() ) { 00047 displayName = collection.attribute<EntityDisplayAttribute>()->displayName(); 00048 iconName = collection.attribute<EntityDisplayAttribute>()->iconName(); 00049 } 00050 00051 if ( displayName.isEmpty() ) 00052 ui.nameEdit->setText( collection.name() ); 00053 else 00054 ui.nameEdit->setText( displayName ); 00055 00056 #ifndef KDEPIM_MOBILE_UI 00057 if ( iconName.isEmpty() ) 00058 ui.customIcon->setIcon( CollectionUtils::defaultIconName( collection ) ); 00059 else 00060 ui.customIcon->setIcon( iconName ); 00061 ui.customIconCheckbox->setChecked( !iconName.isEmpty() ); 00062 #endif 00063 00064 if ( collection.statistics().count() >= 0 ) { 00065 ui.countLabel->setText( i18ncp( "@label", "One object", "%1 objects", 00066 collection.statistics().count() ) ); 00067 ui.sizeLabel->setText( KGlobal::locale()->formatByteSize( collection.statistics().size() ) ); 00068 } else { 00069 ui.statsBox->hide(); 00070 } 00071 } 00072 00073 void CollectionGeneralPropertiesPage::save(Collection & collection) 00074 { 00075 if ( collection.hasAttribute<EntityDisplayAttribute>() && 00076 !collection.attribute<EntityDisplayAttribute>()->displayName().isEmpty() ) 00077 collection.attribute<EntityDisplayAttribute>()->setDisplayName( ui.nameEdit->text() ); 00078 else 00079 collection.setName( ui.nameEdit->text() ); 00080 00081 #ifndef KDEPIM_MOBILE_UI 00082 if ( ui.customIconCheckbox->isChecked() ) 00083 collection.attribute<EntityDisplayAttribute>( Collection::AddIfMissing )->setIconName( ui.customIcon->icon() ); 00084 else if ( collection.hasAttribute<EntityDisplayAttribute>() ) 00085 collection.attribute<EntityDisplayAttribute>()->setIconName( QString() ); 00086 #endif 00087 } 00088 00089 //@endcond 00090 00091 #include "collectiongeneralpropertiespage_p.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:17 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:17 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.