Exemplo n.º 1
0
    def __init__(self, parent, name='SuiteTraitComboBox'):
        QFrame.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.suiteCursor = Suites(self.conn)
        self.suites = self.suiteCursor.list()
        self.traits = Traits(self.conn, self.suites[0])
        self.scombo = KComboBox(self, 'SuiteComboBox')
        self.scombo.insertStrList(self.suites)
        self.tcombo = KComboBox(self, 'TypeComboBox')
        self.tcombo.insertStrList(['template', 'script'])
        self.trcombo = KComboBox(self, 'TraitComboBox')
        self.update_btn = KPushButton('update', self)
        self.listView = TraitListView(self)
        self.vbox = QVBoxLayout(self)
        for attribute in [
                'listView', 'scombo', 'tcombo', 'trcombo', 'update_btn'
        ]:
            widget = getattr(self, attribute)
            self.vbox.addWidget(widget)
        # we need to redo the signals and the methods that are called
        self.connect(self.scombo, SIGNAL('activated(int)'), self.update_traits)

        self.connect(self.update_btn, SIGNAL('clicked()'),
                     self.refreshlistView)
Exemplo n.º 2
0
 def __init__(self, conn, suite):
     self.conn = conn
     self.suite = suite
     self.traits = Traits(self.conn, self.suite)
     self.edit_menu = make_menu(SCRIPTS, self.modify_trait, name='edit')
     self.diff_menu = make_menu(SCRIPTS, self.modify_trait, name='diff')
     self.menu = make_menu(['edit', 'diff'], self.edit_menu)
     self.menu['edit'].set_submenu(self.edit_menu)
     self.menu['diff'].set_submenu(self.diff_menu)
     ListNoteBook.__init__(self)
     self.reset_rows()
Exemplo n.º 3
0
class TraitScriptBrowser(ListNoteBook):
    def __init__(self, conn, suite):
        self.conn = conn
        self.suite = suite
        self.traits = Traits(self.conn, self.suite)
        rows = self.traits.select(table='scriptnames')
        self._scriptnames = [r.script for r in rows]
        self.edit_menu = make_menu(self._scriptnames,
                                   self.modify_trait,
                                   name='edit')
        self.diff_menu = make_menu(self._scriptnames,
                                   self.modify_trait,
                                   name='diff')
        self.menu = make_menu(['edit', 'diff'], self.edit_menu)
        self.menu['edit'].set_submenu(self.edit_menu)
        self.menu['diff'].set_submenu(self.diff_menu)
        ListNoteBook.__init__(self)
        self.reset_rows()

    def modify_trait(self, menuitem, action):
        parent = menuitem.get_parent()
        command = parent.get_name()
        rows = self.get_selected_data()
        if len(rows):
            trait = rows[0].trait
            print action, trait
            if command == 'edit':
                if action not in self.pages[trait].pages:
                    self.pages[trait].new_script(action)
                else:
                    self.pages[trait].edit_script(None, action, None)
            elif command == 'diff':
                print 'diff', action
                AllScriptsDialog('which script?', self.conn, self.suite)

        else:
            dialogs.Message('select a trait first')

    def reset_rows(self):
        rows = self.traits.select(fields=['trait'])
        self.set_rows(rows)
        self.set_row_select(self.trait_selected)

    def trait_selected(self, listbox, row, column, event):
        trait = listbox.get_selected_data()[0].trait
        self.select_trait(trait)

    def select_trait(self, trait):
        if trait not in self.pages:
            newpage = ScriptNotebook(self.conn, self.suite, trait)
            self.append_page(newpage, trait)
        self.set_current_page(trait)
