1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Linguist of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29/* TRANSLATOR FindDialog
30
31 Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
32 Find dialog
33*/
34
35#include "finddialog.h"
36
37QT_BEGIN_NAMESPACE
38
39FindDialog::FindDialog(QWidget *parent)
40 : QDialog(parent)
41{
42 setupUi(this);
43
44 findNxt->setEnabled(false);
45
46 connect(sender: findNxt, SIGNAL(clicked()), receiver: this, SLOT(emitFindNext()));
47 connect(sender: useRegExp, SIGNAL(stateChanged(int)), receiver: this, SLOT(verify()));
48 connect(sender: led, SIGNAL(textChanged(QString)), receiver: this, SLOT(verify()));
49
50 led->setFocus();
51}
52
53void FindDialog::verify()
54{
55 bool validRegExp = true;
56 if (useRegExp->isChecked() && !led->text().isEmpty()) {
57 m_regExp.setPattern(led->text());
58 validRegExp = m_regExp.isValid();
59 }
60 if (validRegExp && m_redText)
61 led->setStyleSheet(QStringLiteral("color: auto;"));
62 else if (!validRegExp && !m_redText)
63 led->setStyleSheet(QStringLiteral("color: red;"));
64 m_redText = !validRegExp;
65 findNxt->setEnabled(!led->text().isEmpty() && validRegExp);
66}
67
68void FindDialog::emitFindNext()
69{
70 DataModel::FindLocation where;
71 if (sourceText != 0)
72 where =
73 DataModel::FindLocation(
74 (sourceText->isChecked() ? DataModel::SourceText : 0) |
75 (translations->isChecked() ? DataModel::Translations : 0) |
76 (comments->isChecked() ? DataModel::Comments : 0));
77 else
78 where = DataModel::Translations;
79 emit findNext(text: led->text(), where, matchCase: matchCase->isChecked(), ignoreAccelerators: ignoreAccelerators->isChecked(),
80 skipObsolete: skipObsolete->isChecked(), useRegExp: useRegExp->isChecked());
81 led->selectAll();
82}
83
84void FindDialog::find()
85{
86 led->setFocus();
87
88 show();
89 activateWindow();
90 raise();
91}
92
93QT_END_NAMESPACE
94

source code of qttools/src/linguist/linguist/finddialog.cpp