Classified ads
privmsgsearchmodel.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
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (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 GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef PRIVMSGSEARCHMODEL_H
22 #define PRIVMSGSEARCHMODEL_H
23 
24 #include <QAbstractListModel>
25 #include "../util/hash.h"
26 #include "../mcontroller.h"
27 #include <QIcon>
28 
29 class Model ;
30 class PrivMessage ;
36 class PrivateMessageSearchModel: public QAbstractTableModel {
37  Q_OBJECT
38 public: // types:
44  QString iMessageSubject ;
45  QString iSenderName ;
46  bool iIsRead ;
48  } ;
49 public:
50  PrivateMessageSearchModel(Model& aModel,MController& aController) ;
52 
61  void setSearchHash(const Hash& aSearch) ;
66  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const ;
71  virtual int columnCount(const QModelIndex & parent = QModelIndex()) const ;
76  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const ;
77  virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const ;
78 
79  void setAsRead(const Hash& aMessage, bool aIsRead) ;
84  void newMsgReceived(const Hash& aMessage,const Hash& aRecipient) ;
90  void newMsgReceived(const PrivMessage& aMessage) ;
91 signals:
93  const QString& aExplanation) ;
94 public slots:
100  void doUpdateDataOnIdle() ;
101 private:// methods
102  void performSearch() ;
109 
110 private: // data
113  QList<PrivateMessageListItem> iPrivateMessages ;
115  QIcon iLeftIcon;
116  QIcon iRightIcon;
117 } ;
118 #endif
Hash iMessageHash
Definition: privmsgsearchmodel.h:40
Carrier-class for private msg inside classified ads.
Definition: privmsg.h:36
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
MController & iController
Definition: privmsgsearchmodel.h:112
QIcon iLeftIcon
Definition: privmsgsearchmodel.h:115
QIcon iRightIcon
Definition: privmsgsearchmodel.h:116
void setAsRead(const Hash &aMessage, bool aIsRead)
Definition: privmsgsearchmodel.h:39
Model & iModel
Definition: privmsgsearchmodel.h:111
QString iSenderName
Definition: privmsgsearchmodel.h:45
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:52
QString iTrustingProfileName
Definition: privmsgsearchmodel.h:47
void error(MController::CAErrorSituation aError, const QString &aExplanation)
void setSearchHash(const Hash &aSearch)
void newMsgReceived(const Hash &aMessage, const Hash &aRecipient)
quint32 iMessageTimeStamp
Definition: privmsgsearchmodel.h:43
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
Model-class for performing search on private messages. This is supposed to act as an underlying data-...
Definition: privmsgsearchmodel.h:36
Hash iSearchHash
Definition: privmsgsearchmodel.h:114
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QList< PrivateMessageListItem > iPrivateMessages
Definition: privmsgsearchmodel.h:113
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
M of the MVC pattern. Handles permanent storage.
Definition: model.h:48
QString iMessageSubject
Definition: privmsgsearchmodel.h:44
PrivateMessageSearchModel(Model &aModel, MController &aController)
Hash iRecipientHash
Definition: privmsgsearchmodel.h:41
Hash iSenderHash
Definition: privmsgsearchmodel.h:42
bool iIsRead
Definition: privmsgsearchmodel.h:46
bool updateSenderAndSubjectOfMsg(PrivateMessageListItem &aItem)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const