DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
csvtablemodel.h
Go to the documentation of this file.
1 #ifndef CSVTABLEMODEL_H
2 #define CSVTABLEMODEL_H
3 
4 #include <qtcommons_global.h>
5 #include <QAbstractTableModel>
6 #include <QList>
7 #include <QStringList>
8 
9 #include <memory>
10 
11 class QTCOMMONSSHARED_EXPORT CsvTableModel : public QAbstractTableModel
12 {
13  Q_OBJECT
14 public:
15  explicit CsvTableModel(std::shared_ptr<QList<QStringList> > data, QObject *parent = 0);
16 
17  int rowCount(const QModelIndex &) const { return mRowCount - (mHeaders ? 1 : 0); }
18  int columnCount(const QModelIndex &) const { return mColCount; }
19 
20  QVariant data(const QModelIndex &index, int role) const;
21  bool setData(const QModelIndex &index, const QVariant &value, int role);
22  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
23 
24  Qt::ItemFlags flags(const QModelIndex &index) const;
25 
26  bool insertRows(int row, int count, const QModelIndex &parent);
27  bool removeRows(int row, int count, const QModelIndex &parent);
28 
29  void setSource (std::shared_ptr<QList<QStringList> > data);
30  void setFirstLineHeaders(bool x);
31 
32  const QList<QStringList> &rawData() const { return *mData; }
33 signals:
34 
35 public slots:
36 
37 private:
38  bool mHeaders;
39  std::shared_ptr<QList<QStringList> > mData;
40  int mRowCount, mColCount;
41 
42  void scan();
43 };
44 
45 #endif // CSVTABLEMODEL_H
#define QTCOMMONSSHARED_EXPORT
Definition: qtcommons_global.h:16
Definition: csvtablemodel.h:11
const QList< QStringList > & rawData() const
Definition: csvtablemodel.h:32
int rowCount(const QModelIndex &) const
Definition: csvtablemodel.h:17
int columnCount(const QModelIndex &) const
Definition: csvtablemodel.h:18
std::pair< box, unsigned > value
Definition: diffusion.cpp:30