forked from qt-creator/qt-creator
Output panes: Respect filter options
The UI elements for case sensitivity and regexp behavior had not been doing anything until now. Change-Id: Ie210103984fda64d4249c56f9a5b21200132108f Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -99,6 +99,8 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
void setupFilterUi(const QString &historyKey);
|
void setupFilterUi(const QString &historyKey);
|
||||||
QString filterText() const;
|
QString filterText() const;
|
||||||
|
bool filterUsesRegexp() const { return m_filterRegexp; }
|
||||||
|
Qt::CaseSensitivity filterCaseSensitivity() const { return m_filterCaseSensitivity; }
|
||||||
void setFilteringEnabled(bool enable);
|
void setFilteringEnabled(bool enable);
|
||||||
QWidget *filterWidget() const { return m_filterOutputLineEdit; }
|
QWidget *filterWidget() const { return m_filterOutputLineEdit; }
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ private:
|
|||||||
QAction *m_filterActionCaseSensitive = nullptr;
|
QAction *m_filterActionCaseSensitive = nullptr;
|
||||||
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
|
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
|
||||||
bool m_filterRegexp = false;
|
bool m_filterRegexp = false;
|
||||||
bool m_filterCaseSensitive = false;
|
Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -146,7 +146,7 @@ bool MessageOutputWindow::canNavigate() const
|
|||||||
|
|
||||||
void MessageOutputWindow::updateFilter()
|
void MessageOutputWindow::updateFilter()
|
||||||
{
|
{
|
||||||
m_widget->setFilterText(filterText());
|
m_widget->updateFilterProperties(filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -195,6 +195,7 @@ void IOutputPane::filterOutputButtonClicked()
|
|||||||
void IOutputPane::setRegularExpressions(bool regularExpressions)
|
void IOutputPane::setRegularExpressions(bool regularExpressions)
|
||||||
{
|
{
|
||||||
m_filterRegexp = regularExpressions;
|
m_filterRegexp = regularExpressions;
|
||||||
|
updateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
Id IOutputPane::filterRegexpActionId() const
|
Id IOutputPane::filterRegexpActionId() const
|
||||||
@@ -209,7 +210,8 @@ Id IOutputPane::filterCaseSensitivityActionId() const
|
|||||||
|
|
||||||
void IOutputPane::setCaseSensitive(bool caseSensitive)
|
void IOutputPane::setCaseSensitive(bool caseSensitive)
|
||||||
{
|
{
|
||||||
m_filterCaseSensitive = caseSensitive;
|
m_filterCaseSensitivity = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||||
|
updateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@@ -284,15 +284,16 @@ void OutputWindow::setHighlightTextColor(const QColor &textColor)
|
|||||||
d->highlightTextColor = textColor;
|
d->highlightTextColor = textColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OutputWindow::filterText() const
|
void OutputWindow::updateFilterProperties(const QString &filterText,
|
||||||
{
|
Qt::CaseSensitivity caseSensitivity, bool isRegexp)
|
||||||
return d->filterText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputWindow::setFilterText(const QString &filterText)
|
|
||||||
{
|
{
|
||||||
|
FilterModeFlags flags;
|
||||||
|
flags.setFlag(FilterModeFlag::CaseSensitive, caseSensitivity == Qt::CaseSensitive)
|
||||||
|
.setFlag(FilterModeFlag::RegExp, isRegexp);
|
||||||
|
if (d->filterMode == flags && d->filterText == filterText)
|
||||||
|
return;
|
||||||
|
d->lastFilteredBlock = {};
|
||||||
if (d->filterText != filterText) {
|
if (d->filterText != filterText) {
|
||||||
d->lastFilteredBlock = {};
|
|
||||||
const bool filterTextWasEmpty = d->filterText.isEmpty();
|
const bool filterTextWasEmpty = d->filterText.isEmpty();
|
||||||
d->filterText = filterText;
|
d->filterText = filterText;
|
||||||
|
|
||||||
@@ -313,23 +314,9 @@ void OutputWindow::setFilterText(const QString &filterText)
|
|||||||
setPalette(pal);
|
setPalette(pal);
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterNewContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputWindow::FilterModeFlags OutputWindow::filterMode() const
|
|
||||||
{
|
|
||||||
return d->filterMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputWindow::setFilterMode(OutputWindow::FilterModeFlag filterMode, bool enabled)
|
|
||||||
{
|
|
||||||
if (d->filterMode.testFlag(filterMode) != enabled) {
|
|
||||||
d->filterMode.setFlag(filterMode, enabled);
|
|
||||||
d->lastFilteredBlock = {};
|
|
||||||
filterNewContent();
|
|
||||||
}
|
}
|
||||||
|
d->filterMode = flags;
|
||||||
|
filterNewContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWindow::filterNewContent()
|
void OutputWindow::filterNewContent()
|
||||||
|
@@ -79,11 +79,7 @@ public:
|
|||||||
void setHighlightBgColor(const QColor &bgColor);
|
void setHighlightBgColor(const QColor &bgColor);
|
||||||
void setHighlightTextColor(const QColor &textColor);
|
void setHighlightTextColor(const QColor &textColor);
|
||||||
|
|
||||||
QString filterText() const;
|
void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity, bool regexp);
|
||||||
void setFilterText(const QString &filterText);
|
|
||||||
|
|
||||||
FilterModeFlags filterMode() const;
|
|
||||||
void setFilterMode(FilterModeFlag filterMode, bool enabled);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void wheelZoom();
|
void wheelZoom();
|
||||||
|
@@ -372,8 +372,10 @@ void AppOutputPane::setFocus()
|
|||||||
void AppOutputPane::updateFilter()
|
void AppOutputPane::updateFilter()
|
||||||
{
|
{
|
||||||
const int index = currentIndex();
|
const int index = currentIndex();
|
||||||
if (index != -1)
|
if (index != -1) {
|
||||||
m_runControlTabs.at(index).window->setFilterText(filterText());
|
m_runControlTabs.at(index).window->updateFilterProperties(
|
||||||
|
filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||||
@@ -703,7 +705,8 @@ void AppOutputPane::tabChanged(int i)
|
|||||||
const int index = indexOf(m_tabWidget->widget(i));
|
const int index = indexOf(m_tabWidget->widget(i));
|
||||||
if (i != -1 && index != -1) {
|
if (i != -1 && index != -1) {
|
||||||
const RunControlTab &controlTab = m_runControlTabs[index];
|
const RunControlTab &controlTab = m_runControlTabs[index];
|
||||||
controlTab.window->setFilterText(filterText());
|
controlTab.window->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
||||||
|
filterUsesRegexp());
|
||||||
enableButtons(controlTab.runControl);
|
enableButtons(controlTab.runControl);
|
||||||
} else {
|
} else {
|
||||||
enableDefaultButtons();
|
enableDefaultButtons();
|
||||||
|
@@ -356,7 +356,8 @@ void CompileOutputWindow::setSettings(const CompileOutputSettings &settings)
|
|||||||
|
|
||||||
void CompileOutputWindow::updateFilter()
|
void CompileOutputWindow::updateFilter()
|
||||||
{
|
{
|
||||||
m_outputWindow->setFilterText(filterText());
|
m_outputWindow->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
||||||
|
filterUsesRegexp());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileOutputWindow::loadSettings()
|
void CompileOutputWindow::loadSettings()
|
||||||
|
@@ -341,6 +341,25 @@ void TaskFilterModel::setFilterIncludesWarnings(bool b)
|
|||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskFilterModel::updateFilterProperties(const QString &filterText,
|
||||||
|
Qt::CaseSensitivity caseSensitivity, bool isRegexp)
|
||||||
|
{
|
||||||
|
if (filterText == m_filterText && m_filterCaseSensitivity == caseSensitivity
|
||||||
|
&& m_filterStringIsRegexp == isRegexp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_filterText = filterText;
|
||||||
|
m_filterCaseSensitivity = caseSensitivity;
|
||||||
|
m_filterStringIsRegexp = isRegexp;
|
||||||
|
if (m_filterStringIsRegexp) {
|
||||||
|
m_filterRegexp.setPattern(m_filterText);
|
||||||
|
m_filterRegexp.setPatternOptions(m_filterCaseSensitivity == Qt::CaseInsensitive
|
||||||
|
? QRegularExpression::CaseInsensitiveOption
|
||||||
|
: QRegularExpression::NoPatternOption);
|
||||||
|
}
|
||||||
|
invalidateFilter();
|
||||||
|
}
|
||||||
|
|
||||||
bool TaskFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
bool TaskFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(source_parent);
|
Q_UNUSED(source_parent);
|
||||||
@@ -365,9 +384,13 @@ bool TaskFilterModel::filterAcceptsTask(const Task &task) const
|
|||||||
if (accept && m_categoryIds.contains(task.category))
|
if (accept && m_categoryIds.contains(task.category))
|
||||||
accept = false;
|
accept = false;
|
||||||
|
|
||||||
if (accept && !filterRegExp().isEmpty() && !task.file.toString().contains(filterRegExp())
|
if (accept && !m_filterText.isEmpty()) {
|
||||||
&& !task.description.contains(filterRegExp())) {
|
const auto accepts = [this](const QString &s) {
|
||||||
accept = false;
|
return m_filterStringIsRegexp ? m_filterRegexp.isValid() && s.contains(m_filterRegexp)
|
||||||
|
: s.contains(m_filterText, m_filterCaseSensitivity);
|
||||||
|
};
|
||||||
|
if (!accepts(task.file.toString()) && !accepts(task.description))
|
||||||
|
accept = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return accept;
|
return accept;
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
@@ -143,6 +144,9 @@ public:
|
|||||||
bool hasFile(const QModelIndex &index) const
|
bool hasFile(const QModelIndex &index) const
|
||||||
{ return taskModel()->hasFile(mapToSource(index)); }
|
{ return taskModel()->hasFile(mapToSource(index)); }
|
||||||
|
|
||||||
|
void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity,
|
||||||
|
bool isRegex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||||
bool filterAcceptsTask(const Task &task) const;
|
bool filterAcceptsTask(const Task &task) const;
|
||||||
@@ -151,7 +155,11 @@ private:
|
|||||||
bool m_includeUnknowns;
|
bool m_includeUnknowns;
|
||||||
bool m_includeWarnings;
|
bool m_includeWarnings;
|
||||||
bool m_includeErrors;
|
bool m_includeErrors;
|
||||||
|
bool m_filterStringIsRegexp = false;
|
||||||
|
Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive;
|
||||||
QList<Core::Id> m_categoryIds;
|
QList<Core::Id> m_categoryIds;
|
||||||
|
QString m_filterText;
|
||||||
|
QRegularExpression m_filterRegexp;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -669,7 +669,7 @@ void TaskWindow::goToPrev()
|
|||||||
|
|
||||||
void TaskWindow::updateFilter()
|
void TaskWindow::updateFilter()
|
||||||
{
|
{
|
||||||
d->m_filter->setFilterRegExp(filterText());
|
d->m_filter->updateFilterProperties(filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskWindow::canNavigate() const
|
bool TaskWindow::canNavigate() const
|
||||||
|
Reference in New Issue
Block a user