Debian Codegraph @

tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp

raw
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"
30 //#include "mainwindow.h"
31 //#include "tabbedbrowser.h"
32 //#include "helpwindow.h"
33
34 #include <QtWidgets/QTextBrowser>
35 #include <QTextCursor>
36 #include <QtWidgets/QStatusBar>
37 #include <QtWidgets/QLineEdit>
38 #include <QDateTime>
39 #include <QtWidgets/QGridLayout>
40
41 CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent)
42 : QStandardItemModel(rows, columns, parent)
43 {}
44 QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value,
45 int hits, Qt::MatchFlags flags) const
46 {
47 if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap))
48 flags |= Qt::MatchCaseSensitive;
49
50 return QStandardItemModel::match(start, role, value, hits, flags);
51 }
52
53 FindDialog::FindDialog(QMainWindow *parent)
54 : QDialog(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(this);
70 l->addWidget(sb);
71
72
73 // Move it to another line and change the text,
74 // then lupdate should add this one as a new one, and mark the old one as obsolete.
75 sb->showMessage(tr("Enter the text you want to find."));
76
77 //connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked()));
78 //connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject()));
79 }
80
81 //FindDialog::~FindDialog()
82 //{
83 //}
84
85 //void FindDialog::findButtonClicked()
86 //{
87 //doFind(ui.radioForward->isChecked());
88 //}
89
90 void FindDialog::doFind(bool forward)
91 {
92 QTextBrowser *browser;// = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser());
93 //sb->clearMessage();
94
95 //if (ui.comboFind->currentText() != findExpr || lastBrowser != browser)
96 // onceFound = false;
97 //findExpr = ui.comboFind->currentText();
98
99 //QTextDocument::FindFlags flags = 0;
100
101 //if (ui.checkCase->isChecked())
102 // flags |= QTextDocument::FindCaseSensitively;
103
104 //if (ui.checkWords->isChecked())
105 // flags |= QTextDocument::FindWholeWords;
106
107 QTextCursor c = browser->textCursor();
108 if (!c.hasSelection()) {
109 if (forward)
110 c.movePosition(QTextCursor::Start);
111 else
112 c.movePosition(QTextCursor::End);
113
114 browser->setTextCursor(c);
115 }
116
117 QTextDocument::FindFlags options;
118 //if (forward == false)
119 // flags |= QTextDocument::FindBackward;
120 bool onceFound = true;
121 QTextCursor found;// = browser->document()->find(findExpr, c, flags);
122 if (found.isNull()) {
123 if (onceFound) {
124 if (forward)
125 auto a = tr("Search reached end of the document");//statusMessage(tr("Search reached end of the document"));
126 else
127 auto aa = tr("Search reached start of the document");//statusMessage(tr("Search reached start of the document"));
128 } else {
129 auto aaa = tr( "Text not found" );//statusMessage(tr( "Text not found" ));
130 }
131 } else {
132 browser->setTextCursor(found);
133 }
134 onceFound |= !found.isNull();
135 auto lastBrowser = browser;
136 }
137
138 void FindDialog::hasFindExpression() const
139 {
140 //% "This is some random text"
141 qtTrId("keep_id");
142
143 //return !findExpr.isEmpty();
144 }
145