ChartSliceItem.cpp
Go to the documentation of this file.
1 #include "ChartSliceItem.h"
2 
3 // Qt
4 #include <QObject>
5 #include <QPainter>
6 
7 QIcon CreateIcon(const int& size, const QColor& penColor, const QColor& brushColor, const int& contourSize)
8 {
9  QPixmap pix(size, size);
10  pix.fill(Qt::transparent);
11 
12  int offset = 2;
13 
14  QPainterPath path;
15  path.addRect(offset, offset, pix.width() - 2 * offset, pix.height() - 2 * offset);
16 
17  QPen pen;
18  pen.setColor(penColor);
19  pen.setWidth(contourSize);
20 
21  QBrush brush;
22  brush.setColor(brushColor);
23 
24  QPainter p(&pix);
25  p.setPen(pen);
26  p.setBrush(brushColor);
27 
28  p.fillPath(path, brush);
29  p.drawPath(path);
30 
31  return QIcon(pix);
32 }
33 
34 
35 te::qt::widgets::ChartSliceItem::ChartSliceItem(const QString& propertyName, const QColor& color,
36  const QColor& contourColor, const int& contourWidth):
37  TreeItem("CHARTSLICE")
38 {
39  m_label = (QObject::tr("Property") + ": " + propertyName).toUtf8().data();
40 
41  m_icon = CreateIcon(16, contourColor, color, contourWidth);
42 }
43 
45 
47 {
48  return m_label;
49 }
50 
52 {
53  return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled;
54 }
55 
57 {
58  return m_icon;
59 }
std::string getAsString() const
Returns the label of the item to be presented in a Qt view.
QIcon CreateIcon(const int &size, const QColor &penColor, const QColor &brushColor, const int &contourSize)
Defines a hierarchical structure.
std::string m_label
Label to be presented on the Qt view.
te::gm::Polygon * p
QIcon m_icon
Icon to be presented.
Qt::ItemFlags flags()
Returns the flags to be used by the model.
A class that represents a chart slice in a LayerItemModel.
ChartSliceItem(const QString &propertyName, const QColor &color, const QColor &contourColor, const int &contourWidth)
Constructor.
QIcon getIcon() const
Returns the icon to be presented in the tree.