Classified ads
binaryfilelistingmodel.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 BINARYFILELISTINGMODEL_H
21 #define BINARYFILELISTINGMODEL_H
22 
23 #include <QAbstractTableModel>
24 #include "../util/hash.h"
25 #include "../mcontroller.h"
26 
27 class BinaryFile ;
28 class Model ;
33 class BinaryFileListingModel: public QAbstractTableModel {
34  Q_OBJECT
35 public:
36  BinaryFileListingModel(QList<Hash>& aFilesToList) ;
44  void addFile(const Hash& aFingerPrint) ;
50  void removeFile(const Hash& aFingerPrint) ;
51 
55  QString fileDisplayNameByFingerPrint(const Hash& aFingerPrint) ;
56 
61  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const ;
66  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const ;
71  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const ;
72  virtual QVariant headerData(int aSection, Qt::Orientation orientation, int role) const ;
73 signals:
75  const QString& aExplanation) ;
76 private: // methods
77  void updateFileDataInArray( const Hash& aFingerPrint,bool aEmit ) ;
78 private: // data
79  QList<Hash>& iFilesToList ;
80  QList<QPair<Hash,QString> > iNamesAndFingerPrints ;
81 } ;
82 #endif
QString fileDisplayNameByFingerPrint(const Hash &aFingerPrint)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
void removeFile(const Hash &aFingerPrint)
virtual QVariant headerData(int aSection, Qt::Orientation orientation, int role) const
Carrier-class for binary blob.
Definition: binaryfile.h:36
Model-class for helping display of shared binary blobs, usually from a profile.
Definition: binaryfilelistingmodel.h:33
QList< Hash > & iFilesToList
Definition: binaryfilelistingmodel.h:79
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
BinaryFileListingModel(QList< Hash > &aFilesToList)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
QList< QPair< Hash, QString > > iNamesAndFingerPrints
Definition: binaryfilelistingmodel.h:80
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
void addFile(const Hash &aFingerPrint)
void error(MController::CAErrorSituation aError, const QString &aExplanation)
void updateFileDataInArray(const Hash &aFingerPrint, bool aEmit)