Example #1
0
class FamilyAssigner(BaseAssigner):
    def __init__(self, parent, profile):
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.profile = Profile(self.conn)
        self.profile.set_profile(profile)
        BaseAssigner.__init__(self, parent, name="FamilyAssigner", udbuttons=True)
        self.connect(self, SIGNAL("okClicked()"), self.slotInsertNewFamilies)

    def initView(self):
        self.suite = self.profile.current.suite
        self.family = Family(self.conn)
        all_fams = self.family.all_families()
        pfams = self.profile.get_families()
        fams = [f for f in all_fams if f not in pfams]
        abox = self.listBox.availableListBox()
        sbox = self.listBox.selectedListBox()
        for family in pfams:
            self._add_family_to_listbox(sbox, family)
        for family in fams:
            self._add_family_to_listbox(abox, family)

    def _add_family_to_listbox(self, box, family):
        r = QListBoxText(box, family)
        r.family = family

    def slotInsertNewFamilies(self):
        sbox = self.listBox.selectedListBox()
        families = [str(sbox.item(n).text()) for n in range(sbox.numRows())]
        self.profile.delete_all_families()
        for family in families:
            self.profile.append_family(family)
Example #2
0
class FamilyAssigner(BaseAssigner):
    def __init__(self, parent, profile):
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.profile = Profile(self.conn)
        self.profile.set_profile(profile)
        BaseAssigner.__init__(self, parent, name='FamilyAssigner',
                              udbuttons=True)
        self.connect(self, SIGNAL('okClicked()'), self.slotInsertNewFamilies)

    def initView(self):
        self.suite = self.profile.current.suite
        self.family = Family(self.conn)
        all_fams = self.family.all_families()
        pfams = self.profile.get_families()
        fams = [f for f in all_fams if f not in pfams]
        abox = self.listBox.availableListBox()
        sbox = self.listBox.selectedListBox()
        for family in pfams:
            self._add_family_to_listbox(sbox, family)
        for family in fams:
            self._add_family_to_listbox(abox, family)
            

    def _add_family_to_listbox(self, box, family):
        r = QListBoxText(box, family)
        r.family = family

    def slotInsertNewFamilies(self):
        sbox = self.listBox.selectedListBox()
        families =[str(sbox.item(n).text()) for n in range(sbox.numRows())]
        self.profile.delete_all_families()
        for family in families:
            self.profile.append_family(family)
Example #3
0
class FamilyParentAssigner(BaseAssigner):
    def __init__(self, parent, family):
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.family = Family(self.conn)
        self.family.set_family(family)
        BaseAssigner.__init__(self, parent, name='FamilyParentAssigner',
                              udbuttons=False)
        self.connect(self, SIGNAL('okClicked()'), self.slotAssignParents)

    def initView(self):
        family = self.family.current
        all_fams = self.family.all_families()
        assigned_parents = self.family.parents()
        avail_parents = [f for f in all_fams if f not in assigned_parents + [family]]
        abox = self.listBox.availableListBox()
        sbox = self.listBox.selectedListBox()
        for family in assigned_parents:
            self._add_family_to_listbox(sbox, family)
        for family in avail_parents:
            self._add_family_to_listbox(abox, family)
        self.already_assigned = assigned_parents
        
    def _add_family_to_listbox(self, box, family):
        item = QListBoxText(box, family)
        item.family = family

    def slotAssignParents(self):
        sbox = self.listBox.selectedListBox()
        families =[str(sbox.item(n).text()) for n in range(sbox.numRows())]
        # since we're using a SimpleRelation class for
        # family.parents, we don't need to worry about
        # inserting families that are already there
        self.family.delete_parents()
        self.family.insert_parents(families)