Exemplo n.º 4
0
class SuiteTraitCombo(QWidget):
    def __init__(self, app, parent, name='SuiteTraitCombo'):
        QWidget.__init__(self, parent, name)
        dbwidget(self, app)
        self.suiteCursor = Suites(self.conn)
        self.suites = self.suiteCursor.list()
        self.traits = Traits(self.conn, self.suites[0])
        self.scombo = SuiteCombo(self, self.suites)
        self.tcombo = MyCombo(self, 'TypeCombo')
        self.tcombo.fill(['template', 'script'])
        self.trcombo = MyCombo(self, 'TraitCombo')
        self.ubutton = KPushButton('update', self)
        self.listView = TraitList(self.app, self)
        self.vbox = QVBoxLayout(self)
        for member in ['listView', 'scombo', 'tcombo', 'trcombo', 'ubutton']:
            widget = getattr(self, member)
            self.vbox.addWidget(widget)
        self.connect(self.scombo,
                     SIGNAL('highlighted(int)'), self.update_traits)
        self.connect(self.ubutton,
                     SIGNAL('clicked()'), self.refreshlistView)
        

    def update_traits(self):
        suite = str(self.scombo.currentText())
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        self.listView.ftype = str(self.tcombo.currentText())
        
    def refreshlistView(self):
        trait = str(self.trcombo.currentText())
        if trait:
            self.listView.set_trait(trait)
        self.listView.ftype = str(self.tcombo.currentText())
        suite = str(self.scombo.currentText())
        self.listView.set_suite(suite)
        self.traits.set_suite(suite)
        traits = [row.trait for row in self.traits.select()]
        self.trcombo.fill(traits)
        if trait in traits:
            self.trcombo.setCurrentItem(traits.index(trait))
        self.listView.refreshlistView()

    def getData(self):
        return self.listView.getData()

    def updateData(self, data):
        self.listView.updateData(data)
Exemplo n.º 5
0
class TraitScriptBrowser(ListNoteBook):
    def __init__(self, conn, suite):
        self.conn = conn
        self.suite = suite
        self.traits = Traits(self.conn, self.suite)
        rows = self.traits.select(table='scriptnames')
        self._scriptnames = [r.script for r in rows]
        self.edit_menu = make_menu(self._scriptnames, self.modify_trait, name='edit')
        self.diff_menu = make_menu(self._scriptnames, self.modify_trait, name='diff')
        self.menu = make_menu(['edit', 'diff'], self.edit_menu)
        self.menu['edit'].set_submenu(self.edit_menu)
        self.menu['diff'].set_submenu(self.diff_menu)
        ListNoteBook.__init__(self)
        self.reset_rows()

    def modify_trait(self, menuitem, action):
        parent = menuitem.get_parent()
        command = parent.get_name()
        rows = self.get_selected_data()
        if len(rows):
            trait = rows[0].trait
            print action, trait
            if command == 'edit':
                if action not in self.pages[trait].pages:
                    self.pages[trait].new_script(action)
                else:
                    self.pages[trait].edit_script(None, action, None)
            elif command == 'diff':
                print 'diff', action
                AllScriptsDialog('which script?', self.conn, self.suite)
            
        else:
            dialogs.Message('select a trait first')

    def reset_rows(self):
        rows = self.traits.select(fields=['trait'])
        self.set_rows(rows)
        self.set_row_select(self.trait_selected)

    def trait_selected(self, listbox, row, column, event):
        trait = listbox.get_selected_data()[0].trait
        self.select_trait(trait)

    def select_trait(self, trait):
        if trait not in self.pages:
            newpage = ScriptNotebook(self.conn, self.suite, trait)
            self.append_page(newpage, trait)
        self.set_current_page(trait)
