瀏覽代碼

Reload all CLI modules

Matt Clarkson 11 年之前
父節點
當前提交
eed8e1f94a

+ 5 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.cpp

@@ -272,6 +272,11 @@ void ctkCLModuleExplorerMainWindow::on_actionClear_Cache_triggered()
   moduleManager.clearCache();
 }
 
+void ctkCLModuleExplorerMainWindow::on_actionReload_Modules_triggered()
+{
+  moduleManager.reloadModules();
+}
+
 void ctkCLModuleExplorerMainWindow::checkModulePaused()
 {
   if (this->currentFutureWatcher.future().isPaused())

+ 1 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.h

@@ -69,6 +69,7 @@ protected Q_SLOTS:
 
   void on_actionReset_triggered();
   void on_actionClear_Cache_triggered();
+  void on_actionReload_Modules_triggered();
 
   void checkModulePaused();
   void currentModuleResumed();

+ 6 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.ui

@@ -67,6 +67,7 @@
     <addaction name="separator"/>
     <addaction name="actionOptions"/>
     <addaction name="actionClear_Cache"/>
+    <addaction name="actionReload_Modules"/>
    </widget>
    <addaction name="menuFile"/>
    <addaction name="menuModule"/>
@@ -355,6 +356,11 @@
     <string>Clear Cache</string>
    </property>
   </action>
+  <action name="actionReload_Modules">
+   <property name="text">
+    <string>Reload Modules</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>

+ 12 - 0
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.cpp

@@ -284,6 +284,18 @@ void ctkCmdLineModuleManager::clearCache()
 
 
 //----------------------------------------------------------------------------
+void ctkCmdLineModuleManager::reloadModules()
+{
+  foreach(const QUrl &location, d->LocationToRef.keys())
+  {
+    ctkCmdLineModuleReference ref = d->LocationToRef[location];
+    this->unregisterModule(ref);
+    this->registerModule(location);
+  }
+}
+
+
+//----------------------------------------------------------------------------
 ctkCmdLineModuleReference ctkCmdLineModuleManager::moduleReference(const QUrl &location) const
 {
   QMutexLocker lock(&d->Mutex);

+ 5 - 0
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.h

@@ -137,6 +137,11 @@ public:
   void clearCache();
 
   /**
+   * @brief Reloads all currently valid modules, forcing the cache to be refreshed.
+   */
+  void reloadModules();
+
+  /**
    * @brief Returns a ctkCmdLineModuleReference object for the given URL.
    * @param location The location URL for which to get a module reference.
    * @return The module reference for the location or an invalid module reference