General Purpose Geodetic Library
SgGuiQTreeWidgetExt.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <SgGuiQTreeWidgetExt.h>
24 #include <SgLogger.h>
25 
26 
27 #if QT_VERSION >= 0x050000
28 # include <QtWidgets/QApplication>
29 #else
30 # include <QtGui/QApplication>
31 #endif
32 
33 #include <QtGui/QMouseEvent>
34 
35 
36 /*==================================================================================================
37 *
38 * METHODS:
39 *
40 *=================================================================================================*/
42  : QTreeWidget(parent)
43 {
44  isMoving_ = false;
45  mItem_ = NULL;
46  mCol_ = -1;
47  mouseButtonState_ = Qt::NoButton;
48  connect(this,
49  SIGNAL(itemPressed(QTreeWidgetItem*, int)),
50  SLOT(movingStarted(QTreeWidgetItem*, int)));
51 };
52 
53 
54 
55 //
57 {
58  if (item)
59  {
60  mItem_ = item;
61  mCol_ = c;
62  isMoving_ = true;
63  emit moveUponItem(mItem_, mCol_, mouseButtonState_, QApplication::keyboardModifiers());
64  };
65 };
66 
67 
68 
69 //
71 {
72  if (e && isMoving_)
73  {
74  //QPoint vp = contentsToViewport(e->pos());
75  QTreeWidgetItem *item = itemAt(e->pos());
76  if (item && item!=mItem_)
77  {
78  mItem_ = item;
79  setCurrentItem(mItem_);
80  emit moveUponItem(mItem_, mCol_, mouseButtonState_, e->modifiers());
81  };
82  };
83  QTreeWidget::mouseMoveEvent(e);
84 };
85 
86 
87 
88 //
90 {
91  if (e)
92  mouseButtonState_ = e->button();
93  QTreeWidget::mousePressEvent(e);
94 };
95 
96 
97 
98 //
100 {
101  mItem_ = NULL;
102  mCol_ = -1;
103  isMoving_ = false;
104  mouseButtonState_ = e->button();
105  QTreeWidget::mouseReleaseEvent(e);
106 };
107 /*================================================================================================*/
void movingStarted(QTreeWidgetItem *, int)
void mouseReleaseEvent(QMouseEvent *)
void mousePressEvent(QMouseEvent *)
void moveUponItem(QTreeWidgetItem *, int, Qt::MouseButton, Qt::KeyboardModifiers)
SgGuiQTreeWidgetExt(QWidget *=0)
void mouseMoveEvent(QMouseEvent *)
QTreeWidgetItem * mItem_
Qt::MouseButton mouseButtonState_