1#ifndef CANSIGNALDATAGUIIMPL_H
2#define CANSIGNALDATAGUIIMPL_H
6#include "ui_cansignaldata.h"
8#include <QItemDelegate>
9#include <QItemEditorFactory>
10#include <QStyledItemDelegate>
19 QRegExp qRegExp(
"[0-9]*");
20 auto v =
new QRegExpValidator(qRegExp,
this);
30 QRegExp qRegExp(
"[0-9A-Fa-f]{" + QString::number(len * 2) +
"}");
31 auto v =
new QRegExpValidator(qRegExp,
this);
33 setPlaceholderText(QString(
" %1 hex digits expected").arg(len*2));
40 : QStyledItemDelegate(parent)
45 virtual QWidget*
createEditor(QWidget* parent,
const QStyleOptionViewItem&,
const QModelIndex& index)
const override
47 uint32_t dlc = _model->data(_model->index(index.row(), 2)).toUInt();
49 return new T(dlc, parent);
53 QAbstractItemModel* _model;
59 , _widget(new QWidget)
61 _ui->setupUi(_widget);
62 _widget->setMinimumSize(_ui->tv->minimumSize());
64 QButtonGroup* bg =
new QButtonGroup(_widget);
65 bg->addButton(_ui->pbMsg);
66 bg->addButton(_ui->pbSig);
68 _ui->tv->setEditTriggers(QAbstractItemView::AllEditTriggers);
73 QObject::connect(_ui->pbDockUndock, &QPushButton::toggled, cb);
78 QObject::connect(_ui->pbMsg, &QPushButton::toggled, cb);
83 _msgSettingsUpdatedCbk = cb;
91 virtual void setMsgView(QAbstractItemModel& tvModel)
override
93 if (_settingsState.size() > 0) {
94 _ui->tv->horizontalHeader()->restoreState(_settingsState);
97 _ui->tv->setModel(&tvModel);
98 _ui->tv->horizontalHeader()->setSectionsMovable(
true);
99 _ui->tv->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
100 _ui->tv->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
101 _ui->tv->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
102 _ui->tv->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch);
103 _ui->tv->setColumnHidden(0,
false);
105 _settingsState = _ui->tv->horizontalHeader()->saveState();
108 _ui->tv->setItemDelegateForColumn(4, _cycleDelegate);
109 QObject::connect(_cycleDelegate, &QAbstractItemDelegate::closeEditor,
113 _ui->tv->setItemDelegateForColumn(5, _initValDelegate);
114 QObject::connect(_initValDelegate, &QAbstractItemDelegate::closeEditor,
120 if (_msgSettingsUpdatedCbk) {
121 _msgSettingsUpdatedCbk();
125 virtual void setSigView(QAbstractItemModel& tvModel)
override
127 if (_tableState.size() > 0) {
128 _ui->tv->horizontalHeader()->restoreState(_tableState);
131 _ui->tv->setModel(&tvModel);
132 _ui->tv->horizontalHeader()->setSectionsMovable(
true);
133 _ui->tv->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
134 _ui->tv->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
135 _ui->tv->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
136 _ui->tv->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
137 _ui->tv->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
138 _ui->tv->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
139 _ui->tv->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
141 _tableState = _ui->tv->horizontalHeader()->saveState();
150 Ui::CanSignalDataPrivate* _ui;
152 QByteArray _settingsState;
153 QByteArray _tableState;
Definition cansignaldata_p.h:14
Definition cansignaldataguiimpl.h:37
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const override
Definition cansignaldataguiimpl.h:45
DbFieldDelegate(QAbstractItemModel *model, QObject *parent=nullptr)
Definition cansignaldataguiimpl.h:39
Definition cansignaldataguiimpl.h:14
IntervalLE(uint32_t, QWidget *parent)
Definition cansignaldataguiimpl.h:16
Definition searchmodel.h:6
void updateFilter(const QString &filter)
Definition searchmodel.cpp:56
Definition cansignaldataguiimpl.h:25
ValueLE(uint32_t len, QWidget *parent)
Definition cansignaldataguiimpl.h:27
Definition canrawsender_p.h:13
Definition cansignaldataguiimpl.h:56
virtual void setDockUndockCbk(const dockUndock_t &cb) override
Definition cansignaldataguiimpl.h:71
CanSignalDataGuiImpl()
Definition cansignaldataguiimpl.h:57
virtual void setMsgViewCbk(const msgView_t &cb) override
Definition cansignaldataguiimpl.h:76
void initSearch(SearchModel &model) override
Definition cansignaldataguiimpl.h:144
virtual void setMsgSettingsUpdatedCbk(const msgSettingsUpdated_t &cb) override
Definition cansignaldataguiimpl.h:81
virtual void setSigView(QAbstractItemModel &tvModel) override
Definition cansignaldataguiimpl.h:125
void msgSettingUpdated()
Definition cansignaldataguiimpl.h:118
virtual void setMsgView(QAbstractItemModel &tvModel) override
Definition cansignaldataguiimpl.h:91
virtual QWidget * mainWidget() override
Definition cansignaldataguiimpl.h:86
Definition cansignaldataguiint.h:11
std::function< void()> msgSettingsUpdated_t
Definition cansignaldataguiint.h:14
std::function< void()> msgView_t
Definition cansignaldataguiint.h:12
std::function< void()> dockUndock_t
Definition cansignaldataguiint.h:13