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:
|
||||
void setupFilterUi(const QString &historyKey);
|
||||
QString filterText() const;
|
||||
bool filterUsesRegexp() const { return m_filterRegexp; }
|
||||
Qt::CaseSensitivity filterCaseSensitivity() const { return m_filterCaseSensitivity; }
|
||||
void setFilteringEnabled(bool enable);
|
||||
QWidget *filterWidget() const { return m_filterOutputLineEdit; }
|
||||
|
||||
@@ -119,7 +121,7 @@ private:
|
||||
QAction *m_filterActionCaseSensitive = nullptr;
|
||||
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
|
||||
bool m_filterRegexp = false;
|
||||
bool m_filterCaseSensitive = false;
|
||||
Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -146,7 +146,7 @@ bool MessageOutputWindow::canNavigate() const
|
||||
|
||||
void MessageOutputWindow::updateFilter()
|
||||
{
|
||||
m_widget->setFilterText(filterText());
|
||||
m_widget->updateFilterProperties(filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -195,6 +195,7 @@ void IOutputPane::filterOutputButtonClicked()
|
||||
void IOutputPane::setRegularExpressions(bool regularExpressions)
|
||||
{
|
||||
m_filterRegexp = regularExpressions;
|
||||
updateFilter();
|
||||
}
|
||||
|
||||
Id IOutputPane::filterRegexpActionId() const
|
||||
@@ -209,7 +210,8 @@ Id IOutputPane::filterCaseSensitivityActionId() const
|
||||
|
||||
void IOutputPane::setCaseSensitive(bool caseSensitive)
|
||||
{
|
||||
m_filterCaseSensitive = caseSensitive;
|
||||
m_filterCaseSensitivity = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
updateFilter();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
@@ -284,15 +284,16 @@ void OutputWindow::setHighlightTextColor(const QColor &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)
|
||||
{
|
||||
if (d->filterText != 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) {
|
||||
const bool filterTextWasEmpty = d->filterText.isEmpty();
|
||||
d->filterText = filterText;
|
||||
|
||||
@@ -313,23 +314,9 @@ void OutputWindow::setFilterText(const QString &filterText)
|
||||
setPalette(pal);
|
||||
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 = {};
|
||||
d->filterMode = flags;
|
||||
filterNewContent();
|
||||
}
|
||||
}
|
||||
|
||||
void OutputWindow::filterNewContent()
|
||||
|
@@ -79,11 +79,7 @@ public:
|
||||
void setHighlightBgColor(const QColor &bgColor);
|
||||
void setHighlightTextColor(const QColor &textColor);
|
||||
|
||||
QString filterText() const;
|
||||
void setFilterText(const QString &filterText);
|
||||
|
||||
FilterModeFlags filterMode() const;
|
||||
void setFilterMode(FilterModeFlag filterMode, bool enabled);
|
||||
void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity, bool regexp);
|
||||
|
||||
signals:
|
||||
void wheelZoom();
|
||||
|
@@ -372,8 +372,10 @@ void AppOutputPane::setFocus()
|
||||
void AppOutputPane::updateFilter()
|
||||
{
|
||||
const int index = currentIndex();
|
||||
if (index != -1)
|
||||
m_runControlTabs.at(index).window->setFilterText(filterText());
|
||||
if (index != -1) {
|
||||
m_runControlTabs.at(index).window->updateFilterProperties(
|
||||
filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||
}
|
||||
}
|
||||
|
||||
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
@@ -703,7 +705,8 @@ void AppOutputPane::tabChanged(int i)
|
||||
const int index = indexOf(m_tabWidget->widget(i));
|
||||
if (i != -1 && index != -1) {
|
||||
const RunControlTab &controlTab = m_runControlTabs[index];
|
||||
controlTab.window->setFilterText(filterText());
|
||||
controlTab.window->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
||||
filterUsesRegexp());
|
||||
enableButtons(controlTab.runControl);
|
||||
} else {
|
||||
enableDefaultButtons();
|
||||
|
@@ -356,7 +356,8 @@ void CompileOutputWindow::setSettings(const CompileOutputSettings &settings)
|
||||
|
||||
void CompileOutputWindow::updateFilter()
|
||||
{
|
||||
m_outputWindow->setFilterText(filterText());
|
||||
m_outputWindow->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
||||
filterUsesRegexp());
|
||||
}
|
||||
|
||||
void CompileOutputWindow::loadSettings()
|
||||
|
@@ -341,6 +341,25 @@ void TaskFilterModel::setFilterIncludesWarnings(bool b)
|
||||
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
|
||||
{
|
||||
Q_UNUSED(source_parent);
|
||||
@@ -365,8 +384,12 @@ bool TaskFilterModel::filterAcceptsTask(const Task &task) const
|
||||
if (accept && m_categoryIds.contains(task.category))
|
||||
accept = false;
|
||||
|
||||
if (accept && !filterRegExp().isEmpty() && !task.file.toString().contains(filterRegExp())
|
||||
&& !task.description.contains(filterRegExp())) {
|
||||
if (accept && !m_filterText.isEmpty()) {
|
||||
const auto accepts = [this](const QString &s) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "task.h"
|
||||
|
||||
@@ -143,6 +144,9 @@ public:
|
||||
bool hasFile(const QModelIndex &index) const
|
||||
{ return taskModel()->hasFile(mapToSource(index)); }
|
||||
|
||||
void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity,
|
||||
bool isRegex);
|
||||
|
||||
private:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
bool filterAcceptsTask(const Task &task) const;
|
||||
@@ -151,7 +155,11 @@ private:
|
||||
bool m_includeUnknowns;
|
||||
bool m_includeWarnings;
|
||||
bool m_includeErrors;
|
||||
bool m_filterStringIsRegexp = false;
|
||||
Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive;
|
||||
QList<Core::Id> m_categoryIds;
|
||||
QString m_filterText;
|
||||
QRegularExpression m_filterRegexp;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -669,7 +669,7 @@ void TaskWindow::goToPrev()
|
||||
|
||||
void TaskWindow::updateFilter()
|
||||
{
|
||||
d->m_filter->setFilterRegExp(filterText());
|
||||
d->m_filter->updateFilterProperties(filterText(), filterCaseSensitivity(), filterUsesRegexp());
|
||||
}
|
||||
|
||||
bool TaskWindow::canNavigate() const
|
||||
|
Reference in New Issue
Block a user