COPASI API  4.16.103
Public Member Functions | Protected Slots | Protected Member Functions | Private Attributes | List of all members
CQTableView Class Reference

#include <CQTableView.h>

Inheritance diagram for CQTableView:
Inheritance graph
[legend]
Collaboration diagram for CQTableView:
Collaboration graph
[legend]

Public Member Functions

 CQTableView (QWidget *pParent=NULL)
 
virtual void setModel (QAbstractItemModel *model)
 
virtual ~CQTableView ()
 

Protected Slots

void slotMoveDown ()
 
void slotSingleClick ()
 

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *pEvent)
 
virtual void mousePressEvent (QMouseEvent *pEvent)
 

Private Attributes

bool mMoveDown
 
QAbstractItemModel * mpModel
 
QMouseEvent * mpMouseEvent
 
QTimer * mpTimer
 

Detailed Description

Definition at line 28 of file CQTableView.h.

Constructor & Destructor Documentation

CQTableView::CQTableView ( QWidget *  pParent = NULL)

Definition at line 13 of file CQTableView.cpp.

References mpTimer, and slotSingleClick().

13  :
14  QTableView(pParent),
15  mpTimer(NULL),
16  mpMouseEvent(NULL),
17  mMoveDown(false),
18  mpModel(NULL)
19 {
20  mpTimer = new QTimer(this);
21  mpTimer->setSingleShot(true);
22  mpTimer->setInterval(250);
23 
24  connect(mpTimer, SIGNAL(timeout()), this, SLOT(slotSingleClick()));
25 }
bool mMoveDown
Definition: CQTableView.h:50
QMouseEvent * mpMouseEvent
Definition: CQTableView.h:49
QAbstractItemModel * mpModel
Definition: CQTableView.h:51
QTimer * mpTimer
Definition: CQTableView.h:48
void slotSingleClick()
Definition: CQTableView.cpp:87
CQTableView::~CQTableView ( )
virtual

Definition at line 28 of file CQTableView.cpp.

29 {}

Member Function Documentation

void CQTableView::keyPressEvent ( QKeyEvent *  pEvent)
protectedvirtual

Definition at line 48 of file CQTableView.cpp.

References mMoveDown.

49 {
50  QTableView::keyPressEvent(pEvent);
51 
52  switch (pEvent->key())
53  {
54  case Qt::Key_Return:
55  case Qt::Key_Enter:
56  mMoveDown = true;
57  break;
58 
59  default:
60  mMoveDown = false;
61  break;
62  }
63 }
bool mMoveDown
Definition: CQTableView.h:50
void CQTableView::mousePressEvent ( QMouseEvent *  pEvent)
protectedvirtual

Definition at line 66 of file CQTableView.cpp.

References mpMouseEvent, and mpTimer.

67 {
68  if (mpMouseEvent != NULL)
69  {
70  delete mpMouseEvent;
71  mpMouseEvent = NULL;
72  }
73 
74  if (mpTimer->isActive())
75  {
76  QTableView::mousePressEvent(pEvent);
77  emit doubleClicked(currentIndex());
78 
79  return;
80  }
81 
82  mpMouseEvent = new QMouseEvent(*pEvent);
83  pEvent->accept();
84  mpTimer->start();
85 }
QMouseEvent * mpMouseEvent
Definition: CQTableView.h:49
QTimer * mpTimer
Definition: CQTableView.h:48
void CQTableView::setModel ( QAbstractItemModel *  model)
virtual

Definition at line 32 of file CQTableView.cpp.

References mpModel, and slotMoveDown().

33 {
34  if (mpModel != NULL)
35  disconnect(mpModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex)),
36  this, SLOT(slotMoveDown()));
37 
38  mpModel = model;
39 
40  if (mpModel != NULL)
41  connect(mpModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex)),
42  this, SLOT(slotMoveDown()));
43 
44  QTableView::setModel(model);
45 }
void slotMoveDown()
Definition: CQTableView.cpp:96
QAbstractItemModel * mpModel
Definition: CQTableView.h:51
void CQTableView::slotMoveDown ( )
protectedslot

Definition at line 96 of file CQTableView.cpp.

References mMoveDown.

Referenced by setModel().

97 {
98  if (mMoveDown)
99  {
100  QKeyEvent Down(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
101  QTableView::keyPressEvent(&Down);
102  }
103 }
bool mMoveDown
Definition: CQTableView.h:50
void CQTableView::slotSingleClick ( )
protectedslot

Definition at line 87 of file CQTableView.cpp.

References mpMouseEvent.

Referenced by CQTableView().

88 {
89  if (mpMouseEvent != NULL)
90  {
91  QTableView::mousePressEvent(mpMouseEvent);
92  mpMouseEvent = NULL;
93  }
94 }
QMouseEvent * mpMouseEvent
Definition: CQTableView.h:49

Member Data Documentation

bool CQTableView::mMoveDown
private

Definition at line 50 of file CQTableView.h.

Referenced by keyPressEvent(), and slotMoveDown().

QAbstractItemModel* CQTableView::mpModel
private

Definition at line 51 of file CQTableView.h.

Referenced by setModel().

QMouseEvent* CQTableView::mpMouseEvent
private

Definition at line 49 of file CQTableView.h.

Referenced by mousePressEvent(), and slotSingleClick().

QTimer* CQTableView::mpTimer
private

Definition at line 48 of file CQTableView.h.

Referenced by CQTableView(), and mousePressEvent().


The documentation for this class was generated from the following files: