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 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 PRIVMSGSEARCHMODEL_H
21 #define PRIVMSGSEARCHMODEL_H
22 
23 #include <QAbstractListModel>
24 #include "../util/hash.h"
25 #include "../mcontroller.h"
26 #include <QIcon>
27 
28 class Model ;
29 class PrivMessage ;
35 class PrivateMessageSearchModel: public QAbstractTableModel {
36  Q_OBJECT
37 public: // types:
39  {
43  quint32 iMessageTimeStamp ;
44  QString iMessageSubject ;
45  QString iSenderName ;
46  bool iIsRead ;
47  } ;
48 public:
49  PrivateMessageSearchModel(Model& aModel,MController& aController) ;
51 
60  void setSearchHash(const Hash& aSearch) ;
65  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const ;
70  virtual int columnCount(const QModelIndex & parent = QModelIndex()) const ;
75  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const ;
76  virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const ;
77 
78  void setAsRead(const Hash& aMessage, bool aIsRead) ;
83  void newMsgReceived(const Hash& aMessage,const Hash& aRecipient) ;
89  void newMsgReceived(const PrivMessage& aMessage) ;
90 signals:
92  const QString& aExplanation) ;
93 public slots:
99  void doUpdateDataOnIdle() ;
100 private:// methods
101  void performSearch() ;
103 
104 private: // data
107  QList<PrivateMessageListItem> iPrivateMessages ;
109  QIcon iLeftIcon;
110  QIcon iRightIcon;
111 } ;
112 #endif
Hash iMessageHash
Definition: privmsgsearchmodel.h:40
Carrier-class for private msg inside classified ads.
Definition: privmsg.h:35
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
MController & iController
Definition: privmsgsearchmodel.h:106
QIcon iLeftIcon
Definition: privmsgsearchmodel.h:109
QIcon iRightIcon
Definition: privmsgsearchmodel.h:110
void setAsRead(const Hash &aMessage, bool aIsRead)
Definition: privmsgsearchmodel.h:38
Model & iModel
Definition: privmsgsearchmodel.h:105
QString iSenderName
Definition: privmsgsearchmodel.h:45
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
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:39
Model-class for performing search on private messages. This is supposed to act as an underlying data-...
Definition: privmsgsearchmodel.h:35
Hash iSearchHash
Definition: privmsgsearchmodel.h:108
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QList< PrivateMessageListItem > iPrivateMessages
Definition: privmsgsearchmodel.h:107
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
QString iMessageSubject
Definition: privmsgsearchmodel.h:44
PrivateMessageSearchModel(Model &aModel, MController &aController)
Hash iRecipientHash
Definition: privmsgsearchmodel.h:41
void updateSenderAndSubjectOfMsg(PrivateMessageListItem &aItem)
Hash iSenderHash
Definition: privmsgsearchmodel.h:42
bool iIsRead
Definition: privmsgsearchmodel.h:46
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const