ctkCmdLineModuleInstanceQtGui.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkCmdLineModuleInstanceQtGui_p.h"
  16. #include "ctkCmdLineModuleReference.h"
  17. #include "ctkCmdLineModuleXslTransform.h"
  18. #include <QBuffer>
  19. #include <QUiLoader>
  20. #include <QWidget>
  21. #include <QVariant>
  22. #include <QDebug>
  23. ctkCmdLineModuleInstanceQtGui::ctkCmdLineModuleInstanceQtGui(const ctkCmdLineModuleReference& moduleRef)
  24. : WidgetTree(NULL), XmlDescription(moduleRef.rawXmlDescription())
  25. {
  26. }
  27. QObject* ctkCmdLineModuleInstanceQtGui::guiHandle() const
  28. {
  29. if (WidgetTree) return WidgetTree;
  30. QBuffer input;
  31. input.setData(XmlDescription);
  32. ctkCmdLineModuleXslTransform xslTransform(&input);
  33. if (!xslTransform.transform())
  34. {
  35. // maybe throw an exception
  36. qCritical() << xslTransform.errorString();
  37. return 0;
  38. }
  39. QUiLoader uiLoader;
  40. QByteArray uiBlob;
  41. uiBlob.append(xslTransform.output());
  42. QBuffer uiForm(&uiBlob);
  43. return uiLoader.load(&uiForm);
  44. }
  45. QVariant ctkCmdLineModuleInstanceQtGui::value(const QString& parameter) const
  46. {
  47. return QVariant();
  48. }
  49. void ctkCmdLineModuleInstanceQtGui::setValue(const QString& parameter, const QVariant& value)
  50. {
  51. }