2 #include "ui_curvelist_panel.h" 10 #include <QHeaderView> 11 #include <QFontDatabase> 12 #include <QMessageBox> 13 #include <QApplication> 16 #include <QStandardItem> 17 #include <QWheelEvent> 18 #include <QItemSelectionModel> 20 #include <QTreeWidget> 31 , _custom_plots(mapped_math_plots)
32 , _column_width_dirty (true)
36 setFocusPolicy(Qt::ClickFocus);
41 auto layout1 =
new QHBoxLayout();
42 ui->listPlaceholder1->setLayout(layout1);
44 layout1->setMargin(0);
46 auto layout2 =
new QHBoxLayout();
47 ui->listPlaceholder2->setLayout(layout2);
49 layout2->setMargin(0);
53 int point_size = settings.value(
"FilterableListWidget/table_point_size", 9).toInt();
56 ui->splitter->setStretchFactor(0, 5);
57 ui->splitter->setStretchFactor(1, 1);
59 connect(
_custom_view->selectionModel(), &QItemSelectionModel::selectionChanged,
79 ui->labelNumberDisplayed->setText(
"0 of 0");
109 if (event->key() == Qt::Key_Delete)
121 settings.setValue(
"FilterableListWidget/table_point_size", point_size);
145 auto FormattedNumber = [](
double value) {
146 QString num_text = QString::number(
value,
'f', 3);
147 if (num_text.contains(
'.'))
149 int idx = num_text.length() - 1;
150 while (num_text[idx] ==
'0')
155 if (num_text[idx] ==
'.')
158 return num_text +
" ";
165 auto&
data = it->second;
175 else if (
data.size() > 0)
177 return data.back().y;
186 table->setViewResizeEnabled(
false);
187 const int vertical_height =
table->visibleRegion().boundingRect().height();
189 for (
int row = 0; row <
table->rowCount(); row++)
191 int vertical_pos =
table->rowViewportPosition(row);
192 if (vertical_pos < 0 || table->isRowHidden(row))
196 if (vertical_pos > vertical_height)
201 const std::string&
name =
table->item(row, 0)->text().toStdString();
202 auto val = GetValue(name);
205 table->item(row, 1)->setText(FormattedNumber(val.value()));
211 table->setViewResizeEnabled(
true);
217 const int vertical_height = tree_view->visibleRegion().boundingRect().height();
219 auto DisplayValue = [&](QTreeWidgetItem* cell) {
220 QString curve_name = cell->data(0, Qt::UserRole).toString();
222 if (!curve_name.isEmpty())
224 auto rect = cell->treeWidget()->visualItemRect(cell);
226 if (rect.bottom() < 0 || cell->isHidden())
230 if (rect.top() > vertical_height)
235 auto val = GetValue(curve_name.toStdString());
238 cell->setText(1, FormattedNumber(val.value()));
243 tree_view->setViewResizeEnabled(
false);
244 tree_view->treeVisitor(DisplayValue);
251 bool updated =
false;
258 int item_count = h_c.second;
259 int visible_count = item_count - h_c.first;
261 ui->labelNumberDisplayed->setText(QString::number(visible_count) + QString(
" of ") + QString::number(item_count));
270 QMessageBox::StandardButton reply;
271 reply = QMessageBox::question(
nullptr, tr(
"Warning"), tr(
"Do you really want to remove these data?\n"),
272 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
274 if (reply == QMessageBox::Yes)
285 QString curve_name = QString::fromStdString(name);
294 std::string suggested_name;
298 if (curve_names.size() > 0)
300 suggested_name = (curve_names.front());
313 bool enabled = (selected.size() == 1);
314 ui->buttonEditCustom->setEnabled(enabled);
315 ui->buttonEditCustom->setToolTip(enabled ?
"Edit the selected custom timeserie" :
316 "Select a single custom Timeserie to Edit it");
322 if (selected.size() == 1)
337 ui->buttonAddCustom->setIcon(
LoadSvgIcon(
":/resources/svg/add_tab.svg", theme));
338 ui->buttonEditCustom->setIcon(
LoadSvgIcon(
":/resources/svg/pencil-edit.svg", theme));
bool is2ndColumnHidden() const
enum MQTTPropertyCodes value
void onCustomSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void addItem(const QString &item_name) override
void editMathPlot(const std::string &plot_name)
QIcon LoadSvgIcon(QString filename, QString style_name="light")
virtual bool applyVisibilityFilter(const QString &filter_string)=0
void changeFontSize(int point_size)
std::vector< std::string > getSelectedNames() override
virtual void hideValuesColumn(bool hide) override
void removeCurve(const QString &name) override
void addItem(const QString &item_name) override
void createMathPlot(const std::string &linked_plot)
void addCurve(const QString &item_name)
std::vector< std::string > getSelectedNames() override
void setFontSize(int size)
CurveTreeView * _tree_view
void deleteCurves(const std::vector< std::string > &curve_names)
table_core< false > table
void on_stylesheetChanged(QString theme)
void refreshColumns() override
virtual void keyPressEvent(QKeyEvent *event) override
CurveListPanel(const CustomPlotMap &mapped_math_plots, QWidget *parent)
void addCustom(const QString &item_name)
std::unordered_map< std::string, CustomPlotPtr > CustomPlotMap
~CurveListPanel() override
void on_buttonEditCustom_clicked()
void removeSelectedCurves()
void hiddenItemsChanged()
void refreshColumns() override
void on_checkBoxShowValues_toggled(bool show)
std::unordered_map< std::string, PlotData > * _numeric_data
void update2ndColumnValues(double time, std::unordered_map< std::string, PlotData > *numeric_data)
virtual std::pair< int, int > hiddenItemsCount()=0
CurveTableView * _custom_view
void removeCurve(const QString &name) override
void on_lineEditFilter_textChanged(const QString &search_string)
void on_buttonAddCustom_clicked()
virtual void hideValuesColumn(bool hide) override
void removeCurve(const std::string &name)