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;
82  refreshFontSize();
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
CustomRoles
QPoint _drag_start_pos
QSet< QString > _inserted_curves
bool operator<(const SortedTableItem &other) const
void setFontSize(int size)
CurveListPanel * _parent_panel
virtual std::pair< int, int > hiddenItemsCount() override
void clear() override
std::string str
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
void clear(lua_State *L, int table_index)
Definition: sol.hpp:11710
bool eventFilterBase(QObject *object, QEvent *event)
bool eventFilter(QObject *object, QEvent *event) override
SortedTableItem(const QString &name)


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:01