Преглед на файлове

Merge branch 'cli-module-support'

Matt Clarkson преди 12 години
родител
ревизия
dd4386a4b0

+ 60 - 34
Libs/CommandLineModules/Core/Testing/Cpp/ctkCmdLineModuleDefaultPathBuilderTest.cpp

@@ -48,86 +48,112 @@ int ctkCmdLineModuleDefaultPathBuilderTest(int argc, char* argv[])
 
   ctkCmdLineModuleDefaultPathBuilder builder;
 
-  QStringList defaultList = builder.build();
+  QStringList defaultList = builder.getDirectoryList();
   if (defaultList.size() != 0)
   {
     qDebug() << "The default list should be empty";
     return EXIT_FAILURE;
   }
 
-  builder.setLoadFromCurrentDir(true);
+  builder.addCurrentDir();
+  QStringList result = builder.getDirectoryList();
 
-  QStringList result = builder.build();
   qDebug() << "1. Built:" << result;
 
-  if (result.size() != 2)
+  if (result.size() != 1)
   {
-    qDebug() << "The flag setLoadFromCurrentDir enables scanning of the current working directory plus the subfolder cli-modules";
+    qDebug() << "Calling addCurrentDir should add one directory to the list of directories.";
     return EXIT_FAILURE;
   }
 
-  builder.setLoadFromApplicationDir(true);
+  builder.addCurrentDir("cli-modules");
+  result = builder.getDirectoryList();
 
-  result = builder.build();
   qDebug() << "2. Built:" << result;
 
-  if (result.size() != 4)
+  if (result.size() != 2)
   {
-    qDebug() << "The flag setLoadFromApplicationDir enables scanning of the current installation directory plus the subfolder cli-modules";
+    qDebug() << "Calling addCurrentDir(cli-modules) should add one directory to the list of directories.";
     return EXIT_FAILURE;
   }
 
-  builder.setLoadFromCurrentDir(false);
+  builder.clear();
+
+  builder.addApplicationDir();
+  result = builder.getDirectoryList();
 
-  result = builder.build();
   qDebug() << "3. Built:" << result;
 
-  if (!result.contains(runtimeDirectory.absolutePath()))
+  if (result.size() != 1)
   {
-    qDebug() << "Loading from the application diretory (where THIS application is located), should produce the same path as passed in via the command line argument ${CTK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}";
+    qDebug() << "Calling addApplicationDir should return the application installation dir.";
+    return EXIT_FAILURE;
   }
 
-  builder.setLoadFromHomeDir(true);
+  builder.addApplicationDir("cli-modules");
+  result = builder.getDirectoryList();
 
-  result = builder.build();
   qDebug() << "4. Built:" << result;
 
-  if (result.size() != 4)
+  if (result.size() != 2)
+  {
+    qDebug() << "Calling addApplicationDir(cli-modules) should return 2 directories, one the sub-directory of the other.";
+    return EXIT_FAILURE;
+  }
+
+  QString tmp1 = result[0];
+  QString tmp2 = result[1];
+  QString expected = tmp1 + QDir::separator() + "cli-modules";
+
+  if (tmp2 != expected)
   {
-    qDebug() << "Should now be loading from applicationDir, applicationDir/cli-modules, homeDir, homeDir/cli-modules";
+    qDebug() << "Expected " << expected << ", but got " << tmp2;
     return EXIT_FAILURE;
   }
 
-  builder.setLoadFromCtkModuleLoadPath(true);
+  builder.clear();
+
+  builder.addCtkModuleLoadPath();
+  result = builder.getDirectoryList();
 
-  result = builder.build();
   qDebug() << "5. Built:" << result;
 
-  // If the environment variable CTK_MODULE_LOAD_PATH exists, it should point to a valid directory.
-  // If it does not exist, then the list should not change.
+  // If the environment variable CTK_MODULE_LOAD_PATH exists, it should point to a valid list of directories.
   QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
   qDebug() << "Environment is:" << env.toStringList();
 
