Sfoglia il codice sorgente

Added moduleAdded and moduleRemoved to ctkCmdLineModuleManager

MattClarkson 12 anni fa
parent
commit
086955896c

+ 1 - 0
Libs/CommandLineModules/Core/CMakeLists.txt

@@ -45,6 +45,7 @@ set(KIT_SRCS
 set(KIT_MOC_SRCS
   ctkCmdLineModuleDirectoryWatcher.h
   ctkCmdLineModuleDirectoryWatcherPrivate.h
+  ctkCmdLineModuleManager.h
   ctkCmdLineModuleInstance.h
   ctkCmdLineModuleProcessTask.h
 )

+ 4 - 1
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.cpp

@@ -89,12 +89,15 @@ ctkCmdLineModuleManager::registerModule(const QString& location)
 //  ref.d->setGUI(descriptionFactory->createGUIFromXML(ref.d->xml));
 
   d->Cache[location] = ref;
+
+  emit moduleAdded(ref);
   return ref;
 }
 
 void ctkCmdLineModuleManager::unregisterModule(const ctkCmdLineModuleReference& ref)
 {
   d->Cache.remove(ref.location());
+  emit moduleRemoved(ref);
 }
 
 ctkCmdLineModuleReference ctkCmdLineModuleManager::moduleReference(const QString& location) const
@@ -104,7 +107,7 @@ ctkCmdLineModuleReference ctkCmdLineModuleManager::moduleReference(const QString
 
 QList<ctkCmdLineModuleReference> ctkCmdLineModuleManager::moduleReferences() const
 {
-  throw ctkException("not implemented yet");
+  return d->Cache.values();
 }
 
 ctkCmdLineModuleInstance*

+ 8 - 2
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.h

@@ -26,18 +26,19 @@
 
 #include <QStringList>
 #include <QString>
+#include "ctkCmdLineModuleReference.h"
 
 struct ctkCmdLineModuleInstanceFactory;
 
 class ctkCmdLineModuleInstance;
-class ctkCmdLineModuleReference;
 class ctkCmdLineModuleManagerPrivate;
 
 /**
  * \ingroup CommandLineModulesCore
  */
-class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleManager
+class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleManager : public QObject
 {
+  Q_OBJECT
 
 public:
 
@@ -68,6 +69,11 @@ public:
 
   QList<ctkCmdLineModuleInstance*> moduleInstances(const ctkCmdLineModuleReference& moduleRef) const;
 
+Q_SIGNALS:
+
+  void moduleAdded(const ctkCmdLineModuleReference);
+  void moduleRemoved(const ctkCmdLineModuleReference);
+
 private:
 
   QScopedPointer<ctkCmdLineModuleManagerPrivate> d;