Commit 93afc8d8 authored by Guy Maurel's avatar Guy Maurel
Browse files

Coding style

REVIEWS:  116169 116170 116171 116172 116173 116174 116175 116176 116177 116178 116179 116180 116181 116182 116183 116184 116185 116186 116187 116188 116189 116190 116191 116192 116193 116194 116195 116196 116197 116198 116199 116200 116201 116202 116203 116204 116205 116206 116207 116208 116209 116210 116211 116212 116213 116214 116215 116216 116217 116218 116219 116220 116221 116222 116223 116224 116225 116226 116227 116228 116229 116230 116231 116232 116233 116234 116235 116236 116237 116238 116239 116240 116241 116242 116243
parent 2236b2f7
......@@ -27,23 +27,23 @@ using namespace Akonadi;
*/
class CachePolicy::Private : public QSharedData
{
public:
Private() :
QSharedData(),
inherit( true ),
timeout( -1 ),
interval( -1 ),
syncOnDemand( false )
public:
Private()
: QSharedData()
, inherit(true)
, timeout(-1)
, interval(-1)
, syncOnDemand(false)
{}
Private( const Private &other ) :
QSharedData( other )
Private(const Private &other)
: QSharedData(other)
{
inherit = other.inherit;
localParts = other.localParts;
timeout = other.timeout;
interval = other.interval;
syncOnDemand = other.syncOnDemand;
inherit = other.inherit;
localParts = other.localParts;
timeout = other.timeout;
interval = other.interval;
syncOnDemand = other.syncOnDemand;
}
bool inherit;
......@@ -53,13 +53,13 @@ class CachePolicy::Private : public QSharedData
bool syncOnDemand;
};
CachePolicy::CachePolicy() :
d( new Private )
CachePolicy::CachePolicy()
: d(new Private)
{
}
CachePolicy::CachePolicy(const CachePolicy & other) :
d( other.d )
CachePolicy::CachePolicy(const CachePolicy &other)
: d(other.d)
{
}
......@@ -67,79 +67,79 @@ CachePolicy::~ CachePolicy()
{
}
CachePolicy & CachePolicy::operator =(const CachePolicy & other)
CachePolicy &CachePolicy::operator =(const CachePolicy &other)
{
d = other.d;
return *this;
d = other.d;
return *this;
}
bool Akonadi::CachePolicy::operator ==(const CachePolicy & other) const
bool Akonadi::CachePolicy::operator ==(const CachePolicy &other) const
{
if ( !d->inherit && !other.d->inherit ) {
return d->localParts == other.d->localParts
&& d->timeout == other.d->timeout
&& d->interval == other.d->interval
&& d->syncOnDemand == other.d->syncOnDemand;
}
return d->inherit == other.d->inherit;
if (!d->inherit && !other.d->inherit) {
return d->localParts == other.d->localParts
&& d->timeout == other.d->timeout
&& d->interval == other.d->interval
&& d->syncOnDemand == other.d->syncOnDemand;
}
return d->inherit == other.d->inherit;
}
bool CachePolicy::inheritFromParent() const
{
return d->inherit;
return d->inherit;
}
void CachePolicy::setInheritFromParent(bool inherit)
{
d->inherit = inherit;
d->inherit = inherit;
}
QStringList CachePolicy::localParts() const
{
return d->localParts;
return d->localParts;
}
void CachePolicy::setLocalParts(const QStringList & parts)
void CachePolicy::setLocalParts(const QStringList &parts)
{
d->localParts = parts;
d->localParts = parts;
}
int CachePolicy::cacheTimeout() const
{
return d->timeout;
return d->timeout;
}
void CachePolicy::setCacheTimeout(int timeout)
{
d->timeout = timeout;
d->timeout = timeout;
}
int CachePolicy::intervalCheckTime() const
{
return d->interval;
return d->interval;
}
void CachePolicy::setIntervalCheckTime(int time)
{
d->interval = time;
d->interval = time;
}
bool CachePolicy::syncOnDemand() const
{
return d->syncOnDemand;
return d->syncOnDemand;
}
void CachePolicy::setSyncOnDemand(bool enable)
{
d->syncOnDemand = enable;
d->syncOnDemand = enable;
}
QDebug operator<<( QDebug d, const CachePolicy& c )
QDebug operator<<(QDebug d, const CachePolicy &c)
{
return d << "CachePolicy: " << endl
<< " inherit:" << c.inheritFromParent() << endl
<< " interval:" << c.intervalCheckTime() << endl
<< " timeout:" << c.cacheTimeout() << endl
<< " sync on demand:" << c.syncOnDemand() << endl
<< " local parts:" << c.localParts();
<< " inherit:" << c.inheritFromParent() << endl
<< " interval:" << c.intervalCheckTime() << endl
<< " timeout:" << c.cacheTimeout() << endl
<< " sync on demand:" << c.syncOnDemand() << endl
<< " local parts:" << c.localParts();
}
......@@ -70,7 +70,7 @@ namespace Akonadi {
*/
class AKONADI_EXPORT CachePolicy
{
public:
public:
/**
* Creates an empty cache policy.
*/
......@@ -79,7 +79,7 @@ class AKONADI_EXPORT CachePolicy
/**
* Creates a cache policy from an @p other cache policy.
*/
CachePolicy( const CachePolicy &other );
CachePolicy(const CachePolicy &other);
/**
* Destroys the cache policy.
......@@ -94,7 +94,7 @@ class AKONADI_EXPORT CachePolicy
/**
* Sets whether the cache policy should be inherited from the parent collection.
*/
void setInheritFromParent( bool inherit );
void setInheritFromParent(bool inherit);
/**
* Returns the parts to permanently cache locally.
......@@ -104,7 +104,7 @@ class AKONADI_EXPORT CachePolicy
/**
* Specifies the parts to permanently cache locally.
*/
void setLocalParts( const QStringList &parts );
void setLocalParts(const QStringList &parts);
/**
* Returns the cache timeout for non-permanently cached parts in minutes;
......@@ -116,7 +116,7 @@ class AKONADI_EXPORT CachePolicy
* Sets cache timeout for non-permanently cached parts.
* @param timeout Timeout in minutes, -1 for indefinitely.
*/
void setCacheTimeout( int timeout );
void setCacheTimeout(int timeout);
/**
* Returns the interval check time in minutes, -1 for never.
......@@ -127,7 +127,7 @@ class AKONADI_EXPORT CachePolicy
* Sets interval check time.
* @param time Check time interval in minutes, -1 for never.
*/
void setIntervalCheckTime( int time );
void setIntervalCheckTime(int time);
/**
* Returns whether the collection will be synced automatically when necessary,
......@@ -140,21 +140,21 @@ class AKONADI_EXPORT CachePolicy
* i.e. as soon as it is accessed by a client.
* @param enable If @c true the collection is synced.
*/
void setSyncOnDemand( bool enable );
void setSyncOnDemand(bool enable);
/**
* @internal.
* @param other other cache policy
*/
CachePolicy& operator=( const CachePolicy &other );
CachePolicy &operator=(const CachePolicy &other);
/**
* @internal
* @param other other cache policy
*/
bool operator==( const CachePolicy &other ) const;
bool operator==(const CachePolicy &other) const;
private:
private:
//@cond PRIVATE
class Private;
QSharedDataPointer<Private> d;
......@@ -166,6 +166,6 @@ class AKONADI_EXPORT CachePolicy
/**
* Allows a cache policy to be output for debugging purposes.
*/
AKONADI_EXPORT QDebug operator<<( QDebug, const Akonadi::CachePolicy& );
AKONADI_EXPORT QDebug operator<<(QDebug, const Akonadi::CachePolicy &);
#endif
......@@ -29,137 +29,137 @@ using namespace Akonadi;
class CachePolicyPage::Private
{
public:
public:
Private()
: mUi( new Ui::CachePolicyPage )
: mUi(new Ui::CachePolicyPage)
{
}
~Private()
{
delete mUi;
delete mUi;
}
void slotIntervalValueChanged( int );
void slotCacheValueChanged( int );
void slotRetrievalOptionsGroupBoxDisabled( bool disable );
void slotIntervalValueChanged(int);
void slotCacheValueChanged(int);
void slotRetrievalOptionsGroupBoxDisabled(bool disable);
Ui::CachePolicyPage* mUi;
Ui::CachePolicyPage *mUi;
};
void CachePolicyPage::Private::slotIntervalValueChanged( int interval )
void CachePolicyPage::Private::slotIntervalValueChanged(int interval)
{
mUi->checkInterval->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
mUi->checkInterval->setSuffix(QLatin1Char(' ') + i18np("minute", "minutes", interval));
}
void CachePolicyPage::Private::slotCacheValueChanged( int interval )
void CachePolicyPage::Private::slotCacheValueChanged(int interval)
{
mUi->localCacheTimeout->setSuffix( QLatin1Char( ' ' ) + i18np( "minute", "minutes", interval ) );
mUi->localCacheTimeout->setSuffix(QLatin1Char(' ') + i18np("minute", "minutes", interval));
}
void CachePolicyPage::Private::slotRetrievalOptionsGroupBoxDisabled( bool disable )
void CachePolicyPage::Private::slotRetrievalOptionsGroupBoxDisabled(bool disable)
{
mUi->retrievalOptionsGroupBox->setDisabled( disable );
if ( !disable ) {
mUi->label->setEnabled( mUi->retrieveOnlyHeaders->isChecked() );
mUi->localCacheTimeout->setEnabled( mUi->retrieveOnlyHeaders->isChecked() );
}
mUi->retrievalOptionsGroupBox->setDisabled(disable);
if (!disable) {
mUi->label->setEnabled(mUi->retrieveOnlyHeaders->isChecked());
mUi->localCacheTimeout->setEnabled(mUi->retrieveOnlyHeaders->isChecked());
}
}
CachePolicyPage::CachePolicyPage( QWidget *parent, GuiMode mode )
: CollectionPropertiesPage( parent ),
d( new Private )
CachePolicyPage::CachePolicyPage(QWidget *parent, GuiMode mode)
: CollectionPropertiesPage(parent)
, d(new Private)
{
setObjectName( QLatin1String( "Akonadi::CachePolicyPage" ) );
setPageTitle( i18n( "Retrieval" ) );
d->mUi->setupUi( this );
connect( d->mUi->checkInterval, SIGNAL(valueChanged(int)),
SLOT(slotIntervalValueChanged(int)) );
connect( d->mUi->localCacheTimeout, SIGNAL(valueChanged(int)),
SLOT(slotCacheValueChanged(int)) );
connect( d->mUi->inherit, SIGNAL(toggled(bool)),
SLOT(slotRetrievalOptionsGroupBoxDisabled(bool)));
if ( mode == AdvancedMode ) {
d->mUi->stackedWidget->setCurrentWidget( d->mUi->rawPage );
}
setObjectName(QLatin1String("Akonadi::CachePolicyPage"));
setPageTitle(i18n("Retrieval"));
d->mUi->setupUi(this);
connect(d->mUi->checkInterval, SIGNAL(valueChanged(int)),
SLOT(slotIntervalValueChanged(int)));
connect(d->mUi->localCacheTimeout, SIGNAL(valueChanged(int)),
SLOT(slotCacheValueChanged(int)));
connect(d->mUi->inherit, SIGNAL(toggled(bool)),
SLOT(slotRetrievalOptionsGroupBoxDisabled(bool)));
if (mode == AdvancedMode) {
d->mUi->stackedWidget->setCurrentWidget(d->mUi->rawPage);
}
}
CachePolicyPage::~CachePolicyPage()
{
delete d;
delete d;
}
bool Akonadi::CachePolicyPage::canHandle( const Collection &collection ) const
bool Akonadi::CachePolicyPage::canHandle(const Collection &collection) const
{
return !collection.isVirtual();
return !collection.isVirtual();
}
void CachePolicyPage::load( const Collection &collection )
void CachePolicyPage::load(const Collection &collection)
{
const CachePolicy policy = collection.cachePolicy();
int interval = policy.intervalCheckTime();
if ( interval == -1 ) {
interval = 0;
}
int cache = policy.cacheTimeout();
if ( cache == -1 ) {
cache = 0;
}
d->mUi->inherit->setChecked( policy.inheritFromParent() );
d->mUi->checkInterval->setValue( interval );
d->mUi->localCacheTimeout->setValue( cache );
d->mUi->syncOnDemand->setChecked( policy.syncOnDemand() );
d->mUi->localParts->setItems( policy.localParts() );
const bool fetchBodies = policy.localParts().contains( QLatin1String( "RFC822" ) );
d->mUi->retrieveFullMessages->setChecked( fetchBodies );
//done explicitly to disable/enabled widgets
d->mUi->retrieveOnlyHeaders->setChecked( !fetchBodies );
d->mUi->label->setEnabled( !fetchBodies );
d->mUi->localCacheTimeout->setEnabled( !fetchBodies );
const CachePolicy policy = collection.cachePolicy();
int interval = policy.intervalCheckTime();
if (interval == -1) {
interval = 0;
}
int cache = policy.cacheTimeout();
if (cache == -1) {
cache = 0;
}
d->mUi->inherit->setChecked(policy.inheritFromParent());
d->mUi->checkInterval->setValue(interval);
d->mUi->localCacheTimeout->setValue(cache);
d->mUi->syncOnDemand->setChecked(policy.syncOnDemand());
d->mUi->localParts->setItems(policy.localParts());
const bool fetchBodies = policy.localParts().contains(QLatin1String("RFC822"));
d->mUi->retrieveFullMessages->setChecked(fetchBodies);
//done explicitly to disable/enabled widgets
d->mUi->retrieveOnlyHeaders->setChecked(!fetchBodies);
d->mUi->label->setEnabled(!fetchBodies);
d->mUi->localCacheTimeout->setEnabled(!fetchBodies);
}
void CachePolicyPage::save( Collection &collection )
void CachePolicyPage::save(Collection &collection)
{
int interval = d->mUi->checkInterval->value();
if ( interval == 0 ) {
interval = -1;
}
int cache = d->mUi->localCacheTimeout->value();
if ( cache == 0 ) {
cache = -1;
}
CachePolicy policy = collection.cachePolicy();
policy.setInheritFromParent( d->mUi->inherit->isChecked() );
policy.setIntervalCheckTime( interval );
policy.setCacheTimeout( cache );
policy.setSyncOnDemand( d->mUi->syncOnDemand->isChecked() );
QStringList localParts = d->mUi->localParts->items();
// Unless we are in "raw" mode, add "bodies" to the list of message
// parts to keep around locally, if the user selected that, or remove
// it otherwise. In "raw" mode we simple use the values from the list
// view.
if ( d->mUi->stackedWidget->currentWidget() != d->mUi->rawPage ) {
if ( d->mUi->retrieveFullMessages->isChecked() &&
!localParts.contains( QLatin1String( "RFC822" ) ) ) {
localParts.append( QLatin1String( "RFC822" ) );
} else if ( !d->mUi->retrieveFullMessages->isChecked() &&
localParts.contains( QLatin1String( "RFC822" ) ) ) {
localParts.removeAll( QLatin1String( "RFC822" ) );
int interval = d->mUi->checkInterval->value();
if (interval == 0) {
interval = -1;
}
int cache = d->mUi->localCacheTimeout->value();
if (cache == 0) {
cache = -1;
}
CachePolicy policy = collection.cachePolicy();
policy.setInheritFromParent(d->mUi->inherit->isChecked());
policy.setIntervalCheckTime(interval);
policy.setCacheTimeout(cache);
policy.setSyncOnDemand(d->mUi->syncOnDemand->isChecked());
QStringList localParts = d->mUi->localParts->items();
// Unless we are in "raw" mode, add "bodies" to the list of message
// parts to keep around locally, if the user selected that, or remove
// it otherwise. In "raw" mode we simple use the values from the list
// view.
if (d->mUi->stackedWidget->currentWidget() != d->mUi->rawPage) {
if (d->mUi->retrieveFullMessages->isChecked() &&
!localParts.contains(QLatin1String("RFC822"))) {
localParts.append(QLatin1String("RFC822"));
} else if (!d->mUi->retrieveFullMessages->isChecked() &&
localParts.contains(QLatin1String("RFC822"))) {
localParts.removeAll(QLatin1String("RFC822"));
}
}
}
policy.setLocalParts( localParts );
collection.setCachePolicy( policy );
policy.setLocalParts(localParts);
collection.setCachePolicy(policy);
}
#include "moc_cachepolicypage.cpp"
......@@ -41,15 +41,15 @@ namespace Akonadi {
*/
class AKONADI_EXPORT CachePolicyPage : public CollectionPropertiesPage
{
Q_OBJECT
Q_OBJECT
public:
public:
/**
* Describes the mode of the cache policy page.
*/
enum GuiMode {
UserMode, ///< A simplified UI for end-users will be provided.
AdvancedMode ///< An advanced UI for debugging will be provided.
UserMode, ///< A simplified UI for end-users will be provided.
AdvancedMode ///< An advanced UI for debugging will be provided.
};
/**
......@@ -58,7 +58,7 @@ class AKONADI_EXPORT CachePolicyPage : public CollectionPropertiesPage
* @param parent The parent widget.
* @param mode The UI mode that will be used for the page.
*/
explicit CachePolicyPage( QWidget *parent, GuiMode mode = UserMode );
explicit CachePolicyPage(QWidget *parent, GuiMode mode = UserMode);
/**
* Destroys the cache policy page.
......@@ -68,31 +68,31 @@ class AKONADI_EXPORT CachePolicyPage : public CollectionPropertiesPage
/**
* Checks if the cache policy page can actually handle the given @p collection.
*/
bool canHandle( const Collection &collection ) const;
bool canHandle(const Collection &collection) const;
/**
* Loads the page content from the given @p collection.
*/
void load( const Collection &collection );
void load(const Collection &collection);
/**
* Saves page content to the given @p collection.
*/
void save( Collection &collection );
void save(Collection &collection);
private:
private:
//@cond PRIVATE
class Private;
Private* const d;
Private *const d;
Q_PRIVATE_SLOT( d, void slotIntervalValueChanged( int ) )
Q_PRIVATE_SLOT( d, void slotCacheValueChanged( int ) )
Q_PRIVATE_SLOT( d, void slotRetrievalOptionsGroupBoxDisabled( bool ) )
Q_PRIVATE_SLOT(d, void slotIntervalValueChanged(int))
Q_PRIVATE_SLOT(d, void slotCacheValueChanged(int))
Q_PRIVATE_SLOT(d, void slotRetrievalOptionsGroupBoxDisabled(bool))
//@endcond
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CachePolicyPageFactory, CachePolicyPage )
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY(CachePolicyPageFactory, CachePolicyPage)
}
......
......@@ -38,154 +38,153 @@ using namespace Akonadi;
K_GLOBAL_STATIC(ChangeMediator, s_globalChangeMediator)
ChangeMediator* ChangeMediator::instance()
ChangeMediator *ChangeMediator::instance()
{
if ( s_globalChangeMediator.isDestroyed() ) {
return 0;
} else {
return s_globalChangeMediator;
}
if (s_globalChangeMediator.isDestroyed()) {
return 0;
} else {
return s_globalChangeMediator;
}
}
ChangeMediator::ChangeMediator(QObject *parent)
: QObject(parent)
: QObject(parent)
{
if ( qApp ) {
this->moveToThread( qApp->thread() );
}
if (qApp) {
this->moveToThread(qApp->thread());
}
}
/* static */
void ChangeMediator::registerMonitor(QObject *monitor)
{
QMetaObject::invokeMethod( instance(), "do_registerMonitor", Q_ARG( QObject*, monitor ) );
QMetaObject::invokeMethod(instance(), "do_registerMonitor", Q_ARG(QObject *, monitor));
}
/* static */