TargetResults.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef TARGETRESULTS_H
#define TARGETRESULTS_H
#include <QString>
#include <QList>
#include <QObject>
class QDomDocument;
class QDomElement;
namespace Buteo {
class TargetResultsPrivate;
struct ItemCounts
{
Q_GADGET
Q_PROPERTY(unsigned added MEMBER added)
Q_PROPERTY(unsigned deleted MEMBER deleted)
Q_PROPERTY(unsigned modified MEMBER modified)
public:
unsigned added;
unsigned deleted;
unsigned modified;
ItemCounts()
: added(0), deleted(0), modified(0)
{}
ItemCounts(unsigned aAdded, unsigned aDeleted, unsigned aModified)
: added(aAdded), deleted(aDeleted), modified(aModified)
{}
};
class TargetResults
{
Q_GADGET
Q_PROPERTY(QString target READ targetName)
Q_PROPERTY(Buteo::ItemCounts local READ localItems)
Q_PROPERTY(Buteo::ItemCounts remote READ remoteItems)
Q_PROPERTY(QStringList localAdditions READ localAdditions)
Q_PROPERTY(QStringList localDeletions READ localDeletions)
Q_PROPERTY(QStringList localModifications READ localModifications)
Q_PROPERTY(QStringList localFailures READ localFailures)
Q_PROPERTY(QStringList remoteAdditions READ remoteAdditions)
Q_PROPERTY(QStringList remoteDeletions READ remoteDeletions)
Q_PROPERTY(QStringList remoteModifications READ remoteModifications)
Q_PROPERTY(QStringList remoteFailures READ remoteFailures)
public:
enum ItemOperation {
ITEM_ADDED,
ITEM_DELETED,
ITEM_MODIFIED
};
enum ItemOperationStatus {
ITEM_OPERATION_SUCCEEDED,
ITEM_OPERATION_FAILED
};
TargetResults();
TargetResults(const TargetResults &aSource);
TargetResults(const QString &aTargetName, ItemCounts aLocalItems = ItemCounts(),
ItemCounts aRemoteItems = ItemCounts());
explicit TargetResults(const QDomElement &aRoot);
~TargetResults();
TargetResults &operator=(const TargetResults &aRhs);
QDomElement toXml(QDomDocument &aDoc) const;
QString targetName() const;
ItemCounts localItems() const;
ItemCounts remoteItems() const;
void addLocalDetails(const QString &aUid,
ItemOperation aOperation,
ItemOperationStatus aStatus = ITEM_OPERATION_SUCCEEDED,
const QString &aMessage = QString());
void addRemoteDetails(const QString &aUid,
ItemOperation aOperation,
ItemOperationStatus aStatus = ITEM_OPERATION_SUCCEEDED,
const QString &aMessage = QString());
QList<QString> localDetails(ItemOperation aOperation,
ItemOperationStatus aStatus) const;
Q_INVOKABLE QString localMessage(const QString &aUid) const;
QList<QString> remoteDetails(ItemOperation aOperation,
ItemOperationStatus aStatus) const;
Q_INVOKABLE QString remoteMessage(const QString &aUid) const;
private:
QStringList localAdditions() const { return localDetails(ITEM_ADDED, ITEM_OPERATION_SUCCEEDED); }
QStringList localDeletions() const { return localDetails(ITEM_DELETED, ITEM_OPERATION_SUCCEEDED); }
QStringList localModifications() const { return localDetails(ITEM_MODIFIED, ITEM_OPERATION_SUCCEEDED); }
QStringList localFailures() const {
return localDetails(ITEM_ADDED, ITEM_OPERATION_FAILED)
+ localDetails(ITEM_MODIFIED, ITEM_OPERATION_FAILED)
+ localDetails(ITEM_DELETED, ITEM_OPERATION_FAILED);
}
QStringList remoteAdditions() const { return remoteDetails(ITEM_ADDED, ITEM_OPERATION_SUCCEEDED); }
QStringList remoteDeletions() const { return remoteDetails(ITEM_DELETED, ITEM_OPERATION_SUCCEEDED); }
QStringList remoteModifications() const { return remoteDetails(ITEM_MODIFIED, ITEM_OPERATION_SUCCEEDED); }
QStringList remoteFailures() const
{
return remoteDetails(ITEM_ADDED, ITEM_OPERATION_FAILED)
+ remoteDetails(ITEM_MODIFIED, ITEM_OPERATION_FAILED)
+ remoteDetails(ITEM_DELETED, ITEM_OPERATION_FAILED);
}
TargetResultsPrivate *d_ptr;
};
}
Q_DECLARE_METATYPE(Buteo::ItemCounts)
Q_DECLARE_METATYPE(Buteo::TargetResults)
#endif // TARGETRESULTS_H
Buteo::TargetResults
Sync results for one target.
Definition TargetResults.h:72
Buteo::TargetResults::operator=
TargetResults & operator=(const TargetResults &aRhs)
Assignment operator.
Definition TargetResults.cpp:197
Buteo::TargetResults::remoteItems
ItemCounts remoteItems() const
Gets the counts of items added, deleted and modified at remote.
Definition TargetResults.cpp:255
Buteo::TargetResults::addRemoteDetails
void addRemoteDetails(const QString &aUid, ItemOperation aOperation, ItemOperationStatus aStatus=ITEM_OPERATION_SUCCEEDED, const QString &aMessage=QString())
Add some details on the remote changes done during the sync process.
Definition TargetResults.cpp:288
Buteo::TargetResults::~TargetResults
~TargetResults()
Destructor.
Definition TargetResults.cpp:191
Buteo::TargetResults::localDetails
QList< QString > localDetails(ItemOperation aOperation, ItemOperationStatus aStatus) const
Gets the details, if any for changes done local during a sync process.
Definition TargetResults.cpp:316
Buteo::TargetResults::toXml
QDomElement toXml(QDomDocument &aDoc) const
Exports the target results to XML.
Definition TargetResults.cpp:207
Buteo::TargetResults::addLocalDetails
void addLocalDetails(const QString &aUid, ItemOperation aOperation, ItemOperationStatus aStatus=ITEM_OPERATION_SUCCEEDED, const QString &aMessage=QString())
Add some details on the local changes done during the sync process.
Definition TargetResults.cpp:260
Buteo::TargetResults::localMessage
Q_INVOKABLE QString localMessage(const QString &aUid) const
Gets a possible message related to the a given item.
Definition TargetResults.cpp:331
Buteo::TargetResults::targetName
QString targetName() const
Gets the target name.
Definition TargetResults.cpp:245
Buteo::TargetResults::remoteDetails
QList< QString > remoteDetails(ItemOperation aOperation, ItemOperationStatus aStatus) const
Gets the details, if any for changes done remote during a sync process.
Definition TargetResults.cpp:344
Buteo::TargetResults::remoteMessage
Q_INVOKABLE QString remoteMessage(const QString &aUid) const
Gets a possible message related to the a given item.
Definition TargetResults.cpp:358
Buteo::TargetResults::localItems
ItemCounts localItems() const
Gets the counts of items added, deleted and modified locally.
Definition TargetResults.cpp:250
QList
Definition SyncBackupAdaptor.h:40
Buteo::ItemCounts
Container for number of items added, deleted and modified.
Definition TargetResults.h:39
Buteo::ItemCounts::modified
unsigned modified
No. of Items modified.
Definition TargetResults.h:43
Buteo::ItemCounts::ItemCounts
ItemCounts()
Default Constructor.
Definition TargetResults.h:56
Buteo::ItemCounts::ItemCounts
ItemCounts(unsigned aAdded, unsigned aDeleted, unsigned aModified)
Constructor with 3 parameters.
Definition TargetResults.h:61
Buteo::ItemCounts::added
unsigned added
No. of Items added.
Definition TargetResults.h:41
Buteo::ItemCounts::deleted
unsigned deleted
No. of Items deleted.
Definition TargetResults.h:42