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

akonadi

  • 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 
70 CachePolicyPage::CachePolicyPage( QWidget *parent, GuiMode mode )
71  : CollectionPropertiesPage( parent ),
72  d( new Private )
73 {
74  setObjectName( QLatin1String( "Akonadi::CachePolicyPage" ) );
75  setPageTitle( i18n( "Retrieval" ) );
76 
77  d->mUi->setupUi( this );
78  connect( d->mUi->checkInterval, SIGNAL(valueChanged(int)),
79  SLOT(slotIntervalValueChanged(int)) );
80  connect( d->mUi->localCacheTimeout, SIGNAL(valueChanged(int)),
81  SLOT(slotCacheValueChanged(int)) );
82  connect( d->mUi->inherit, SIGNAL(toggled(bool)),
83  SLOT(slotRetrievalOptionsGroupBoxDisabled(bool)));
84  if ( mode == AdvancedMode ) {
85  d->mUi->stackedWidget->setCurrentWidget( d->mUi->rawPage );
86  }
87 }
88 
89 CachePolicyPage::~CachePolicyPage()
90 {
91  delete d;
92 }
93 
94 bool Akonadi::CachePolicyPage::canHandle( const Collection &collection ) const
95 {
96  return !collection.isVirtual();
97 }
98 
99 void CachePolicyPage::load( const Collection &collection )
100 {
101  const CachePolicy policy = collection.cachePolicy();
102 
103  int interval = policy.intervalCheckTime();
104  if ( interval == -1 ) {
105  interval = 0;
106  }
107 
108  int cache = policy.cacheTimeout();
109  if ( cache == -1 ) {
110  cache = 0;
111  }
112 
113  d->mUi->inherit->setChecked( policy.inheritFromParent() );
114  d->mUi->checkInterval->setValue( interval );
115  d->mUi->localCacheTimeout->setValue( cache );
116  d->mUi->syncOnDemand->setChecked( policy.syncOnDemand() );
117  d->mUi->localParts->setItems( policy.localParts() );
118 
119  const bool fetchBodies = policy.localParts().contains( QLatin1String( "RFC822" ) );
120  d->mUi->retrieveFullMessages->setChecked( fetchBodies );
121 
122  //done explicitly to disable/enabled widgets
123  d->mUi->retrieveOnlyHeaders->setChecked( !fetchBodies );
124  d->mUi->label->setEnabled( !fetchBodies );
125  d->mUi->localCacheTimeout->setEnabled( !fetchBodies );
126 }
127 
128 void CachePolicyPage::save( Collection &collection )
129 {
130  int interval = d->mUi->checkInterval->value();
131  if ( interval == 0 ) {
132  interval = -1;
133  }
134 
135  int cache = d->mUi->localCacheTimeout->value();
136  if ( cache == 0 ) {
137  cache = -1;
138  }
139 
140  CachePolicy policy = collection.cachePolicy();
141  policy.setInheritFromParent( d->mUi->inherit->isChecked() );
142  policy.setIntervalCheckTime( interval );
143  policy.setCacheTimeout( cache );
144  policy.setSyncOnDemand( d->mUi->syncOnDemand->isChecked() );
145 
146  QStringList localParts = d->mUi->localParts->items();
147 
148  // Unless we are in "raw" mode, add "bodies" to the list of message
149  // parts to keep around locally, if the user selected that, or remove
150  // it otherwise. In "raw" mode we simple use the values from the list
151  // view.
152  if ( d->mUi->stackedWidget->currentWidget() != d->mUi->rawPage ) {
153  if ( d->mUi->retrieveFullMessages->isChecked() &&
154  !localParts.contains( QLatin1String( "RFC822" ) ) ) {
155  localParts.append( QLatin1String( "RFC822" ) );
156  } else if ( !d->mUi->retrieveFullMessages->isChecked() &&
157  localParts.contains( QLatin1String( "RFC822" ) ) ) {
158  localParts.removeAll( QLatin1String( "RFC822" ) );
159  }
160  }
161 
162  policy.setLocalParts( localParts );
163  collection.setCachePolicy( policy );
164 }
165 
166 #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:118
Akonadi::CachePolicy::setSyncOnDemand
void setSyncOnDemand(bool enable)
Sets whether the collection shall be synced automatically when necessary, i.e.
Definition: cachepolicy.cpp:133
Akonadi::CachePolicy::inheritFromParent
bool inheritFromParent() const
Returns whether it inherits cache policy from the parent collection.
Definition: cachepolicy.cpp:88
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:123
Akonadi::CachePolicy::setCacheTimeout
void setCacheTimeout(int timeout)
Sets cache timeout for non-permanently cached parts.
Definition: cachepolicy.cpp:113
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:94
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:128
Akonadi::CachePolicyPage::~CachePolicyPage
~CachePolicyPage()
Destroys the cache policy page.
Definition: cachepolicypage.cpp:89
Akonadi::CachePolicy::cacheTimeout
int cacheTimeout() const
Returns the cache timeout for non-permanently cached parts in minutes; -1 means indefinitely.
Definition: cachepolicy.cpp:108
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:103
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:98
Akonadi::CachePolicyPage::CachePolicyPage
CachePolicyPage(QWidget *parent, GuiMode mode=UserMode)
Creates a new cache policy page.
Definition: cachepolicypage.cpp:70
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:93
Akonadi::CachePolicyPage::load
void load(const Collection &collection)
Loads the page content from the given collection.
Definition: cachepolicypage.cpp:99
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:128
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:15 by doxygen 1.8.5 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-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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