BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
importtablemodel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/dataloader/importtablemodel.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI2_DATALOADER_IMPORTTABLEMODEL_H
16 #define BORNAGAIN_GUI2_DATALOADER_IMPORTTABLEMODEL_H
17 
18 #include "darefl_export.h"
19 #include <QAbstractTableModel>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace gui2 {
25 
26 struct ColumnInfo;
27 
28 class ImportTableHeader;
29 
30 //! Table model to hold imported ASCII data after parsing it to multi-column presentation.
31 
32 class DAREFLCORE_EXPORT ImportTableModel : public QAbstractTableModel {
33  Q_OBJECT
34 
35 public:
36  using raw_data_t = std::vector<std::vector<std::string>>;
37 
38  ImportTableModel(QObject* parent = nullptr);
39  ~ImportTableModel() override;
40 
41  void setRawData(const raw_data_t& raw_data);
42 
43  int rowCount(const QModelIndex& = QModelIndex()) const override;
44 
45  int columnCount(const QModelIndex& = QModelIndex()) const override;
46 
47  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
48 
49  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
50 
51  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
52 
53  Qt::ItemFlags flags(const QModelIndex& index) const override;
54 
55  std::vector<ColumnInfo> columnInfo() const;
56 
57 private:
58  int utilityRowCount() const;
59  QVariant dataFromIndex(const QModelIndex& index) const;
60 
61  std::unique_ptr<ImportTableHeader> m_header;
62  raw_data_t m_rawData; //! parsed column data
63 
64  int m_maxColumnCount{0};
65 };
66 
67 } // namespace gui2
68 
69 #endif // BORNAGAIN_GUI2_DATALOADER_IMPORTTABLEMODEL_H
Table model to hold imported ASCII data after parsing it to multi-column presentation.
std::unique_ptr< ImportTableHeader > m_header
~ImportTableModel() override
std::vector< std::vector< std::string > > raw_data_t
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20