Changeset View
Changeset View
Standalone View
Standalone View
documentation/documentationfindwidget.cpp
Show All 23 Lines | |||||
24 | using namespace KDevelop; | 24 | using namespace KDevelop; | ||
25 | 25 | | |||
26 | DocumentationFindWidget::DocumentationFindWidget(QWidget* parent) | 26 | DocumentationFindWidget::DocumentationFindWidget(QWidget* parent) | ||
27 | : QWidget(parent) | 27 | : QWidget(parent) | ||
28 | { | 28 | { | ||
29 | m_ui = new Ui::FindWidget; | 29 | m_ui = new Ui::FindWidget; | ||
30 | m_ui->setupUi(this); | 30 | m_ui->setupUi(this); | ||
31 | 31 | | |||
32 | m_ui->hideButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close"))); | 32 | connect(m_ui->findText, &QLineEdit::textEdited, | ||
33 | m_ui->nextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down-search"))); | 33 | this, &DocumentationFindWidget::emitDataChanged); | ||
34 | m_ui->previousButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up-search"))); | 34 | connect(m_ui->matchCase, &QAbstractButton::toggled, | ||
35 | 35 | this, &DocumentationFindWidget::emitDataChanged); | |||
36 | connect(m_ui->findText, &QLineEdit::returnPressed, | 36 | connect(m_ui->findText, &QLineEdit::returnPressed, | ||
37 | this, &DocumentationFindWidget::searchNext); | 37 | this, &DocumentationFindWidget::searchNext); | ||
38 | connect(m_ui->nextButton, &QPushButton::clicked, | 38 | connect(m_ui->nextButton, &QToolButton::clicked, | ||
39 | this, &DocumentationFindWidget::searchNext); | 39 | this, &DocumentationFindWidget::searchNext); | ||
40 | connect(m_ui->previousButton, &QPushButton::clicked, | 40 | connect(m_ui->previousButton, &QToolButton::clicked, | ||
41 | this, &DocumentationFindWidget::searchPrevious); | 41 | this, &DocumentationFindWidget::searchPrevious); | ||
42 | // TODO: disable next/previous buttons if no (more) search hits, color coding in text field | ||||
42 | } | 43 | } | ||
43 | 44 | | |||
44 | DocumentationFindWidget::~DocumentationFindWidget() | 45 | DocumentationFindWidget::~DocumentationFindWidget() | ||
45 | { | 46 | { | ||
46 | delete m_ui; | 47 | delete m_ui; | ||
47 | } | 48 | } | ||
48 | 49 | | |||
49 | void KDevelop::DocumentationFindWidget::searchNext() | 50 | void KDevelop::DocumentationFindWidget::searchNext() | ||
50 | { | 51 | { | ||
51 | FindOptions opts=Next; | 52 | FindOptions opts=Next; | ||
52 | if(m_ui->matchCase->checkState()==Qt::Checked) | 53 | if(m_ui->matchCase->isChecked()) | ||
53 | opts |= MatchCase; | 54 | opts |= MatchCase; | ||
54 | 55 | | |||
55 | emit newSearch(m_ui->findText->text(), opts); | 56 | emit searchRequested(m_ui->findText->text(), opts); | ||
56 | } | 57 | } | ||
57 | 58 | | |||
58 | void KDevelop::DocumentationFindWidget::searchPrevious() | 59 | void KDevelop::DocumentationFindWidget::searchPrevious() | ||
59 | { | 60 | { | ||
60 | FindOptions opts=Previous; | 61 | FindOptions opts=Previous; | ||
61 | if(m_ui->matchCase->checkState()==Qt::Checked) | 62 | if(m_ui->matchCase->isChecked()) | ||
62 | opts |= MatchCase; | 63 | opts |= MatchCase; | ||
63 | 64 | | |||
64 | emit newSearch(m_ui->findText->text(), opts); | 65 | emit searchRequested(m_ui->findText->text(), opts); | ||
65 | } | 66 | } | ||
66 | 67 | | |||
67 | void KDevelop::DocumentationFindWidget::startSearch() | 68 | void KDevelop::DocumentationFindWidget::startSearch() | ||
68 | { | 69 | { | ||
69 | show(); | 70 | show(); | ||
70 | m_ui->findText->selectAll(); | 71 | m_ui->findText->selectAll(); | ||
71 | m_ui->findText->setFocus(); | 72 | m_ui->findText->setFocus(); | ||
72 | } | 73 | } | ||
73 | 74 | | |||
74 | void KDevelop::DocumentationFindWidget::showEvent(QShowEvent* e) | 75 | void DocumentationFindWidget::emitDataChanged() | ||
76 | { | ||||
77 | FindOptions opts; | ||||
78 | if (m_ui->matchCase->isChecked()) | ||||
79 | opts |= MatchCase; | ||||
80 | | ||||
81 | emit searchDataChanged(m_ui->findText->text(), opts); | ||||
82 | } | ||||
83 | | ||||
84 | void KDevelop::DocumentationFindWidget::hideEvent(QHideEvent* event) | ||||
75 | { | 85 | { | ||
76 | QWidget::showEvent(e); | 86 | emit searchFinished(); | ||
87 | QWidget::hideEvent(event); | ||||
77 | } | 88 | } |