Example #4
0
class FamilyParentAssigner(BaseAssigner):
    def __init__(self, parent, family):
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.family = Family(self.conn)
        self.family.set_family(family)
        BaseAssigner.__init__(self,
                              parent,
                              name='FamilyParentAssigner',
                              udbuttons=False)
        self.connect(self, SIGNAL('okClicked()'), self.slotAssignParents)

    def initView(self):
        family = self.family.current
        all_fams = self.family.all_families()
        assigned_parents = self.family.parents()
        avail_parents = [
            f for f in all_fams if f not in assigned_parents + [family]
        ]
        abox = self.listBox.availableListBox()
        sbox = self.listBox.selectedListBox()
        for family in assigned_parents:
            self._add_family_to_listbox(sbox, family)
        for family in avail_parents:
            self._add_family_to_listbox(abox, family)
        self.already_assigned = assigned_parents

    def _add_family_to_listbox(self, box, family):
        item = QListBoxText(box, family)
        item.family = family

    def slotAssignParents(self):
        sbox = self.listBox.selectedListBox()
        families = [str(sbox.item(n).text()) for n in range(sbox.numRows())]
        # since we're using a SimpleRelation class for
        # family.parents, we don't need to worry about
        # inserting families that are already there
        self.family.delete_parents()
        self.family.insert_parents(families)
Example #5
0
class FamilyMainWindow(SimpleSplitWindow):
    def __init__(self, app, parent):
        SimpleSplitWindow.__init__(self, app, parent, FamilyView, 'FamilyMainWindow')
        self.app = app
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.conn = app.conn
        self.cfg = app.cfg
        self.cursor = StatementCursor(self.conn)
        self.family = Family(self.conn)
        self.refreshListView()
        self.resize(600, 800)
        self.setCaption('paella families')
        
    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newFamilyAction = KStdAction.openNew(self.newFamily, collection)
        
    def initMenus(self):
        mainMenu = KPopupMenu(self)
        menus = [mainMenu]
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))
        self.newFamilyAction.plug(mainMenu)
        self.quitAction.plug(mainMenu)
        
    def initToolbar(self):
        toolbar = self.toolBar()
        self.newFamilyAction.plug(toolbar)
        self.quitAction.plug(toolbar)
        
    def initlistView(self):
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('group')
        
    def refreshListView(self):
        self.listView.clear()
        for row in self.family.family_rows():
            item = KListViewItem(self.listView, row.family)
            item.family = row.family

    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'family'):
            self.view.set_family(current.family)
        if hasattr(current, 'trait'):
            print 'trait is', current.trait
            self.view.set_trait(current.trait)
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            if hasattr(current, 'widget'):
                print 'widget is', current.widget

    def newFamily(self):
        dialog = SimpleRecordDialog(self, ['family'])
        dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewFamily)
        self._dialog = dialog

    def insertNewFamily(self):
        dialog = self._dialog
        data = dialog.getRecordData()
        family = data['family']
        if family not in self.family.all_families():
            self.family.create_family(family)
        else:
            KMessageBox.information(self, '%s already exists.' % family)
        self.refreshListView()
Example #6
0
class FamilyMainWindow(SimpleSplitWindow):
    def __init__(self, app, parent):
        SimpleSplitWindow.__init__(self, app, parent, FamilyView,
                                   'FamilyMainWindow')
        self.app = app
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.conn = app.conn
        self.cfg = app.cfg
        self.cursor = StatementCursor(self.conn)
        self.family = Family(self.conn)
        self.refreshListView()
        self.resize(600, 800)
        self.setCaption('paella families')

    def initActions(self):
        collection = self.actionCollection()
        self.quitAction = KStdAction.quit(self.close, collection)
        self.newFamilyAction = KStdAction.openNew(self.newFamily, collection)

    def initMenus(self):
        mainMenu = KPopupMenu(self)
        menus = [mainMenu]
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))
        self.newFamilyAction.plug(mainMenu)
        self.quitAction.plug(mainMenu)

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newFamilyAction.plug(toolbar)
        self.quitAction.plug(toolbar)

    def initlistView(self):
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('group')

    def refreshListView(self):
        self.listView.clear()
        for row in self.family.family_rows():
            item = KListViewItem(self.listView, row.family)
            item.family = row.family

    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'family'):
            self.view.set_family(current.family)
        if hasattr(current, 'trait'):
            print 'trait is', current.trait
            self.view.set_trait(current.trait)
        if hasattr(current, 'suite'):
            print 'suite is', current.suite
            if hasattr(current, 'widget'):
                print 'widget is', current.widget

    def newFamily(self):
        dialog = SimpleRecordDialog(self, ['family'])
        dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewFamily)
        self._dialog = dialog

    def insertNewFamily(self):
        dialog = self._dialog
        data = dialog.getRecordData()
        family = data['family']
        if family not in self.family.all_families():
            self.family.create_family(family)
        else:
            KMessageBox.information(self, '%s already exists.' % family)
        self.refreshListView()