59 ProjectionModel::ProjectionModel(QObject *parent)
60 : QAbstractTableModel(parent)
61 , m_bFileloaded(false)
68 ProjectionModel::ProjectionModel(QObject *parent, QFile& qFile)
69 : QAbstractTableModel(parent)
70 , m_bFileloaded(false)
73 loadProjections(qFile);
79 ProjectionModel::ProjectionModel(QObject *parent, QList<FiffProj>& dataProjs)
80 : QAbstractTableModel(parent)
81 , m_bFileloaded(false)
83 addProjections(dataProjs);
101 int ProjectionModel::columnCount(
const QModelIndex & )
const
109 QVariant ProjectionModel::headerData(
int section, Qt::Orientation orientation,
int role)
const
111 if(role != Qt::DisplayRole && role != Qt::TextAlignmentRole)
115 if(orientation == Qt::Vertical) {
117 return QString(
"%1").arg(section);
120 if(role==Qt::TextAlignmentRole)
121 return Qt::AlignHCenter + Qt::AlignVCenter;
124 if(orientation == Qt::Horizontal) {
127 return QString(
"%1").arg(
"Name");
131 return QString(
"%1").arg(
"State");
135 return QString(
"%1").arg(
"Dimension");
139 return QString(
"%1").arg(
"Data");
150 QVariant ProjectionModel::data(
const QModelIndex &index,
int role)
const
155 if (index.isValid()) {
157 if(index.column()==0) {
161 case Qt::DisplayRole:
162 v.setValue(QString(
"%1").arg(
m_dataProjs.at(index.row()).desc));
166 case ProjectionModelRoles::GetProjectionName:
171 case Qt::TextAlignmentRole:
172 return Qt::AlignHCenter + Qt::AlignVCenter;
177 if(index.column()==1) {
181 case Qt::DisplayRole:
183 v.setValue(QString(
"%1").arg(
"Active"));
185 v.setValue(QString(
"%1").arg(
"Inactive"));
189 case ProjectionModelRoles::GetProjectionState:
194 case Qt::TextAlignmentRole:
195 return Qt::AlignHCenter + Qt::AlignVCenter;
200 if(index.column()==2) {
204 case Qt::DisplayRole:
205 v.setValue(QString(
"(%1|%2)").arg(
m_dataProjs.at(index.row()).data->data.rows()).arg(
m_dataProjs.at(index.row()).data->data.cols()));
209 case ProjectionModelRoles::GetProjectionDimension:
210 v.setValue(QPair<int,int>(
m_dataProjs.at(index.row()).data->data.rows(),
m_dataProjs.at(index.row()).data->data.cols()));
214 case Qt::TextAlignmentRole:
215 return Qt::AlignHCenter + Qt::AlignVCenter;
220 if(index.column()==3) {
224 case ProjectionModelRoles::GetProjectionData:
229 case Qt::TextAlignmentRole:
230 return Qt::AlignHCenter + Qt::AlignVCenter;
241 bool ProjectionModel::insertRows(
int position,
int span,
const QModelIndex & parent)
253 bool ProjectionModel::removeRows(
int position,
int span,
const QModelIndex & parent)
265 Qt::ItemFlags ProjectionModel::flags(
const QModelIndex & index)
const
268 return Qt::ItemIsEnabled | Qt::ItemIsSelectable ;
274 bool ProjectionModel::setData(
const QModelIndex & index,
const QVariant & value,
int role)
295 QString t_sFileName = t_pStream->streamName();
297 qDebug()<<
"Opening header data %s...\n"<<t_sFileName.toUtf8().constData();
300 QList<FiffDirEntry> t_Dir;
302 if(!t_pStream->open(t_Tree, t_Dir))
305 QList<FiffProj> q_ListProj = t_pStream->read_proj(t_Tree);
307 if (q_ListProj.size() == 0)
309 qDebug()<<
"Could not find projectors\n";
316 t_pStream->device()->close();
321 emit dataChanged(createIndex(0,0), createIndex(
rowCount(),columnCount()));
322 emit headerDataChanged(Qt::Vertical, 0,
rowCount());
350 emit dataChanged(createIndex(0,0), createIndex(
rowCount(),columnCount()));
351 emit headerDataChanged(Qt::Vertical, 0,
rowCount());
361 emit dataChanged(createIndex(0,0), createIndex(
rowCount(),columnCount()));
362 emit headerDataChanged(Qt::Vertical, 0,
rowCount());
378 qDebug(
"ProjectionModel cleared.");
FIFF measurement file information.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
bool loadProjections(QFile &qFile)
QSharedPointer< FiffStream > SPtr
QList< FiffProj > m_dataProjs
Directory tree structure.
bool saveProjections(QFile &qFile)
void addProjections(const QList< FiffProj > &dataProjs)
This class represents the projection model of the model/view framework of mne_browse_raw_qt applicati...