/
cellmlannotationviewmetadataviewdetailswidget.cpp
132 lines (94 loc) · 4.53 KB
/
cellmlannotationviewmetadataviewdetailswidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
//==============================================================================
// CellML Annotation view metadata view details widget
//==============================================================================
#include "cellmlannotationvieweditingwidget.h"
#include "cellmlannotationviewmetadatanormalviewdetailswidget.h"
#include "cellmlannotationviewmetadatarawviewdetailswidget.h"
#include "cellmlannotationviewmetadataviewdetailswidget.h"
//==============================================================================
namespace OpenCOR {
namespace CellMLAnnotationView {
//==============================================================================
CellmlAnnotationViewMetadataViewDetailsWidget::CellmlAnnotationViewMetadataViewDetailsWidget(CellMLSupport::CellmlFile *pCellmlFile,
QWidget *pParent) :
QStackedWidget(pParent),
Core::CommonWidget(this),
mCellmlFile(pCellmlFile)
{
// Create our different metadata views
mRawView = new CellmlAnnotationViewMetadataRawViewDetailsWidget(pCellmlFile, this);
mNormalView = new CellmlAnnotationViewMetadataNormalViewDetailsWidget(pCellmlFile, this);
// Make our raw view the default widget
// Note: for the GUI to be properly initialised, we must add and immediately
// remove the views that we don't yet need. Not to do that may mess
// things up in our parent...
addWidget(mRawView);
addWidget(mNormalView);
removeWidget(mNormalView);
}
//==============================================================================
void CellmlAnnotationViewMetadataViewDetailsWidget::retranslateUi()
{
// Retranslate our GUI
mRawView->retranslateUi();
mNormalView->retranslateUi();
}
//==============================================================================
void CellmlAnnotationViewMetadataViewDetailsWidget::updateGui(iface::cellml_api::CellMLElement *pElement)
{
if (!pElement)
return;
// Decide on which view to use and update it, if needed
switch (mCellmlFile->rdfTriples(pElement).type()) {
case CellMLSupport::CellmlFileRdfTriple::Unknown:
removeWidget(mNormalView);
addWidget(mRawView);
mRawView->updateGui(pElement);
break;
case CellMLSupport::CellmlFileRdfTriple::BioModelsDotNetQualifier:
case CellMLSupport::CellmlFileRdfTriple::Empty:
removeWidget(mRawView);
addWidget(mNormalView);
mNormalView->updateGui(pElement);
break;
}
}
//==============================================================================
CellmlAnnotationViewMetadataRawViewDetailsWidget * CellmlAnnotationViewMetadataViewDetailsWidget::rawView() const
{
// Return our raw view
return mRawView;
}
//==============================================================================
CellmlAnnotationViewMetadataNormalViewDetailsWidget * CellmlAnnotationViewMetadataViewDetailsWidget::normalView() const
{
// Return our normal view
return mNormalView;
}
//==============================================================================
void CellmlAnnotationViewMetadataViewDetailsWidget::filePermissionsChanged()
{
// Let our normal view widget know that the file has been un/locked
// Note: we don't need to let our raw view widget know about it since it
// only presents information to the user...
mNormalView->filePermissionsChanged();
}
//==============================================================================
} // namespace CellMLAnnotationView
} // namespace OpenCOR
//==============================================================================
// End of file
//==============================================================================