summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2024-05-02 14:13:03 +0300
committerTomi Korpipaa <tomi.korpipaa@qt.io>2024-05-03 11:14:34 +0300
commitda442fbcad79f5b0ef328756cb9b947bebf4732f (patch)
treee7479f6612f4346d51dc60257fff423ca8d3a943
parent3d7eefe540b578a25954ce8883df74da127ddf69 (diff)
Get rid of unnecessary orientation enum
Replace QGraphsView::GraphOrientation with Qt::Orientation Change-Id: I7c561a2cd3cac27f3d88dc9375bac30f357f890f Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Sami Varanka <sami.varanka@qt.io>
-rw-r--r--examples/graphs/2d/testbed/qml/testbed/BarLabels.qml6
-rw-r--r--examples/graphs/2d/testbed/qml/testbed/BarSelection.qml6
-rw-r--r--src/graphs2d/qgraphsview.cpp27
-rw-r--r--src/graphs2d/qgraphsview_p.h13
-rw-r--r--src/graphs2d/qsgrenderer/axisrenderer.cpp2
-rw-r--r--src/graphs2d/qsgrenderer/barsrenderer.cpp4
6 files changed, 16 insertions, 42 deletions
diff --git a/examples/graphs/2d/testbed/qml/testbed/BarLabels.qml b/examples/graphs/2d/testbed/qml/testbed/BarLabels.qml
index 80db595..219062e 100644
--- a/examples/graphs/2d/testbed/qml/testbed/BarLabels.qml
+++ b/examples/graphs/2d/testbed/qml/testbed/BarLabels.qml
@@ -76,10 +76,10 @@ Rectangle {
width: 250
text: "Vertical/Horizontal bars"
onClicked: {
- if (chartView.orientation === GraphsView.GraphOrientation.Vertical)
- chartView.orientation = GraphsView.GraphOrientation.Horizontal
+ if (chartView.orientation === Qt.Vertical)
+ chartView.orientation = Qt.Horizontal
else
- chartView.orientation = GraphsView.GraphOrientation.Vertical
+ chartView.orientation = Qt.Vertical
}
}
Button {
diff --git a/examples/graphs/2d/testbed/qml/testbed/BarSelection.qml b/examples/graphs/2d/testbed/qml/testbed/BarSelection.qml
index 876a989..99b73bf 100644
--- a/examples/graphs/2d/testbed/qml/testbed/BarSelection.qml
+++ b/examples/graphs/2d/testbed/qml/testbed/BarSelection.qml
@@ -114,10 +114,10 @@ Rectangle {
width: 250
text: "Vertical/Horizontal bars"
onClicked: {
- if (chartView.orientation === GraphsView.GraphOrientation.Vertical)
- chartView.orientation = GraphsView.GraphOrientation.Horizontal
+ if (chartView.orientation === Qt.Vertical)
+ chartView.orientation = Qt.Horizontal
else
- chartView.orientation = GraphsView.GraphOrientation.Vertical
+ chartView.orientation = Qt.Vertical
}
}
}
diff --git a/src/graphs2d/qgraphsview.cpp b/src/graphs2d/qgraphsview.cpp
index 1fc4480..e1333d3 100644
--- a/src/graphs2d/qgraphsview.cpp
+++ b/src/graphs2d/qgraphsview.cpp
@@ -750,35 +750,12 @@ void QGraphsView::setAxisY(QAbstractAxis *axis)
emit update();
}
-/*!
- \enum QGraphsView::GraphOrientation
-
- This enum value describes the orientation of the view:
-
- \value Vertical The series appear vertically.
- \value Horizontal The series appear horizontally.
-*/
-/*!
- \property QGraphsView::orientation
- \brief The orientation of the view. By default the series appear vertically.
-*/
-/*!
- \qmlproperty enumeration QGraphsView::orientation
-
- The orientation of the view:
-
- \value QGraphsView.GraphOrientation.Vertical
- The series appear vertically. This is the default value.
- \value QGraphsView.GraphOrientation.Horizontal
- The series appear horizontally.
-*/
-
-QGraphsView::GraphOrientation QGraphsView::orientation() const
+Qt::Orientation QGraphsView::orientation() const
{
return m_orientation;
}
-void QGraphsView::setOrientation(QGraphsView::GraphOrientation newOrientation)
+void QGraphsView::setOrientation(Qt::Orientation newOrientation)
{
if (m_orientation == newOrientation)
return;
diff --git a/src/graphs2d/qgraphsview_p.h b/src/graphs2d/qgraphsview_p.h
index 9d8199e..9263590 100644
--- a/src/graphs2d/qgraphsview_p.h
+++ b/src/graphs2d/qgraphsview_p.h
@@ -58,16 +58,13 @@ class QGraphsView : public QQuickItem
Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
- Q_PROPERTY(GraphOrientation orientation READ orientation WRITE setOrientation NOTIFY
- orientationChanged)
+ Q_PROPERTY(
+ Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
Q_CLASSINFO("DefaultProperty", "seriesList")
QML_NAMED_ELEMENT(GraphsView)
public:
- enum class GraphOrientation { Vertical, Horizontal };
- Q_ENUM(GraphOrientation)
-
explicit QGraphsView(QQuickItem *parent = nullptr);
~QGraphsView() override;
@@ -146,8 +143,8 @@ public:
QAbstractAxis *axisY() const;
void setAxisY(QAbstractAxis *axis);
- GraphOrientation orientation() const;
- void setOrientation(GraphOrientation newOrientation);
+ Qt::Orientation orientation() const;
+ void setOrientation(Qt::Orientation newOrientation);
protected:
void handleHoverEnter(QString seriesName, QPointF position, QPointF value);
@@ -211,7 +208,7 @@ private:
QAbstractAxis *m_axisX = nullptr;
QAbstractAxis *m_axisY = nullptr;
- GraphOrientation m_orientation = GraphOrientation::Vertical;
+ Qt::Orientation m_orientation = Qt::Orientation::Vertical;
QGraphsTheme *m_theme = nullptr;
QGraphsTheme *m_defaultTheme = nullptr;
diff --git a/src/graphs2d/qsgrenderer/axisrenderer.cpp b/src/graphs2d/qsgrenderer/axisrenderer.cpp
index 72f8bef..0d2cf62 100644
--- a/src/graphs2d/qsgrenderer/axisrenderer.cpp
+++ b/src/graphs2d/qsgrenderer/axisrenderer.cpp
@@ -147,7 +147,7 @@ void AxisRenderer::updateAxis()
// See if series is horizontal, so axis should also switch places.
bool vertical = true;
- if (m_graph->orientation() == QGraphsView::GraphOrientation::Horizontal)
+ if (m_graph->orientation() == Qt::Orientation::Horizontal)
vertical = false;
if (vertical) {
m_axisVertical = axisVertical;
diff --git a/src/graphs2d/qsgrenderer/barsrenderer.cpp b/src/graphs2d/qsgrenderer/barsrenderer.cpp
index 39005fc..afa7801 100644
--- a/src/graphs2d/qsgrenderer/barsrenderer.cpp
+++ b/src/graphs2d/qsgrenderer/barsrenderer.cpp
@@ -65,7 +65,7 @@ QString BarsRenderer::generateLabelText(QBarSeries *series, qreal value)
void BarsRenderer::positionLabelItem(QBarSeries *series, QQuickText *textItem, const BarSeriesData &d)
{
auto pos = series->labelsPosition();
- const bool vertical = m_graph->orientation() == QGraphsView::GraphOrientation::Vertical;
+ const bool vertical = m_graph->orientation() == Qt::Orientation::Vertical;
const float w = textItem->contentWidth() + series->labelsMargin() * 2;
const float h = textItem->contentHeight() + series->labelsMargin() * 2;
textItem->setWidth(w);
@@ -444,7 +444,7 @@ void BarsRenderer::handlePolish(QBarSeries *series)
// Get bars values
int valuesPerSet = series->barSets().first()->values().size();
- if (m_graph->orientation() == QGraphsView::GraphOrientation::Vertical)
+ if (m_graph->orientation() == Qt::Orientation::Vertical)
updateVerticalBars(series, setCount, valuesPerSet);
else
updateHorizontalBars(series, setCount, valuesPerSet);