XSLTools

Change of examples/Common/QtConfigurator/__init__.py

349:83ce900fe957
examples/Common/QtConfigurator/__init__.py
     1.1 --- a/examples/Common/QtConfigurator/__init__.py	Tue Oct 25 15:52:43 2005 +0000
     1.2 +++ b/examples/Common/QtConfigurator/__init__.py	Tue Oct 25 17:27:43 2005 +0000
     1.3 @@ -1,13 +1,10 @@
     1.4  #!/usr/bin/env python
     1.5  
     1.6 +import XSLForms.PyQt
     1.7  import QtConfigurator.Forms
     1.8 -import XSLForms.Prepare
     1.9 -import factory
    1.10 -import qtui
    1.11 -import qtxmldom
    1.12  import os
    1.13  
    1.14 -class Configurator(QtConfigurator.Forms.Configurator):
    1.15 +class Configurator(QtConfigurator.Forms.Configurator, XSLForms.PyQt.XSLFormsResource):
    1.16  
    1.17      # Standard attributes.
    1.18  
    1.19 @@ -35,52 +32,11 @@
    1.20          "screen" : "config_screen.xml"
    1.21          }
    1.22  
    1.23 -    # Helper methods.
    1.24 -    # NOTE: Should be moved to a superclass.
    1.25 -
    1.26 -    def prepare_document(self, document_identifier):
    1.27 -        filename = self.document_resources[document_identifier]
    1.28 -        return os.path.abspath(os.path.join(self.resource_dir, filename))
    1.29 -
    1.30 -    def get_document(self, document_identifier):
    1.31 -        return qtxmldom.parse(self.prepare_document(document_identifier))
    1.32 -
    1.33 -    def get_elements(self, document_identifier):
    1.34 -        doc = self.get_document(document_identifier)
    1.35 -        return doc.getElementsByTagName(document_identifier + "-enum")
    1.36 -
    1.37 -    def populate_list(self, field, elements):
    1.38 -        current_text = field.currentText()
    1.39 -        while field.count() > 0:
    1.40 -            field.removeItem(0)
    1.41 -        item = 0
    1.42 -        set = 0
    1.43 -        for element in elements:
    1.44 -            text = element.getAttribute("value")
    1.45 -            field.insertItem(text)
    1.46 -            if text == current_text:
    1.47 -                field.setCurrentItem(item)
    1.48 -                set = 1
    1.49 -            item += 1
    1.50 -        if not set:
    1.51 -            field.setCurrentItem(0)
    1.52 -
    1.53 -    def prepare_template(self, template_identifier):
    1.54 -        filename = self.template_resources[template_identifier]
    1.55 -        return os.path.abspath(os.path.join(self.resource_dir, filename))
    1.56 -
    1.57 -    def prepare_widget(self, template_identifier, widget_identifier, parent=None):
    1.58 -        template_path = self.prepare_template(template_identifier)
    1.59 -        fragment_name, widget_name = self.widget_resources[widget_identifier]
    1.60 -        fragment_path = os.path.abspath(os.path.join(self.resource_dir, fragment_name))
    1.61 -        XSLForms.Prepare.ensure_qt_fragment(template_path, fragment_path, widget_name)
    1.62 -        return qtui.QWidgetFactory.create(fragment_path, None, parent)
    1.63 -
    1.64      # Initialisation.
    1.65  
    1.66      def __init__(self, *args, **kw):
    1.67          QtConfigurator.Forms.Configurator.__init__(self, *args, **kw)
    1.68 -        self.factory = factory.Factory(self.prepare_template("configuration"))
    1.69 +        self.factory = XSLForms.PyQt.Factory(self.prepare_template("configuration"))
    1.70  
    1.71          # Get field data.
    1.72          # NOTE: This would be done for whole page updates in a Web application.