| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
//#include "finddialog.h" nothing is picked up from there |
| 30 |
//#include "mainwindow.h" |
| 31 |
//#include "tabbedbrowser.h" |
| 32 |
//#include "helpwindow.h" |
| 33 |
#include <QtCore> |
| 34 |
#include <QtWidgets/QTextBrowser> |
| 35 |
#include <QTextCursor> |
| 36 |
#include <QtWidgets/QStatusBar> |
| 37 |
#include <QtWidgets/QLineEdit> |
| 38 |
#include <QDateTime> |
| 39 |
#include <QtWidgets/QGridLayout> |
| 40 |
#include <QtWidgets/QMainWindow> |
| 41 |
class FindDialog |
| 42 |
{ Q_OBJECT |
| 43 |
FindDialog(QMainWindow *parent); |
| 44 |
void findButtonClicked(); |
| 45 |
void doFind(bool forward); |
| 46 |
void statusMessage(const QString &message); |
| 47 |
//QMainWindow *mainWindow() const; |
| 48 |
void reset(); |
| 49 |
|
| 50 |
|
| 51 |
}; |
| 52 |
|
| 53 |
|
| 54 |
FindDialog::FindDialog(QMainWindow *parent) |
| 55 |
{ |
| 56 |
//auto contentsWidget = new QWidget(this); |
| 57 |
//ui.setupUi(contentsWidget); |
| 58 |
//ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); |
| 59 |
|
| 60 |
//QVBoxLayout *l = new QVBoxLayout(this); |
| 61 |
//l->setContentsMargins(QMargins()); |
| 62 |
//l->setSpacing(0); |
| 63 |
//l->addWidget(contentsWidget); |
| 64 |
|
| 65 |
auto lastBrowser = 0; |
| 66 |
auto onceFound = false; |
| 67 |
//findExpr.clear(); |
| 68 |
|
| 69 |
auto sb = new QStatusBar; |
| 70 |
//l->addWidget(sb); |
| 71 |
|
| 72 |
sb->showMessage(tr("Enter the text you are looking for.")); |
| 73 |
|
| 74 |
//connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); |
| 75 |
//connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); |
| 76 |
} |
| 77 |
|
| 78 |
//FindDialog::~FindDialog() |
| 79 |
//{ |
| 80 |
//} |
| 81 |
|
| 82 |
//void FindDialog::findButtonClicked() |
| 83 |
//{ |
| 84 |
// doFind(ui.radioForward->isChecked()); |
| 85 |
//} |
| 86 |
|
| 87 |
void FindDialog::doFind(bool forward) |
| 88 |
{ |
| 89 |
//QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser()); |
| 90 |
//sb->clearMessage(); |
| 91 |
|
| 92 |
//if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) |
| 93 |
// onceFound = false; |
| 94 |
//findExpr = ui.comboFind->currentText(); |
| 95 |
bool onceFound = false; |
| 96 |
//QTextDocument::FindFlags flags = 0; |
| 97 |
/* |
| 98 |
if (ui.checkCase->isChecked()) |
| 99 |
flags |= QTextDocument::FindCaseSensitively; |
| 100 |
|
| 101 |
if (ui.checkWords->isChecked()) |
| 102 |
flags |= QTextDocument::FindWholeWords; |
| 103 |
|
| 104 |
QTextCursor c = browser->textCursor(); |
| 105 |
if (!c.hasSelection()) { |
| 106 |
if (forward) |
| 107 |
c.movePosition(QTextCursor::Start); |
| 108 |
else |
| 109 |
c.movePosition(QTextCursor::End); |
| 110 |
|
| 111 |
browser->setTextCursor(c); |
| 112 |
} |
| 113 |
|
| 114 |
QTextDocument::FindFlags options; |
| 115 |
if (forward == false) |
| 116 |
flags |= QTextDocument::FindBackward; |
| 117 |
*/ |
| 118 |
QTextCursor found;//browser->document()->find(findExpr, c, flags); |
| 119 |
if (found.isNull()) { |
| 120 |
if (onceFound) { |
| 121 |
if (forward) |
| 122 |
statusMessage(tr("Search reached end of the document")); |
| 123 |
else |
| 124 |
statusMessage(tr("Search reached start of the document")); |
| 125 |
} else { |
| 126 |
statusMessage(tr( "Text not found" )); |
| 127 |
} |
| 128 |
} else { |
| 129 |
//browser->setTextCursor(found); |
| 130 |
} |
| 131 |
onceFound |= !found.isNull(); |
| 132 |
//lastBrowser = browser; |
| 133 |
} |
| 134 |
|
| 135 |
//bool FindDialog::hasFindExpression() const |
| 136 |
//{ |
| 137 |
// return !findExpr.isEmpty(); |
| 138 |
//} |
| 139 |
|
| 140 |
void FindDialog::statusMessage(const QString &message) |
| 141 |
{ /* |
| 142 |
if (isVisible()) |
| 143 |
sb->showMessage(message); |
| 144 |
else |
| 145 |
static_cast<MainWindow*>(parent())->statusBar()->showMessage(message, 2000); */ |
| 146 |
} |
| 147 |
|
| 148 |
//QMainWindow *FindDialog::mainWindow() const |
| 149 |
//{ |
| 150 |
// return static_cast<MainWindow*>(parentWidget()); |
| 151 |
//} |
| 152 |
|
| 153 |
void FindDialog::reset() |
| 154 |
{ |
| 155 |
//ui.comboFind->setFocus(); |
| 156 |
//ui.comboFind->lineEdit()->setSelection( |
| 157 |
// 0, ui.comboFind->lineEdit()->text().length()); |
| 158 |
|
| 159 |
QString s = QCoreApplication::translate("QCoreApplication", "with comment", "comment"); |
| 160 |
QString s1 = QCoreApplication::translate("QCoreApplication", "empty comment", ""); |
| 161 |
QString s2 = QCoreApplication::translate("QCoreApplication", "null comment", 0); |
| 162 |
QString s3 = tr("null comment"); |
| 163 |
|
| 164 |
QString s4 = QCoreApplication::translate("QCoreApplication", "encoding, using QCoreApplication", 0); |
| 165 |
QString s5 = QCoreApplication::translate("QCoreApplication", "encoding, using QApplication", 0); |
| 166 |
|
| 167 |
QString s6 = QCoreApplication::translate("Kåntekst", "encoding, using QApplication", 0); |
| 168 |
QString s7 = QCoreApplication::translate("QTranslator", "Key", "disambiguation"); |
| 169 |
} |
| 170 |
|
| 171 |
|