src/terralib/ws/ogc/wms/qt/WMSItemDelegate.cpp
Go to the documentation of this file.
1 #include "WMSItemDelegate.h"
2 
3 //TerraLib
4 #include "../../../../qt/widgets/layer/explorer/LayerItem.h"
5 
6 te::ws::ogc::wms::qt::WMSItemDelegate::WMSItemDelegate(QStyledItemDelegate *decorated, QObject *parent)
7  : te::common::Decorator<QStyledItemDelegate>(decorated, false)
8 {
9  setParent(parent);
10 
11  m_icon = QIcon::fromTheme("datasource-wms");
12 }
13 
15 
16 void te::ws::ogc::wms::qt::WMSItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
17 {
18  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(index.internalPointer());
19 
20  if(item->getType() == "LAYER")
21  {
23 
24  if(li->getLayer()->isValid() && li->getLayer()->getType() == "OGCWMSLAYER")
25  {
26  QStyleOptionViewItem opt = option;
27  opt.decorationSize = QSize(20, 20);
28 
29 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
30  opt.features |= QStyleOptionViewItem::HasDecoration;
31  opt.icon = m_icon;
32 #endif
33 
34  QStyledItemDelegate::paint(painter, opt, index);
35 
36  return;
37  }
38  }
39 
40  if(m_decorated != nullptr)
41  m_decorated->paint(painter, option, index);
42  else
43  QStyledItemDelegate::paint(painter, option, index);
44 }
Implements Terralib item delegate for OGCWMSLAYER.
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
te::map::AbstractLayerPtr getLayer() const
Returns the layer contained in the item.
Definition: LayerItem.cpp:140
Defines a hierarchical structure.
QStyledItemDelegate * m_decorated
The object decorated.
Definition: Decorator.h:98
URI C++ Library.
Definition: Attributes.h:37
WMSItemDelegate(QStyledItemDelegate *decorated, QObject *parent=0)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
std::string getType() const
Returns the type of the item.
void paint(te::qt::widgets::Canvas *c, bool generatePNG, std::string fileName)