File indexing completed on 2024-05-12 04:37:44
0001 /* 0002 SPDX-License-Identifier: LGPL-2.0-only 0003 */ 0004 0005 #include "projectfolder.h" 0006 0007 #include "../../interfaces/iproject.h" 0008 #include "../../serialization/indexedstring.h" 0009 #include <KLocalizedString> 0010 0011 using namespace KDevelop; 0012 using namespace ClassModelNodes; 0013 0014 ////////////////////////////////////////////////////////////////////////////// 0015 ////////////////////////////////////////////////////////////////////////////// 0016 0017 ProjectFolder::ProjectFolder(NodesModelInterface* a_model, IProject* project) 0018 : DocumentClassesFolder(i18n("Classes in project %1", project->name()), a_model) 0019 , m_project(project) 0020 { 0021 } 0022 0023 ProjectFolder::ProjectFolder(NodesModelInterface* a_model) 0024 : DocumentClassesFolder(QString(), a_model) 0025 , m_project(nullptr) 0026 { 0027 } 0028 0029 void ProjectFolder::populateNode() 0030 { 0031 const auto files = m_project->fileSet(); 0032 for (const IndexedString& file : files) { 0033 parseDocument(file); 0034 } 0035 0036 recursiveSort(); 0037 } 0038 0039 ////////////////////////////////////////////////////////////////////////////// 0040 ////////////////////////////////////////////////////////////////////////////// 0041 0042 FilteredProjectFolder::FilteredProjectFolder(NodesModelInterface* a_model, IProject* project) 0043 : ProjectFolder(a_model, project) 0044 { 0045 } 0046 0047 void FilteredProjectFolder::updateFilterString(const QString& a_newFilterString) 0048 { 0049 m_filterString = a_newFilterString; 0050 0051 if (isPopulated()) { 0052 #if 1 // Choose speed over correctness. 0053 // Close the node and re-open it should be quicker than reload each document 0054 // and remove individual nodes (at the cost of losing the current selection). 0055 performPopulateNode(true); 0056 #else 0057 bool hadChanges = false; 0058 0059 // Reload the documents. 0060 foreach (const IndexedString& file, getAllOpenDocuments()) 0061 hadChanges |= updateDocument(file); 0062 0063 // Sort if we've updated documents. 0064 if (hadChanges) 0065 recursiveSort(); 0066 else 0067 { 0068 // If nothing changed, the title changed so mark the node as updated. 0069 m_model->nodesLayoutAboutToBeChanged(this); 0070 m_model->nodesLayoutChanged(this); 0071 } 0072 #endif 0073 } else { 0074 // Displayed name changed only... 0075 m_model->nodesLayoutAboutToBeChanged(this); 0076 m_model->nodesLayoutChanged(this); 0077 } 0078 } 0079 0080 bool FilteredProjectFolder::isClassFiltered(const KDevelop::QualifiedIdentifier& a_id) 0081 { 0082 return !a_id.last().toString().contains(m_filterString, Qt::CaseInsensitive); 0083 } 0084 0085 #include "moc_projectfolder.cpp"