Vespucci  1.0.0
datasettreemodel.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
20 #ifndef DATASETTREEMODEL_H
21 #define DATASETTREEMODEL_H
22 
23 #include <QAbstractItemModel>
25 #include <Global/datamodel.h>
27 class TreeItem;
28 class DatasetTreeItem;
29 class MatrixTreeItem;
30 class ImageTreeItem;
31 class AnalysisResultTreeItem;
32 class DataModel;
33 class DatasetTreeModel : public QAbstractItemModel
34 {
35  Q_OBJECT
36 public:
37  DatasetTreeModel(QObject *parent);
38  DatasetTreeModel(QObject *parent, const DataModel *data_model);
39  void SetupModelData(const DataModel *data_model);
40 
42  QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
43  Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
44  QVariant headerData(int section, Qt::Orientation orientation,
45  int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
46  QModelIndex index(int row, int column,
47  const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
48  QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
49  int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
50  int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
51  bool removeRows(int row, int count,
52  const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
53  void UpdateData(const DataModel *data_model);
54  void AddDataset(QSharedPointer<VespucciDataset> dataset);
55  bool IsMatrix(const QModelIndex &index);
56  bool IsDataset(const QModelIndex &index);
57  bool IsMap(const QModelIndex &index);
58  void ClearDatasets();
59  void removeRow(const QModelIndex &index);
60  TreeItem *getItem(const QModelIndex &index) const;
62 
63 
64 private:
65  TreeItem *SetupDatasetTreeItem(QSharedPointer<VespucciDataset> dataset);
66  TreeItem *SetupAnalysisResultTreeItem(QSharedPointer<VespucciDataset> dataset, QSharedPointer<AnalysisResults> results, TreeItem *parent);
67  TreeItem *SetupMatrixTreeItem(const QString &dataset_key, const QString &results_key, const QString &matrix_key, const mat & matrix, TreeItem *parent);
68  TreeItem *SetupMatrixTreeItem(const QString &dataset_key, const QString &matrix_key, const mat & matrix, TreeItem *parent);
69  TreeItem *SetupMapTreeItem(const QString &dataset_key,
70  const QString &map_key,
71  QSharedPointer<MapData> data,
72  TreeItem *parent);
73  QString DescribeMatrix(const mat & matrix) const;
74  QString DescribeSpectra(const mat & spectra_matrix) const;
75  QString DescribeAbscissa(const vec &abscissa) const;
76  bool DatasetAdded() const;
77  bool DatasetRemoved() const;
78 
79  TreeItem *root_item_;
80 
81 };
82 
83 #endif // DATASETTREEMODEL_H
bool IsMap(const QModelIndex &index)
void AddDataset(QSharedPointer< VespucciDataset > dataset)
bool IsMatrix(const QModelIndex &index)
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE
bool IsDataset(const QModelIndex &index)
void UpdateData(const DataModel *data_model)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
TreeItem * getItem(const QModelIndex &index) const
QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE
int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE
DatasetTreeModel(QObject *parent)
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE
void removeRow(const QModelIndex &index)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE
void SetupModelData(const DataModel *data_model)
DatasetTreeModel::SetupModelData.
TreeItem * root_item()
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE