27 #include "../../../../maptools/Chart.h"
28 #include "../../Utils.h"
57 if(role == Qt::DecorationRole)
58 return QVariant(QIcon::fromTheme(
"chart-pie"));
60 if(role == Qt::DisplayRole)
62 switch(m_chart->getType())
65 return QVariant(tr(
"Pie Chart"));
68 return QVariant(tr(
"Bar Chart"));
71 return QVariant(tr(
"Chart"));
75 if(role == Qt::CheckStateRole && m_isCheckable)
76 return QVariant(m_isChecked ? Qt::Checked : Qt::Unchecked);
88 return !m_chart->getProperties().empty() && children().isEmpty();
93 return (m_isCheckable ? (Qt::ItemIsEnabled | Qt::ItemIsUserCheckable) : Qt::ItemIsEnabled);
98 if(!children().isEmpty())
101 int contourWidth =
static_cast<int>(m_chart->getContourWidth());
102 QColor contourColor =
Convert2Qt(m_chart->getContourColor());
104 const std::vector<std::string>& properties = m_chart->getProperties();
106 for(std::size_t i = 0; i < properties.size(); ++i)
108 QColor color =
Convert2Qt(m_chart->getColor(i));
109 new ChartSliceItem(properties[i].c_str(), color, contourColor, contourWidth,
this);
115 return !m_chart->getProperties().empty();
120 if(role == Qt::CheckStateRole && m_isCheckable)
123 Qt::CheckState checkState =
static_cast<Qt::CheckState
>(value.toInt(&ok));
128 m_isChecked = (checkState == Qt::Checked ?
true :
false);
130 m_chart->setVisibility(m_isChecked);
150 m_isCheckable = checkable;
155 return m_isCheckable;
This class represents the informations needed to build map charts.
A class that represents a chart of a layer in a LayerTreeModel.
A class that represents a chart slice in a LayerTreeModel.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr