attic/src/qt/plugins/datasource/wms/WMSItemDelegate.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 "WMSItemDelegate.h"
21 
22 // TerraLib
23 #include "../../../widgets/layer/explorer/LayerItem.h"
24 
25 te::qt::plugins::wms::WMSItemDelegate::WMSItemDelegate(QStyledItemDelegate* decorated, QObject* parent) :
26  te::common::Decorator<QStyledItemDelegate>(decorated, false)
27 {
28  setParent(parent);
29 
30  m_icon = QIcon::fromTheme("datasource-wms");
31 }
32 
34 {
35 
36 }
37 
38 void te::qt::plugins::wms::WMSItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
39 {
40  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(index.internalPointer());
41 
42  if(item->getType() == "LAYER")
43  {
45 
46  if(li->getLayer()->isValid() && li->getLayer()->getType() == "WMSLAYER")
47  {
48  QStyleOptionViewItem opt = option;
49  opt.decorationSize = QSize(20, 20);
50  opt.features |= QStyleOptionViewItem::HasDecoration;
51 
52  opt.icon = m_icon;
53 
54  QStyledItemDelegate::paint(painter, opt, index);
55 
56  return;
57  }
58  }
59 
60  if(m_decorated != 0)
61  m_decorated->paint(painter, option, index);
62  else
63  QStyledItemDelegate::paint(painter, option, index);
64 }
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
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.
WMSItemDelegate(QStyledItemDelegate *decorated, QObject *parent=0)
QStyledItemDelegate * m_decorated
The object decorated.
Definition: Decorator.h:98
URI C++ Library.
Definition: Attributes.h:37
std::string getType() const
Returns the type of the item.
void paint(te::qt::widgets::Canvas *c, bool generatePNG, std::string fileName)