Changeset - d622519d65b3
[Not reviewed]
new-textview
0 2 0
Hasan Yavuz ÖZDERYA - 7 years ago 2019-01-12 15:16:54
hy@ozderya.net
add copyright headers
2 files changed with 38 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/datatextview.cpp
Show inline comments
 
/*
 
  Copyright © 2019 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "datatextview.h"
 
#include "ui_datatextview.h"
 

	
 
#include "utils.h"
 

	
 
class DataTextViewSink : public Sink
 
{
 
public:
 
    DataTextViewSink(DataTextView* textView)
 
    {
 
        _textView = textView;
 
    }
 

	
 
protected:
 
    virtual void feedIn(const SamplePack& data) override
 
    {
 
        _textView->addData(data);
 
    };
 

	
 
private:
 
    DataTextView* _textView;
 
};
 

	
 
DataTextView::DataTextView(Stream* stream, QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::DataTextView)
 
{
 
    _stream = stream;
 
    ui->setupUi(this);
 
    sink = new DataTextViewSink(this);
 

	
 
    connect(ui->cbEnable, &QCheckBox::toggled, [this](bool checked)
 
            {
 
                if (checked)
 
                {
 
                    _stream->connectFollower(sink);
 
                }
 
                else
 
                {
 
                    _stream->disconnectFollower(sink);
 
                }
 
            });
 

	
 
    ui->textView->setMaximumBlockCount(ui->spNumLines->value());
 
    connect(ui->spNumLines, SELECT<int>::OVERLOAD_OF(&QSpinBox::valueChanged),
 
            [this](int value)
 
            {
 
                ui->textView->setMaximumBlockCount(value);
src/datatextview.h
Show inline comments
 
/*
 
  Copyright © 2019 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef DATATEXTVIEW_H
 
#define DATATEXTVIEW_H
 

	
 
#include <QWidget>
 

	
 
#include "stream.h"
 

	
 
namespace Ui {
 
class DataTextView;
 
}
 

	
 
class DataTextViewSink;
 

	
 
class DataTextView : public QWidget
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit DataTextView(Stream* stream, QWidget *parent = 0);
 
    ~DataTextView();
 

	
 
protected:
 
    void addData(const SamplePack& data);
 

	
 
    friend DataTextViewSink;
 

	
 
private:
 
    Ui::DataTextView *ui;
 
    DataTextViewSink* sink;
 
    Stream* _stream;
 
};
 

	
 
#endif // DATATEXTVIEW_H
0 comments (0 inline, 0 general)