SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
selectsampletablemodel.cpp
Go to the documentation of this file.
2
3SelectSampleTableModel::SelectSampleTableModel(SourceSinkData *_data, QObject *parent) : QAbstractTableModel(parent)
4{
5 Data = _data;
6}
7int SelectSampleTableModel::rowCount(const QModelIndex &index) const
8{
9 return Data->operator[](selectedSource).size();
10}
11int SelectSampleTableModel::columnCount(const QModelIndex &index) const
12{
13 return 3;
14}
15QVariant SelectSampleTableModel::data(const QModelIndex &index, int role) const
16{
17 if (role == Qt::DisplayRole)
18 { if (index.column()==0)
19 {
20 return QString::fromStdString(Data->operator[](selectedSource).GetSampleNames()[index.row()]);
21 }
22 if (index.column()==1)
23 {
24 if (GetProfileSet(index.row())->IsIncludedInAnalysis())
25 return "Yes";
26 else
27 return "No";
28 }
29 if (index.column()==2)
30 {
31 return QString::fromStdString(GetProfileSet(index.row())->GetNotes());
32 }
33
34 }
35 if (role == Qt::ForegroundRole)
36 {
37 if (GetProfileSet(index.row())->GetNotes()!="")
38 return QVariant::fromValue(QColor(Qt::red));
39 else
40 return QVariant::fromValue(QColor(Qt::black));
41 }
42
43 return QVariant();
44
45}
46
51
53{
54 return &Data->operator[](selectedSource)[Data->operator[](selectedSource).GetSampleNames()[row]];
55}
56QVariant SelectSampleTableModel::headerData(int section, Qt::Orientation orientation, int role) const
57{
58 if (role == Qt::DisplayRole)
59 {
60 if (orientation == Qt::Horizontal)
61 { if (section==0)
62 {
63 return "Sample";
64 }
65 if (section==1)
66 {
67 return "Include";
68 }
69 if (section==2)
70 {
71 return "Notes";
72 }
73 }
74 }
75 return QVariant();
76}
77bool SelectSampleTableModel::setData(const QModelIndex & index, const QVariant & value, int role)
78{
79 if (role==Qt::EditRole)
80 {
81
82 if (index.column()==1)
83 {
84 if (value.toString()=="Yes" || value.toBool())
85 GetProfileSet(index.row())->SetIncludedInAnalysis(true);
86 else
87 GetProfileSet(index.row())->SetIncludedInAnalysis(false);
88 }
89
90 }
91 QString result = "Done";
92 emit editCompleted(result);
93 return true;
94}
95Qt::ItemFlags SelectSampleTableModel::flags(const QModelIndex & index) const
96{
97 if (index.column()!=0)
98 return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ;
99 else
100 return Qt::ItemIsSelectable | Qt::ItemIsEnabled ;
101}
Container for elemental concentration data of a single sediment sample.
void SetIncludedInAnalysis(bool included)
Set analysis inclusion status.
bool IsIncludedInAnalysis() const
Check if profile is included in analysis.
string GetNotes() const
Get the notes/annotations associated with this object.
Definition interface.h:177
Elemental_Profile * GetProfileSet(int row)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
SelectSampleTableModel(SourceSinkData *Data, QObject *parent=nullptr)
void editCompleted(const QString &)
vector< string > GetSampleNames(const string &group_name) const
Get all sample names within a specific group.