Exemplo n.º 1
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.º 2
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.º 3
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.º 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 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.º 6
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)