curvelist_view.h
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef CURVELIST_VIEW_H
8 #define CURVELIST_VIEW_H
9 
10 #include <QFont>
11 #include <QFontDatabase>
12 #include <QGuiApplication>
13 #include <QHeaderView>
14 #include <QMouseEvent>
15 #include <QPainter>
16 #include <QSettings>
17 #include <QStandardItem>
18 #include <QStandardItemModel>
19 #include <QTableWidget>
20 #include <vector>
21 #include <QSet>
22 
23 #include "PlotJuggler/alphanum.hpp"
24 
25 class CurveListPanel;
26 
27 template <typename Item>
28 class SortedTableItem : public Item
29 {
30 public:
31  SortedTableItem(const QString& name) : Item(name), str(name.toStdString())
32  {
33  }
34 
35  bool operator<(const SortedTableItem& other) const
36  {
37  return doj::alphanum_impl(this->str.c_str(), other.str.c_str()) < 0;
38  }
39 
40 protected:
41  std::string str;
42 };
43 
45 {
46  Name = Qt::UserRole,
47  IsGroupName = Qt::UserRole + 1,
48  ToolTip = Qt::UserRole + 2
49 };
50 
52 {
53 public:
54  CurvesView(CurveListPanel* parent);
55 
56  virtual void clear() = 0;
57 
58  virtual void addItem(const QString& prefix, const QString& tree_name,
59  const QString& plot_ID) = 0;
60 
61  virtual std::vector<std::string> getSelectedNames() = 0;
62 
63  virtual bool applyVisibilityFilter(const QString& filter_string) = 0;
64 
65  virtual void refreshFontSize() = 0;
66 
67  virtual void refreshColumns() = 0;
68 
69  virtual void hideValuesColumn(bool hide) = 0;
70 
71  virtual void setViewResizeEnabled(bool enable) = 0;
72 
73  bool eventFilterBase(QObject* object, QEvent* event);
74 
75  virtual std::pair<int, int> hiddenItemsCount() = 0;
76 
77  virtual void removeCurve(const QString& name) = 0;
78 
79  void setFontSize(int size)
80  {
81  _point_size = size;
83  }
84 
85 protected:
86  int _point_size = 9;
88  bool _newX_modifier = false;
89  bool _dragging = false;
91 };
92 
93 class CurveTableView : public QTableWidget, public CurvesView
94 {
95 public:
97 
98  void clear() override
99  {
100  setRowCount(0);
101  _inserted_curves.clear();
102  }
103 
104  void addItem(const QString& prefix, const QString& tree_name,
105  const QString& plot_ID) override;
106 
107  void refreshColumns() override;
108 
109  std::vector<std::string> getSelectedNames() override;
110 
111  void refreshFontSize() override;
112 
113  void removeCurve(const QString& name) override;
114 
115  bool applyVisibilityFilter(const QString& filter_string) override;
116 
117  bool eventFilter(QObject* object, QEvent* event) override
118  {
119  bool ret = CurvesView::eventFilterBase(object, event);
120  if (!ret)
121  {
122  return QWidget::eventFilter(object, event);
123  }
124  else
125  {
126  return true;
127  }
128  }
129 
130  void setViewResizeEnabled(bool enable) override;
131 
132  virtual std::pair<int, int> hiddenItemsCount() override
133  {
134  return { _hidden_count, model()->rowCount() };
135  }
136 
137  virtual void hideValuesColumn(bool hide) override;
138 
139 private:
140  int _hidden_count = 0;
141  QSet<QString> _inserted_curves;
142 };
143 
144 #endif // CURVELIST_VIEW_H
CurveTableView::_inserted_curves
QSet< QString > _inserted_curves
Definition: curvelist_view.h:141
CurvesView::refreshFontSize
virtual void refreshFontSize()=0
CurvesView::refreshColumns
virtual void refreshColumns()=0
CurvesView::hideValuesColumn
virtual void hideValuesColumn(bool hide)=0
SortedTableItem::str
std::string str
Definition: curvelist_view.h:41
CurvesView::_drag_start_pos
QPoint _drag_start_pos
Definition: curvelist_view.h:87
CurveTableView::hideValuesColumn
virtual void hideValuesColumn(bool hide) override
Definition: curvelist_view.cpp:192
CurvesView::hiddenItemsCount
virtual std::pair< int, int > hiddenItemsCount()=0
CurveTableView::_hidden_count
int _hidden_count
Definition: curvelist_view.h:140
IsGroupName
@ IsGroupName
Definition: curvelist_view.h:47
SortedTableItem::operator<
bool operator<(const SortedTableItem &other) const
Definition: curvelist_view.h:35
CurvesView::eventFilterBase
bool eventFilterBase(QObject *object, QEvent *event)
Definition: curvelist_view.cpp:209
CurvesView::_dragging
bool _dragging
Definition: curvelist_view.h:89
CurvesView
Definition: curvelist_view.h:51
CurveTableView::addItem
void addItem(const QString &prefix, const QString &tree_name, const QString &plot_ID) override
Definition: curvelist_view.cpp:45
CurveListPanel
Definition: curvelist_panel.h:29
CurvesView::getSelectedNames
virtual std::vector< std::string > getSelectedNames()=0
CurveTableView::refreshFontSize
void refreshFontSize() override
Definition: curvelist_view.cpp:98
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
CurvesView::applyVisibilityFilter
virtual bool applyVisibilityFilter(const QString &filter_string)=0
CurveTableView::clear
void clear() override
Definition: curvelist_view.h:98
CurveTableView::getSelectedNames
std::vector< std::string > getSelectedNames() override
Definition: curvelist_view.cpp:87
ToolTip
@ ToolTip
Definition: curvelist_view.h:48
CurveTableView::applyVisibilityFilter
bool applyVisibilityFilter(const QString &filter_string) override
Definition: curvelist_view.cpp:134
CurveTableView::eventFilter
bool eventFilter(QObject *object, QEvent *event) override
Definition: curvelist_view.h:117
Name
@ Name
Definition: curvelist_view.h:46
CurveTableView::hiddenItemsCount
virtual std::pair< int, int > hiddenItemsCount() override
Definition: curvelist_view.h:132
CurvesView::removeCurve
virtual void removeCurve(const QString &name)=0
sol::meta::enable
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
CurveTableView
Definition: curvelist_view.h:93
CurvesView::addItem
virtual void addItem(const QString &prefix, const QString &tree_name, const QString &plot_ID)=0
SortedTableItem
Definition: curvelist_view.h:28
CurvesView::_parent_panel
CurveListPanel * _parent_panel
Definition: curvelist_view.h:90
SortedTableItem::SortedTableItem
SortedTableItem(const QString &name)
Definition: curvelist_view.h:31
CurvesView::_point_size
int _point_size
Definition: curvelist_view.h:86
CurveTableView::removeCurve
void removeCurve(const QString &name) override
Definition: curvelist_view.cpp:121
CustomRoles
CustomRoles
Definition: curvelist_view.h:44
CurveTableView::setViewResizeEnabled
void setViewResizeEnabled(bool enable) override
Definition: curvelist_view.cpp:177
CurvesView::CurvesView
CurvesView(CurveListPanel *parent)
Definition: curvelist_view.cpp:205
CurveTableView::refreshColumns
void refreshColumns() override
Definition: curvelist_view.cpp:81
CurvesView::setViewResizeEnabled
virtual void setViewResizeEnabled(bool enable)=0
CurvesView::clear
virtual void clear()=0
CurvesView::setFontSize
void setFontSize(int size)
Definition: curvelist_view.h:79
CurveTableView::CurveTableView
CurveTableView(CurveListPanel *parent)
Definition: curvelist_view.cpp:16
mqtt_test.ret
ret
Definition: mqtt_test.py:30
alphanum.hpp
CurvesView::_newX_modifier
bool _newX_modifier
Definition: curvelist_view.h:88


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43