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

akonadi

cachepolicypage.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 "cachepolicypage.h"
00021 
00022 #include "cachepolicy.h"
00023 #include "collection.h"
00024 #include "collectionutils_p.h"
00025 
00026 using namespace Akonadi;
00027 
00028 CachePolicyPage::CachePolicyPage(QWidget * parent) :
00029     CollectionPropertiesPage( parent )
00030 {
00031   setPageTitle( i18n( "Cache" ) );
00032   ui.setupUi( this );
00033   connect( ui.checkInterval, SIGNAL( valueChanged( int ) ),
00034            SLOT( slotIntervalValueChanged( int ) ) );
00035   connect( ui.localCacheTimeout, SIGNAL( valueChanged( int ) ),
00036            SLOT( slotCacheValueChanged( int ) ) );
00037 }
00038 
00039 bool Akonadi::CachePolicyPage::canHandle(const Collection & collection) const
00040 {
00041   return !CollectionUtils::isVirtual( collection );
00042 }
00043 
00044 void CachePolicyPage::load(const Collection & collection)
00045 {
00046   CachePolicy policy = collection.cachePolicy();
00047   
00048   int interval = policy.intervalCheckTime();
00049   if (interval == -1)
00050     interval = 0;
00051 
00052   int cache = policy.cacheTimeout();
00053   if (cache == -1)
00054     cache = 0;
00055 
00056   ui.inherit->setChecked( policy.inheritFromParent() );
00057   ui.checkInterval->setValue( interval );
00058   ui.localCacheTimeout->setValue( cache );
00059   ui.syncOnDemand->setChecked( policy.syncOnDemand() );
00060   ui.localParts->setItems( policy.localParts() );
00061 }
00062 
00063 void CachePolicyPage::save(Collection & collection)
00064 {
00065   int interval = ui.checkInterval->value();
00066   if (interval == 0)
00067     interval = -1;
00068 
00069   int cache = ui.localCacheTimeout->value();
00070   if (cache == 0)
00071     cache = -1;
00072 
00073   CachePolicy policy = collection.cachePolicy();
00074   policy.setInheritFromParent( ui.inherit->isChecked() );
00075   policy.setIntervalCheckTime( interval );
00076   policy.setCacheTimeout( cache );
00077   policy.setSyncOnDemand( ui.syncOnDemand->isChecked() );
00078   policy.setLocalParts( ui.localParts->items() );
00079   collection.setCachePolicy( policy );
00080 }
00081 
00082 void CachePolicyPage::slotIntervalValueChanged( int i )
00083 {
00084     ui.checkInterval->setSuffix( ' ' + i18np( "minute", "minutes", i ) );
00085 }
00086 
00087 void CachePolicyPage::slotCacheValueChanged( int i )
00088 {
00089     ui.localCacheTimeout->setSuffix( ' ' + i18np( "minute", "minutes", i ) );
00090 }
00091 
00092 #include "cachepolicypage.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
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.4
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