File indexing completed on 2024-05-12 04:37:44
0001 /* 0002 SPDX-FileCopyrightText: 2009 Lior Mualem <lior.m.kde@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_CLASSMODELNODESCONTROLLER_H 0008 #define KDEVPLATFORM_CLASSMODELNODESCONTROLLER_H 0009 0010 #include <QObject> 0011 #include "../../serialization/indexedstring.h" 0012 #include "../duchain/ducontext.h" 0013 0014 class QTimer; 0015 0016 class ClassModelNodeDocumentChangedInterface 0017 { 0018 public: 0019 virtual ~ClassModelNodeDocumentChangedInterface(); 0020 0021 /// Called when the registered document is changed. 0022 virtual void documentChanged(const KDevelop::IndexedString& a_file) = 0; 0023 }; 0024 0025 /// This class provides notifications for updates between the different nodes 0026 /// and the various kdevelop sub-systems (such as notification when a DUChain gets 0027 /// updated). 0028 class ClassModelNodesController 0029 : public QObject 0030 { 0031 Q_OBJECT 0032 0033 ClassModelNodesController(); 0034 public: 0035 ~ClassModelNodesController() override; 0036 0037 static ClassModelNodesController& self(); 0038 0039 /// Register the given class node to receive notifications about its top context changes. 0040 void registerForChanges(const KDevelop::IndexedString& a_file, ClassModelNodeDocumentChangedInterface* a_node); 0041 /// Unregister the given class node from further notifications. 0042 void unregisterForChanges(const KDevelop::IndexedString& a_file, ClassModelNodeDocumentChangedInterface* a_node); 0043 0044 private Q_SLOTS: 0045 // Files update. 0046 void updateChangedFiles(); 0047 0048 private: // File updates related. 0049 /// List of updated files we check this list when update timer expires. 0050 QSet<KDevelop::IndexedString> m_updatedFiles; 0051 0052 /// Timer for batch updates. 0053 QTimer* m_updateTimer; 0054 0055 using FilesMap = QMultiMap<KDevelop::IndexedString, ClassModelNodeDocumentChangedInterface*>; 0056 /// Maps between monitored files and their class nodes. 0057 FilesMap m_filesMap; 0058 }; 0059 0060 #endif