All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataSourceTreeView.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 DataSourceTreeView.cpp
22 
23  \brief A tree view for the data sources of an application.
24 */
25 
26 // TerraLib
28 #include "DataSourceTreeModel.h"
29 #include "DataSourceTreeView.h"
30 
32  : QTreeView(parent)
33 {
34  connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(itemActivated(const QModelIndex&)));
35  connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(itemClicked(const QModelIndex&)));
36  connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(itemDoubleClicked(const QModelIndex&)));
37  connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(itemEntered(const QModelIndex&)));
38  connect(this, SIGNAL(pressed(const QModelIndex&)), this, SLOT(itemPressed(const QModelIndex&)));
39 }
40 
42 {
43 }
44 
46 {
47  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
48 
49  emit activated(item);
50 }
51 
52 void te::qt::widgets::DataSourceTreeView::itemClicked(const QModelIndex & index)
53 {
54  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
55 
56  emit clicked(item);
57 
58  DataSourceTreeModel* model = dynamic_cast<DataSourceTreeModel*>(this->model());
59 
60  if(!model->isCheckable())
61  return;
62 
63  QVariant value = item->data(0, Qt::CheckStateRole);
64 
65  if(value.isNull())
66  return;
67 
68  emit toggled(item, value.toBool());
69 }
70 
72 {
73  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
74 
75  emit doubleClicked(item);
76 }
77 
78 void te::qt::widgets::DataSourceTreeView::itemEntered(const QModelIndex & index)
79 {
80  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
81 
82  emit entered(item);
83 }
84 
85 void te::qt::widgets::DataSourceTreeView::itemPressed(const QModelIndex & index)
86 {
87  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
88 
89  emit pressed(item);
90 }
91 
A tree view for the data sources of an application.
void itemDoubleClicked(const QModelIndex &index)
void itemEntered(const QModelIndex &index)
void activated(AbstractDataSourceTreeItem *item)
A class that represents an item from a DataSourceTreeModel.
void itemPressed(const QModelIndex &index)
void itemClicked(const QModelIndex &index)
void pressed(AbstractDataSourceTreeItem *item)
void entered(AbstractDataSourceTreeItem *item)
void itemActivated(const QModelIndex &index)
void clicked(AbstractDataSourceTreeItem *item)
void doubleClicked(AbstractDataSourceTreeItem *item)
virtual QVariant data(int column, int role) const =0