Exemplo n.º 6
0
class SuiteTraitCombo(QWidget):
    def __init__(self, app, parent, name='SuiteTraitCombo'):
        QWidget.__init__(self, parent, name)
        dbwidget(self, app)
        self.suiteCursor = Suites(self.conn)
        self.suites = self.suiteCursor.list()
        self.traits = Traits(self.conn, self.suites[0])
        self.scombo = SuiteCombo(self, self.suites)
        self.tcombo = MyCombo(self, 'TypeCombo')
        self.tcombo.fill(['template', 'script'])
        self.trcombo = MyCombo(self, 'TraitCombo')
        self.ubutton = KPushButton('update', self)
        self.listView = TraitList(self.app, self)
        self.vbox = QVBoxLayout(self)
        for member in ['listView', 'scombo', 'tcombo', 'trcombo', 'ubutton']:
            widget = getattr(self, member)
            self.vbox.addWidget(widget)
        self.connect(self.scombo, SIGNAL('highlighted(int)'),
                     self.update_traits)
        self.connect(self.ubutton, SIGNAL('clicked()'), self.refreshlistView)

    def update_traits(self):
        suite = str(self.scombo.currentText())
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        self.listView.ftype = str(self.tcombo.currentText())

    def refreshlistView(self):
        trait = str(self.trcombo.currentText())
        if trait:
            self.listView.set_trait(trait)
        self.listView.ftype = str(self.tcombo.currentText())
        suite = str(self.scombo.currentText())
        self.listView.set_suite(suite)
        self.traits.set_suite(suite)
        traits = [row.trait for row in self.traits.select()]
        self.trcombo.fill(traits)
        if trait in traits:
            self.trcombo.setCurrentItem(traits.index(trait))
        self.listView.refreshlistView()

    def getData(self):
        return self.listView.getData()

    def updateData(self, data):
        self.listView.updateData(data)
Exemplo n.º 7
0
 def __init__(self, conn, suite):
     self.conn = conn
     self.suite = suite
     self.traits = Traits(self.conn, self.suite)
     rows = self.traits.select(table='scriptnames')
     self._scriptnames = [r.script for r in rows]
     self.edit_menu = make_menu(self._scriptnames,
                                self.modify_trait,
                                name='edit')
     self.diff_menu = make_menu(self._scriptnames,
                                self.modify_trait,
                                name='diff')
     self.menu = make_menu(['edit', 'diff'], self.edit_menu)
     self.menu['edit'].set_submenu(self.edit_menu)
     self.menu['diff'].set_submenu(self.diff_menu)
     ListNoteBook.__init__(self)
     self.reset_rows()
Exemplo n.º 8
0
 def __init__(self, app, parent, name='SuiteTraitCombo'):
     QWidget.__init__(self, parent, name)
     dbwidget(self, app)
     self.suiteCursor = Suites(self.conn)
     self.suites = self.suiteCursor.list()
     self.traits = Traits(self.conn, self.suites[0])
     self.scombo = SuiteCombo(self, self.suites)
     self.tcombo = MyCombo(self, 'TypeCombo')
     self.tcombo.fill(['template', 'script'])
     self.trcombo = MyCombo(self, 'TraitCombo')
     self.ubutton = KPushButton('update', self)
     self.listView = TraitList(self.app, self)
     self.vbox = QVBoxLayout(self)
     for member in ['listView', 'scombo', 'tcombo', 'trcombo', 'ubutton']:
         widget = getattr(self, member)
         self.vbox.addWidget(widget)
     self.connect(self.scombo, SIGNAL('highlighted(int)'),
                  self.update_traits)
     self.connect(self.ubutton, SIGNAL('clicked()'), self.refreshlistView)
Exemplo n.º 9
0
 def __init__(self, conn, suite):
     self.conn = conn
     self.suite = suite
     self.traits = Traits(self.conn, self.suite)
     self.edit_menu = make_menu(SCRIPTS, self.modify_trait, name='edit')
     self.diff_menu = make_menu(SCRIPTS, self.modify_trait, name='diff')
     self.menu = make_menu(['edit', 'diff'], self.edit_menu)
     self.menu['edit'].set_submenu(self.edit_menu)
     self.menu['diff'].set_submenu(self.diff_menu)
     ListNoteBook.__init__(self)
     self.reset_rows()
Exemplo n.º 10
0
 def __init__(self, conn, suite):
     self.conn = conn
     self.suite = suite
     self.traits = Traits(self.conn, self.suite)
     rows = self.traits.select(table='scriptnames')
     self._scriptnames = [r.script for r in rows]
     self.edit_menu = make_menu(self._scriptnames, self.modify_trait, name='edit')
     self.diff_menu = make_menu(self._scriptnames, self.modify_trait, name='diff')
     self.menu = make_menu(['edit', 'diff'], self.edit_menu)
     self.menu['edit'].set_submenu(self.edit_menu)
     self.menu['diff'].set_submenu(self.diff_menu)
     ListNoteBook.__init__(self)
     self.reset_rows()
