def readItemNode(self): """ readItemNode() -> read a pickle into the items node object """ filename = kfile.KFileDialog.getOpenFileName('', '*', self) filename = str(filename) if not filename: return item = self.context itemkey = str(item.text(0)) parent = item.parent() if not parent: return parentnodey = parent.node if hasattr(parentnodey, itemkey): ## the parent node has the context label as an attribute ## open and load the file onto that try: graft_node = tools.load_object(filename) except (Exception, ), ex: #self.displayException('Error opening item', ex) util.displayException(self, 'Error opening item', ex) return else: setattr(parentnodey, itemkey, graft_node) parent.setOpen(False)
def saveItemNode(self): """ saveItemNode() -> save an items node to a file """ dlg = kfile.KFileDialog('', '*', None, 'Save As', True) if dlg.exec_loop() == kfile.KFileDialog.Accepted: filename = '%s' % dlg.selectedFile() else: return try: tools.save_object(self.context.node, filename) except (Exception, ), ex: util.displayException(self, 'Error saving item', ex)
def newSession(self): """ newSession() -> slot for new session construction This is where the new session is actually created. A separate signal is then emitted from this slot. """ params = {} params['connection_builder'] = link.QIbSocketReader.build config = util.appConfig(util.groups.session) for (bkey, ckey) in configdialog.sessionBuilderKeys: value = '%s' % config.readEntry(ckey, '') if value: params[bkey] = value try: sess = session.Session(**params) except (Exception, ), ex: import traceback traceback.print_exc() print >> sys.__stdout__, ex util.displayException(self, 'Problem building session object', ex) sess = {}
def newSession(self): """ newSession() -> slot for new session construction This is where the new session is actually created. A separate signal is then emitted from this slot. """ params = {} params["connection_builder"] = link.QIbSocketReader.build config = util.appConfig(util.groups.session) for (bkey, ckey) in configdialog.sessionBuilderKeys: value = "%s" % config.readEntry(ckey, "") if value: params[bkey] = value try: sess = session.Session(**params) except (Exception,), ex: import traceback traceback.print_exc() print >>sys.__stdout__, ex util.displayException(self, "Problem building session object", ex) sess = {}
parentnodey = parent.node if hasattr(parentnodey, itemkey): ## the parent node has the context label as an attribute ## open and load the file onto that try: graft_node = tools.load_object(filename) except (Exception, ), ex: #self.displayException('Error opening item', ex) util.displayException(self, 'Error opening item', ex) return else: setattr(parentnodey, itemkey, graft_node) parent.setOpen(False) elif isinstance(item, (tuple, list, )): util.displayException(self, 'Cannot read file into this item', '') else: try: parentnodey[itemkey] = tools.load_object(filename) except (Exception, ), ex: util.displayException(self, 'Error opening item', ex) else: parent.setOpen(False) def contentsMouseDoubleClickEvent(self, event): """ This probably breaks some kde/qt ui standard because the list view items are *not* expanded. I just can't stand this list opening its items on a double click, so the event is sunk here and a signal is emitted just the same.
## the parent node has the context label as an attribute ## open and load the file onto that try: graft_node = tools.load_object(filename) except (Exception, ), ex: #self.displayException('Error opening item', ex) util.displayException(self, 'Error opening item', ex) return else: setattr(parentnodey, itemkey, graft_node) parent.setOpen(False) elif isinstance(item, ( tuple, list, )): util.displayException(self, 'Cannot read file into this item', '') else: try: parentnodey[itemkey] = tools.load_object(filename) except (Exception, ), ex: util.displayException(self, 'Error opening item', ex) else: parent.setOpen(False) def contentsMouseDoubleClickEvent(self, event): """ This probably breaks some kde/qt ui standard because the list view items are *not* expanded. I just can't stand this list opening its items on a double click, so the event is sunk here and a signal is emitted just the same.