File indexing completed on 2024-04-28 08:27:06
0001 /* This file is part of KDevelop 0002 0003 Copyright 2017 Anton Anikin <anton@anikin.xyz> 0004 0005 This program is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; see the file COPYING. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "problemmodel.h" 0022 0023 #include "tool.h" 0024 #include "plugin.h" 0025 #include "utils.h" 0026 0027 #include <interfaces/icore.h> 0028 #include <interfaces/ilanguagecontroller.h> 0029 #include <shell/problemmodelset.h> 0030 0031 #include <KLocalizedString> 0032 0033 namespace Valgrind 0034 { 0035 0036 inline KDevelop::ProblemModelSet* problemModelSet() 0037 { 0038 return KDevelop::ICore::self()->languageController()->problemModelSet(); 0039 } 0040 0041 inline QString problemModelId() { return QStringLiteral("Valgrind"); } 0042 0043 ProblemModel::ProblemModel() 0044 : KDevelop::ProblemModel(Plugin::self()) 0045 { 0046 setFeatures(CanDoFullUpdate | 0047 ScopeFilter | 0048 SeverityFilter | 0049 Grouping | 0050 CanByPassScopeFilter | 0051 ShowSource); 0052 0053 reset(nullptr); 0054 problemModelSet()->addModel(problemModelId(), i18n("Valgrind"), this); 0055 } 0056 0057 ProblemModel::~ProblemModel() 0058 { 0059 problemModelSet()->removeModel(problemModelId()); 0060 } 0061 0062 void ProblemModel::reset(const Tool* tool) 0063 { 0064 m_tool = tool; 0065 clearProblems(); 0066 0067 QString toolName = tool ? tool->name() : i18n("Valgrind"); 0068 setFullUpdateTooltip(i18nc("@info:tooltip", "Re-Run %1 Analysis for Current Launch Configuration", toolName)); 0069 } 0070 0071 void ProblemModel::show() 0072 { 0073 problemModelSet()->showModel(problemModelId()); 0074 } 0075 0076 void ProblemModel::forceFullUpdate() 0077 { 0078 if (m_tool && !Plugin::self()->isRunning()) { 0079 Plugin::self()->executeDefaultLaunch(m_tool->id()); 0080 } 0081 } 0082 0083 }