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
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 BINARYFILELISTINGMODEL_H
22 #define BINARYFILELISTINGMODEL_H
23 
24 #include <QAbstractTableModel>
25 #include "../util/hash.h"
26 #include "../mcontroller.h"
27 
28 class BinaryFile ;
29 class Model ;
34 class BinaryFileListingModel: public QAbstractTableModel {
35  Q_OBJECT
36 public:
37  BinaryFileListingModel(QList<Hash>& aFilesToList) ;
45  void addFile(const Hash& aFingerPrint) ;
51  void removeFile(const Hash& aFingerPrint) ;
52 
56  QString fileDisplayNameByFingerPrint(const Hash& aFingerPrint) ;
57 
62  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const ;
67  virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const ;
72  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const ;
73  virtual QVariant headerData(int aSection, Qt::Orientation orientation, int role) const ;
77  void clear() ;
78 signals:
80  const QString& aExplanation) ;
81 private: // methods
82  void updateFileDataInArray( const Hash& aFingerPrint,bool aEmit ) ;
83 private: // data
84  QList<Hash>& iFilesToList ;
85  QList<QPair<Hash,QString> > iNamesAndFingerPrints ;
86 } ;
87 #endif
QString fileDisplayNameByFingerPrint(const Hash &aFingerPrint)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:52
void removeFile(const Hash &aFingerPrint)
virtual QVariant headerData(int aSection, Qt::Orientation orientation, int role) const
Carrier-class for binary blob.
Definition: binaryfile.h:37
Model-class for helping display of shared binary blobs, usually from a profile.
Definition: binaryfilelistingmodel.h:34
QList< Hash > & iFilesToList
Definition: binaryfilelistingmodel.h:84
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:48
QList< QPair< Hash, QString > > iNamesAndFingerPrints
Definition: binaryfilelistingmodel.h:85
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)