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_pUi(std::make_unique<Ui::ProjectSettingsViewWidget>())
58, m_sDataPath(sDataPath)
59, m_sCurrentProject(sCurrentProject)
60, m_sCurrentSubject(sCurrentSubject)
61, m_sCurrentParadigm(sCurrentParadigm)
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);
158 QSettings settings(
"MNECPP");
170 QSettings settings(
"MNECPP");
201 QTime remainingTime(0, 0, 0, 0);
203 QTime remainingTimeFinal = remainingTime.addMSecs(m_iRecordingTime - mSecsElapsed);
205 m_pUi->m_label_timeToGo->setText(remainingTimeFinal.toString());
207 QTime passedTime(0, 0, 0, 0);
212 if (m_iRecordingTime - mSecsElapsed < 500) {
213 mSecsElapsed = m_iRecordingTime;
216 QTime passedTimeFinal = passedTime.addMSecs(mSecsElapsed);
218 m_pUi->m_label_timePassed->setText(passedTimeFinal.toString(
"HH:mm:ss"));
233void ProjectSettingsView::deleteSubject()
236 msgBox.setText(QString(
"Deleting subject data '%1'.").arg(m_pUi->m_qComboBox_SubjectSelection->currentText()));
237 msgBox.setInformativeText(
"You are about to delete a subject. Do you want to delete all data corresponding to this subject?");
238 msgBox.setIcon(QMessageBox::Warning);
239 QPushButton* keepData = msgBox.addButton(tr(
"Keep data"), QMessageBox::ActionRole);
240 QPushButton* deleteData = msgBox.addButton(tr(
"Delete data"), QMessageBox::ActionRole);
244 if (msgBox.clickedButton() == keepData)
247 if (msgBox.clickedButton() == deleteData) {
248 QMessageBox confirmBox;
249 confirmBox.setText(QString(
"Deleting subject data '%1'.").arg(m_pUi->m_qComboBox_SubjectSelection->currentText()));
250 confirmBox.setInformativeText(
"Do really want to delete the data permantley? The deleted data cannot be recovered!");
251 confirmBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
252 confirmBox.setDefaultButton(QMessageBox::No);
253 confirmBox.setWindowModality(Qt::ApplicationModal);
254 confirmBox.setIcon(QMessageBox::Critical);
255 int ret = confirmBox.exec();
257 if (ret == QMessageBox::No)
260 QString dirName = m_sDataPath +
"/" + m_pUi->m_qComboBox_ProjectSelection->currentText() +
"/" + m_pUi->m_qComboBox_SubjectSelection->currentText();
264 bool result = dir.removeRecursively();
267 qDebug() <<
"Could not remove all data from the subject folder!";
269 m_pUi->m_qComboBox_SubjectSelection->removeItem(m_pUi->m_qComboBox_SubjectSelection->currentIndex());
275void ProjectSettingsView::deleteProject()
278 msgBox.setText(QString(
"Deleting project data '%1'.").arg(m_pUi->m_qComboBox_ProjectSelection->currentText()));
279 msgBox.setInformativeText(
"You are about to delete a project. Do you want to delete all data corresponding to this project?");
280 msgBox.setIcon(QMessageBox::Warning);
281 QPushButton* keepData = msgBox.addButton(tr(
"Keep data"), QMessageBox::ActionRole);
282 QPushButton* deleteData = msgBox.addButton(tr(
"Delete data"), QMessageBox::ActionRole);
286 if (msgBox.clickedButton() == keepData)
289 if (msgBox.clickedButton() == deleteData) {
290 QMessageBox confirmBox;
291 confirmBox.setText(QString(
"Deleting project data '%1'.").arg(m_pUi->m_qComboBox_ProjectSelection->currentText()));
292 confirmBox.setInformativeText(
"Do really want to delete the data permantley? All subject data in this project will be lost! The deleted data cannot be recovered!");
293 confirmBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
294 confirmBox.setDefaultButton(QMessageBox::No);
295 confirmBox.setWindowModality(Qt::ApplicationModal);
296 confirmBox.setIcon(QMessageBox::Critical);
297 int ret = confirmBox.exec();
299 if (ret == QMessageBox::No)
302 QString dirName = m_sDataPath +
"/" + m_pUi->m_qComboBox_ProjectSelection->currentText();
306 bool result = dir.removeRecursively();
309 qDebug() <<
"Could not remove all data from the project folder!";
311 m_pUi->m_qComboBox_ProjectSelection->removeItem(m_pUi->m_qComboBox_ProjectSelection->currentIndex());
317void ProjectSettingsView::addProject()
320 QString sProject = QInputDialog::getText(
this, tr(
"Add new Project"),
321 tr(
"Add new Project:"), QLineEdit::Normal,
322 tr(
"NewProject"), &ok);
323 if (ok && !sProject.isEmpty()) {
324 if (!QDir(m_sDataPath +
"/" + sProject).exists())
325 QDir().mkdir(m_sDataPath +
"/" + sProject);
327 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()) {
346 if (!QDir(m_sDataPath +
"/" + m_sCurrentProject +
"/" + sSubject).exists())
347 QDir().mkdir(m_sDataPath +
"/" + m_sCurrentProject +
"/" + sSubject);
349 m_sCurrentSubject = sSubject;
359void ProjectSettingsView::paradigmChanged(
const QString& sNewParadigm)
361 m_sCurrentParadigm = sNewParadigm;
368void ProjectSettingsView::scanForProjects()
371 const QSignalBlocker blocker(m_pUi->m_qComboBox_ProjectSelection);
374 m_pUi->m_qComboBox_ProjectSelection->clear();
375 m_sListProjects.clear();
377 QDir t_qDirData(m_sDataPath);
379 QFileInfoList t_qFileInfoList = t_qDirData.entryInfoList();
380 QFileInfoList::const_iterator it;
381 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
382 if (it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
383 m_sListProjects.append(it->fileName());
385 m_pUi->m_qComboBox_ProjectSelection->insertItems(0, m_sListProjects);
386 m_pUi->m_qComboBox_ProjectSelection->setCurrentIndex(m_pUi->m_qComboBox_ProjectSelection->findText(m_sCurrentProject));
391void ProjectSettingsView::scanForSubjects()
394 const QSignalBlocker blocker(m_pUi->m_qComboBox_SubjectSelection);
397 m_pUi->m_qComboBox_SubjectSelection->clear();
398 m_sListSubjects.clear();
400 QDir t_qDirProject(m_sDataPath +
"/" + m_sCurrentProject);
402 QFileInfoList t_qFileInfoList = t_qDirProject.entryInfoList();
403 QFileInfoList::const_iterator it;
404 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
405 if (it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
406 m_sListSubjects.append(it->fileName());
408 m_pUi->m_qComboBox_SubjectSelection->insertItems(0, m_sListSubjects);
410 qint32 idx = m_pUi->m_qComboBox_SubjectSelection->findText(m_sCurrentSubject);
412 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(idx);
414 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(0);
415 selectNewSubject(m_pUi->m_qComboBox_SubjectSelection->itemText(0));
421void ProjectSettingsView::selectNewProject(
const QString& sNewProject)
423 m_sCurrentProject = sNewProject;
432void ProjectSettingsView::selectNewSubject(
const QString& sNewSubject)
434 m_sCurrentSubject = sNewSubject;
442void ProjectSettingsView::updateFileName(
bool currentTime)
444 QString sFilePath = m_sDataPath +
"/" + m_sCurrentProject +
"/" + m_sCurrentSubject;
449 sTimeStamp = QDateTime::currentDateTime().toString(
"yyMMdd_hhmmss");
451 sTimeStamp =
"<YYMMDD_HMS>";
454 if (m_sCurrentParadigm.isEmpty())
455 sFilePath.append(
"/" + sTimeStamp +
"_" + m_sCurrentSubject +
"_raw.fif");
457 sFilePath.append(
"/" + sTimeStamp +
"_" + m_sCurrentSubject +
"_" + m_sCurrentParadigm +
"_raw.fif");
459 m_sFileName = sFilePath;
461 m_pUi->m_qLineEditFileName->setText(m_sFileName);
468void ProjectSettingsView::onTimeChanged()
470 m_iRecordingTime = (m_pUi->m_spinBox_hours->value() * 60 * 60) + (m_pUi->m_spinBox_min->value() * 60) + (m_pUi->m_spinBox_sec->value());
472 m_iRecordingTime *= 1000;
474 QTime remainingTime(0, 0, 0, 0);
476 QTime remainingTimeFinal = remainingTime.addMSecs(m_iRecordingTime);
478 m_pUi->m_label_timeToGo->setText(remainingTimeFinal.toString());
485void ProjectSettingsView::onRecordingTimerStateChanged(
bool state)
505void ProjectSettingsView::browseDirectories()
507 QString sDir = QFileDialog::getExistingDirectory(
this,
508 tr(
"Select Project Directory"),
510 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
511 if (!sDir.isEmpty() && !sDir.isNull()) {
513 m_pUi->m_lineEditDirectory->setText(m_sDataPath);
516 updateFileName(
true);
524 m_pUi->m_qLine->hide();
525 m_pUi->m_qLineEditFileName->hide();
526 m_pUi->m_qLabel->hide();
533 m_pUi->m_qLine->show();
534 m_pUi->m_qLineEditFileName->show();
535 m_pUi->m_qLabel->show();
542 m_pUi->m_qLabel_Paradigm->hide();
543 m_pUi->m_qLineEditParadigm->hide();
550 m_pUi->m_qLabel_Paradigm->show();
551 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)