Classified ads
contactlistingmodel.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef CONTACTSEARCHMODEL_H
21 #define CONTACTSEARCHMODEL_H
22 
23 #include <QAbstractListModel>
24 #include "../util/hash.h"
25 #include "../mcontroller.h"
26 #include "contact.h"
27 
28 class Model ;
29 
35 class ContactListingModel: public QAbstractTableModel {
36  Q_OBJECT
37 public:
38  ContactListingModel(Model& aModel,MController& aController) ;
40 
41  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const ;
46  virtual int columnCount(const QModelIndex & parent = QModelIndex()) const ;
51  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const ;
52  virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const ;
53 
54  void newContactAdded(const Contact& aContact) ;
55  void removeContact(const Hash& aContact) ;
61  bool contactByFingerPrint(const Hash& aFingerPrint, Contact* aResultingContact) const ;
65  QVariant contactsAsQVariant() const ;
66  void setContactsFromQVariant(const QVariantList& aContacts) ;
67  bool isContactContained(const Hash& aFingerPrint) const ;
68  void clearContents() ;
69 signals:
71  const QString& aExplanation) ;
72 
73 private: // data
76  QList<Contact> iContacts ;
77 } ;
78 #endif
QList< Contact > iContacts
Definition: contactlistingmodel.h:76
QVariant contactsAsQVariant() const
ContactListingModel(Model &aModel, MController &aController)
bool isContactContained(const Hash &aFingerPrint) const
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
Carrier-class for a profile that is in contacts-list.
Definition: contact.h:34
void newContactAdded(const Contact &aContact)
Model & iModel
Definition: contactlistingmodel.h:74
void error(MController::CAErrorSituation aError, const QString &aExplanation)
MController & iController
Definition: contactlistingmodel.h:75
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
bool contactByFingerPrint(const Hash &aFingerPrint, Contact *aResultingContact) const
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Model-class for performing search on contact-list contacts This is supposed to act as an underlying d...
Definition: contactlistingmodel.h:35
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
void removeContact(const Hash &aContact)
void setContactsFromQVariant(const QVariantList &aContacts)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const