OpendTect-6_4  6.4
i_qlistbox.h
Go to the documentation of this file.
1 #ifndef i_qlistbox_h
2 #define i_qlistbox_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink
9  Date: 16/05/2000
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uilistbox.h"
16 
17 #include <QListWidget>
18 #include <QObject>
19 
21 
25 QT_BEGIN_NAMESPACE
26 
27 class i_listMessenger : public QObject
28 {
29  Q_OBJECT
30  friend class uiListBoxBody;
31 
32 protected:
33  i_listMessenger( QListWidget* sndr,
34  uiListBox* receiver )
35  : sender_( sndr )
36  , receiver_( receiver )
37  {
38  connect( sndr,
39  SIGNAL(itemDoubleClicked(QListWidgetItem*)),
40  this,
41  SLOT(itemDoubleClicked(QListWidgetItem*)) );
42 
43  connect( sndr,
44  SIGNAL(itemClicked(QListWidgetItem*)),
45  this,
46  SLOT(itemClicked(QListWidgetItem*)) );
47 
48  connect( sndr, SIGNAL(itemSelectionChanged()),
49  this, SLOT(itemSelectionChanged()) );
50 
51  connect( sndr,
52  SIGNAL(itemEntered(QListWidgetItem*)),
53  this, SLOT(itemEntered(QListWidgetItem*)) );
54 
55  connect( sndr,
56  SIGNAL(itemChanged(QListWidgetItem*)),
57  this, SLOT(itemChanged(QListWidgetItem*)) );
58  }
59 
60  virtual ~i_listMessenger() {}
61 
62 private:
63 
65  QListWidget* sender_;
66 
67 
68 #define mTrigger( notifier, itm ) \
69 { \
70  BufferString msg = #notifier; \
71  if ( itm ) \
72  { \
73  QListWidgetItem* qlwi = itm; \
74  msg += " "; msg += qlwi->listWidget()->row( qlwi ); \
75  } \
76  const int refnr = receiver_->box()->beginCmdRecEvent( msg ); \
77  receiver_->notifier.trigger( *receiver_ ); \
78  receiver_->box()->endCmdRecEvent( refnr, msg ); \
79 }
80 
81 private slots:
82 
83 void itemDoubleClicked( QListWidgetItem* itm )
84 { mTrigger( doubleClicked, itm ); }
85 
86 
87 void itemClicked( QListWidgetItem* itm )
88 {
89  if ( receiver_->buttonstate_ == OD::RightButton )
90  mTrigger( rightButtonClicked, itm )
91  else if ( receiver_->buttonstate_ == OD::LeftButton )
92  mTrigger( leftButtonClicked, itm );
93 }
94 
96 {
97  mTrigger( selectionChanged, 0 );
98 }
99 
100 
101 void itemEntered( QListWidgetItem* itm )
102 {
103  const int refnr = receiver_->box()->beginCmdRecEvent( "itemEntered" );
104  receiver_->box()->endCmdRecEvent( refnr, "itemEntered" );
105 }
106 
107 
108 void itemChanged( QListWidgetItem* itm )
109 {
110  receiver_->handleCheckChange( itm );
111 }
112 
113 #undef mTrigger
114 
115 };
116 
117 QT_END_NAMESPACE
118 
119 #endif
void itemSelectionChanged()
Definition: i_qlistbox.h:95
i_listMessenger(QListWidget *sndr, uiListBox *receiver)
Definition: i_qlistbox.h:33
void itemChanged(QListWidgetItem *itm)
Definition: i_qlistbox.h:108
friend class uiListBoxBody
Definition: i_qlistbox.h:30
void itemEntered(QListWidgetItem *itm)
Definition: i_qlistbox.h:101
QListWidget * sender_
Definition: i_qlistbox.h:65
Definition: keyenum.h:23
List Box.
Definition: uilistbox.h:75
uiListBoxObj * box()
Definition: uilistbox.h:110
uiListBox * receiver_
Definition: i_qlistbox.h:64
OD::ButtonState buttonstate_
Definition: uilistbox.h:226
void itemClicked(QListWidgetItem *itm)
Definition: i_qlistbox.h:87
void itemDoubleClicked(QListWidgetItem *itm)
Definition: i_qlistbox.h:83
#define mTrigger(notifier, itm)
Definition: i_qlistbox.h:68
void handleCheckChange(mQtclass(QListWidgetItem *))
virtual ~i_listMessenger()
Definition: i_qlistbox.h:60
Helper class for uiListBox to relay Qt&#39;s messages.
Definition: i_qlistbox.h:27
Definition: keyenum.h:24

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019