• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • 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 <kdeversion.h>
00023 
00024 #if KDE_IS_VERSION( 4, 5, 74 )
00025 #include "ui_cachepolicypage.h"
00026 #else
00027 #include "ui_cachepolicypage-45.h"
00028 #endif
00029 
00030 #include "cachepolicy.h"
00031 #include "collection.h"
00032 #include "collectionutils_p.h"
00033 
00034 using namespace Akonadi;
00035 
00036 class CachePolicyPage::Private
00037 {
00038   public:
00039     Private()
00040       : mUi( new Ui::CachePolicyPage )
00041     {
00042     }
00043 
00044     ~Private()
00045     {
00046       delete mUi;
00047     }
00048 
00049     void slotIntervalValueChanged( int );
00050     void slotCacheValueChanged( int );
00051 
00052     Ui::CachePolicyPage* mUi;
00053 };
00054 
00055 void CachePolicyPage::Private::slotIntervalValueChanged( int interval )
00056 {
00057   mUi->checkInterval->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
00058 }
00059 
00060 void CachePolicyPage::Private::slotCacheValueChanged( int interval )
00061 {
00062   mUi->localCacheTimeout->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
00063 }
00064 
00065 CachePolicyPage::CachePolicyPage( QWidget *parent, GuiMode mode )
00066   : CollectionPropertiesPage( parent ),
00067     d( new Private )
00068 {
00069   setObjectName( QLatin1String( "Akonadi::CachePolicyPage" ) );
00070   setPageTitle( i18n( "Retrieval" ) );
00071 
00072   d->mUi->setupUi( this );
00073   connect( d->mUi->checkInterval, SIGNAL( valueChanged( int ) ),
00074            SLOT( slotIntervalValueChanged( int ) ) );
00075   connect( d->mUi->localCacheTimeout, SIGNAL( valueChanged( int ) ),
00076            SLOT( slotCacheValueChanged( int ) ) );
00077 
00078   if ( mode == AdvancedMode ) {
00079     d->mUi->stackedWidget->setCurrentWidget( d->mUi->rawPage );
00080   }
00081 }
00082 
00083 CachePolicyPage::~CachePolicyPage()
00084 {
00085   delete d;
00086 }
00087 
00088 bool Akonadi::CachePolicyPage::canHandle( const Collection &collection ) const
00089 {
00090   return !CollectionUtils::isVirtual( collection );
00091 }
00092 
00093 void CachePolicyPage::load( const Collection &collection )
00094 {
00095   const CachePolicy policy = collection.cachePolicy();
00096 
00097   int interval = policy.intervalCheckTime();
00098   if ( interval == -1 )
00099     interval = 0;
00100 
00101   int cache = policy.cacheTimeout();
00102   if ( cache == -1 )
00103     cache = 0;
00104 
00105   d->mUi->inherit->setChecked( policy.inheritFromParent() );
00106   d->mUi->checkInterval->setValue( interval );
00107   d->mUi->localCacheTimeout->setValue( cache );
00108   d->mUi->syncOnDemand->setChecked( policy.syncOnDemand() );
00109   d->mUi->localParts->setItems( policy.localParts() );
00110 
00111   const bool fetchBodies = policy.localParts().contains( QLatin1String( "RFC822" ) );
00112   d->mUi->retrieveFullMessages->setChecked( fetchBodies );
00113 
00114   //done explicitely to disable/enabled widgets
00115   d->mUi->retrieveOnlyHeaders->setChecked( !fetchBodies );
00116 }
00117 
00118 void CachePolicyPage::save( Collection &collection )
00119 {
00120   int interval = d->mUi->checkInterval->value();
00121   if ( interval == 0 )
00122     interval = -1;
00123 
00124   int cache = d->mUi->localCacheTimeout->value();
00125   if ( cache == 0 )
00126     cache = -1;
00127 
00128   CachePolicy policy = collection.cachePolicy();
00129   policy.setInheritFromParent( d->mUi->inherit->isChecked() );
00130   policy.setIntervalCheckTime( interval );
00131   policy.setCacheTimeout( cache );
00132   policy.setSyncOnDemand( d->mUi->syncOnDemand->isChecked() );
00133 
00134   QStringList localParts = d->mUi->localParts->items();
00135 
00136   // Unless we are in "raw" mode, add "bodies" to the list of message
00137   // parts to keep around locally, if the user selected that, or remove
00138   // it otherwise. In "raw" mode we simple use the values from the list
00139   // view.
00140   if ( d->mUi->stackedWidget->currentWidget() != d->mUi->rawPage ) {
00141     if ( d->mUi->retrieveFullMessages->isChecked()
00142          && !localParts.contains( QLatin1String( "RFC822" ) ) ) {
00143         localParts.append( QLatin1String( "RFC822" ) );
00144     } else if ( !d->mUi->retrieveFullMessages->isChecked()
00145          && localParts.contains( QLatin1String( "RFC822" ) ) ) {
00146       localParts.removeAll( QLatin1String( "RFC822" )  );
00147     }
00148   }
00149 
00150   policy.setLocalParts( localParts );
00151   collection.setCachePolicy( policy );
00152 }
00153 
00154 #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
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.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