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

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • 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.5
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