Exemplo n.º 11
0
 def __init__(self, app, parent, name='SuiteTraitCombo'):
     QWidget.__init__(self, parent, name)
     dbwidget(self, app)
     self.suiteCursor = Suites(self.conn)
     self.suites = self.suiteCursor.list()
     self.traits = Traits(self.conn, self.suites[0])
     self.scombo = SuiteCombo(self, self.suites)
     self.tcombo = MyCombo(self, 'TypeCombo')
     self.tcombo.fill(['template', 'script'])
     self.trcombo = MyCombo(self, 'TraitCombo')
     self.ubutton = KPushButton('update', self)
     self.listView = TraitList(self.app, self)
     self.vbox = QVBoxLayout(self)
     for member in ['listView', 'scombo', 'tcombo', 'trcombo', 'ubutton']:
         widget = getattr(self, member)
         self.vbox.addWidget(widget)
     self.connect(self.scombo,
                  SIGNAL('highlighted(int)'), self.update_traits)
     self.connect(self.ubutton,
                  SIGNAL('clicked()'), self.refreshlistView)
Exemplo n.º 12
0
 def __init__(self, parent, name='SuiteTraitComboBox'):
     QFrame.__init__(self, parent, name)
     self.app = get_application_pointer()
     self.conn = self.app.conn
     self.suiteCursor = Suites(self.conn)
     self.suites = self.suiteCursor.list()
     self.traits = Traits(self.conn, self.suites[0])
     self.scombo = KComboBox(self, 'SuiteComboBox')
     self.scombo.insertStrList(self.suites)
     self.tcombo = KComboBox(self, 'TypeComboBox')
     self.tcombo.insertStrList(['template', 'script'])
     self.trcombo = KComboBox(self, 'TraitComboBox')
     self.update_btn = KPushButton('update', self)
     self.listView = TraitListView(self)
     self.vbox = QVBoxLayout(self)
     for attribute in ['listView', 'scombo', 'tcombo', 'trcombo', 'update_btn']:
         widget = getattr(self, attribute)
         self.vbox.addWidget(widget)
     # we need to redo the signals and the methods that are called
     self.connect(self.scombo,
                  SIGNAL('activated(int)'), self.update_traits)
     
     self.connect(self.update_btn,
                  SIGNAL('clicked()'), self.refreshlistView)
Exemplo n.º 13
0
 def set_suite(self, suite):
     self.scripts = TraitScript(self.conn, suite)
     self.templates = TraitTemplate(self.conn, suite)
     self.traits = Traits(self.conn, suite)
Exemplo n.º 14
0
class TraitListView(KListView):
    def __init__(self, parent, file_type='template', name='TraitListView'):
        KListView.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.file_type = file_type
        self.scripts = None
        self.templates = None
        self.traits = None
        self.trait = None
        self.setRootIsDecorated(True)
        self.addColumn('trait/file')
        self.addColumn('name')
        self.addColumn('package')

    def set_suite(self, suite):
        self.scripts = TraitScript(self.conn, suite)
        self.templates = TraitTemplate(self.conn, suite)
        self.traits = Traits(self.conn, suite)

    def set_trait(self, trait):
        self.trait = trait

    def refreshlistView(self):
        self.clear()
        self.setColumnText(1, self.file_type)
        if self.trait is None:
            traits = self.traits.list()
        else:
            traits = [self.trait]
        for trait in traits:
            item = KListViewItem(self, trait)
            item.trait = trait
            # expand tree by default
            item.setOpen(True)
            if self.file_type == 'template':
                for row in self.templates.templates(trait):
                    template_item = KListViewItem(item, str(row.templatefile),
                                                  row.template)
                    template_item.trait = trait
                    template_item.row = row
            elif self.file_type == 'script':
                # perhaps we need to make a method to obtain scriptnames
                # in TraitScript object
                for row in self.scripts.cmd.select(clause=Eq('trait', trait), order='script'):
                    script_item = KListViewItem(item, str(row.scriptfile), row.script)
                    script_item.trait = trait
                    script_item.row = row
            else:
                raise ValueError, "unknown file_type %s" % self.file_type

    # get template or script contents
    def getData(self):
        item = self.currentItem()
        if self.file_type == 'template':
            self.templates.set_trait(item.trait)
            return self.templates.templatedata(item.row.template)
        elif self.file_type == 'script':
            self.scripts.set_trait(item.trait)
            return self.scripts.scriptdata(item.row.script)
        else:
            raise ValueError, "unknown file_type %s" % self.file_type

    # replace template or script contents
    def updateData(self, data):
        item = self.currentItem()
        row = item.row
        if self.file_type == 'template':
            self.templates.set_trait(item.trait)
            self.templates.update_template(row.template, contents=data)
        elif self.file_type == 'script':
            self.scripts.set_trait(item.trait)
            self.scripts.update_scriptdata(row.script, data)
        else:
            raise ValueError, "unknown file_type %s" % self.file_type
