"Clear Filter" button instead of "Show All"

This commit is contained in:
RebeccaStankus 2018-01-04 12:51:11 -08:00
parent 3e8063f80a
commit 9ba324b85f
4 changed files with 37 additions and 17 deletions

View file

@ -116,8 +116,8 @@ void BaseLogDialog::handleSearchButton() {
} }
void BaseLogDialog::handleSearchTextChanged(QString searchText) { void BaseLogDialog::handleSearchTextChanged(QString searchText) {
QTextCursor cursor = _logTextBox->textCursor(); QTextCursor cursor = _logTextBox->textCursor();
if (cursor.hasSelection()) { if (cursor.hasSelection()) {
QString selectedTerm = cursor.selectedText(); QString selectedTerm = cursor.selectedText();
if (selectedTerm == searchText) { if (selectedTerm == searchText) {
@ -139,6 +139,10 @@ void BaseLogDialog::handleSearchTextChanged(QString searchText) {
_highlighter->rehighlight(); _highlighter->rehighlight();
} }
void BaseLogDialog::clearSearch() {
_searchTextBox->setText("");
}
void BaseLogDialog::toggleSearchPrev() { void BaseLogDialog::toggleSearchPrev() {
QTextCursor searchCursor = _logTextBox->textCursor(); QTextCursor searchCursor = _logTextBox->textCursor();
if (searchCursor.hasSelection()) { if (searchCursor.hasSelection()) {

View file

@ -67,6 +67,7 @@ protected:
void resizeEvent(QResizeEvent* event) override; void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override; void showEvent(QShowEvent* event) override;
virtual QString getCurrentLog() = 0; virtual QString getCurrentLog() = 0;
void clearSearch();
private: private:
QPushButton* _searchButton{ nullptr }; QPushButton* _searchButton{ nullptr };

View file

@ -19,7 +19,7 @@
#include <shared/AbstractLoggerInterface.h> #include <shared/AbstractLoggerInterface.h>
const int REVEAL_BUTTON_WIDTH = 122; const int REVEAL_BUTTON_WIDTH = 122;
const int SHOW_ALL_BUTTON_WIDTH = 80; const int CLEAR_FILTER_BUTTON_WIDTH = 80;
const int MARGIN_LEFT = 25; const int MARGIN_LEFT = 25;
const int DEBUG_CHECKBOX_WIDTH = 70; const int DEBUG_CHECKBOX_WIDTH = 70;
const int INFO_CHECKBOX_WIDTH = 65; const int INFO_CHECKBOX_WIDTH = 65;
@ -149,13 +149,12 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : BaseLog
_extraDebuggingBox->show(); _extraDebuggingBox->show();
connect(_extraDebuggingBox, &QCheckBox::stateChanged, this, &LogDialog::handleExtraDebuggingCheckbox); connect(_extraDebuggingBox, &QCheckBox::stateChanged, this, &LogDialog::handleExtraDebuggingCheckbox);
_showAllButton = new QPushButton("Show All", this); _clearFilterButton = new QPushButton("Clear Filters", this);
// set object name for css styling // set object name for css styling
_showAllButton->setObjectName("showAllButton"); _clearFilterButton->setObjectName("showAllButton");
_showAllButton->show(); _clearFilterButton->show();
connect(_showAllButton, &QPushButton::clicked, this, &LogDialog::handleShowAllButton); connect(_clearFilterButton, &QPushButton::clicked, this, &LogDialog::handleClearFilterButton);
handleClearFilterButton();
} }
void LogDialog::resizeEvent(QResizeEvent* event) { void LogDialog::resizeEvent(QResizeEvent* event) {
@ -164,11 +163,11 @@ void LogDialog::resizeEvent(QResizeEvent* event) {
ELEMENT_MARGIN, ELEMENT_MARGIN,
REVEAL_BUTTON_WIDTH, REVEAL_BUTTON_WIDTH,
ELEMENT_HEIGHT); ELEMENT_HEIGHT);
_showAllButton->setGeometry(width() - ELEMENT_MARGIN - SHOW_ALL_BUTTON_WIDTH, _clearFilterButton->setGeometry(width() - ELEMENT_MARGIN - CLEAR_FILTER_BUTTON_WIDTH,
THIRD_ROW, THIRD_ROW,
SHOW_ALL_BUTTON_WIDTH, CLEAR_FILTER_BUTTON_WIDTH,
ELEMENT_HEIGHT); ELEMENT_HEIGHT);
_extraDebuggingBox->setGeometry(width() - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN - SHOW_ALL_BUTTON_WIDTH, _extraDebuggingBox->setGeometry(width() - ELEMENT_MARGIN - COMBOBOX_WIDTH - ELEMENT_MARGIN - CLEAR_FILTER_BUTTON_WIDTH,
THIRD_ROW, THIRD_ROW,
COMBOBOX_WIDTH, COMBOBOX_WIDTH,
ELEMENT_HEIGHT); ELEMENT_HEIGHT);
@ -178,10 +177,26 @@ void LogDialog::handleRevealButton() {
_logger->locateLog(); _logger->locateLog();
} }
void LogDialog::handleShowAllButton() { void LogDialog::handleClearFilterButton() {
_logTextBox->clear(); _logger->setExtraDebugging(false);
QString log = getCurrentLog(); _extraDebuggingBox->setCheckState(Qt::Unchecked);
_logTextBox->appendPlainText(log); _logger->setDebugPrint(false);
_debugPrintBox->setCheckState(Qt::Unchecked);
_logger->setInfoPrint(false);
_infoPrintBox->setCheckState(Qt::Unchecked);
_logger->setCriticalPrint(true);
_criticalPrintBox->setCheckState(Qt::Checked);
_logger->setWarningPrint(true);
_warningPrintBox->setCheckState(Qt::Checked);
_logger->setSuppressPrint(true);
_suppressPrintBox->setCheckState(Qt::Checked);
_logger->setFatalPrint(true);
_fatalPrintBox->setCheckState(Qt::Checked);
_logger->setUnknownPrint(true);
_unknownPrintBox->setCheckState(Qt::Checked);
clearSearch();
_filterDropdown->setCurrentIndex(0);
printLogFile();
} }
void LogDialog::handleExtraDebuggingCheckbox(int state) { void LogDialog::handleExtraDebuggingCheckbox(int state) {

View file

@ -40,7 +40,7 @@ private slots:
void handleFatalPrintBox(int); void handleFatalPrintBox(int);
void handleUnknownPrintBox(int); void handleUnknownPrintBox(int);
void handleFilterDropdownChanged(int); void handleFilterDropdownChanged(int);
void handleShowAllButton(); void handleClearFilterButton();
protected: protected:
void resizeEvent(QResizeEvent* event) override; void resizeEvent(QResizeEvent* event) override;
@ -50,7 +50,7 @@ protected:
private: private:
QCheckBox* _extraDebuggingBox; QCheckBox* _extraDebuggingBox;
QPushButton* _revealLogButton; QPushButton* _revealLogButton;
QPushButton* _showAllButton; QPushButton* _clearFilterButton;
QCheckBox* _debugPrintBox; QCheckBox* _debugPrintBox;
QCheckBox* _infoPrintBox; QCheckBox* _infoPrintBox;
QCheckBox* _criticalPrintBox; QCheckBox* _criticalPrintBox;