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 
44 {
45  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
46 
47  emit activated(item);
48 }
49 
50 void te::qt::widgets::DataSourceTreeView::itemClicked(const QModelIndex & index)
51 {
52  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
53 
54  emit clicked(item);
55 
56  DataSourceTreeModel* model = dynamic_cast<DataSourceTreeModel*>(this->model());
57 
58  if(!model->isCheckable())
59  return;
60 
61  QVariant value = item->data(0, Qt::CheckStateRole);
62 
63  if(value.isNull())
64  return;
65 
66  emit toggled(item, value.toBool());
67 }
68 
70 {
71  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
72 
73  emit doubleClicked(item);
74 }
75 
76 void te::qt::widgets::DataSourceTreeView::itemEntered(const QModelIndex & index)
77 {
78  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
79 
80  emit entered(item);
81 }
82 
83 void te::qt::widgets::DataSourceTreeView::itemPressed(const QModelIndex & index)
84 {
85  AbstractDataSourceTreeItem* item = static_cast<AbstractDataSourceTreeItem*>(index.internalPointer());
86 
87  emit pressed(item);
88 }
89 
A tree view for the data sources of an application.
void itemDoubleClicked(const QModelIndex &index)
void toggled(AbstractDataSourceTreeItem *item, bool checked)
void itemEntered(const QModelIndex &index)
void activated(AbstractDataSourceTreeItem *item)
virtual QVariant data(int column, int role) const =0
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)