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