Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
finddialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4/* TRANSLATOR FindDialog
5
6 Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
7 Find dialog
8*/
9
10#include "finddialog.h"
11
13
16{
17 setupUi(this);
18
19 statusFilter->addItem(tr("All"), -1);
20 statusFilter->addItem(tr("Finished"), TranslatorMessage::Finished);
21 statusFilter->addItem(tr("Unfinished"), TranslatorMessage::Unfinished);
22
23 findNxt->setEnabled(false);
24
25 connect(findNxt, &QAbstractButton::clicked,
26 this, &FindDialog::emitFindNext);
27 connect(useRegExp, &QCheckBox::checkStateChanged,
28 this, &FindDialog::verify);
29 connect(led, &QLineEdit::textChanged,
30 this, &FindDialog::verify);
31 connect(statusFilter, &QComboBox::currentIndexChanged,
32 this, &FindDialog::statusFilterChanged);
33
34 led->setFocus();
35}
36
37void FindDialog::verify()
38{
39 bool validRegExp = true;
40 if (useRegExp->isChecked() && !led->text().isEmpty()) {
41 m_regExp.setPattern(led->text());
42 validRegExp = m_regExp.isValid();
43 }
44 if (validRegExp && m_redText)
45 led->setStyleSheet(QStringLiteral("color: auto;"));
46 else if (!validRegExp && !m_redText)
47 led->setStyleSheet(QStringLiteral("color: red;"));
48 m_redText = !validRegExp;
49 findNxt->setEnabled(!led->text().isEmpty() && validRegExp);
50}
51
52void FindDialog::statusFilterChanged()
53{
54 int newStateFilter = statusFilter->currentData().toInt();
55 if (newStateFilter != -1) {
56 if (m_lastStateFilter == -1)
57 m_storedSkipObsolete = skipObsolete->isChecked();
58 skipObsolete->setEnabled(false);
59 skipObsolete->setChecked(true);
60 } else {
61 skipObsolete->setEnabled(true);
62 skipObsolete->setChecked(m_storedSkipObsolete);
63 }
64 m_lastStateFilter = newStateFilter;
65}
66
67void FindDialog::emitFindNext()
68{
70 if (sourceText != 0)
71 where =
72 DataModel::FindLocation(
73 (sourceText->isChecked() ? DataModel::SourceText : 0) |
74 (translations->isChecked() ? DataModel::Translations : 0) |
75 (comments->isChecked() ? DataModel::Comments : 0));
76 else
78
79 FindOptions options((matchCase->isChecked() ? FindOption::MatchCase : 0) |
80 (ignoreAccelerators->isChecked() ? FindDialog::IgnoreAccelerators : 0) |
81 (skipObsolete->isChecked() ? FindDialog::SkipObsolete : 0) |
82 (useRegExp->isChecked() ? FindDialog::UseRegExp : 0));
83 emit findNext(led->text(), where, options, statusFilter->currentData().toInt());
84 led->selectAll();
85}
86
87void FindDialog::find()
88{
89 led->setFocus();
90
91 show();
92 activateWindow();
93 raise();
94}
95
96QT_END_NAMESPACE
QObject * parent
Definition qobject.h:73
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.