forked from qt-creator/qt-creator
ClangTools: Make use of TreeModels' levels
Change-Id: I34ed24a09bac900ca0eca4c6022ef98da1b0a58f Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -300,8 +300,8 @@ ClangTidyClazyTool::ClangTidyClazyTool()
|
||||
});
|
||||
connect(m_applyFixitsButton, &QToolButton::clicked, [this]() {
|
||||
QVector<DiagnosticItem *> diagnosticItems;
|
||||
m_diagnosticModel->rootItem()->forChildrenAtLevel(2, [&](TreeItem *item){
|
||||
diagnosticItems += static_cast<DiagnosticItem *>(item);
|
||||
m_diagnosticModel->forItemsAtLevel<2>([&](DiagnosticItem *item){
|
||||
diagnosticItems += item;
|
||||
});
|
||||
|
||||
ApplyFixIts(diagnosticItems).apply(m_diagnosticModel);
|
||||
|
@@ -81,7 +81,7 @@ private:
|
||||
};
|
||||
|
||||
ClangToolsDiagnosticModel::ClangToolsDiagnosticModel(QObject *parent)
|
||||
: Utils::TreeModel<>(parent)
|
||||
: ClangToolsDiagnosticModelBase(parent)
|
||||
, m_filesWatcher(std::make_unique<QFileSystemWatcher>())
|
||||
{
|
||||
setHeader({tr("Diagnostic")});
|
||||
@@ -146,7 +146,7 @@ void ClangToolsDiagnosticModel::clear()
|
||||
m_filePathToItem.clear();
|
||||
m_diagnostics.clear();
|
||||
clearAndSetupCache();
|
||||
Utils::TreeModel<>::clear();
|
||||
ClangToolsDiagnosticModelBase::clear();
|
||||
}
|
||||
|
||||
void ClangToolsDiagnosticModel::updateItems(const DiagnosticItem *changedItem)
|
||||
@@ -174,10 +174,9 @@ void ClangToolsDiagnosticModel::clearAndSetupCache()
|
||||
|
||||
void ClangToolsDiagnosticModel::onFileChanged(const QString &path)
|
||||
{
|
||||
rootItem()->forChildrenAtLevel(2, [&](Utils::TreeItem *item){
|
||||
auto diagnosticItem = static_cast<DiagnosticItem *>(item);
|
||||
if (diagnosticItem->diagnostic().location.filePath == path)
|
||||
diagnosticItem->setFixItStatus(FixitStatus::Invalidated);
|
||||
forItemsAtLevel<2>([&](DiagnosticItem *item){
|
||||
if (item->diagnostic().location.filePath == path)
|
||||
item->setFixItStatus(FixitStatus::Invalidated);
|
||||
});
|
||||
removeWatchedPath(path);
|
||||
}
|
||||
|
@@ -100,7 +100,11 @@ private:
|
||||
ClangToolsDiagnosticModel *m_parentModel = nullptr;
|
||||
};
|
||||
|
||||
class ClangToolsDiagnosticModel : public Utils::TreeModel<>
|
||||
class ExplainingStepItem;
|
||||
|
||||
using ClangToolsDiagnosticModelBase
|
||||
= Utils::TreeModel<Utils::TreeItem, FilePathItem, DiagnosticItem, ExplainingStepItem>;
|
||||
class ClangToolsDiagnosticModel : public ClangToolsDiagnosticModelBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
Reference in New Issue
Block a user