RasterLayerDelegate.cpp
Go to the documentation of this file.
1 #include "RasterLayerDelegate.h"
2 
3 #include "LayerItem.h"
4 
5 // Terralib
6 #include "../../../../maptools/AbstractLayer.h"
7 
8 // Qt
9 #include <QFont>
10 #include <QPainter>
11 
12 te::qt::widgets::RasterLayerDelegate::RasterLayerDelegate(QStyledItemDelegate* decorated, QObject* parent):
13 te::common::Decorator<QStyledItemDelegate>(decorated)
14 {
15  setParent(parent);
16 }
17 
19 
20 void te::qt::widgets::RasterLayerDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
21 {
22  TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
23 
24  if(item->getType() == "LAYER")
25  {
26  te::map::AbstractLayerPtr l = ((LayerItem*)item)->getLayer();
27 
28  if(l->getSchema()->hasRaster())
29  {
30  QStyleOptionViewItem opt = option;
31 
32 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
33 
34  opt.icon = QIcon(QIcon::fromTheme("file-raster"));
35 
36 #endif
37 
38  opt.decorationSize = QSize(20, 20);
39 
40 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
41 
42  opt.features |= QStyleOptionViewItem::HasDecoration;
43 
44 #endif
45 
46  QStyledItemDelegate::paint(painter, opt, index);
47 
48  return;
49  }
50  }
51 
52  if(m_decorated != nullptr)
53  m_decorated->paint(painter, option, index);
54 }
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Defines a hierarchical structure.
RasterLayerDelegate(QStyledItemDelegate *decorated, QObject *parent=0)
QStyledItemDelegate * m_decorated
The object decorated.
Definition: Decorator.h:98
URI C++ Library.
Definition: Attributes.h:37
Defines a layer item.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
std::string getType() const
Returns the type of the item.
void paint(te::qt::widgets::Canvas *c, bool generatePNG, std::string fileName)