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.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"