CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
cansignalviewerguiimpl.h
Go to the documentation of this file.
1#ifndef CANSINGALVIEWERGUIIMPL_H
2#define CANSINGALVIEWERGUIIMPL_H
3
4//#include "crv_enums.h"
6#include "ui_cansignalviewer.h"
7#include <QStandardItemModel>
8#include <QWidget>
9#include <log.h>
10#include <memory>
11
13
15 : _ui(new Ui::CanSignalViewerPrivate)
16 , _widget(new QWidget)
17 {
18 _ui->setupUi(_widget);
19 _widget->setMinimumSize(_ui->tv->minimumSize());
20 }
21
22 virtual void setClearCbk(const clear_t& cb) override
23 {
24 QObject::connect(_ui->pbClear, &QPushButton::pressed, cb);
25 }
26
27 virtual void setDockUndockCbk(const dockUndock_t& cb) override
28 {
29 QObject::connect(_ui->pbDockUndock, &QPushButton::toggled, cb);
30 }
31
32 virtual void setSectionClikedCbk(const sectionClicked_t& cb) override
33 {
34 QObject::connect(_ui->tv->horizontalHeader(), &QHeaderView::sectionClicked, cb);
35 }
36
37 virtual void setFilterCbk(const filter_t& cb) override
38 {
39 QObject::connect(_ui->pbToggleFilter, &QPushButton::toggled, cb);
40 }
41
42 virtual QWidget* mainWidget() override
43 {
44 return _widget;
45 }
46
47 virtual void setModel(QAbstractItemModel* model) override
48 {
49 _ui->tv->setModel(model);
50 }
51
52 virtual void initTableView(QAbstractItemModel& tvModel) override
53 {
54 _ui->tv->setModel(&tvModel);
55 _ui->tv->horizontalHeader()->setSectionsMovable(true);
56 _ui->tv->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
57 _ui->tv->setColumnHidden(0, true);
58 _ui->tv->setColumnWidth(3, 85);
59 _ui->tv->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
60 _ui->tv->setColumnWidth(5, 200);
61 }
62
63 virtual bool isViewFrozen() override
64 {
65 return _ui->freezeBox->isChecked();
66 }
67
68 virtual void setViewFrozen(bool state) override
69 {
70 if (_ui->freezeBox->isChecked() != state) {
71 _ui->freezeBox->setChecked(state);
72 }
73 }
74
75 virtual void scrollToBottom() override
76 {
77 _ui->tv->scrollToBottom();
78 }
79
80 virtual Qt::SortOrder getSortOrder() override
81 {
82 return _ui->tv->horizontalHeader()->sortIndicatorOrder();
83 }
84
85 virtual QString getClickedColumn(int ndx) override
86 {
87 return _ui->tv->model()->headerData(ndx, Qt::Horizontal).toString();
88 }
89
90 virtual void setSorting(int sortNdx, Qt::SortOrder order) override
91 {
92 _ui->tv->sortByColumn(sortNdx, order);
93 _ui->tv->horizontalHeader()->setSortIndicator(sortNdx, order);
94 }
95
96 virtual QString getWindowTitle() override
97 {
98 return _widget->windowTitle();
99 }
100
101 virtual bool isColumnHidden(int ndx) override
102 {
103 return _ui->tv->isColumnHidden(ndx);
104 }
105
106 virtual void getColumnProper(int ndx, int& vIdx) override
107 {
108 auto horHeader = _ui->tv->horizontalHeader();
109 vIdx = horHeader->visualIndex(ndx);
110 }
111
112 virtual void setColumnProper(int vIdxFrom, int vIdxTo) override
113 {
114 auto horHeader = _ui->tv->horizontalHeader();
115 horHeader->moveSection(vIdxFrom, vIdxTo);
116 }
117
118private:
119 Ui::CanSignalViewerPrivate* _ui;
120 QWidget* _widget;
121};
122
123#endif // CANSINGALVIEWERGUIIMPL_H
Definition cansignalviewer_p.h:12
Definition canrawsender_p.h:13
Definition cansignalviewerguiimpl.h:12
virtual QString getClickedColumn(int ndx) override
Definition cansignalviewerguiimpl.h:85
virtual void initTableView(QAbstractItemModel &tvModel) override
Definition cansignalviewerguiimpl.h:52
virtual bool isViewFrozen() override
Definition cansignalviewerguiimpl.h:63
virtual QWidget * mainWidget() override
Definition cansignalviewerguiimpl.h:42
virtual void setClearCbk(const clear_t &cb) override
Definition cansignalviewerguiimpl.h:22
virtual void setSorting(int sortNdx, Qt::SortOrder order) override
Definition cansignalviewerguiimpl.h:90
virtual bool isColumnHidden(int ndx) override
Definition cansignalviewerguiimpl.h:101
virtual Qt::SortOrder getSortOrder() override
Definition cansignalviewerguiimpl.h:80
CanSignalViewerGuiImpl()
Definition cansignalviewerguiimpl.h:14
virtual void setFilterCbk(const filter_t &cb) override
Definition cansignalviewerguiimpl.h:37
virtual void scrollToBottom() override
Definition cansignalviewerguiimpl.h:75
virtual QString getWindowTitle() override
Definition cansignalviewerguiimpl.h:96
virtual void setDockUndockCbk(const dockUndock_t &cb) override
Definition cansignalviewerguiimpl.h:27
virtual void setViewFrozen(bool state) override
Definition cansignalviewerguiimpl.h:68
virtual void setSectionClikedCbk(const sectionClicked_t &cb) override
Definition cansignalviewerguiimpl.h:32
virtual void getColumnProper(int ndx, int &vIdx) override
Definition cansignalviewerguiimpl.h:106
virtual void setColumnProper(int vIdxFrom, int vIdxTo) override
Definition cansignalviewerguiimpl.h:112
virtual void setModel(QAbstractItemModel *model) override
Definition cansignalviewerguiimpl.h:47
Definition cansignalviewerguiint.h:10
std::function< void(bool)> filter_t
Definition cansignalviewerguiint.h:14
std::function< void()> dockUndock_t
Definition cansignalviewerguiint.h:12
std::function< void(int)> sectionClicked_t
Definition cansignalviewerguiint.h:13
std::function< void()> clear_t
Definition cansignalviewerguiint.h:11