+#ifdef Q_OS_WIN32
+    QString pathSeparator(";");
+#else
+    QString pathSeparator(":");
+#endif
+
   if (env.contains("CTK_MODULE_LOAD_PATH"))
   {
-    QDir loadDir(env.value("CTK_MODULE_LOAD_PATH"));
-
-    qDebug() << "CTK_MODULE_LOAD_PATH does exist, and is set to:" << env.value("CTK_MODULE_LOAD_PATH") << ", and isExists() returns " << loadDir.exists();
+    QString loadPath = env.value("CTK_MODULE_LOAD_PATH");
+    QStringList loadPaths = loadPath.split(pathSeparator, QString::SkipEmptyParts);
 
-    if (loadDir.exists() && result.size() != 5)
-    {
-      qDebug() << "Environment variable CTK_MODULE_LOAD_PATH did exist and is valid, so there should be 5 entries";
-      return EXIT_FAILURE;
-    }
-    else if (!loadDir.exists() && result.size() != 4)
+    foreach (QString path, loadPaths)
     {
-      qDebug() << "Environment variable CTK_MODULE_LOAD_PATH did exist but is invalid, so there should be 4 entries";
-      return EXIT_FAILURE;
+      if (!loadPaths.contains(path))
+      {
+        qDebug() << "Expecte loadPaths to contain path=" << path;
+        return EXIT_FAILURE;
+      }
     }
   }
-  else if (result.size() != 4)
+
+  builder.clear();
+
+  builder.addApplicationDir("blah-blah-blah");
+  builder.setStrictMode(true);
+  result = builder.getDirectoryList();
+
+  qDebug() << "6. Built:" << result;
+
+  if (result.size() != 0)
   {
-    qDebug() << "Environment variable CTK_MODULE_LOAD_PATH did not exist, so there should still be 4 entries as previous test";
+    qDebug() << "Calling addApplicationDir(blah-blah-blah) should return nothing unless we do have a sub-folder called blah-blah-blah.";
     return EXIT_FAILURE;
   }
 

+ 135 - 61
Libs/CommandLineModules/Core/ctkCmdLineModuleDefaultPathBuilder.cpp

@@ -23,25 +23,30 @@
 #include <QDebug>
 #include <QCoreApplication>
 #include <cstdlib>
+#include <QStringList>
 
 //----------------------------------------------------------------------------
 struct ctkCmdLineModuleDefaultPathBuilderPrivate
 {
 public:
+
   ctkCmdLineModuleDefaultPathBuilderPrivate();
   ~ctkCmdLineModuleDefaultPathBuilderPrivate();
-  QStringList build() const;
+  void clear();
+  void setStrictMode(const bool& strict);
+  bool strictMode() const;
+  void addHomeDir(const QString& subFolder = QString());
+  void addCurrentDir(const QString& subFolder = QString());
+  void addApplicationDir(const QString& subFolder = QString());
+  void addCtkModuleLoadPath();
+  QStringList getDirectoryList() const;
 
-  void setLoadFromHomeDir(bool doLoad);
-  void setLoadFromCurrentDir(bool doLoad);
-  void setLoadFromApplicationDir(bool doLoad);
-  void setLoadFromCtkModuleLoadPath(bool doLoad);
+  bool isStrictMode;
+  QStringList directoryList;
 
-  bool LoadFromHomeDir;
-  bool LoadFromCurrentDir;
-  bool LoadFromApplicationDir;
-  bool LoadFromCtkModuleLoadPath;
+private:
 
+  QString addSubFolder(const QString& folder, const QString& subFolder);
 };
 
 //-----------------------------------------------------------------------------
@@ -49,92 +54,135 @@ public:
 
 //-----------------------------------------------------------------------------
 ctkCmdLineModuleDefaultPathBuilderPrivate::ctkCmdLineModuleDefaultPathBuilderPrivate()
-: LoadFromHomeDir(false)
-, LoadFromCurrentDir(false)
-, LoadFromApplicationDir(false)
-, LoadFromCtkModuleLoadPath(false)
+: isStrictMode(false)
 {
-
 }
 
