1 /*
2     This file is part of the Okteta Kasten module, made within the KDE community.
3 
4     SPDX-FileCopyrightText: 2006-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #include "searchdialog.hpp"
10 
11 // controller
12 #include "searchtool.hpp"
13 // KF
14 #include <KLocalizedString>
15 
16 namespace Kasten {
17 
SearchDialog(SearchTool * tool,QWidget * parent)18 SearchDialog::SearchDialog(SearchTool* tool, QWidget* parent)
19     : AbstractFindDialog(parent)
20     , mTool(tool)
21 {
22     setWindowTitle(i18nc("@title:window", "Find Bytes"));
23 
24     setFindButton(i18nc("@action:button", "&Find"),
25                   QStringLiteral("edit-find"),
26                   i18nc("@info:tooltip", "Start searching"),
27                   xi18nc("@info:whatsthis",
28                          "If you press the <interface>Find</interface> button, "
29                          "the bytes you entered above are searched for within "
30                          "the byte array."));
31 
32     setupFindBox();
33     setupOperationBox();
34     setupCheckBoxes();
35 
36     setFindButtonEnabled(false);
37     setModal(true);
38 
39     setCharCodec(mTool->charCodingName());
40     connect(mTool,  &SearchTool::charCodecChanged,
41             this, &SearchDialog::setCharCodec);
42 }
43 
44 SearchDialog::~SearchDialog() = default;
45 
onFindButtonClicked()46 void SearchDialog::onFindButtonClicked()
47 {
48     hide();
49 
50     rememberCurrentSettings();
51 
52     mTool->setSearchData(data());
53     mTool->setCaseSensitivity(caseSensitivity());
54 
55     mTool->search(direction(), fromCursor(), inSelection());
56 }
57 
showEvent(QShowEvent * showEvent)58 void SearchDialog::showEvent(QShowEvent* showEvent)
59 {
60     AbstractFindDialog::showEvent(showEvent);
61 
62     setInSelectionEnabled(mTool->hasSelectedData());
63     setInSelection(mTool->hasSelectedData());
64 }
65 
66 }
67