43 #include "chinfomodel.h"
59 ChInfoModel::ChInfoModel(QObject *parent)
60 : QAbstractTableModel(parent)
79 int ChInfoModel::columnCount(
const QModelIndex & )
const
87 QVariant ChInfoModel::headerData(
int section, Qt::Orientation orientation,
int role)
const
89 if(role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
93 case Qt::TextAlignmentRole:
94 return Qt::AlignHCenter + Qt::AlignVCenter;
96 case Qt::DisplayRole: {
98 if(orientation == Qt::Vertical)
100 return QString(
"Ch %1").arg(section);
103 if(orientation == Qt::Horizontal) {
106 return QString(
"%1").arg(
"Data number");
110 return QString(
"%1").arg(
"Original name");
114 return QString(
"%1").arg(
"Alias");
118 return QString(
"%1").arg(
"Mapped layout name");
122 return QString(
"%1").arg(
"Channel kind");
126 return QString(
"%1").arg(
"MEG type");
130 return QString(
"%1").arg(
"Unit");
134 return QString(
"%1").arg(
"Position");
138 return QString(
"%1").arg(
"Digitizer (cm)");
142 return QString(
"%1").arg(
"Active filter");
146 return QString(
"%1").arg(
"Coil Type");
159 QVariant ChInfoModel::data(
const QModelIndex &index,
int role)
const
164 if (index.isValid()) {
166 if(index.column()==0) {
170 case Qt::DisplayRole:
171 v.setValue(index.row());
174 case ChInfoModelRoles::GetChNumber:
175 v.setValue(index.row());
178 case Qt::TextAlignmentRole:
179 return Qt::AlignHCenter + Qt::AlignVCenter;
184 if(index.column()==1) {
188 case Qt::DisplayRole:
189 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).ch_name));
192 case ChInfoModelRoles::GetOrigChName:
193 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).ch_name));
196 case Qt::TextAlignmentRole:
197 return Qt::AlignHCenter + Qt::AlignVCenter;
202 if(index.column()==2) {
206 case Qt::DisplayRole:
207 v.setValue(QString(
"%1").arg(
m_aliasNames.at(index.row())));
210 case ChInfoModelRoles::GetChAlias:
214 case Qt::TextAlignmentRole:
215 return Qt::AlignHCenter + Qt::AlignVCenter;
220 if(index.column()==3) {
224 case Qt::DisplayRole:
228 case ChInfoModelRoles::GetMappedLayoutChName:
232 case Qt::TextAlignmentRole:
233 return Qt::AlignHCenter + Qt::AlignVCenter;
238 if(index.column()==4) {
242 case Qt::DisplayRole:
243 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).kind));
246 case ChInfoModelRoles::GetChKind:
250 case Qt::TextAlignmentRole:
251 return Qt::AlignHCenter + Qt::AlignVCenter;
256 if(index.column()==5) {
259 v.setValue(QString(
"%1").arg(
"non_MEG"));
264 v.setValue(QString(
"MEG_grad"));
265 else if(unit == FIFF_UNIT_T)
266 v.setValue(QString(
"MEG_mag"));
270 case Qt::DisplayRole:
273 case ChInfoModelRoles::GetMEGType:
276 case Qt::TextAlignmentRole:
277 return Qt::AlignHCenter + Qt::AlignVCenter;
282 if(index.column()==6) {
286 case Qt::DisplayRole:
287 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).unit));
290 case ChInfoModelRoles::GetChUnit:
294 case Qt::TextAlignmentRole:
295 return Qt::AlignHCenter + Qt::AlignVCenter;
300 if(index.column()==7) {
306 case Qt::DisplayRole:
307 v.setValue(QString(
"(%1|%2)").arg(point.x()).arg(point.y()));
310 case ChInfoModelRoles::GetChPosition:
314 case Qt::TextAlignmentRole:
315 return Qt::AlignHCenter + Qt::AlignVCenter;
320 if(index.column()==8) {
323 QVector3D point3D(
m_fiffInfo.
chs.at(index.row()).loc(0,0) * 100,
328 case Qt::DisplayRole:
329 v.setValue(QString(
"(%1|%2|%3)").arg(point3D.x()).arg(point3D.y()).arg(point3D.z()));
332 case ChInfoModelRoles::GetChDigitizer:
336 case Qt::TextAlignmentRole:
337 return Qt::AlignHCenter + Qt::AlignVCenter;
342 if(index.column()==9) {
350 case Qt::DisplayRole: {
403 case Qt::TextAlignmentRole:
404 return Qt::AlignHCenter + Qt::AlignVCenter;
408 if(index.column()==10) {
412 case Qt::DisplayRole:
413 v.setValue(QString(
"%1").arg(
m_fiffInfo.
chs.at(index.row()).coil_type));
416 case ChInfoModelRoles::GetChCoilType:
420 case Qt::TextAlignmentRole:
421 return Qt::AlignHCenter + Qt::AlignVCenter;
433 bool ChInfoModel::insertRows(
int position,
int span,
const QModelIndex & parent)
445 bool ChInfoModel::removeRows(
int position,
int span,
const QModelIndex & parent)
457 Qt::ItemFlags ChInfoModel::flags(
const QModelIndex & index)
const
460 return Qt::ItemIsEnabled | Qt::ItemIsSelectable ;
466 bool ChInfoModel::setData(
const QModelIndex &index,
const QVariant &value,
int role)
490 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
522 emit dataChanged(createIndex(0,0), createIndex(
rowCount(), columnCount()));
558 for(
int i = 0; i<channelList.size(); i++) {
561 QString chName = chInfo.
ch_name;
562 QRegExp regExpRemove;
565 switch(chInfo.
kind) {
568 regExpRemove = QRegExp(
"(MEG|-|_|/|\| )");
569 chName.remove(regExpRemove);
579 regExpRemove = QRegExp(
"(EEG|-|_|/|\| )");
580 chName.remove(regExpRemove);
608 qDebug(
"ChInfoModel cleared.");
void fiffInfoChanged(const FiffInfo &fiffInfo)
FIFF measurement file information.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QMap< QString, QPointF > m_layoutMap
void layoutChanged(const QMap< QString, QPointF > &layoutMap)
void mapLayoutToChannels()
const QStringList & getMappedChannelsList()
void channelsMappedToLayout(const QStringList &mappedLayoutChNames)
QStringList m_mappedLayoutChNames
int getIndexFromMappedChName(QString chName)
int getIndexFromOrigChName(QString chName)