diff -r 64e38f08e49c -r 47d84de1c893 email_plat/contact_history_model_api/inc/nmcontacthistorymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/email_plat/contact_history_model_api/inc/nmcontacthistorymodel.h Mon Oct 04 00:05:37 2010 +0300 @@ -0,0 +1,142 @@ +/* +* 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: Public declaration of Contact History Model API +* +*/ +#ifndef NMCONTACTHISTORYMODEL_H +#define NMCONTACTHISTORYMODEL_H + +#include +#include + +#include "nmcontacthistorymodelcommon.h" + +// NmContactHistoryModelSubItem - display name is one item, email address/phone number another +class NmContactHistoryModelSubItem +{ +public: + +inline NmContactHistoryModelSubItem() +{ +} + +inline ~NmContactHistoryModelSubItem() +{ +} + // email address, or concatenated firstName+' '+lastName. + QString mItemText; + // amount of items in mMatchingRanges is 2*mItemTexts.length() because for each text there is begin/end index + // TODO: Fix above^ always two indeces + // for example "Ville Virtanen" with query "vi" returns indeces 0,1,6,7 + QList mMatchingRanges; +}; + +class NmContactHistoryModelPrivate; +class NmContactHistoryModelItemData; + +class NMCHMAPI_EXPORT NmContactHistoryModelItem +{ +public: + NmContactHistoryModelItem(); + NmContactHistoryModelItem(const NmContactHistoryModelItem &other); + ~NmContactHistoryModelItem(); + +public: + // contact id is 0xDEAD if not associated with a contact item + unsigned int contactId() const; + + void setContactId(unsigned int contactId); + + int subItemCount() const; + + NmContactHistoryModelSubItem subItemAt(int index) const; + + // First entry is display name, second email address. + QList subEntries() const; + + void appendSubItem(NmContactHistoryModelSubItem entry); + +private: + // + QSharedDataPointer d; +}; +Q_DECLARE_METATYPE(NmContactHistoryModelItem) + +/** + * Model for contact history queries. + * + */ +class NMCHMAPI_EXPORT NmContactHistoryModel : public QAbstractListModel +{ + Q_OBJECT + +public: // The exported API + + /** + * Constructor + * @param modelType + */ + explicit NmContactHistoryModel( + const NmContactHistoryModelType modelType); + + /** + * Destructor + */ + ~NmContactHistoryModel(); + +public: // From QAbstractItemModel + + /** + * Get number of rows currently in the model. + * @return number of rows + */ + virtual int rowCount(const QModelIndex &parent) const; + + /** + * Get various data from the model. Fetched data type is defined + * by role input parameter. Only Qt::DisplayRole is supported. + */ + virtual QVariant data(const QModelIndex &index, int role) const; + +signals: + + /** + * Signaled once model is ready. + * @param err, 0 if building model was success + */ + void modelCompleted(int err); + +public slots: + + // TODO: query could keep previous query in order to check if results will only get narrowed (a char is appended) + void query(const QString &query); + +private slots: + + /** + * Signaled once query is completed, emits modelCompleted. + * @param err, 0 if building model was success + */ + void handleQueryCompleted(int err); + +private: + /* + * Private Implementation + * Own + */ + NmContactHistoryModelPrivate *d_ptr; + +}; + +#endif //NMCONTACTHISTORYMODEL_H