Index: trunk/BNC/src/bnchlpdlg.cpp
===================================================================
--- trunk/BNC/src/bnchlpdlg.cpp	(revision 10081)
+++ trunk/BNC/src/bnchlpdlg.cpp	(revision 10082)
@@ -52,12 +52,10 @@
   const int ww = QFontMetrics(font()).width('w');
 
-  bncHtml* _tb = new bncHtml;
+  _tb = new bncHtml;
   setWindowTitle("Help Contents");
   _tb->setSource(url);
   _tb->setReadOnly(true);
-  connect(_tb, SIGNAL(backwardAvailable(bool)),
-          this, SLOT(backwardAvailable(bool)));
-  connect(_tb, SIGNAL(forwardAvailable(bool)),
-          this, SLOT(forwardAvailable(bool)));
+  connect(_tb, SIGNAL(backwardAvailable(bool)), this, SLOT(backwardAvailable(bool)));
+  connect(_tb, SIGNAL(forwardAvailable(bool)),  this, SLOT(forwardAvailable(bool)));
 
   QVBoxLayout* dlgLayout = new QVBoxLayout;
@@ -80,6 +78,31 @@
   _closeButton = new QPushButton("Close");
   _closeButton->setMaximumWidth(10*ww);
+  connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
   butLayout->addWidget(_closeButton);
-  connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
+
+  _label = new QLabel("Find &what:"); // 2.
+  _what  = new QLineEdit();
+  _label->setBuddy(_what); // 3.
+  _cbCase = new QCheckBox("Match &case");
+  _cbBack = new QCheckBox("Search &backward");
+  _findButton = new QPushButton("&Find"); // 4.
+  _findButton->setDefault(true);
+  _findButton->setEnabled(false);
+  connect(_what, SIGNAL(textChanged(const QString&)), this, SLOT(enableBtnFind(const QString&)));
+  connect(_findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
+
+  butLayout->addWidget(_label);
+  butLayout->addWidget(_what);
+  butLayout->addWidget(_findButton);
+  butLayout->addWidget(_cbCase);
+  butLayout->addWidget(_cbBack);
+
+  connect(this, SIGNAL(findNext(const QString &, Qt::CaseSensitivity)),
+          this, SLOT(slotFindNext(const QString &, Qt::CaseSensitivity)));
+
+  connect(this, SIGNAL(findPrev(const QString &, Qt::CaseSensitivity)),
+          this, SLOT(slotFindPrev(const QString &, Qt::CaseSensitivity)));
+
+  _hlCursor =  QTextCursor(_tb->document());
 
   dlgLayout->addLayout(butLayout);
@@ -97,4 +120,9 @@
   delete _forwButton;
   delete _closeButton;
+  delete _findButton;
+  delete _label;
+  delete _what;
+  delete _cbCase;
+  delete _cbBack;
 }
 
@@ -108,2 +136,75 @@
   _forwButton->setEnabled(avail);
 }
+
+void bncHlpDlg::findClicked() {
+
+  QString text = _what->text();
+  Qt::CaseSensitivity cs = _cbCase->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
+
+  if(_cbBack->isChecked()) {
+      emit findPrev(text, cs);
+  }
+  else {
+      emit findNext(text, cs);
+  }
+}
+
+void bncHlpDlg::enableBtnFind(const QString& text) {
+  _findButton->setEnabled(!text.isEmpty());
+}
+
+void bncHlpDlg::slotFindNext(const QString& str, Qt::CaseSensitivity cs) {
+  QString searchString = str;
+  bool found = false;
+  QTextDocument::FindFlags flags;
+  flags |= QTextDocument::FindWholeWords;
+  if ( cs == Qt::CaseSensitive) {
+      flags |= QTextDocument::FindCaseSensitively;
+  }
+
+  if (!_hlCursor.atEnd()) {
+    _hlCursor = (_tb->document()->find(searchString, _hlCursor, flags));
+    if (!_hlCursor.isNull()) {
+        found = true;
+        _hlCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor);
+        _tb->setTextCursor(_hlCursor);
+    }
+  }
+
+  if (found == false) {
+    _hlCursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
+    _tb->setTextCursor(_hlCursor);
+  }
+
+}
+
+
+void bncHlpDlg::slotFindPrev(const QString& str, Qt::CaseSensitivity cs) {
+  QString searchString = str;
+  bool found = false;
+  QTextDocument::FindFlags flags;
+  flags |= QTextDocument::FindWholeWords;
+  flags |= QTextDocument::FindBackward;
+  if ( cs == Qt::CaseSensitive) {
+      flags |= QTextDocument::FindCaseSensitively;
+  }
+
+  if (!_hlCursor.atEnd()) {
+    _hlCursor = (_tb->document()->find(searchString, _hlCursor, flags));
+    if (!_hlCursor.isNull()) {
+        found = true;
+        _hlCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor);
+        _tb->setTextCursor(_hlCursor);
+    }
+  }
+
+  if (found == false) {
+    _hlCursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
+    _tb->setTextCursor(_hlCursor);
+  }
+}
+
+
+
+
+
Index: trunk/BNC/src/bnchlpdlg.h
===================================================================
--- trunk/BNC/src/bnchlpdlg.h	(revision 10081)
+++ trunk/BNC/src/bnchlpdlg.h	(revision 10082)
@@ -29,4 +29,7 @@
 
 #include <QDialog>
+#include <QLabel>
+#include <QCheckBox>
+#include <QLineEdit>
 #include <QPushButton>
 
@@ -41,14 +44,26 @@
 
   signals:
- 
+  void findNext(const QString& str, Qt::CaseSensitivity cs);
+  void findPrev(const QString& str, Qt::CaseSensitivity cs);
+
   public slots:
     void backwardAvailable(bool);
     void forwardAvailable(bool);
+    void findClicked();
+    void enableBtnFind(const QString& text);
+    void slotFindNext(const QString& str, Qt::CaseSensitivity cs);
+    void slotFindPrev(const QString& str, Qt::CaseSensitivity cs);
 
   private:
-    bncHtml*     _tb;
-    QPushButton* _backButton;
-    QPushButton* _forwButton;
-    QPushButton* _closeButton;
+    bncHtml*       _tb;
+    QPushButton*   _backButton;
+    QPushButton*   _forwButton;
+    QPushButton*   _closeButton;
+    QPushButton*   _findButton;
+    QTextCursor    _hlCursor;
+    QLabel*        _label;
+    QLineEdit*     _what;
+    QCheckBox*     _cbCase;
+    QCheckBox*     _cbBack;
 };
 