Exemplo n.º 15
0
class SuiteTraitComboBox(QFrame):
    def __init__(self, parent, name='SuiteTraitComboBox'):
        QFrame.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.suiteCursor = Suites(self.conn)
        self.suites = self.suiteCursor.list()
        self.traits = Traits(self.conn, self.suites[0])
        self.scombo = KComboBox(self, 'SuiteComboBox')
        self.scombo.insertStrList(self.suites)
        self.tcombo = KComboBox(self, 'TypeComboBox')
        self.tcombo.insertStrList(['template', 'script'])
        self.trcombo = KComboBox(self, 'TraitComboBox')
        self.update_btn = KPushButton('update', self)
        self.listView = TraitListView(self)
        self.vbox = QVBoxLayout(self)
        for attribute in ['listView', 'scombo', 'tcombo', 'trcombo', 'update_btn']:
            widget = getattr(self, attribute)
            self.vbox.addWidget(widget)
        # we need to redo the signals and the methods that are called
        self.connect(self.scombo,
                     SIGNAL('activated(int)'), self.update_traits)
        
        self.connect(self.update_btn,
                     SIGNAL('clicked()'), self.refreshlistView)

    def update_traits(self, suite_index):
        suite = self.suites[suite_index]
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        self.listView.file_type = str(self.tcombo.currentText())
        self._update_traits_combobox()
        

    def _update_traits_combobox(self):
        traits = [row.trait for row in self.traits.select()]
        traits.sort()
        self.trcombo.clear()
        self.trcombo.insertStrList(traits)
        return traits
    
    def refreshlistView(self):
        trait = str(self.trcombo.currentText())
        if trait:
            self.listView.set_trait(trait)
        self.listView.file_type = str(self.tcombo.currentText())
        suite = str(self.scombo.currentText())
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        traits = self._update_traits_combobox()
        if trait in traits:
            self.trcombo.setCurrentItem(traits.index(trait))
        self.listView.refreshlistView()

    # returns template or script contents
    def getData(self):
        return self.listView.getData()

    # replace template or script contents
    def updateData(self, data):
        self.listView.updateData(data)
Exemplo n.º 16
0
class SuiteTraitComboBox(QFrame):
    def __init__(self, parent, name='SuiteTraitComboBox'):
        QFrame.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.suiteCursor = Suites(self.conn)
        self.suites = self.suiteCursor.list()
        self.traits = Traits(self.conn, self.suites[0])
        self.scombo = KComboBox(self, 'SuiteComboBox')
        self.scombo.insertStrList(self.suites)
        self.tcombo = KComboBox(self, 'TypeComboBox')
        self.tcombo.insertStrList(['template', 'script'])
        self.trcombo = KComboBox(self, 'TraitComboBox')
        self.update_btn = KPushButton('update', self)
        self.listView = TraitListView(self)
        self.vbox = QVBoxLayout(self)
        for attribute in [
                'listView', 'scombo', 'tcombo', 'trcombo', 'update_btn'
        ]:
            widget = getattr(self, attribute)
            self.vbox.addWidget(widget)
        # we need to redo the signals and the methods that are called
        self.connect(self.scombo, SIGNAL('activated(int)'), self.update_traits)

        self.connect(self.update_btn, SIGNAL('clicked()'),
                     self.refreshlistView)

    def update_traits(self, suite_index):
        suite = self.suites[suite_index]
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        self.listView.file_type = str(self.tcombo.currentText())
        self._update_traits_combobox()

    def _update_traits_combobox(self):
        traits = [row.trait for row in self.traits.select()]
        traits.sort()
        self.trcombo.clear()
        self.trcombo.insertStrList(traits)
        return traits

    def refreshlistView(self):
        trait = str(self.trcombo.currentText())
        if trait:
            self.listView.set_trait(trait)
        self.listView.file_type = str(self.tcombo.currentText())
        suite = str(self.scombo.currentText())
        self.traits.set_suite(suite)
        self.listView.set_suite(suite)
        traits = self._update_traits_combobox()
        if trait in traits:
            self.trcombo.setCurrentItem(traits.index(trait))
        self.listView.refreshlistView()

    # returns template or script contents
    def getData(self):
        return self.listView.getData()

    # replace template or script contents
    def updateData(self, data):
        self.listView.updateData(data)
