diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntnamefetcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntnamefetcher.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Private data and helper classes used by class CntCache. +* +*/ + +#ifndef CNTNAMEFETCHER_H +#define CNTNAMEFETCHER_H + +#include +#include +#include +#include +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntSrvSession; +class CntNameCacheItem; +class XQSettingsManager; +class XQSettingsKey; + +class CntSrvConnection : public QObject +{ + Q_OBJECT +public: + CntSrvConnection(); + ~CntSrvConnection(); + void setAsynchronous(); + bool executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB); + QList names() { return mNames; } + +protected: + bool event(QEvent *event); + +signals: + void namesRead(); + void namesSorted(); + +private: + QThread mThread; + QList mNames; + CntSrvSession *mSession; + QString mSqlQuery; + CntNameOrder mNameFormat; + int mSizeHintKB; + bool mIsAsynchronous; +}; + +class CntAllNamesJob : public CntAbstractJob +{ +public: + virtual bool isEmpty() { return false; } + virtual bool equals(const CntAbstractJob &/*other*/) { return true; } + QString toString() { return QString(); } +}; + +class CntNameFetcher : public CntAbstractFetcher +{ + Q_OBJECT +public: + CntNameFetcher(); + ~CntNameFetcher(); + + // functions for the asynchronous fetching of all names + bool isProcessingJob(); + void processNextJob(); + + // synchronous functions + CntNameCacheItem * fetchOneName(QContactLocalId contactId) const; + bool readNamesFromCache(QList &names); + bool writeNamesToCache(const QList &names) const; + void sortNames(QList &names) const; + static bool compareNames(const CntNameCacheItem *a, const CntNameCacheItem *b); + +signals: + void nameFormatChanged(CntNameOrder nameFormat); + void databaseAccessComplete(); + void namesAvailable(QList contactNames); + +private slots: + void setNameFormat(const XQSettingsKey &key, const QVariant &value); + void sendCompletionSignal(); + +private: + CntSrvConnection *mDbConnection; + CntSrvConnection *mAsynchDbConnection; + XQSettingsManager *mSettingsManager; + XQSettingsKey *mNameFormatSetting; + CntNameOrder mNameFormat; + int mBufferSizeEstimate; + + friend class TestNameFetcher; +}; + +#endif