OpendTect-6_4  6.4
i_qtextedit.h
Go to the documentation of this file.
1 #ifndef i_qtextedit_h
2 #define i_qtextedit_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: September 2007
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uitextedit.h"
16 
17 #include <QAbstractSlider>
18 #include <QTextEdit>
19 #include <QTextBrowser>
20 
21 
23 
27 QT_BEGIN_NAMESPACE
28 
29 class QString;
30 
31 class i_TextEditMessenger : public QObject
32 {
33  Q_OBJECT
34  friend class uiTextEditBody;
35 
36 protected:
37 
38 i_TextEditMessenger( QTextEdit* sndr, uiTextEditBase* receiver )
39  : sender_(sndr)
40  , receiver_(receiver)
41 {
42  connect( sndr, SIGNAL(textChanged()), this, SLOT(textChanged()) );
43  connect( sndr, SIGNAL(copyAvailable(bool)),this,SLOT(copyAvailable(bool)));
44 }
45 
46 private:
47 
49  QTextEdit* sender_;
50 
51 private slots:
52 
54 { receiver_->textChanged.trigger( *receiver_ ); }
55 
56 void copyAvailable( bool yn )
57 { receiver_->copyAvailable.trigger( yn ); }
58 
59 };
60 
61 class i_ScrollBarMessenger : public QObject
62 {
63  Q_OBJECT;
64 public:
65 
66  i_ScrollBarMessenger( QAbstractSlider* sndr, uiTextEditBase* receiver )
67  : sender_(sndr)
68  , receiver_(receiver)
69  {
70  connect( sndr, SIGNAL(sliderPressed()), this, SLOT(sliderPressed()) );
71  connect( sndr, SIGNAL(sliderReleased()), this, SLOT(sliderReleased()) );
72  }
73 
74 private:
75 
77  QAbstractSlider* sender_;
78 
79 private slots:
80 
82  {
83  receiver_->sliderPressed.trigger( *receiver_ );
84  }
85 
87  {
88  receiver_->sliderReleased.trigger( *receiver_ );
89  }
90 
91 };
92 
93 
95 
100 {
101  Q_OBJECT
102  friend class uiTextBrowserBody;
103 
104 protected:
105  i_BrowserMessenger( QTextBrowser* sndr,
106  uiTextBrowser* receiver )
107  : i_TextEditMessenger(sndr,receiver)
108  , bsender_( sndr )
109  , breceiver_( receiver )
110  {
111  connect( sndr, SIGNAL(backwardAvailable(bool)),
112  this, SLOT(backwardAvailable(bool)) );
113  connect(sndr,SIGNAL(forwardAvailable(bool)),
114  this, SLOT(forwardAvailable(bool)));
115  connect(sndr,SIGNAL(highlighted(const QString&)),
116  this, SLOT(highlighted(const QString&)));
117  connect(sndr,SIGNAL(anchorClicked(const QUrl&)),
118  this,SLOT(anchorClicked(const QUrl&)));
119  }
120 
121  virtual ~i_BrowserMessenger() {}
122 
123 private:
124 
126  QTextBrowser* bsender_;
127 
128 private slots:
129 
130  void backwardAvailable( bool yn )
131  {
132  breceiver_->cangobackw_ = yn;
133  breceiver_->goneForwardOrBack.trigger( *breceiver_ );
134  }
135 
136  void forwardAvailable( bool yn )
137  {
138  breceiver_->cangoforw_ = yn;
139  breceiver_->goneForwardOrBack.trigger( *breceiver_ );
140  }
141 
142  void highlighted( const QString& lnk )
143  {
144  breceiver_->lastlink_ = lnk.toLatin1().data();
145  breceiver_->linkHighlighted.trigger( *breceiver_ );
146  }
147 
148  void anchorClicked( const QUrl& lnk )
149  {
150  breceiver_->lastlink_ = lnk.toString().toLatin1().data();
151  breceiver_->linkClicked.trigger( *breceiver_ );
152  }
153 };
154 
155 QT_END_NAMESPACE
156 
157 #endif
Definition: i_qtextedit.h:31
Notifier< uiTextEditBase > textChanged
Definition: uitextedit.h:49
void copyAvailable(bool yn)
Definition: i_qtextedit.h:56
friend class uiTextEditBody
Definition: i_qtextedit.h:34
QAbstractSlider * sender_
Definition: i_qtextedit.h:77
void trigger(C c, T &t)
Definition: callback.h:399
Notifier< uiTextEditBase > sliderReleased
Definition: uitextedit.h:51
i_TextEditMessenger(QTextEdit *sndr, uiTextEditBase *receiver)
Definition: i_qtextedit.h:38
i_BrowserMessenger(QTextBrowser *sndr, uiTextBrowser *receiver)
Definition: i_qtextedit.h:105
Notifier< uiTextBrowser > linkHighlighted
Definition: uitextedit.h:136
uiTextEditBase * receiver_
Definition: i_qtextedit.h:76
i_ScrollBarMessenger(QAbstractSlider *sndr, uiTextEditBase *receiver)
Definition: i_qtextedit.h:66
bool cangobackw_
Definition: uitextedit.h:145
uiTextBrowser * breceiver_
Definition: i_qtextedit.h:125
BufferString lastlink_
Definition: uitextedit.h:143
bool cangoforw_
Definition: uitextedit.h:144
void backwardAvailable(bool yn)
Definition: i_qtextedit.h:130
virtual ~i_BrowserMessenger()
Definition: i_qtextedit.h:121
void forwardAvailable(bool yn)
Definition: i_qtextedit.h:136
Definition: uitextedit.h:25
void trigger(T &t)
Definition: callback.h:258
Notifier< uiTextEditBase > sliderPressed
Definition: uitextedit.h:50
void anchorClicked(const QUrl &lnk)
Definition: i_qtextedit.h:148
QTextEdit * sender_
Definition: i_qtextedit.h:49
Definition: i_qtextedit.h:61
CNotifier< uiTextEditBase, bool > copyAvailable
Definition: uitextedit.h:52
void sliderReleased()
Definition: i_qtextedit.h:86
void sliderPressed()
Definition: i_qtextedit.h:81
Definition: uitextedit.h:102
Notifier< uiTextBrowser > linkClicked
Definition: uitextedit.h:137
Helper class for uiTextBrowser to relay Qt&#39;s messages.
Definition: i_qtextedit.h:99
void highlighted(const QString &lnk)
Definition: i_qtextedit.h:142
void textChanged()
Definition: i_qtextedit.h:53
QTextBrowser * bsender_
Definition: i_qtextedit.h:126
uiTextEditBase * receiver_
Definition: i_qtextedit.h:48
Notifier< uiTextBrowser > goneForwardOrBack
Definition: uitextedit.h:135

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