Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/NotepadNext/dialogs/FindReplaceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "FindReplaceDialog.h"
#include "ApplicationSettings.h"
#include "ui_FindReplaceDialog.h"
#include "MarkerAppDecorator.h"
#include "BookMarkDecorator.h"

#include <QStatusBar>
#include <QLineEdit>
Expand Down Expand Up @@ -205,6 +207,14 @@ FindReplaceDialog::FindReplaceDialog(ISearchResultsHandler *searchResults, MainW

showMessage(tr("Replaced matches in %Ln files", "", count), "green");
});
connect(ui->buttonClearBookmarks, &QPushButton::clicked, this, [=]() {
auto app = qobject_cast<NotepadNextApplication*>(qApp);
MarkerAppDecorator *decorator = app->findChild<MarkerAppDecorator*>(QString(), Qt::FindDirectChildrenOnly);
BookMarkDecorator *bookMarkDecorator = editor->findChild<BookMarkDecorator*>(QString(), Qt::FindDirectChildrenOnly);

bookMarkDecorator->clearAllBookmarks();
decorator->clearAll(editor);
});
connect(ui->buttonClose, &QPushButton::clicked, this, &FindReplaceDialog::close);

loadSettings();
Expand Down Expand Up @@ -317,6 +327,12 @@ void FindReplaceDialog::findAllInCurrentDocument()
{
qInfo(Q_FUNC_INFO);

qDebug() << "Editor pointer:" << editor;

auto app = qobject_cast<NotepadNextApplication*>(qApp);
MarkerAppDecorator *decorator = app->findChild<MarkerAppDecorator*>(QString(), Qt::FindDirectChildrenOnly);
BookMarkDecorator *bookMarkDecorator = editor->findChild<BookMarkDecorator*>(QString(), Qt::FindDirectChildrenOnly);

bool firstMatch = true;

QString text = findString();
Expand All @@ -330,6 +346,17 @@ void FindReplaceDialog::findAllInCurrentDocument()
}

const int line = editor->lineFromPosition(start);
qDebug() << "Found result on line " << line;
if (ui->checkBoxMarkRes->isChecked()) {
if (!bookMarkDecorator->isBookmarkSet(line)){
qDebug() << "Marking result at line " << line;
bookMarkDecorator->toggleBookmark(line);
}
if (decorator && decorator->isEnabled()) {
// Options: 0, 1, 2
decorator->mark(editor, 1);
}
}
const int lineStartPosition = editor->positionFromLine(line);
const int lineEndPosition = editor->lineEndPosition(line);
const int startPositionFromBeginning = start - lineStartPosition;
Expand Down Expand Up @@ -502,6 +529,8 @@ void FindReplaceDialog::changeTab(int index)
ui->buttonReplaceAllInFiles->hide();
ui->buttonFindInFilesSelector->hide();

ui->checkBoxMarkRes->show();
ui->buttonClearBookmarks->show();
ui->buttonCount->show();
ui->buttonFindAllInCurrent->show();
ui->buttonFindAllInDocuments->show();
Expand All @@ -521,6 +550,8 @@ void FindReplaceDialog::changeTab(int index)
ui->buttonReplaceAllInFiles->show();
ui->buttonFindInFilesSelector->show();

ui->checkBoxMarkRes->hide();
ui->buttonClearBookmarks->hide();
ui->buttonCount->hide();
ui->buttonFindAllInCurrent->hide();
ui->buttonFindAllInDocuments->hide();
Expand Down
22 changes: 18 additions & 4 deletions src/NotepadNext/dialogs/FindReplaceDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>350</height>
</size>
<size>
<width>600</width>
<height>350</height>
</size>
</property>
<property name="windowTitle">
<string>Find</string>
Expand Down Expand Up @@ -315,6 +315,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonClearBookmarks">
<property name="text">
<string>Clear All Marks</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonClose">
<property name="text">
Expand Down Expand Up @@ -470,6 +477,13 @@
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkBoxMarkRes">
<property name="text">
<string>Mark Results</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxBackwardsDirection">
<property name="text">
Expand Down
3 changes: 3 additions & 0 deletions src/NotepadNext/dialogs/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2245,4 +2245,7 @@ void MainWindow::languageMenuTriggered()
QVariant v = act->data();

setLanguage(editor, v.toString());

// Some debugging stuff
qDebug() << "MainWindow editor pointer:" << currentEditor();
}
Loading