• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
cachepolicypage.cpp
1 /*
2  Copyright (c) 2008 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "cachepolicypage.h"
21 
22 #include "ui_cachepolicypage.h"
23 
24 #include "cachepolicy.h"
25 #include "collection.h"
26 #include "collectionutils_p.h"
27 
28 using namespace Akonadi;
29 
30 class CachePolicyPage::Private
31 {
32  public:
33  Private()
34  : mUi( new Ui::CachePolicyPage )
35  {
36  }
37 
38  ~Private()
39  {
40  delete mUi;
41  }
42 
43  void slotIntervalValueChanged( int );
44  void slotCacheValueChanged( int );
45  void slotRetrievalOptionsGroupBoxDisabled( bool disable );
46 
47  Ui::CachePolicyPage* mUi;
48 };
49 
50 void CachePolicyPage::Private::slotIntervalValueChanged( int interval )
51 {
52  mUi->checkInterval->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
53 }
54 
55 void CachePolicyPage::Private::slotCacheValueChanged( int interval )
56 {
57  mUi->localCacheTimeout->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
58 }
59 
60 void CachePolicyPage::Private::slotRetrievalOptionsGroupBoxDisabled( bool disable )
61 {
62  mUi->retrievalOptionsGroupBox->setDisabled( disable );
63  if ( !disable ) {
64  mUi->label->setEnabled( mUi->retrieveOnlyHeaders->isChecked() );
65  mUi->localCacheTimeout->setEnabled( mUi->retrieveOnlyHeaders->isChecked() );
66  }
67 }
68 
69 CachePolicyPage::CachePolicyPage( QWidget *parent, GuiMode mode )
70  : CollectionPropertiesPage( parent ),
71  d( new Private )
72 {
73  setObjectName( QLatin1String( "Akonadi::CachePolicyPage" ) );
74  setPageTitle( i18n( "Retrieval" ) );
75 
76  d->mUi->setupUi( this );
77  connect( d->mUi->checkInterval, SIGNAL(valueChanged(int)),
78  SLOT(slotIntervalValueChanged(int)) );
79  connect( d->mUi->localCacheTimeout, SIGNAL(valueChanged(int)),
80  SLOT(slotCacheValueChanged(int)) );
81  connect( d->mUi->inherit, SIGNAL(toggled(bool)),
82  SLOT(slotRetrievalOptionsGroupBoxDisabled(bool)));
83  if ( mode == AdvancedMode ) {
84  d->mUi->stackedWidget->setCurrentWidget( d->mUi->rawPage );
85  }
86 }
87 
88 CachePolicyPage::~CachePolicyPage()
89 {
90  delete d;
91 }
92 
93 bool Akonadi::CachePolicyPage::canHandle( const Collection &collection ) const
94 {
95  return !collection.isVirtual();
96 }
97 
98 void CachePolicyPage::load( const Collection &collection )
99 {
100  const CachePolicy policy = collection.cachePolicy();
101 
102  int interval = policy.intervalCheckTime();
103  if ( interval == -1 ) {
104  interval = 0;
105  }
106 
107  int cache = policy.cacheTimeout();
108  if ( cache == -1 ) {
109  cache = 0;
110  }
111 
112  d->mUi->inherit->setChecked( policy.inheritFromParent() );
113  d->mUi->checkInterval->setValue( interval );
114  d->mUi->localCacheTimeout->setValue( cache );
115  d->mUi->syncOnDemand->setChecked( policy.syncOnDemand() );
116  d->mUi->localParts->setItems( policy.localParts() );
117 
118  const bool fetchBodies = policy.localParts().contains( QLatin1String( "RFC822" ) );
119  d->mUi->retrieveFullMessages->setChecked( fetchBodies );
120 
121  //done explicitly to disable/enabled widgets
122  d->mUi->retrieveOnlyHeaders->setChecked( !fetchBodies );
123  d->mUi->label->setEnabled( !fetchBodies );
124  d->mUi->localCacheTimeout->setEnabled( !fetchBodies );
125 }
126 
127 void CachePolicyPage::save( Collection &collection )
128 {
129  int interval = d->mUi->checkInterval->value();
130  if ( interval == 0 ) {
131  interval = -1;
132  }
133 
134  int cache = d->mUi->localCacheTimeout->value();
135  if ( cache == 0 ) {
136  cache = -1;
137  }
138 
139  CachePolicy policy = collection.cachePolicy();
140  policy.setInheritFromParent( d->mUi->inherit->isChecked() );
141  policy.setIntervalCheckTime( interval );
142  policy.setCacheTimeout( cache );
143  policy.setSyncOnDemand( d->mUi->syncOnDemand->isChecked() );
144 
145  QStringList localParts = d->mUi->localParts->items();
146 
147  // Unless we are in "raw" mode, add "bodies" to the list of message
148  // parts to keep around locally, if the user selected that, or remove
149  // it otherwise. In "raw" mode we simple use the values from the list
150  // view.
151  if ( d->mUi->stackedWidget->currentWidget() != d->mUi->rawPage ) {
152  if ( d->mUi->retrieveFullMessages->isChecked() &&
153  !localParts.contains( QLatin1String( "RFC822" ) ) ) {
154  localParts.append( QLatin1String( "RFC822" ) );
155  } else if ( !d->mUi->retrieveFullMessages->isChecked() &&
156  localParts.contains( QLatin1String( "RFC822" ) ) ) {
157  localParts.removeAll( QLatin1String( "RFC822" ) );
158  }
159  }
160 
161  policy.setLocalParts( localParts );
162  collection.setCachePolicy( policy );
163 }
164 
165 #include "moc_cachepolicypage.cpp"
Akonadi::CachePolicyPage::AdvancedMode
An advanced UI for debugging will be provided.
Definition: cachepolicypage.h:52
Akonadi::CachePolicy::intervalCheckTime
int intervalCheckTime() const
Returns the interval check time in minutes, -1 for never.
Definition: cachepolicy.cpp:117
Akonadi::CachePolicy::setSyncOnDemand
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:132
Akonadi::CachePolicy::inheritFromParent
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
Definition: cachepolicy.cpp:87
Akonadi::CachePolicyPage::GuiMode
GuiMode
Describes the mode of the cache policy page.
Definition: cachepolicypage.h:50
Akonadi::CachePolicy::setIntervalCheckTime
void setIntervalCheckTime(int time)
Sets interval check time.
Definition: cachepolicy.cpp:122
Akonadi::CachePolicy::setCacheTimeout
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
Definition: cachepolicy.cpp:112
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::CollectionPropertiesPage
A single page in a collection properties dialog.
Definition: collectionpropertiespage.h:99
Akonadi::CachePolicyPage::canHandle
bool canHandle(const Collection &collection) const
Checks if the cache policy page can actually handle the given collection.
Definition: cachepolicypage.cpp:93
Akonadi::CollectionPropertiesPage::setPageTitle
void setPageTitle(const QString &title)
Sets the page title.
Akonadi::CachePolicyPage::save
void save(Collection &collection)
Saves page content to the given collection.
Definition: cachepolicypage.cpp:127
Akonadi::CachePolicyPage::~CachePolicyPage
~CachePolicyPage()
Destroys the cache policy page.
Definition: cachepolicypage.cpp:88
Akonadi::CachePolicy::cacheTimeout
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
Definition: cachepolicy.cpp:107
Akonadi::CachePolicy
Represents the caching policy for a collection.
Definition: cachepolicy.h:71
Akonadi::Collection::setCachePolicy
void setCachePolicy(const CachePolicy &policy)
Sets the cache policy of the collection.
Definition: collection.cpp:254
Akonadi::CachePolicy::setLocalParts
void setLocalParts(const QStringList &parts)
Specifies the parts to permanently cache locally.
Definition: cachepolicy.cpp:102
Akonadi::Collection::cachePolicy
CachePolicy cachePolicy() const
Returns the cache policy of the collection.
Definition: collection.cpp:249
Akonadi::CachePolicy::localParts
QStringList localParts() const
Returns the parts to permanently cache locally.
Definition: cachepolicy.cpp:97
Akonadi::CachePolicyPage::CachePolicyPage
CachePolicyPage(QWidget *parent, GuiMode mode=UserMode)
Creates a new cache policy page.
Definition: cachepolicypage.cpp:69
Akonadi::CachePolicyPage
A page in a collection properties dialog to configure the cache policy.
Definition: cachepolicypage.h:42
Akonadi::CachePolicy::setInheritFromParent
void setInheritFromParent(bool inherit)
Sets whether the cache policy should be inherited from the parent collection.
Definition: cachepolicy.cpp:92
Akonadi::CachePolicyPage::load
void load(const Collection &collection)
Loads the page content from the given collection.
Definition: cachepolicypage.cpp:98
Akonadi::Collection::isVirtual
bool isVirtual() const
Returns whether the collection is virtual, for example a search collection.
Definition: collection.cpp:261
Akonadi::CachePolicy::syncOnDemand
bool syncOnDemand() const
Returns whether the collection will be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:127
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal