aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/qml/statsview2.qml6
-rw-r--r--desktop-widgets/qml/statsview2.qrc5
-rw-r--r--desktop-widgets/statswidget.cpp17
-rw-r--r--desktop-widgets/statswidget.h2
-rw-r--r--desktop-widgets/statswidget.ui10
5 files changed, 27 insertions, 13 deletions
diff --git a/desktop-widgets/qml/statsview2.qml b/desktop-widgets/qml/statsview2.qml
new file mode 100644
index 000000000..ccad7fd1e
--- /dev/null
+++ b/desktop-widgets/qml/statsview2.qml
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+import QtQuick 2.0
+import org.subsurfacedivelog.mobile 1.0
+
+StatsView {
+}
diff --git a/desktop-widgets/qml/statsview2.qrc b/desktop-widgets/qml/statsview2.qrc
new file mode 100644
index 000000000..d54f6c6b9
--- /dev/null
+++ b/desktop-widgets/qml/statsview2.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/qml">
+ <file>statsview2.qml</file>
+ </qresource>
+</RCC>
diff --git a/desktop-widgets/statswidget.cpp b/desktop-widgets/statswidget.cpp
index 01fd16eb1..e0090395f 100644
--- a/desktop-widgets/statswidget.cpp
+++ b/desktop-widgets/statswidget.cpp
@@ -70,6 +70,7 @@ QSize ChartItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod
return size;
}
+static const QUrl urlStatsView = QUrl(QStringLiteral("qrc:/qml/statsview2.qml"));
StatsWidget::StatsWidget(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
@@ -83,6 +84,13 @@ StatsWidget::StatsWidget(QWidget *parent) : QWidget(parent)
connect(ui.var1Binner, QOverload<int>::of(&QComboBox::activated), this, &StatsWidget::var1BinnerChanged);
connect(ui.var2Binner, QOverload<int>::of(&QComboBox::activated), this, &StatsWidget::var2BinnerChanged);
connect(ui.var2Operation, QOverload<int>::of(&QComboBox::activated), this, &StatsWidget::var2OperationChanged);
+
+ ui.stats->setSource(urlStatsView);
+ ui.stats->setResizeMode(QQuickWidget::SizeRootObjectToView);
+ QQuickItem *root = ui.stats->rootObject();
+ view = qobject_cast<StatsView *>(root);
+ if (!view)
+ qWarning("Oops. The root of the StatsView is not a StatsView.");
}
// Initialize QComboBox with list of variables
@@ -96,7 +104,7 @@ static void setVariableList(QComboBox *combo, const StatsState::VariableList &li
}
// Initialize QComboBox and QLabel of binners. Hide if there are no binners.
-static void setBinList(QLabel *label, QComboBox *combo, const StatsState::BinnerList &list)
+static void setBinList(QComboBox *combo, const StatsState::BinnerList &list)
{
combo->clear();
combo->setEnabled(!list.binners.empty());
@@ -114,8 +122,8 @@ void StatsWidget::updateUi()
int pos = charts.update(uiState.charts);
ui.chartType->setCurrentIndex(pos);
ui.chartType->setItemDelegate(new ChartItemDelegate);
- setBinList(ui.var1BinnerLabel, ui.var1Binner, uiState.binners1);
- setBinList(ui.var2BinnerLabel, ui.var2Binner, uiState.binners2);
+ setBinList(ui.var1Binner, uiState.binners1);
+ setBinList(ui.var2Binner, uiState.binners2);
setVariableList(ui.var2Operation, uiState.operations2);
// Add checkboxes for additional features
@@ -129,7 +137,8 @@ void StatsWidget::updateUi()
ui.features->addWidget(check);
}
- ui.stats->plot(state);
+ if (view)
+ view->plot(state);
}
void StatsWidget::closeStats()
diff --git a/desktop-widgets/statswidget.h b/desktop-widgets/statswidget.h
index 40e6d106c..b85d89730 100644
--- a/desktop-widgets/statswidget.h
+++ b/desktop-widgets/statswidget.h
@@ -9,6 +9,7 @@
#include <memory>
class QCheckBox;
+class StatsView;
class StatsWidget : public QWidget {
Q_OBJECT
@@ -27,6 +28,7 @@ slots:
private:
Ui::StatsWidget ui;
StatsState state;
+ StatsView *view;
void updateUi();
std::vector<std::unique_ptr<QCheckBox>> features;
diff --git a/desktop-widgets/statswidget.ui b/desktop-widgets/statswidget.ui
index 684b0fa58..a20fb4a8f 100644
--- a/desktop-widgets/statswidget.ui
+++ b/desktop-widgets/statswidget.ui
@@ -105,7 +105,7 @@
</layout>
</item>
<item>
- <widget class="StatsView" name="stats">
+ <widget class="QQuickWidget" name="stats">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -116,14 +116,6 @@
</item>
</layout>
</widget>
- <customwidgets>
- <customwidget>
- <class>StatsView</class>
- <extends>QQuickWidget</extends>
- <header>stats/statsview.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
<resources>
<include location="../subsurface.qrc"/>
</resources>