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(new 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);
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) {
249 QMessageBox confirmBox;
250 confirmBox.setText(QString(
"Deleting subject data '%1'.").arg(m_pUi->m_qComboBox_SubjectSelection->currentText()));
251 confirmBox.setInformativeText(
"Do really want to delete the data permantley? The deleted data cannot be recovered!");
252 confirmBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
253 confirmBox.setDefaultButton(QMessageBox::No);
254 confirmBox.setWindowModality(Qt::ApplicationModal);
255 confirmBox.setIcon(QMessageBox::Critical);
256 int ret = confirmBox.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) {
291 QMessageBox confirmBox;
292 confirmBox.setText(QString(
"Deleting project data '%1'.").arg(m_pUi->m_qComboBox_ProjectSelection->currentText()));
293 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!");
294 confirmBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
295 confirmBox.setDefaultButton(QMessageBox::No);
296 confirmBox.setWindowModality(Qt::ApplicationModal);
297 confirmBox.setIcon(QMessageBox::Critical);
298 int ret = confirmBox.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()) {
325 if (!QDir(m_sDataPath +
"/" + sProject).exists())
326 QDir().mkdir(m_sDataPath +
"/" + sProject);
328 m_sCurrentProject = sProject;
339void ProjectSettingsView::addSubject()
342 QString sSubject = QInputDialog::getText(
this, tr(
"Add new Subject"),
343 tr(
"Add new Subject:"), QLineEdit::Normal,
344 tr(
"NewSubject"), &ok);
346 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 const QSignalBlocker blocker(m_pUi->m_qComboBox_ProjectSelection);
375 m_pUi->m_qComboBox_ProjectSelection->clear();
376 m_sListProjects.clear();
378 QDir t_qDirData(m_sDataPath);
380 QFileInfoList t_qFileInfoList = t_qDirData.entryInfoList();
381 QFileInfoList::const_iterator it;
382 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
383 if (it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
384 m_sListProjects.append(it->fileName());
386 m_pUi->m_qComboBox_ProjectSelection->insertItems(0, m_sListProjects);
387 m_pUi->m_qComboBox_ProjectSelection->setCurrentIndex(m_pUi->m_qComboBox_ProjectSelection->findText(m_sCurrentProject));
392void ProjectSettingsView::scanForSubjects()
395 const QSignalBlocker blocker(m_pUi->m_qComboBox_SubjectSelection);
398 m_pUi->m_qComboBox_SubjectSelection->clear();
399 m_sListSubjects.clear();
401 QDir t_qDirProject(m_sDataPath +
"/" + m_sCurrentProject);
403 QFileInfoList t_qFileInfoList = t_qDirProject.entryInfoList();
404 QFileInfoList::const_iterator it;
405 for (it = t_qFileInfoList.constBegin(); it != t_qFileInfoList.constEnd(); ++it)
406 if (it->isDir() && it->fileName() !=
"." && it->fileName() !=
"..")
407 m_sListSubjects.append(it->fileName());
409 m_pUi->m_qComboBox_SubjectSelection->insertItems(0, m_sListSubjects);
411 qint32 idx = m_pUi->m_qComboBox_SubjectSelection->findText(m_sCurrentSubject);
413 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(idx);
415 m_pUi->m_qComboBox_SubjectSelection->setCurrentIndex(0);
416 selectNewSubject(m_pUi->m_qComboBox_SubjectSelection->itemText(0));
422void ProjectSettingsView::selectNewProject(
const QString& sNewProject)
424 m_sCurrentProject = sNewProject;
433void ProjectSettingsView::selectNewSubject(
const QString& sNewSubject)
435 m_sCurrentSubject = sNewSubject;
443void ProjectSettingsView::updateFileName(
bool currentTime)
445 QString sFilePath = m_sDataPath +
"/" + m_sCurrentProject +
"/" + m_sCurrentSubject;
450 sTimeStamp = QDateTime::currentDateTime().toString(
"yyMMdd_hhmmss");
452 sTimeStamp =
"<YYMMDD_HMS>";
455 if (m_sCurrentParadigm.isEmpty())
456 sFilePath.append(
"/" + sTimeStamp +
"_" + m_sCurrentSubject +
"_raw.fif");
458 sFilePath.append(
"/" + sTimeStamp +
"_" + m_sCurrentSubject +
"_" + m_sCurrentParadigm +
"_raw.fif");
460 m_sFileName = sFilePath;
462 m_pUi->m_qLineEditFileName->setText(m_sFileName);
469void ProjectSettingsView::onTimeChanged()
471 m_iRecordingTime = (m_pUi->m_spinBox_hours->value() * 60 * 60) + (m_pUi->m_spinBox_min->value() * 60) + (m_pUi->m_spinBox_sec->value());
473 m_iRecordingTime *= 1000;
475 QTime remainingTime(0, 0, 0, 0);
477 QTime remainingTimeFinal = remainingTime.addMSecs(m_iRecordingTime);
479 m_pUi->m_label_timeToGo->setText(remainingTimeFinal.toString());
486void ProjectSettingsView::onRecordingTimerStateChanged(
bool state)
506void ProjectSettingsView::browseDirectories()
508 QString sDir = QFileDialog::getExistingDirectory(
this,
509 tr(
"Select Project Directory"),
511 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
512 if (!sDir.isEmpty() && !sDir.isNull()) {
514 m_pUi->m_lineEditDirectory->setText(m_sDataPath);
517 updateFileName(
true);
525 m_pUi->m_qLine->hide();
526 m_pUi->m_qLineEditFileName->hide();
527 m_pUi->m_qLabel->hide();
534 m_pUi->m_qLine->show();
535 m_pUi->m_qLineEditFileName->show();
536 m_pUi->m_qLabel->show();
543 m_pUi->m_qLabel_Paradigm->hide();
544 m_pUi->m_qLineEditParadigm->hide();
551 m_pUi->m_qLabel_Paradigm->show();
552 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)