unused classes removed
This commit is contained in:
parent
a52499a7fc
commit
0109ffe675
|
@ -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"
|
|
|
@ -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 <QskControl.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
|
@ -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 <QskBoxNode.h>
|
|
||||||
#include <QskBoxShapeMetrics.h>
|
|
||||||
#include <QskBoxBorderMetrics.h>
|
|
||||||
#include <QskBoxBorderColors.h>
|
|
||||||
|
|
||||||
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"
|
|
|
@ -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 <QskSkinlet.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
Loading…
Reference in New Issue