27 #include "../../../../maptools/Chart.h"
28 #include "../../Utils.h"
33 #include <QtGui/QMenu>
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;
A class that represents a chart slice in a LayerTreeModel.
const std::string getItemType() const
It returns the item type: "CHART_ITEM".
bool setData(int column, const QVariant &value, int role=Qt::EditRole)
ChartItem(te::map::Chart *chart, QObject *parent=0)
QMenu * getMenu(QWidget *parent=0) const
bool canFetchMore() const
void setCheckable(bool checkable)
The class that represents an item in a LayerTreeModel.
TEQTWIDGETSEXPORT QColor Convert2Qt(const te::color::RGBAColor &color)
It converts a TerraLib Color to Qt Color.
Qt::ItemFlags flags() const
This class represents the informations needed to build map charts.
te::map::AbstractLayerPtr getLayer() const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A class that represents a chart of a layer in a LayerTreeModel.
QVariant data(int column, int role) const