22#include "ui_projectsettingsview.h"
30#include <QInputDialog>
51 const QString& sDataPath,
52 const QString& sCurrentProject,
53 const QString& sCurrentSubject,
54 const QString& sCurrentParadigm,
57, m_sDataPath(sDataPath)
58, m_sCurrentProject(sCurrentProject)
59, m_sCurrentSubject(sCurrentSubject)
60, m_sCurrentParadigm(sCurrentParadigm)
61, m_pUi(new Ui::ProjectSettingsViewWidget)
62, m_iRecordingTime(5*60*1000)
72 m_pUi->m_qLineEditFileName->setReadOnly(
true);
74 m_pUi->m_lineEditDirectory->setReadOnly(
true);
75 m_pUi->m_lineEditDirectory->setText(m_sDataPath);
80 m_pUi->m_label_RemainingTime->hide();
81 m_pUi->m_label_timeToGo->hide();
88 m_pUi->m_qPushButtonDeleteProject->hide();
89 m_pUi->m_qPushButtonDeleteSubject->hide();
96void ProjectSettingsView::connectGui()
98#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
99 connect(m_pUi->m_qComboBox_ProjectSelection,
static_cast<void (QComboBox::*)(
const QString&)
>(&QComboBox::currentIndexChanged),
100 this,&ProjectSettingsView::selectNewProject);
102 connect(m_pUi->m_qComboBox_SubjectSelection,
static_cast<void (QComboBox::*)(
const QString&)
>(&QComboBox::currentIndexChanged),
103 this,&ProjectSettingsView::selectNewSubject);
105 connect(m_pUi->m_qComboBox_ProjectSelection,&QComboBox::currentTextChanged,
106 this,&ProjectSettingsView::selectNewProject);
108 connect(m_pUi->m_qComboBox_SubjectSelection,&QComboBox::currentTextChanged,
109 this,&ProjectSettingsView::selectNewSubject);
111 connect(m_pUi->m_qLineEditParadigm,&QLineEdit::textChanged,
112 this,&ProjectSettingsView::paradigmChanged);
114 connect(m_pUi->m_qPushButtonNewProject,&QPushButton::clicked,
115 this,&ProjectSettingsView::addProject);
117 connect(m_pUi->m_qPushButtonNewSubject,&QPushButton::clicked,
118 this,&ProjectSettingsView::addSubject);
120 connect(m_pUi->m_qPushButtonDeleteProject,&QPushButton::clicked,
121 this,&ProjectSettingsView::deleteProject);
123 connect(m_pUi->m_qPushButtonDeleteSubject,&QPushButton::clicked,
124 this,&ProjectSettingsView::deleteSubject);
126 connect(m_pUi->m_spinBox_hours,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
127 this,&ProjectSettingsView::onTimeChanged);
129 connect(m_pUi->m_spinBox_min,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
130 this,&ProjectSettingsView::onTimeChanged);
132 connect(m_pUi->m_spinBox_sec,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
133 this,&ProjectSettingsView::onTimeChanged);
135 connect(m_pUi->m_checkBox_useRecordingTimer,&QCheckBox::toggled,
136 this,&ProjectSettingsView::onRecordingTimerStateChanged);
138 connect(m_pUi->m_pushButtonDirectory, &QPushButton::released,
139 this, &ProjectSettingsView::browseDirectories);
159 QSettings settings(
"MNECPP");
171 QSettings settings(
"MNECPP");
202 QTime remainingTime(0,0,0,0);
204 QTime remainingTimeFinal = remainingTime.addMSecs(m_iRecordingTime-mSecsElapsed);
206 m_pUi->m_label_timeToGo->setText(remainingTimeFinal.toString());
208 QTime passedTime(0,0,0,0);
213 if(m_iRecordingTime-mSecsElapsed < 500) {
214 mSecsElapsed = m_iRecordingTime;
217 QTime passedTimeFinal = passedTime.addMSecs(mSecsElapsed);
219 m_pUi->m_label_timePassed->setText(passedTimeFinal.toString(
"HH:mm:ss"));
234void ProjectSettingsView::deleteSubject()
237 msgBox.setText(QString(
"Deleting subject data '%1'.").arg(m_pUi->m_qComboBox_SubjectSelection->currentText()));
238 msgBox.setInformativeText(
"You are about to delete a subject. Do you want to delete all data corresponding to this subject?");
239 msgBox.setIcon(QMessageBox::Warning);
240 QPushButton *keepData = msgBox.addButton(tr(
"Keep data"), QMessageBox::ActionRole);
241 QPushButton *deleteData = msgBox.addButton(tr(
"Delete data"), QMessageBox::ActionRole);
245 if(msgBox.clickedButton() == keepData)
248 if(msgBox.clickedButton() == deleteData) {
250 msgBox.setText(QString(
"Deleting subject data '%1'.").arg(m_pUi->m_qComboBox_SubjectSelection->currentText()));
251 msgBox.setInformativeText(
"Do really want to delete the data permantley? The deleted data cannot be recovered!");
252 msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
253 msgBox.setDefaultButton(QMessageBox::No);
254 msgBox.setWindowModality(Qt::ApplicationModal);
255 msgBox.setIcon(QMessageBox::Critical);
256 int ret = msgBox.exec();
258 if(ret == QMessageBox::No)
261 QString dirName = m_sDataPath +
"/" + m_pUi->m_qComboBox_ProjectSelection->currentText() +
"/" + m_pUi->m_qComboBox_SubjectSelection->currentText();
265 bool result = dir.removeRecursively();
268 qDebug()<<
"Could not remove all data from the subject folder!";
270 m_pUi->m_qComboBox_SubjectSelection->removeItem(m_pUi->m_qComboBox_SubjectSelection->currentIndex());
276void ProjectSettingsView::deleteProject()
279 msgBox.setText(QString(
"Deleting project data '%1'.").arg(m_pUi->m_qComboBox_ProjectSelection->currentText()));
280 msgBox.setInformativeText(
"You are about to delete a project. Do you want to delete all data corresponding to this project?");
281 msgBox.setIcon(QMessageBox::Warning);
282 QPushButton *keepData = msgBox.addButton(tr(
"Keep data"), QMessageBox::ActionRole);
283 QPushButton *deleteData = msgBox.addButton(tr(
"Delete data"), QMessageBox::ActionRole);
287 if(msgBox.clickedButton() == keepData)
290 if(msgBox.clickedButton() == deleteData) {
292 msgBox.setText(QString(
"Deleting project data '%1'.").arg(m_pUi->m_qComboBox_ProjectSelection->currentText()));
293 msgBox.setInformativeText(
"Do really want to delete the data permantley? All subject data in this project will be lost! The deleted data cannot be recovered!");
294 msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
295 msgBox.setDefaultButton(QMessageBox::No);
296 msgBox.setWindowModality(Qt::ApplicationModal);
297 msgBox.setIcon(QMessageBox::Critical);
298 int ret = msgBox.exec();
300 if(ret == QMessageBox::No)
303 QString dirName = m_sDataPath +
"/" + m_pUi->m_qComboBox_ProjectSelection->currentText();
307 bool result = dir.removeRecursively();
310 qDebug()<<
"Could not remove all data from the project folder!";
312 m_pUi->m_qComboBox_ProjectSelection->removeItem(m_pUi->m_qComboBox_ProjectSelection->currentIndex());
318void ProjectSettingsView::addProject()
321 QString sProject = QInputDialog::getText(
this, tr(
"Add new Project"),
322 tr(
"Add new Project:"), QLineEdit::Normal,
323 tr(
"NewProject"), &ok);
324 if (ok && !sProject.isEmpty())
326 if(!QDir(m_sDataPath+
"/" + sProject).exists())
327 QDir().mkdir(m_sDataPath+
"/"+sProject);
329 m_sCurrentProject = sProject;
338void ProjectSettingsView::addSubject()
341 QString sSubject = QInputDialog::getText(
this, tr(
"Add new Subject"),
342 tr(
"Add new Subject:"), QLineEdit::Normal,
343 tr(
"NewSubject"), &ok);
345 if (ok && !sSubject.isEmpty())
347 if(!QDir(m_sDataPath +
"/" + m_sCurrentProject +
"/" + sSubject).exists())
348 QDir().mkdir(m_sDataPath +
"/" + m_sCurrentProject +
"/" + sSubject);
350 m_sCurrentSubject = sSubject;
360void ProjectSettingsView::paradigmChanged(
const QString &sNewParadigm)
362 m_sCurrentParadigm = sNewParadigm;
369void ProjectSettingsView::scanForProjects()
372 m_pUi->m_qComboBox_ProjectSelection->clear();
373 m_sListProjects.clear();
375 QDir t_qDirData(m_sDataPath);
377 QFileInfoList t_qFileInfoList = t_qDirData.entryInfoList();
378 QFileInfoList::const_iterator it;
379 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
380 if(it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
381 m_sListProjects.append(it->fileName());
383 m_pUi->m_qComboBox_ProjectSelection->insertItems(0,m_sListProjects);
384 m_pUi->m_qComboBox_ProjectSelection->setCurrentIndex(m_pUi->m_qComboBox_ProjectSelection->findText(m_sCurrentProject));
389void ProjectSettingsView::scanForSubjects()
392 m_pUi->m_qComboBox_SubjectSelection->clear();
393 m_sListSubjects.clear();
395 QDir t_qDirProject(m_sDataPath+
"/"+m_sCurrentProject);
397 QFileInfoList t_qFileInfoList = t_qDirProject.entryInfoList();
398 QFileInfoList::const_iterator it;
399 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
400 if(it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
401 m_sListSubjects.append(it->fileName());
403 m_pUi->m_qComboBox_SubjectSelection->insertItems(0,m_sListSubjects);
405 qint32 idx = m_pUi->m_qComboBox_SubjectSelection->findText(m_sCurrentSubject);
407 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(idx);
410 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(0);
411 selectNewSubject(m_pUi->m_qComboBox_SubjectSelection->itemText(0));
417void ProjectSettingsView::selectNewProject(
const QString &sNewProject)
419 m_sCurrentProject = sNewProject;
428void ProjectSettingsView::selectNewSubject(
const QString &sNewSubject)
430 m_sCurrentSubject = sNewSubject;
438void ProjectSettingsView::updateFileName(
bool currentTime)
440 QString sFilePath = m_sDataPath +
"/" + m_sCurrentProject +
"/" + m_sCurrentSubject;
445 sTimeStamp = QDateTime::currentDateTime().toString(
"yyMMdd_hhmmss");
447 sTimeStamp =
"<YYMMDD_HMS>";
450 if(m_sCurrentParadigm.isEmpty())
451 sFilePath.append(
"/"+ sTimeStamp +
"_" + m_sCurrentSubject +
"_raw.fif");
453 sFilePath.append(
"/"+ sTimeStamp +
"_" + m_sCurrentSubject +
"_" + m_sCurrentParadigm +
"_raw.fif");
455 m_sFileName = sFilePath;
457 m_pUi->m_qLineEditFileName->setText(m_sFileName);
464void ProjectSettingsView::onTimeChanged()
466 m_iRecordingTime = (m_pUi->m_spinBox_hours->value()*60*60)+(m_pUi->m_spinBox_min->value()*60)+(m_pUi->m_spinBox_sec->value());
468 m_iRecordingTime*=1000;
470 QTime remainingTime(0,0,0,0);
472 QTime remainingTimeFinal = remainingTime.addMSecs(m_iRecordingTime);
474 m_pUi->m_label_timeToGo->setText(remainingTimeFinal.toString());
481void ProjectSettingsView::onRecordingTimerStateChanged(
bool state)
502void ProjectSettingsView::browseDirectories()
504 QString sDir = QFileDialog::getExistingDirectory(
this,
505 tr(
"Select Project Directory"),
507 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
508 if(!sDir.isEmpty() && !sDir.isNull()){
510 m_pUi->m_lineEditDirectory->setText(m_sDataPath);
513 updateFileName(
true);
521 m_pUi->m_qLine->hide();
522 m_pUi->m_qLineEditFileName->hide();
523 m_pUi->m_qLabel->hide();
530 m_pUi->m_qLine->show();
531 m_pUi->m_qLineEditFileName->show();
532 m_pUi->m_qLabel->show();
539 m_pUi->m_qLabel_Paradigm->hide();
540 m_pUi->m_qLineEditParadigm->hide();
547 m_pUi->m_qLabel_Paradigm->show();
548 m_pUi->m_qLineEditParadigm->show();
Output-path and filename-template panel for recording / export sessions.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void newSubject(const QString &sCurrentSubject)
QString getCurrentFileName()
void fileNameChanged(const QString &sCurrentFileName)
void triggerFileNameUpdate()
void setRecordingElapsedTime(int mSecsElapsed)
void timerChanged(int secs)
void updateGuiMode(GuiMode mode)
void newProject(const QString &sCurrentProject)
ProjectSettingsView(const QString &sSettingsPath="", const QString &sDataPath="/TestData", const QString &sCurrentProject="TestProject", const QString &sCurrentSubject="TestSubject", const QString &sCurrentParadigm="UnknownParadigm", QWidget *parent=0)
void updateProcessingMode(ProcessingMode mode)
void newParadigm(const QString &sCurrentParadigm)
void recordingTimerStateChanged(bool state)