All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataSetTableHorizontalHeader.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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 
22 
23 #include "DataSetTableView.h"
24 
25 // Qt
26 #include <QtGui/QMouseEvent>
27 
29 QHeaderView(Qt::Horizontal, view),
30  m_view(view)
31 {
32 }
33 
34 
36 {
37  if(e->button() == Qt::LeftButton)
38  {
39  int c = m_view->columnAt(e->pos().x());
40  QItemSelectionModel* sel = m_view->selectionModel();
41 
42  if(c > 0)
43  {
44  QItemSelectionModel::SelectionFlag selF = (sel->isColumnSelected(c, QModelIndex())) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
45 
46  if(m_view->selectionMode() == QAbstractItemView::SingleSelection)
47  sel->clear();
48 
49 
50  QModelIndex tl = m_view->model()->index(0, c);
51  QModelIndex br = m_view->model()->index(model()->rowCount()-1, c);
52 
53  QItemSelection newSel(tl, br);
54 
55  sel->select(newSel, selF);
56  }
57  else
58  sel->clear();
59  }
60 
61  QHeaderView::mousePressEvent(e);
62 }
A table view for a dataset.
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...