Changeset 10082 in ntrip for trunk/BNC/src/bnchlpdlg.cpp
- Timestamp:
- Jun 1, 2023, 8:00:11 AM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bnchlpdlg.cpp
r8238 r10082 52 52 const int ww = QFontMetrics(font()).width('w'); 53 53 54 bncHtml*_tb = new bncHtml;54 _tb = new bncHtml; 55 55 setWindowTitle("Help Contents"); 56 56 _tb->setSource(url); 57 57 _tb->setReadOnly(true); 58 connect(_tb, SIGNAL(backwardAvailable(bool)), 59 this, SLOT(backwardAvailable(bool))); 60 connect(_tb, SIGNAL(forwardAvailable(bool)), 61 this, SLOT(forwardAvailable(bool))); 58 connect(_tb, SIGNAL(backwardAvailable(bool)), this, SLOT(backwardAvailable(bool))); 59 connect(_tb, SIGNAL(forwardAvailable(bool)), this, SLOT(forwardAvailable(bool))); 62 60 63 61 QVBoxLayout* dlgLayout = new QVBoxLayout; … … 80 78 _closeButton = new QPushButton("Close"); 81 79 _closeButton->setMaximumWidth(10*ww); 80 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close())); 82 81 butLayout->addWidget(_closeButton); 83 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close())); 82 83 _label = new QLabel("Find &what:"); // 2. 84 _what = new QLineEdit(); 85 _label->setBuddy(_what); // 3. 86 _cbCase = new QCheckBox("Match &case"); 87 _cbBack = new QCheckBox("Search &backward"); 88 _findButton = new QPushButton("&Find"); // 4. 89 _findButton->setDefault(true); 90 _findButton->setEnabled(false); 91 connect(_what, SIGNAL(textChanged(const QString&)), this, SLOT(enableBtnFind(const QString&))); 92 connect(_findButton, SIGNAL(clicked()), this, SLOT(findClicked())); 93 94 butLayout->addWidget(_label); 95 butLayout->addWidget(_what); 96 butLayout->addWidget(_findButton); 97 butLayout->addWidget(_cbCase); 98 butLayout->addWidget(_cbBack); 99 100 connect(this, SIGNAL(findNext(const QString &, Qt::CaseSensitivity)), 101 this, SLOT(slotFindNext(const QString &, Qt::CaseSensitivity))); 102 103 connect(this, SIGNAL(findPrev(const QString &, Qt::CaseSensitivity)), 104 this, SLOT(slotFindPrev(const QString &, Qt::CaseSensitivity))); 105 106 _hlCursor = QTextCursor(_tb->document()); 84 107 85 108 dlgLayout->addLayout(butLayout); … … 97 120 delete _forwButton; 98 121 delete _closeButton; 122 delete _findButton; 123 delete _label; 124 delete _what; 125 delete _cbCase; 126 delete _cbBack; 99 127 } 100 128 … … 108 136 _forwButton->setEnabled(avail); 109 137 } 138 139 void bncHlpDlg::findClicked() { 140 141 QString text = _what->text(); 142 Qt::CaseSensitivity cs = _cbCase->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive; 143 144 if(_cbBack->isChecked()) { 145 emit findPrev(text, cs); 146 } 147 else { 148 emit findNext(text, cs); 149 } 150 } 151 152 void bncHlpDlg::enableBtnFind(const QString& text) { 153 _findButton->setEnabled(!text.isEmpty()); 154 } 155 156 void bncHlpDlg::slotFindNext(const QString& str, Qt::CaseSensitivity cs) { 157 QString searchString = str; 158 bool found = false; 159 QTextDocument::FindFlags flags; 160 flags |= QTextDocument::FindWholeWords; 161 if ( cs == Qt::CaseSensitive) { 162 flags |= QTextDocument::FindCaseSensitively; 163 } 164 165 if (!_hlCursor.atEnd()) { 166 _hlCursor = (_tb->document()->find(searchString, _hlCursor, flags)); 167 if (!_hlCursor.isNull()) { 168 found = true; 169 _hlCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor); 170 _tb->setTextCursor(_hlCursor); 171 } 172 } 173 174 if (found == false) { 175 _hlCursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor); 176 _tb->setTextCursor(_hlCursor); 177 } 178 179 } 180 181 182 void bncHlpDlg::slotFindPrev(const QString& str, Qt::CaseSensitivity cs) { 183 QString searchString = str; 184 bool found = false; 185 QTextDocument::FindFlags flags; 186 flags |= QTextDocument::FindWholeWords; 187 flags |= QTextDocument::FindBackward; 188 if ( cs == Qt::CaseSensitive) { 189 flags |= QTextDocument::FindCaseSensitively; 190 } 191 192 if (!_hlCursor.atEnd()) { 193 _hlCursor = (_tb->document()->find(searchString, _hlCursor, flags)); 194 if (!_hlCursor.isNull()) { 195 found = true; 196 _hlCursor.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor); 197 _tb->setTextCursor(_hlCursor); 198 } 199 } 200 201 if (found == false) { 202 _hlCursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor); 203 _tb->setTextCursor(_hlCursor); 204 } 205 } 206 207 208 209 210
Note:
See TracChangeset
for help on using the changeset viewer.