Skip to content

Commit

Permalink
refactor DataViewWidget to DataViewFilterSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr authored and fvacek committed Nov 28, 2024
1 parent 0b1a4fe commit 1792ee2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 45 deletions.
6 changes: 3 additions & 3 deletions libshvvisu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(libshvvisu
images/images.qrc
src/logview/dataviewwidget.cpp
src/logview/dataviewwidget.ui
src/logview/dataviewfilterselector.cpp
src/logview/dataviewfilterselector.ui
src/logview/dlgloginspector.cpp
src/logview/dlgloginspector.ui
src/logview/logmodel.cpp
Expand Down Expand Up @@ -34,7 +34,7 @@ add_library(libshvvisu
src/timeline/sample.cpp
src/widgets/timezonecombobox.cpp

include/shv/visu/logview/dataviewwidget.h
include/shv/visu/logview/dataviewfilterselector.h
include/shv/visu/logview/dlgloginspector.h
include/shv/visu/logview/logsortfilterproxymodel.h
include/shv/visu/logview/logmodel.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@
namespace shv::visu::logview {

namespace Ui {
class DataViewWidget;
class DataViewFilterSelector;
}

class SHVVISU_DECL_EXPORT DataViewWidget : public QWidget
class SHVVISU_DECL_EXPORT DataViewFilterSelector : public QWidget
{
Q_OBJECT

public:
explicit DataViewWidget(QWidget *parent = nullptr);
~DataViewWidget() override;
explicit DataViewFilterSelector(QWidget *parent = nullptr);
~DataViewFilterSelector() override;

void init(const QString &site_path, timeline::Graph *graph);
void setPredefinedViews(const QVector<timeline::Graph::VisualSettings> &views);
const QVector<timeline::Graph::VisualSettings> &predefinedViews();
void applyPredefinedView(const QString &name);

private:
Expand All @@ -33,6 +32,6 @@ class SHVVISU_DECL_EXPORT DataViewWidget : public QWidget
QString m_sitePath;
QVector<timeline::Graph::VisualSettings> m_predefinedViews;

Ui::DataViewWidget *ui;
Ui::DataViewFilterSelector *ui;
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ui_dataviewwidget.h"
#include "ui_dataviewfilterselector.h"

#include <shv/visu/logview/dataviewwidget.h>
#include <shv/visu/logview/dataviewfilterselector.h>
#include <shv/visu/timeline/graph.h>
#include <shv/visu/timeline/channelfilterdialog.h>

Expand All @@ -10,22 +10,22 @@ namespace tl = shv::visu::timeline;

namespace shv::visu::logview {

DataViewWidget::DataViewWidget(QWidget *parent) :
DataViewFilterSelector::DataViewFilterSelector(QWidget *parent) :
QWidget(parent),
ui(new Ui::DataViewWidget)
ui(new Ui::DataViewFilterSelector)
{
ui->setupUi(this);

connect(ui->pbShowChannelFilterDialog, &QToolButton::clicked, this, &DataViewWidget::onShowChannelFilterClicked);
connect(ui->pbShowRawData, &QToolButton::clicked, this, &DataViewWidget::onShowRawDataClicked);
connect(ui->pbShowChannelFilterDialog, &QToolButton::clicked, this, &DataViewFilterSelector::onShowChannelFilterClicked);
connect(ui->pbShowRawData, &QToolButton::clicked, this, &DataViewFilterSelector::onShowRawDataClicked);
}

DataViewWidget::~DataViewWidget()
DataViewFilterSelector::~DataViewFilterSelector()
{
delete ui;
}

void DataViewWidget::init(const QString &site_path, timeline::Graph *graph)
void DataViewFilterSelector::init(const QString &site_path, timeline::Graph *graph)
{
if (m_graph != nullptr) {
shvWarning() << "Dialog is allready initialized.";
Expand All @@ -42,17 +42,12 @@ void DataViewWidget::init(const QString &site_path, timeline::Graph *graph)
ui->pbShowRawData->setIcon(m_graph->style().isRawDataVisible()? QIcon(QStringLiteral(":/shv/visu/images/raw.svg")): QIcon(QStringLiteral(":/shv/visu/images/raw-off.svg")));
}

void DataViewWidget::setPredefinedViews(const QVector<timeline::Graph::VisualSettings> &views)
void DataViewFilterSelector::setPredefinedViews(const QVector<timeline::Graph::VisualSettings> &views)
{
m_predefinedViews = views;
}

const QVector<timeline::Graph::VisualSettings> &DataViewWidget::predefinedViews()
{
return m_predefinedViews;
}

void DataViewWidget::applyPredefinedView(const QString &name)
void DataViewFilterSelector::applyPredefinedView(const QString &name)
{
for (const auto &v: m_predefinedViews) {
if (v.name == name) {
Expand All @@ -62,7 +57,7 @@ void DataViewWidget::applyPredefinedView(const QString &name)
}
}

void DataViewWidget::onShowChannelFilterClicked()
void DataViewFilterSelector::onShowChannelFilterClicked()
{
auto *channel_filter_dialog = new tl::ChannelFilterDialog(this, m_sitePath, m_graph, m_predefinedViews);

Expand All @@ -73,7 +68,7 @@ void DataViewWidget::onShowChannelFilterClicked()
channel_filter_dialog->deleteLater();
}

void DataViewWidget::onShowRawDataClicked()
void DataViewFilterSelector::onShowRawDataClicked()
{
tl::Graph::Style graph_style = m_graph->style();
graph_style.setRawDataVisible(!m_graph->style().isRawDataVisible());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>shv::visu::logview::DataViewWidget</class>
<widget class="QWidget" name="shv::visu::logview::DataViewWidget">
<class>shv::visu::logview::DataViewFilterSelector</class>
<widget class="QWidget" name="shv::visu::logview::DataViewFilterSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>54</width>
<height>23</height>
<width>58</width>
<height>24</height>
</rect>
</property>
<property name="windowTitle">
Expand Down
2 changes: 1 addition & 1 deletion libshvvisu/src/logview/dlgloginspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ DlgLogInspector::DlgLogInspector(const QString &shv_path, QWidget *parent) :
m_graph->setModel(m_graphModel);
m_graphWidget->setGraph(m_graph);

ui->wDataView->init(ui->edShvPath->text(), m_graph);
ui->wDataViewFilterSelector->init(ui->edShvPath->text(), m_graph);

#if SHVVISU_HAS_TIMEZONE
connect(ui->cbxTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &) {
Expand Down
28 changes: 14 additions & 14 deletions libshvvisu/src/logview/dlgloginspector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<item>
<widget class="QDateTimeEdit" name="edSince">
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not defined</string>
Expand Down Expand Up @@ -104,7 +104,7 @@
<item>
<widget class="QDateTimeEdit" name="edUntil">
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not defined</string>
Expand Down Expand Up @@ -160,7 +160,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -206,7 +206,7 @@
<item row="2" column="1">
<widget class="QSpinBox" name="edMaxRecordCount">
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
Expand All @@ -228,7 +228,7 @@
<item row="2" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -241,7 +241,7 @@
<item row="3" column="1">
<widget class="QSpinBox" name="edTimeout">
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> sec</string>
Expand Down Expand Up @@ -347,10 +347,10 @@
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
Expand Down Expand Up @@ -410,7 +410,7 @@
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -421,7 +421,7 @@
</spacer>
</item>
<item>
<widget class="shv::visu::logview::DataViewWidget" name="wDataView" native="true"/>
<widget class="shv::visu::logview::DataViewFilterSelector" name="wDataViewFilterSelector" native="true"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -459,7 +459,7 @@
<x>0</x>
<y>0</y>
<width>1152</width>
<height>295</height>
<height>354</height>
</rect>
</property>
</widget>
Expand All @@ -486,7 +486,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -564,9 +564,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>shv::visu::logview::DataViewWidget</class>
<class>shv::visu::logview::DataViewFilterSelector</class>
<extends>QWidget</extends>
<header>shv/visu/logview/dataviewwidget.h</header>
<header>shv/visu/logview/dataviewfilterselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down

0 comments on commit 1792ee2

Please sign in to comment.