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