All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ForeignKeyItem.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/ForeignKeyItem.cpp
22 
23  \brief A class that represents a foreign key in a TreeModel.
24 */
25 
26 // TerraLib
27 #include "../../../../common/Translator.h"
28 #include "../../../../dataaccess/dataset/ForeignKey.h"
29 #include "../../Exception.h"
30 #include "ForeignKeyItem.h"
31 
32 // Qt
33 #include <QMenu>
34 #include <QWidget>
35 
38  m_fk(fk)
39 {
40 }
41 
43 {
44  //if(m_fk && (m_fk->getDataSetType() == 0))
45  // delete m_fk;
46 }
47 
49 {
50  return 1;
51 }
52 
53 QVariant te::qt::widgets::ForeignKeyItem::data(int /*column*/, int role) const
54 {
55  if(role == Qt::DecorationRole)
56  return QVariant(QIcon::fromTheme("foreignkey"));
57 
58  if(role == Qt::DisplayRole)
59  return QVariant(m_fk->getName().c_str());
60 
61  return QVariant();
62 }
63 
64 QMenu* te::qt::widgets::ForeignKeyItem::getMenu(QWidget* parent) const
65 {
66  QMenu* m = new QMenu(parent);
67 
68  QAction* aOpenForeignKey = m->addAction(tr("&Open foreign-key"));
69 
70  connect(aOpenForeignKey, SIGNAL(triggered()), this, SLOT(openForeignKey()));
71 
72  return m;
73 }
74 
76 {
77  return false;
78 }
79 
81 {
82  return Qt::NoItemFlags;
83 }
84 
86 {
87 }
88 
90 {
91  return false;
92 }
93 
94 bool te::qt::widgets::ForeignKeyItem::setData(const QVariant& /*value*/, int /*role*/)
95 {
96  return false;
97 }
98 
100 {
101  return m_fk;
102 }
103 
QMenu * getMenu(QWidget *parent=0) const
te::da::ForeignKey * getForeignKey() const
A class that represents a foreign key in a TreeModel.
ForeignKeyItem(te::da::ForeignKey *fk, AbstractDataSourceTreeItem *parent)
Constructor.
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
bool setData(const QVariant &value, int role=Qt::EditRole)
Qt::ItemFlags flags() const
QVariant data(int column, int role) const