PropertyItem.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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 /*!
21  \file terralib/qt/widgets/datasource/explorer/PropertyItem.cpp
22 
23  \brief A class that represents a dataset in a TreeModel.
24 */
25 
26 // TerraLib
27 #include "../../../../core/translator/Translator.h"
28 #include "../../../../datatype/Property.h"
29 #include "../../Exception.h"
30 #include "PropertyGroupItem.h"
31 #include "PropertyItem.h"
32 
33 // Qt
34 #include <QMenu>
35 #include <QWidget>
36 
39  m_property(p)
40 {
41 }
42 
44 {
45  //if(m_property && (m_property->getParent() == 0))
46  // delete m_property;
47 }
48 
50 {
51  return 1;
52 }
53 
54 QVariant te::qt::widgets::PropertyItem::data(int /*column*/, int role) const
55 {
56  if(role == Qt::DecorationRole)
57  return QVariant(QIcon::fromTheme("property"));
58 
59  if (role == Qt::DisplayRole)
60  {
62  return QVariant((m_property->getName() + " (Spatial)").c_str());
63  else
64  return QVariant(m_property->getName().c_str());
65  }
66 
67 
68  return QVariant();
69 }
70 
72 {
73  QMenu* m = new QMenu(parent);
74 
75  QAction* aOpenProperty = m->addAction(tr("&Open property"));
76 
77  connect(aOpenProperty, SIGNAL(triggered()), this, SLOT(openProperty()));
78 
79  return m;
80 }
81 
83 {
84  return false;
85 }
86 
88 {
89  return Qt::NoItemFlags;
90 }
91 
93 {
94 }
95 
97 {
98  return false;
99 }
100 
101 bool te::qt::widgets::PropertyItem::setData(const QVariant& /*value*/, int /*role*/)
102 {
103  return false;
104 }
105 
107 {
108  return m_property;
109 }
QMenu * getMenu(QWidget *parent=0) const
Qt::ItemFlags flags() const
te::dt::Property * m_property
Definition: PropertyItem.h:76
It models a property definition.
Definition: Property.h:59
A class that represents a dataset in a TreeModel.
te::gm::Polygon * p
te::dt::Property * getProperty() const
bool setData(const QVariant &value, int role=Qt::EditRole)
int getType() const
It returns the property data type.
Definition: Property.h:161
A class used to group a set of properties from a dataset in a TreeModel.
QVariant data(int column, int role) const
PropertyItem(te::dt::Property *p, AbstractDataSourceTreeItem *parent)
Constructor.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127