+
 //-----------------------------------------------------------------------------
 ctkCmdLineModuleDefaultPathBuilderPrivate::~ctkCmdLineModuleDefaultPathBuilderPrivate()
 {
-
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilderPrivate::setLoadFromHomeDir(bool doLoad)
+void ctkCmdLineModuleDefaultPathBuilderPrivate::clear()
 {
-  LoadFromHomeDir = doLoad;
+  directoryList.clear();
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilderPrivate::setLoadFromCurrentDir(bool doLoad)
+void ctkCmdLineModuleDefaultPathBuilderPrivate::setStrictMode(const bool& strict)
 {
-  LoadFromCurrentDir = doLoad;
+  isStrictMode = strict;
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilderPrivate::setLoadFromApplicationDir(bool doLoad)
+bool ctkCmdLineModuleDefaultPathBuilderPrivate::strictMode() const
 {
-  LoadFromApplicationDir = doLoad;
+  return isStrictMode;
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilderPrivate::setLoadFromCtkModuleLoadPath(bool doLoad)
+QString ctkCmdLineModuleDefaultPathBuilderPrivate::addSubFolder(
+    const QString& folder, const QString& subFolder)
 {
-  LoadFromCtkModuleLoadPath = doLoad;
+  if (subFolder.length() > 0)
+  {
+    return folder + QDir::separator() + subFolder;
+  }
+  else
+  {
+    return folder;
+  }
 }
 
 
 //-----------------------------------------------------------------------------
-QStringList ctkCmdLineModuleDefaultPathBuilderPrivate::build() const
+void ctkCmdLineModuleDefaultPathBuilderPrivate::addHomeDir(const QString& subFolder)
 {
-  QStringList result;
+  if (QDir::home().exists())
+  {
+    QString result = addSubFolder(QDir::homePath(), subFolder);
+    directoryList << result;
+  }
+}
 
-  QString suffix = "cli-modules";
 
-  if (LoadFromCtkModuleLoadPath)
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilderPrivate::addCurrentDir(const QString& subFolder)
+{
+  if (QDir::current().exists())
   {
-    char *ctkModuleLoadPath = getenv("CTK_MODULE_LOAD_PATH");
-    if (ctkModuleLoadPath != NULL)
-    {
-      QDir dir = QDir(QString(ctkModuleLoadPath));
-      if (dir.exists())
-      {
-        result << dir.canonicalPath();
-      }
-    }
+    QString result = addSubFolder(QDir::currentPath(), subFolder);
+    directoryList << result;
   }
+}
+
 
-  if (LoadFromHomeDir)
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilderPrivate::addApplicationDir(const QString& subFolder)
+{
+  QString result = addSubFolder(QCoreApplication::applicationDirPath(), subFolder);
+  directoryList << result;
+}
+
+
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilderPrivate::addCtkModuleLoadPath()
+{
+  char *ctkModuleLoadPath = getenv("CTK_MODULE_LOAD_PATH");
+  if (ctkModuleLoadPath != NULL)
   {
-    if (QDir::home().exists())
+    // The load path may in fact be a semi-colon or colon separated list of directories, not just one.
+    QString paths(ctkModuleLoadPath);
+
+#ifdef Q_OS_WIN32
+    QString pathSeparator(";");
+#else
+    QString pathSeparator(":");
+#endif
+
+    QStringList splitPath = paths.split(pathSeparator, QString::SkipEmptyParts);
+
+    foreach (QString path, splitPath)
     {
-      result << QDir::homePath();
-      result << QDir::homePath() + QDir::separator() + suffix;
+      QDir dir = QDir(path);
+      directoryList << dir.absolutePath();
     }
   }
+}
+
 
-  if (LoadFromCurrentDir)
+//-----------------------------------------------------------------------------
+QStringList ctkCmdLineModuleDefaultPathBuilderPrivate::getDirectoryList() const
+{
+  if (!isStrictMode)
   {
-    if (QDir::current().exists())
+    return directoryList;
+  }
+  else
+  {
+    QStringList filteredList;
+    foreach (QString directory, directoryList)
     {
-      result << QDir::currentPath();
-      result << QDir::currentPath() + QDir::separator() + suffix;
+      QDir dir(directory);
+      if (dir.exists())
+      {
+        filteredList << directory;
+      }
     }
-  }
 
-  if (LoadFromApplicationDir)
-  {
-    result << QCoreApplication::applicationDirPath();
-    result << QCoreApplication::applicationDirPath() + QDir::separator() + suffix;
+    qDebug() << "Filtered directory list " << directoryList << " to " << filteredList;
+    return filteredList;
   }
-
-  return result;
 }
 
+
+
 //-----------------------------------------------------------------------------
 // ctkCmdLineModuleDefaultPathBuilder methods
 
@@ -149,32 +197,58 @@ ctkCmdLineModuleDefaultPathBuilder::~ctkCmdLineModuleDefaultPathBuilder()
 {
 }
 
+
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilder::clear()
+{
+  d->clear();
+}
+
+
 //-----------------------------------------------------------------------------
-QStringList ctkCmdLineModuleDefaultPathBuilder::build() const
+void ctkCmdLineModuleDefaultPathBuilder::setStrictMode(const bool& strict)
 {
-  return d->build();
+  d->setStrictMode(strict);
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilder::setLoadFromHomeDir(bool doLoad)
+bool ctkCmdLineModuleDefaultPathBuilder::strictMode() const
 {
-  d->setLoadFromHomeDir(doLoad);
+  return d->strictMode();
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilder::setLoadFromCurrentDir(bool doLoad)
+void ctkCmdLineModuleDefaultPathBuilder::addHomeDir(const QString& subFolder)
 {
-  d->setLoadFromCurrentDir(doLoad);
+  d->addHomeDir(subFolder);
 }
 
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilder::setLoadFromApplicationDir(bool doLoad)
+void ctkCmdLineModuleDefaultPathBuilder::addCurrentDir(const QString& subFolder)
 {
-  d->setLoadFromApplicationDir(doLoad);
+  d->addCurrentDir(subFolder);
 }
 
+
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilder::addApplicationDir(const QString& subFolder)
+{
+  d->addApplicationDir(subFolder);
+}
+
+
+//-----------------------------------------------------------------------------
+void ctkCmdLineModuleDefaultPathBuilder::addCtkModuleLoadPath()
+{
+  d->addCtkModuleLoadPath();
+}
+
+
 //-----------------------------------------------------------------------------
-void ctkCmdLineModuleDefaultPathBuilder::setLoadFromCtkModuleLoadPath(bool doLoad)
+QStringList ctkCmdLineModuleDefaultPathBuilder::getDirectoryList() const
 {
-  d->setLoadFromCtkModuleLoadPath(doLoad);
+  return d->getDirectoryList();
 }

+ 49 - 28
Libs/CommandLineModules/Core/ctkCmdLineModuleDefaultPathBuilder.h

@@ -29,24 +29,25 @@ struct ctkCmdLineModuleDefaultPathBuilderPrivate;
 
 /**
  * \class ctkCmdLineModuleDefaultPathBuilder
- * \brief Builds up a list of directory paths to search for command
- * line modules.
+ * \brief Builds up a list of directory paths to search for command line modules.
  * \ingroup CommandLineModulesCore_API
  * \author m.clarkson@ucl.ac.uk
  *
- * Implements the following basic strategy, depending on which boolean
- * flags are on: By default they are all off, as directory scanning is
- * often time consuming.
+ * Simple class to enable the user to easily add various directories
+ * to a list of directories. You create this object, add a load of directories
+ * by repeatedly calling add..() functions, and then call getDirectoryList()
+ * to get the final StringList of directory locations.
  *
+ * The choices are:
  * <pre>
- * 1. CTK_MODULE_LOAD_PATH environment variable
- * 2. Home directory
- * 3. Home directory / cli-modules
- * 4. Current working directory
- * 5. Current working directory / cli-modules
- * 6. Application directory
- * 7. Application directory / cli-modules
+ * 1. The directory or list of directories defined by the CTK_MODULE_LOAD_PATH environment variable.
+ * Uses usual PATH semantics such as colon separator on *nix systems and semi-colon on Windows.
+ * 2. The directory defined by the users HOME directory, or any sub-directory under this.
+ * 3. The directory defined by the current working directory, or any sub-directory under this.
+ * 4. The directory defined by the application installation directory or any sub-directory under this.
  * </pre>
+ *
+ * A strictMode flag exists to decide if this class only returns directories that already exist.
  */
 class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleDefaultPathBuilder
 {
@@ -57,35 +58,55 @@ public:
   ~ctkCmdLineModuleDefaultPathBuilder();
 
   /**
-   * @brief Instruct the builder to include the users
-   * home directory and sub-folder cli-modules.
+   * @brief Clears the current list of directories.
+   */
+  virtual void clear();
+
+  /**
+   * @brief Sets strict mode which checks that all directories already exist.
+   * @param strict if true this object will only return existing directories,
+   * if false, the return StringList is un-checked.
+   */
+  virtual void setStrictMode(const bool& strict);
+
+  /**
+   * @brief Returns the strict mode flag.
+   */
+  virtual bool strictMode() const;
+
+  /**
+   * @brief Adds the users home directory, or if specified a sub-directory.
+   *
+   * This depends on QDir::home() existing. If this is not the case,
+   * then this method will do nothing and ignore the request.
    */
-  virtual void setLoadFromHomeDir(bool doLoad);
+  virtual void addHomeDir(const QString& subFolder = QString());
 
   /**
-   * @brief Instruct the builder to include the current
-   * running directory and sub-folder cli-modules.
+   * @brief Adds the current working directory, or if specified a sub-directory.
+   *
+   * This depends on QDir::current() existing. If this is not the case,
+   * then this method will do nothing and ignore the request.
    */
-  virtual void setLoadFromCurrentDir(bool doLoad);
+  virtual void addCurrentDir(const QString& subFolder = QString());
 
   /**
-   * @brief Instruct the builder to include the application
-   * installation directory and sub-folder cli-modules.
+   * @brief Adds the application installation directory, or if specified a sub-directory.
    */
-  virtual void setLoadFromApplicationDir(bool doLoad);
+  virtual void addApplicationDir(const QString& subFolder = QString());
 
   /**
-   * @brief Instruct the builder to include the path denoted
-   * by the environment variable CTK_MODULE_LOAD_PATH.
+   * @brief Adds the directories denoted by the environment variable CTK_MODULE_LOAD_PATH.
+   *
+   * Semi-colon separated lists of directories are allowed.
    */
-  virtual void setLoadFromCtkModuleLoadPath(bool doLoad);
+  virtual void addCtkModuleLoadPath();
 
   /**
-   * @brief Builds the list of paths to search and returns them
-   * as QStringList
-   * @return a QStringList of directory path names
+   * @brief Returns the QStringList containing directories.
+   * @return QStringList of directories or, if in strict mode, directories that already exist.
    */
-  virtual QStringList build() const;
+  virtual QStringList getDirectoryList() const;
 
 private:
 

+ 15 - 8
Libs/CommandLineModules/Core/ctkCmdLineModuleXmlProgressWatcher.cpp

@@ -61,7 +61,13 @@ public:
   void _q_readyRead()
   {
     input->seek(readPos);
-    reader.addData(input->readAll());
+
+    QByteArray buffer = input->readAll();
+
+    buffer.prepend("<module-snippet>");
+    buffer.append("</module-snippet>");
+
+    reader.addData(buffer);
     readPos = input->pos();
     parseProgressXml();
   }
@@ -123,7 +129,7 @@ public:
         QString parent;
         if (!stack.empty()) parent = stack.back();
 
-        if (name.compare("module-root") != 0)
+        if (name.compare("module-root") != 0 && name.compare("module-snippet") != 0)
         {
           stack.push_back(name.toString());
         }
@@ -171,13 +177,8 @@ public:
           if (!stack.empty()) parent = stack.back();
         }
 
-        if (parent.isEmpty())
+        if (parent.isEmpty() && name.compare("module-snippet") != 0)
         {
-          if (!outputData.isEmpty())
-          {
-            emit q->outputDataAvailable(outputData);
-            outputData.clear();
-          }
           if (name.compare(FILTER_START, Qt::CaseInsensitive) == 0)
           {
             emit q->filterStarted(currentName, currentComment);
@@ -208,6 +209,12 @@ public:
       default:
         break;
       }
+
+      if (!outputData.isEmpty())
+      {
+        emit q->outputDataAvailable(outputData);
+        outputData.clear();
+      }
       type = reader.readNext();
     }
 

+ 86 - 74
Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/ctkCmdLineModuleQtXslTransformTest.cpp

@@ -108,12 +108,24 @@ QString parametersWidgetHeader =
   ;
 
 QString parametersWidgetEmptyLayout =
-  "                    <layout class=\"QGridLayout\"/>\n";
+  "                    <layout class=\"QVBoxLayout\" name=\"paramContainerLayout:Parameters\">\n"
+  "                        <item>\n"
+  "                            <widget class=\"QWidget\" name=\"paramContainer:Parameters\">\n"
+  "                                <layout class=\"QGridLayout\"/>\n"
+  "                            </widget>\n"
+  "                        </item>\n"
+  "                    </layout>\n";
 
 QString parametersLayoutHeader =
-  "                    <layout class=\"QGridLayout\">\n";
+  "                    <layout class=\"QVBoxLayout\" name=\"paramContainerLayout:Parameters\">\n"
+  "                        <item>\n"
+  "                            <widget class=\"QWidget\" name=\"paramContainer:Parameters\">\n"
+  "                                <layout class=\"QGridLayout\">\n";
 
 QString parametersLayoutFooter =
+  "                                </layout>\n"
+  "                            </widget>\n"
+  "                        </item>\n"
   "                    </layout>\n";
 
 QString parametersWidgetFooter =
@@ -132,44 +144,44 @@ QString integer =
   ;
 
 QString integerWidgetLabel =
-  "                        <item row=\"0\" column=\"0\">\n"
-  "                            <widget class=\"QLabel\">\n"
-  "                                <property name=\"sizePolicy\">\n"
-  "                                    <sizepolicy hsizetype=\"Fixed\" vsizetype=\"Preferred\">\n"
-  "                                        <horstretch>0</horstretch>\n"
-  "                                        <verstretch>0</verstretch>\n"
-  "                                    </sizepolicy>\n"
-  "                                </property>\n"
-  "                                <property name=\"text\">\n"
-  "                                    <string>Integer</string>\n"
-  "                                </property>\n"
-  "                            </widget>\n"
-  "                        </item>\n"
+  "                                    <item row=\"0\" column=\"0\">\n"
+  "                                        <widget class=\"QLabel\">\n"
+  "                                            <property name=\"sizePolicy\">\n"
+  "                                                <sizepolicy hsizetype=\"Fixed\" vsizetype=\"Preferred\">\n"
+  "                                                    <horstretch>0</horstretch>\n"
+  "                                                    <verstretch>0</verstretch>\n"
+  "                                                </sizepolicy>\n"
+  "                                            </property>\n"
+  "                                            <property name=\"text\">\n"
+  "                                                <string>Integer</string>\n"
+  "                                            </property>\n"
+  "                                        </widget>\n"
+  "                                    </item>\n"
   ;
 QString integerWidgetSpinBoxHeader =
-  "                        <item row=\"0\" column=\"1\">\n"
+  "                                    <item row=\"0\" column=\"1\">\n"
   ;
 QString integerWidgetSpinBox =
-  "                            <widget class=\"QSpinBox\" name=\"parameter:integer\">\n"
-  "                                <property name=\"minimum\">\n"
-  "                                    <number>-999999999</number>\n"
-  "                                </property>\n"
-  "                                <property name=\"maximum\">\n"
-  "                                    <number>999999999</number>\n"
-  "                                </property>\n"
-  "                                <property name=\"toolTip\">\n"
-  "                                    <string>Integer description</string>\n"
-  "                                </property>\n"
-  "                                <property name=\"parameter:valueProperty\">\n"
-  "                                    <string>value</string>\n"
-  "                                </property>\n"
-  "                                <property name=\"value\">\n"
-  "                                    <number>1</number>\n"
-  "                                </property>\n"
-  "                            </widget>\n"
+  "                                        <widget class=\"QSpinBox\" name=\"parameter:integer\">\n"
+  "                                            <property name=\"minimum\">\n"
+  "                                                <number>-999999999</number>\n"
+  "                                            </property>\n"
+  "                                            <property name=\"maximum\">\n"
+  "                                                <number>999999999</number>\n"
+  "                                            </property>\n"
+  "                                            <property name=\"toolTip\">\n"
+  "                                                <string>Integer description</string>\n"
+  "                                            </property>\n"
+  "                                            <property name=\"parameter:valueProperty\">\n"
+  "                                                <string>value</string>\n"
+  "                                            </property>\n"
+  "                                            <property name=\"value\">\n"
+  "                                                <number>1</number>\n"
+  "                                            </property>\n"
+  "                                        </widget>\n"
   ;
 QString integerWidgetSpinBoxFooter =
-  "                        </item>\n"
+  "                                    </item>\n"
   ;
 
 
@@ -394,46 +406,46 @@ void ctkCmdLineModuleQtXslTransformTester::testXslExtraTransformation_data()
     "</xsl:template>\n"
     ;
   QString integerWidgetSliderSpinBox =
-    "                            <layout class=\"QHBoxLayout\">\n"
-    "                                <item>\n"
-    "                                    <widget class=\"QSlider\" name=\"parameter:integerSlider\">\n"
-    "                                        <property name=\"minimum\">\n"
-    "                                            <number>-999999999</number>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"maximum\">\n"
-    "                                            <number>999999999</number>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"toolTip\">\n"
-    "                                            <string>Integer description</string>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"parameter:valueProperty\">\n"
-    "                                            <string>value</string>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"value\">\n"
-    "                                            <number>1</number>\n"
-    "                                        </property>\n"
-    "                                    </widget>\n"
-    "                                </item>\n"
-    "                                <item>\n"
-    "                                    <widget class=\"QSpinBox\" name=\"parameter:integer\">\n"
-    "                                        <property name=\"minimum\">\n"
-    "                                            <number>-999999999</number>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"maximum\">\n"
-    "                                            <number>999999999</number>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"toolTip\">\n"
-    "                                            <string>Integer description</string>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"parameter:valueProperty\">\n"
-    "                                            <string>value</string>\n"
-    "                                        </property>\n"
-    "                                        <property name=\"value\">\n"
-    "                                            <number>1</number>\n"
-    "                                        </property>\n"
-    "                                    </widget>\n"
-    "                                </item>\n"
-    "                            </layout>\n"
+    "                                        <layout class=\"QHBoxLayout\">\n"
+    "                                            <item>\n"
+    "                                                <widget class=\"QSlider\" name=\"parameter:integerSlider\">\n"
+    "                                                    <property name=\"minimum\">\n"
+    "                                                        <number>-999999999</number>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"maximum\">\n"
+    "                                                        <number>999999999</number>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"toolTip\">\n"
+    "                                                        <string>Integer description</string>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"parameter:valueProperty\">\n"
+    "                                                        <string>value</string>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"value\">\n"
+    "                                                        <number>1</number>\n"
+    "                                                    </property>\n"
+    "                                                </widget>\n"
+    "                                            </item>\n"
+    "                                            <item>\n"
+    "                                                <widget class=\"QSpinBox\" name=\"parameter:integer\">\n"
+    "                                                    <property name=\"minimum\">\n"
+    "                                                        <number>-999999999</number>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"maximum\">\n"
+    "                                                        <number>999999999</number>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"toolTip\">\n"
+    "                                                        <string>Integer description</string>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"parameter:valueProperty\">\n"
+    "                                                        <string>value</string>\n"
+    "                                                    </property>\n"
+    "                                                    <property name=\"value\">\n"
+    "                                                        <number>1</number>\n"
+    "                                                    </property>\n"
+    "                                                </widget>\n"
+    "                                            </item>\n"
+    "                                        </layout>\n"
     ;
   QTest::addColumn<QString>("input");
   QTest::addColumn<QString>("extra");