Changeset - 840ec925ba83
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 9 years ago 2017-01-30 04:05:29
hy@ozderya.net
api for simpler access to channel info
4 files changed with 21 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/channelinfomodel.cpp
Show inline comments
 
@@ -95,12 +95,27 @@ ChannelInfoModel::ChannelInfo::ChannelIn
 
{
 
    name = tr("Channel %1").arg(index + 1);
 
    visibility = true;
 
    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;
 
}
 

	
 
int ChannelInfoModel::columnCount(const QModelIndex & parent) const
src/channelinfomodel.h
Show inline comments
 
@@ -38,12 +38,16 @@ public:
 
    };
 

	
 
    explicit ChannelInfoModel(unsigned numberOfChannels, QObject *parent = 0);
 
    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;
 
    QVariant      data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
    bool          setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
 
    Qt::ItemFlags flags(const QModelIndex &index) const;
src/plotmanager.cpp
Show inline comments
 
@@ -273,14 +273,13 @@ void PlotManager::addCurve(QString title
 
void PlotManager::_addCurve(QwtPlotCurve* curve)
 
{
 
    // store and init the curve
 
    curves.append(curve);
 

	
 
    unsigned index = curves.size()-1;
 
    auto color = _infoModel->index(index, ChannelInfoModel::COLUMN_NAME)\
 
        .data(Qt::ForegroundRole).value<QColor>();
 
    auto color = _infoModel->color(index);
 
    curve->setPen(color);
 

	
 
    // create the plot for the curve if we are on multi display
 
    Plot* plot;
 
    if (isMulti)
 
    {
src/snapshot.cpp
Show inline comments
 
@@ -111,14 +111,13 @@ ChannelInfoModel* Snapshot::infoModel()
 
{
 
    return &cInfoModel;
 
}
 

	
 
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)
 
{
 
    // TODO: remove code duplication (MainWindow::onExportCsv)
 
    QSaveFile file(fileName);
0 comments (0 inline, 0 general)