akonadi
cachepolicypage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "cachepolicypage_p.h"
00021
00022 #include "cachepolicy.h"
00023 #include "collection.h"
00024 #include "collectionutils_p.h"
00025
00026
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( QLatin1Char(' ') + i18np( "minute", "minutes", i ) );
00087 }
00088
00089 void CachePolicyPage::slotCacheValueChanged( int i )
00090 {
00091 ui.localCacheTimeout->setSuffix( QLatin1Char(' ') + i18np( "minute", "minutes", i ) );
00092 }
00093
00094
00095
00096 #include "cachepolicypage_p.moc"