Exemplo n.º 17
0
class TraitListView(KListView):
    def __init__(self, parent, file_type='template', name='TraitListView'):
        KListView.__init__(self, parent, name)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.file_type = file_type
        self.scripts = None
        self.templates = None
        self.traits = None
        self.trait = None
        self.setRootIsDecorated(True)
        self.addColumn('trait/file')
        self.addColumn('name')
        self.addColumn('package')

    def set_suite(self, suite):
        self.scripts = TraitScript(self.conn, suite)
        self.templates = TraitTemplate(self.conn, suite)
        self.traits = Traits(self.conn, suite)

    def set_trait(self, trait):
        self.trait = trait

    def refreshlistView(self):
        self.clear()
        self.setColumnText(1, self.file_type)
        if self.trait is None:
            traits = self.traits.list()
        else:
            traits = [self.trait]
        for trait in traits:
            item = KListViewItem(self, trait)
            item.trait = trait
            # expand tree by default
            item.setOpen(True)
            if self.file_type == 'template':
                for row in self.templates.templates(trait):
                    template_item = KListViewItem(item, str(row.templatefile),
                                                  row.template)
                    template_item.trait = trait
                    template_item.row = row
            elif self.file_type == 'script':
                # perhaps we need to make a method to obtain scriptnames
                # in TraitScript object
                for row in self.scripts.cmd.select(clause=Eq('trait', trait),
                                                   order='script'):
                    script_item = KListViewItem(item, str(row.scriptfile),
                                                row.script)
                    script_item.trait = trait
                    script_item.row = row
            else:
                raise ValueError, "unknown file_type %s" % self.file_type

    # get template or script contents
    def getData(self):
        item = self.currentItem()
        if self.file_type == 'template':
            self.templates.set_trait(item.trait)
            return self.templates.templatedata(item.row.template)
        elif self.file_type == 'script':
            self.scripts.set_trait(item.trait)
            return self.scripts.scriptdata(item.row.script)
        else:
            raise ValueError, "unknown file_type %s" % self.file_type

    # replace template or script contents
    def updateData(self, data):
        item = self.currentItem()
        row = item.row
        if self.file_type == 'template':
            self.templates.set_trait(item.trait)
            self.templates.update_template(row.template, contents=data)
        elif self.file_type == 'script':
            self.scripts.set_trait(item.trait)
            self.scripts.update_scriptdata(row.script, data)
        else:
            raise ValueError, "unknown file_type %s" % self.file_type
