WFSItemDelegate.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2013 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 #include "WFSItemDelegate.h"
21 
22 // TerraLib
23 #include "../../../../wfs/Utils.h"
24 #include "../../../widgets/layer/explorer/LayerItem.h"
25 
26 te::qt::plugins::wfs::WFSItemDelegate::WFSItemDelegate(QStyledItemDelegate* decorated, QObject* parent) :
27  te::common::Decorator<QStyledItemDelegate>(decorated, false)
28 {
29  setParent(parent);
30 
31  m_icon = QIcon::fromTheme("datasource-wfs");
32 }
33 
35 
36 void te::qt::plugins::wfs::WFSItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
37 {
38  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(index.internalPointer());
39 
40  if(item->getType() == "LAYER")
41  {
43 
44  if(te::wfs::IsWFSLayer(*li->getLayer()))
45  {
46  QStyleOptionViewItem opt = option;
47  opt.decorationSize = QSize(20, 20);
48 
49 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
50  opt.features |= QStyleOptionViewItem::HasDecoration;
51  opt.icon = m_icon;
52 #endif
53 
54  QStyledItemDelegate::paint(painter, opt, index);
55 
56  return;
57  }
58  }
59 
60  if(m_decorated != nullptr)
61  m_decorated->paint(painter, option, index);
62  else
63  QStyledItemDelegate::paint(painter, option, index);
64 }
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
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
WFSItemDelegate(QStyledItemDelegate *decorated, QObject *parent=0)
Defines a hierarchical structure.
QStyledItemDelegate * m_decorated
The object decorated.
Definition: Decorator.h:98
URI C++ Library.
Definition: Attributes.h:37
TEWFSEXPORT bool IsWFSLayer(const te::map::AbstractLayer &layer)
std::string getType() const
Returns the type of the item.
void paint(te::qt::widgets::Canvas *c, bool generatePNG, std::string fileName)