forked from qt-creator/qt-creator
ClangTools: Add clear button to toolbar
Change-Id: I0caeb3fa118b57084f7df7a22952f3057ca601e0 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -245,6 +245,18 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
||||
connect(action, &QAction::triggered, m_diagnosticView, &DetailedErrorView::goNext);
|
||||
m_goNext = action;
|
||||
|
||||
// Clear data
|
||||
action = new QAction(this);
|
||||
action->setDisabled(true);
|
||||
action->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
|
||||
action->setToolTip(tr("Clear"));
|
||||
connect(action, &QAction::triggered, [this](){
|
||||
m_clear->setEnabled(false);
|
||||
m_diagnosticModel->clear();
|
||||
Debugger::showPermanentStatusMessage(QString());
|
||||
});
|
||||
m_clear = action;
|
||||
|
||||
// Filter line edit
|
||||
m_filterLineEdit = new Utils::FancyLineEdit();
|
||||
m_filterLineEdit->setFiltering(true);
|
||||
@@ -291,6 +303,7 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
||||
|
||||
m_perspective.addToolBarAction(m_startAction);
|
||||
m_perspective.addToolBarAction(m_stopAction);
|
||||
m_perspective.addToolBarAction(m_clear);
|
||||
m_perspective.addToolBarAction(m_goBack);
|
||||
m_perspective.addToolBarAction(m_goNext);
|
||||
m_perspective.addToolBarWidget(m_filterLineEdit);
|
||||
@@ -362,7 +375,6 @@ void ClangTidyClazyTool::startTool(bool askUserForFileSelection)
|
||||
|
||||
m_perspective.select();
|
||||
|
||||
m_diagnosticModel->clearAndSetupCache();
|
||||
m_diagnosticModel->clear();
|
||||
|
||||
setToolBusy(true);
|
||||
@@ -381,6 +393,7 @@ void ClangTidyClazyTool::updateRunActions()
|
||||
QString tooltipText = tr("Clang-Tidy and Clazy are still running.");
|
||||
m_startAction->setToolTip(tooltipText);
|
||||
m_stopAction->setEnabled(true);
|
||||
m_clear->setEnabled(false);
|
||||
} else {
|
||||
QString toolTip = tr("Start Clang-Tidy and Clazy.");
|
||||
Project *project = SessionManager::startupProject();
|
||||
@@ -394,6 +407,7 @@ void ClangTidyClazyTool::updateRunActions()
|
||||
m_startAction->setToolTip(toolTip);
|
||||
m_startAction->setEnabled(canRun);
|
||||
m_stopAction->setEnabled(false);
|
||||
m_clear->setEnabled(m_diagnosticModel->diagnosticsCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -69,6 +69,7 @@ private:
|
||||
|
||||
QAction *m_goBack = nullptr;
|
||||
QAction *m_goNext = nullptr;
|
||||
QAction *m_clear = nullptr;
|
||||
|
||||
Utils::Perspective m_perspective{ClangTidyClazyPerspectiveId, tr("Clang-Tidy and Clazy")};
|
||||
};
|
||||
|
@@ -90,6 +90,12 @@ int ClangToolsDiagnosticModel::diagnosticsCount() const
|
||||
return rootItem()->childCount();
|
||||
}
|
||||
|
||||
void ClangToolsDiagnosticModel::clear()
|
||||
{
|
||||
clearAndSetupCache();
|
||||
Utils::TreeModel<>::clear();
|
||||
}
|
||||
|
||||
void ClangToolsDiagnosticModel::updateItems(const DiagnosticItem *changedItem)
|
||||
{
|
||||
for (auto item : stepsToItemsCache[changedItem->diagnostic().explainingSteps]) {
|
||||
|
@@ -107,7 +107,7 @@ public:
|
||||
DiagnosticRole = Debugger::DetailedErrorView::FullTextRole + 1
|
||||
};
|
||||
|
||||
void clearAndSetupCache();
|
||||
void clear();
|
||||
void removeWatchedPath(const QString &path);
|
||||
void addWatchedPath(const QString &path);
|
||||
|
||||
@@ -118,6 +118,7 @@ private:
|
||||
void connectFileWatcher();
|
||||
void updateItems(const DiagnosticItem *changedItem);
|
||||
void onFileChanged(const QString &path);
|
||||
void clearAndSetupCache();
|
||||
|
||||
private:
|
||||
std::map<QVector<ExplainingStep>, QVector<DiagnosticItem *>> stepsToItemsCache;
|
||||
|
Reference in New Issue
Block a user