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