diff --git a/examples/iotdashboard/PieChart.cpp b/examples/iotdashboard/PieChart.cpp deleted file mode 100644 index 4a8bf227..00000000 --- a/examples/iotdashboard/PieChart.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2021 Edelhirsch Software GmbH - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "PieChart.h" - -QSK_SUBCONTROL( PieChart, Panel ) -QSK_SUBCONTROL( PieChart, Labels ) - -PieChart::PieChart( QQuickItem* parent ) - : QskControl( parent ) -{ -} - -QVector< float > PieChart::angles() const -{ - return m_angles; -} - -void PieChart::setAngles( const QVector< float >& angles ) -{ - m_angles = angles; -} - -QVector< QString > PieChart::labels() const -{ - return m_labels; -} - -void PieChart::setLabels( const QVector< QString >& labels ) -{ - m_labels = labels; -} - -#include "moc_PieChart.cpp" diff --git a/examples/iotdashboard/PieChart.h b/examples/iotdashboard/PieChart.h deleted file mode 100644 index 32901ad9..00000000 --- a/examples/iotdashboard/PieChart.h +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2021 Edelhirsch Software GmbH - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#pragma once - -#include - -class PieChart : public QskControl -{ - Q_OBJECT - - public: - QSK_SUBCONTROLS( Panel, Labels ) - - PieChart( QQuickItem* parent = nullptr ); - - QVector< float > angles() const; - void setAngles( const QVector< float >& angles ); - - QVector< QString > labels() const; - void setLabels( const QVector< QString >& labels ); - - private: - QVector< float > m_angles; - QVector< QString > m_labels; -}; diff --git a/examples/iotdashboard/PieChartSkinlet.cpp b/examples/iotdashboard/PieChartSkinlet.cpp deleted file mode 100644 index 4bc29c8c..00000000 --- a/examples/iotdashboard/PieChartSkinlet.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2021 Edelhirsch Software GmbH - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "PieChartSkinlet.h" -#include "PieChart.h" - -#include -#include -#include -#include - -PieChartSkinlet::PieChartSkinlet( QskSkin* skin ) - : QskSkinlet( skin ) -{ - setNodeRoles( { PanelRole, LabelsRole } ); -} - -QRectF PieChartSkinlet::subControlRect( const QskSkinnable*, - const QRectF& contentsRect, QskAspect::Subcontrol ) const -{ - return contentsRect; -} - -QSGNode* PieChartSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const -{ - const auto pieChart = static_cast< const PieChart* >( skinnable ); - - switch( nodeRole ) - { - case PanelRole: - return updatePanelNode( pieChart, node ); - - case LabelsRole: - return updateLabelsNode( pieChart, node ); - - default: - return nullptr; - } -} - -QSGNode* PieChartSkinlet::updatePanelNode( const PieChart* pieChart, QSGNode* node ) const -{ - auto boxNode = static_cast< QskBoxNode* >( node ); - - if( boxNode == nullptr ) - { - boxNode = new QskBoxNode; - } - - auto panelRect = subControlRect( pieChart, pieChart->contentsRect(), PieChart::Panel ); - - // ### when displaying a legend we might want to revise this - if( panelRect.width() > panelRect.height() ) - { - panelRect.setWidth( panelRect.height() ); - } - else if( panelRect.width() < panelRect.height() ) - { - panelRect.setHeight( panelRect.width() ); - } - - const qreal radius = panelRect.width() / 2; - - QskBoxShapeMetrics shapeMetrics( radius, radius, radius, radius ); - QskBoxBorderMetrics borderMetrics = pieChart->boxBorderMetricsHint( PieChart::Panel ); - QskBoxBorderColors borderColors = pieChart->boxBorderColorsHint( PieChart::Panel ); - QskGradient gradient = pieChart->gradientHint( PieChart::Panel ); - boxNode->setBoxData( panelRect, shapeMetrics, borderMetrics, borderColors, gradient ); - - return boxNode; -} - -QSGNode* PieChartSkinlet::updateLabelsNode( const PieChart* pieChart, QSGNode* ) const -{ - const int labelsCount = pieChart->labels().count(); - - if( labelsCount < 1 ) - { - return nullptr; - } - - return nullptr; -} - -#include "moc_PieChartSkinlet.cpp" diff --git a/examples/iotdashboard/PieChartSkinlet.h b/examples/iotdashboard/PieChartSkinlet.h deleted file mode 100644 index b06c0066..00000000 --- a/examples/iotdashboard/PieChartSkinlet.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2021 Edelhirsch Software GmbH - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#pragma once - -#include - -class PieChart; - -class PieChartSkinlet : public QskSkinlet -{ - Q_GADGET - - public: - enum NodeRole - { - PanelRole, - LabelsRole - }; - - Q_INVOKABLE PieChartSkinlet( QskSkin* skin = nullptr ); - - QRectF subControlRect( const QskSkinnable*, - const QRectF&, QskAspect::Subcontrol ) const override; - - protected: - virtual QSGNode* updateSubNode( const QskSkinnable*, - quint8 nodeRole, QSGNode* node ) const override; - - private: - QSGNode* updatePanelNode( const PieChart*, QSGNode* ) const; - QSGNode* updateLabelsNode( const PieChart*, QSGNode* ) const; -};