diff --git a/src/channelinfomodel.cpp b/src/channelinfomodel.cpp --- a/src/channelinfomodel.cpp +++ b/src/channelinfomodel.cpp @@ -98,21 +98,31 @@ ChannelInfoModel::ChannelInfo::ChannelIn color = colors[index % NUMOF_COLORS]; } -QString ChannelInfoModel::name(unsigned i) +QString ChannelInfoModel::name(unsigned i) const { return infos[i].name; } -QColor ChannelInfoModel::color(unsigned i) +QColor ChannelInfoModel::color(unsigned i) const { return infos[i].color; } -bool ChannelInfoModel::isVisible(unsigned i) +bool ChannelInfoModel::isVisible(unsigned i) const { return infos[i].visibility; } +QStringList ChannelInfoModel::channelNames() const +{ + QStringList r; + for (unsigned ci = 0; ci < _numOfChannels; ci++) + { + r << name(ci); + } + return r; +} + int ChannelInfoModel::rowCount(const QModelIndex &parent) const { return _numOfChannels; diff --git a/src/channelinfomodel.h b/src/channelinfomodel.h --- a/src/channelinfomodel.h +++ b/src/channelinfomodel.h @@ -41,9 +41,11 @@ public: ChannelInfoModel(const ChannelInfoModel& other); explicit ChannelInfoModel(const QStringList& channelNames); - QString name (unsigned i); - QColor color (unsigned i); - bool isVisible(unsigned i); + QString name (unsigned i) const; + QColor color (unsigned i) const; + bool isVisible(unsigned i) const; + /// Returns a list of channel names + QStringList channelNames() const; // implemented from QAbstractItemModel int rowCount(const QModelIndex &parent = QModelIndex()) const; diff --git a/src/channelmanager.h b/src/channelmanager.h --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -39,7 +39,6 @@ public: unsigned numOfChannels(); unsigned numOfSamples(); FrameBuffer* channelBuffer(unsigned channel); - // QStringListModel* channelNames(); QString channelName(unsigned channel); /// Stores channel names into a `QSettings` void saveSettings(QSettings* settings); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,7 +63,7 @@ MainWindow::MainWindow(QWidget *parent) snapshotMan(this, &channelMan), commandPanel(&serialPort), dataFormatPanel(&serialPort, &channelMan, &recorder), - recordPanel(&recorder) + recordPanel(&recorder, &channelMan) { ui->setupUi(this); diff --git a/src/recordpanel.cpp b/src/recordpanel.cpp --- a/src/recordpanel.cpp +++ b/src/recordpanel.cpp @@ -29,7 +29,7 @@ #include -RecordPanel::RecordPanel(DataRecorder* recorder, QWidget *parent) : +RecordPanel::RecordPanel(DataRecorder* recorder, ChannelManager* channelMan, QWidget *parent) : QWidget(parent), ui(new Ui::RecordPanel), recordToolBar(tr("Record Toolbar")), @@ -37,6 +37,7 @@ RecordPanel::RecordPanel(DataRecorder* r { overwriteSelected = false; _recorder = recorder; + _channelMan = channelMan; ui->setupUi(this); @@ -216,9 +217,7 @@ bool RecordPanel::confirmOverwrite(QStri void RecordPanel::startRecording(void) { - // TODO: channel names - QStringList cn; - _recorder->startRecording(selectedFile, cn); + _recorder->startRecording(selectedFile, _channelMan->infoModel()->channelNames()); emit recordStarted(); } diff --git a/src/recordpanel.h b/src/recordpanel.h --- a/src/recordpanel.h +++ b/src/recordpanel.h @@ -26,6 +26,7 @@ #include #include "datarecorder.h" +#include "channelmanager.h" namespace Ui { class RecordPanel; @@ -36,7 +37,8 @@ class RecordPanel : public QWidget Q_OBJECT public: - explicit RecordPanel(DataRecorder* recorder, QWidget* parent = 0); + explicit RecordPanel(DataRecorder* recorder, ChannelManager* channelMan, + QWidget* parent = 0); ~RecordPanel(); QToolBar* toolbar(); @@ -60,6 +62,7 @@ private: QString selectedFile; bool overwriteSelected; DataRecorder* _recorder; + ChannelManager* _channelMan; /** * @brief Increments the file name.