Exemplo n.º 18
0
class TraitList(KListView):
    def __init__(self, app, parent, ftype='template', name='TraitList'):
        KListView.__init__(self, parent, name)
        dbwidget(self, app)
        self.ftype = ftype
        self.scripts = None
        self.templates = None
        self.traits = None
        self.trait = None
        self.setRootIsDecorated(True)
        self.addColumn('trait/file')
        self.addColumn('name')
        self.addColumn('package')

    def set_suite(self, suite):
        self.scripts = TraitScript(self.conn, suite)
        self.templates = TraitTemplate(self.conn, suite)
        self.traits = Traits(self.conn, suite)

    def set_trait(self, trait):
        self.trait = trait

    def refreshlistView(self):
        self.clear()
        if self.ftype == 'template':
            self.setColumnText(1, 'template')
        elif self.ftype == 'script':
            self.setColumnText(1, 'script')
        if self.trait is None:
            traits = self.traits.list()
        else:
            traits = [self.trait]
        for trait in traits:
            item = KListViewItem(self, trait)
            item.trait = trait
            if self.ftype == 'template':
                for row in self.templates.templates(trait):
                    titem = KListViewItem(item, str(row.templatefile),
                                          row.template, row.package)
                    titem.trait = trait
                    titem.row = row
            elif self.ftype == 'script':
                for row in self.scripts.cmd.select(clause=Eq('trait', trait),
                                                   order='script'):
                    sitem = KListViewItem(item, str(row.scriptfile),
                                          row.script)
                    sitem.trait = trait
                    sitem.row = row

    def getData(self):
        item = self.currentItem()
        if self.ftype == 'template':
            self.templates.set_trait(item.trait)
            return self.templates.templatedata(item.row.package,
                                               item.row.template)
        elif self.ftype == 'script':
            self.scripts.set_trait(item.trait)
            return self.scripts.scriptdata(item.row.script)

    def updateData(self, data):
        item = self.currentItem()
        row = item.row
        if self.ftype == 'template':
            self.templates.set_trait(item.trait)
            self.templates.update_templatedata(row.package, row.template, data)
        elif self.ftype == 'script':
            self.scripts.set_trait(item.trait)
            self.scripts.update_scriptdata(row.script, data)
Exemplo n.º 19
0
 def set_suite(self, suite):
     self.scripts = TraitScript(self.conn, suite)
     self.templates = TraitTemplate(self.conn, suite)
     self.traits = Traits(self.conn, suite)
Exemplo n.º 20
0
class TraitList(KListView):
    def __init__(self, app, parent, ftype='template', name='TraitList'):
        KListView.__init__(self, parent, name)
        dbwidget(self, app)
        self.ftype = ftype
        self.scripts = None
        self.templates = None
        self.traits = None
        self.trait = None
        self.setRootIsDecorated(True)
        self.addColumn('trait/file')
        self.addColumn('name')
        self.addColumn('package')
        
    def set_suite(self, suite):
        self.scripts = TraitScript(self.conn, suite)
        self.templates = TraitTemplate(self.conn, suite)
        self.traits = Traits(self.conn, suite)
        

    def set_trait(self, trait):
        self.trait = trait
        
    def refreshlistView(self):
        self.clear()
        if self.ftype == 'template':
            self.setColumnText(1, 'template')
        elif self.ftype == 'script':
            self.setColumnText(1, 'script')
        if self.trait is None:
            traits = self.traits.list()
        else:
            traits = [self.trait]
        for trait in traits:
            item = KListViewItem(self, trait)
            item.trait = trait
            if self.ftype == 'template':
                for row in self.templates.templates(trait):
                    titem = KListViewItem(item, str(row.templatefile), row.template, row.package)
                    titem.trait = trait
                    titem.row = row
            elif self.ftype == 'script':
                for row in self.scripts.cmd.select(clause=Eq('trait', trait), order='script'):
                    sitem = KListViewItem(item, str(row.scriptfile), row.script)
                    sitem.trait = trait
                    sitem.row = row
                    
    def getData(self):
        item = self.currentItem()
        if self.ftype == 'template':
            self.templates.set_trait(item.trait)
            return self.templates.templatedata(item.row.package, item.row.template)
        elif self.ftype == 'script':
            self.scripts.set_trait(item.trait)
            return self.scripts.scriptdata(item.row.script)

    def updateData(self, data):
        item = self.currentItem()
        row = item.row
        if self.ftype == 'template':
            self.templates.set_trait(item.trait)
            self.templates.update_templatedata(row.package, row.template, data)
        elif self.ftype == 'script':
            self.scripts.set_trait(item.trait)
            self.scripts.update_scriptdata(row.script, data)