Erste lauffähige Version
This commit is contained in:
52
include/tableview.h
Normal file
52
include/tableview.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QTableWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
|
||||
// TableView interprets UART lines as delimited data and shows them in a table.
|
||||
// The first line that matches the column count is used as the header row if it
|
||||
// starts with '#'. Otherwise column names are auto-generated (Col 1, Col 2, …).
|
||||
//
|
||||
// Supported delimiters: comma, semicolon, tab, pipe, space
|
||||
// To use: send lines like:
|
||||
// #time,temp,voltage,current
|
||||
// 1234,23.5,3.3,0.42
|
||||
class TableView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TableView(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void appendLine(const QString &line);
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void onDelimiterChanged(int index);
|
||||
void onMaxRowsChanged();
|
||||
void rebuildTable();
|
||||
|
||||
private:
|
||||
void parseHeaders(const QString &line);
|
||||
bool tryAppendRow(const QString &line);
|
||||
|
||||
QTableWidget *m_table = nullptr;
|
||||
QComboBox *m_delimCombo = nullptr;
|
||||
QLineEdit *m_maxRowsEdit = nullptr;
|
||||
QPushButton *m_clearBtn = nullptr;
|
||||
QCheckBox *m_autoScrollCb = nullptr;
|
||||
|
||||
QStringList m_headers;
|
||||
QList<QStringList> m_rows; // raw data for rebuild
|
||||
int m_maxRows = 500;
|
||||
char m_delimiter = ',';
|
||||
bool m_autoScroll = true;
|
||||
bool m_headersSet = false;
|
||||
};
|
||||
Reference in New Issue
Block a user