diff --git a/src/channelinfomodel.cpp b/src/channelinfomodel.cpp --- a/src/channelinfomodel.cpp +++ b/src/channelinfomodel.cpp @@ -98,6 +98,21 @@ ChannelInfoModel::ChannelInfo::ChannelIn color = colors[index % NUMOF_COLORS]; } +QString ChannelInfoModel::name(unsigned i) +{ + return infos[i].name; +} + +QColor ChannelInfoModel::color(unsigned i) +{ + return infos[i].color; +} + +bool ChannelInfoModel::isVisible(unsigned i) +{ + return infos[i].visibility; +} + 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,6 +41,10 @@ public: ChannelInfoModel(const ChannelInfoModel& other); explicit ChannelInfoModel(const QStringList& channelNames); + QString name (unsigned i); + QColor color (unsigned i); + bool isVisible(unsigned i); + // implemented from QAbstractItemModel int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; diff --git a/src/plotmanager.cpp b/src/plotmanager.cpp --- a/src/plotmanager.cpp +++ b/src/plotmanager.cpp @@ -276,8 +276,7 @@ void PlotManager::_addCurve(QwtPlotCurve curves.append(curve); unsigned index = curves.size()-1; - auto color = _infoModel->index(index, ChannelInfoModel::COLUMN_NAME)\ - .data(Qt::ForegroundRole).value(); + auto color = _infoModel->color(index); curve->setPen(color); // create the plot for the curve if we are on multi display diff --git a/src/snapshot.cpp b/src/snapshot.cpp --- a/src/snapshot.cpp +++ b/src/snapshot.cpp @@ -114,8 +114,7 @@ ChannelInfoModel* Snapshot::infoModel() QString Snapshot::channelName(unsigned channel) { - return cInfoModel.data(cInfoModel.index(channel, ChannelInfoModel::COLUMN_NAME), - Qt::DisplayRole).toString(); + return cInfoModel.name(channel); } void Snapshot::save(QString fileName)