def handleInitialHash(self, pathList, params): assert self.canHandleInitialHash(pathList, params) if pathList[1] == "list": wdg = displayDelegateSelector.select(self.moduleName, self.moduleInfo) assert wdg is not None, "Got no handler for %s" % self.moduleName self.addWidget(wdg(self.moduleName)) self.focus() elif pathList[1] in ["edit", "clone"] and len(pathList) > 3: pane = Pane(translate("Edit"), closeable=True, iconClasses=[ "module_%s" % self.moduleName, "apptype_tree", "action_edit" ]) edwg = EditWidget(self.moduleName, EditWidget.appTree, key=pathList[3], skelType=pathList[2], hashArgs=(params or None), clone=pathList[1] == "clone") pane.addWidget(edwg) conf["mainWindow"].addPane(pane, parentPane=self) pane.focus()
def openEditor(self, key): pane = Pane(translate("Clone"), closeable=True, iconClasses=["modul_%s" % self.parent().parent().module, "apptype_list", "action_edit" ]) conf["mainWindow"].stackPane( pane ) edwg = EditWidget(self.parent().parent().module, EditWidget.appList, key=key, clone=True, context=self.parent().parent().context) pane.addWidget( edwg ) pane.focus()
def openEditor(self, key): pane = Pane(translate("Recurrent Events"), closeable=True, iconClasses=[ "modul_%s" % self.parent().parent().module, "apptype_list", "action_edit" ]) conf["mainWindow"].stackPane(pane) edwg = RepeatDatePopup(self.parent().parent().module, key=key) pane.addWidget(edwg) pane.focus()
def handleInitialHash(self, pathList, params): assert self.canHandleInitialHash(pathList, params) if pathList[1] == "list": self.addWidget(HierarchyWidget(self.moduleName)) self.focus() elif pathList[1] in ["edit", "clone"] and len(pathList) > 2: pane = Pane(translate("Edit"), closeable=True, iconClasses=["module_%s" % self.moduleName, "apptype_hierarchy", "action_edit"]) edwg = EditWidget(self.moduleName, EditWidget.appHierarchy, key=pathList[2], hashArgs=(params or None), clone=pathList[1] == "clone") pane.addWidget(edwg) conf["mainWindow"].addPane(pane, parentPane=self) pane.focus()
def openModule(self, data, title=None): # Have a handler? widgen = moduleHandlerSelector.select(self.contextModule, self.adminInfo) assert widgen # Generate title if title is None: for key in ["name", "title"]: title = data.get(key) if title: if isinstance(title, dict) and conf["currentlanguage"] in title: title = title[conf["currentlanguage"]] break # Merge contexts context = {} context.update(self.widget.context or {}) context.update(self.adminInfo.get("context", {})) # Evaluate context variables for var in self.contextVariables: if "=" in var: key, value = var.split("=", 1) if value[0] == "$": value = data.get(value[1:]) else: key = var value = data.get("key") context[key] = value print(context) widget = widgen(self.contextModule, self.adminInfo, context) if widget: pane = Pane(translate(u"{module} - {name}", module=self.title, name=title), closeable=True, iconURL=self.icon, iconClasses=["module_%s" % self.contextModule]) conf["mainWindow"].stackPane(pane) pane.addWidget(widget) pane.focus() else: print("Widget could not be generated")
def onSelectionActivated(self, table, selection ): if not self.parent().parent().selectMode and len(selection)==1: pane = Pane( translate("Edit"), closeable=True, iconClasses=["modul_%s" % self.parent().parent().module, "apptype_tree", "action_edit" ]) conf["mainWindow"].stackPane( pane ) if isinstance( selection[0], self.parent().parent().nodeWidget): skelType = "node" elif isinstance( selection[0], self.parent().parent().leafWidget): skelType = "leaf" else: raise ValueError("Unknown selection type: %s" % str(type(selection[0]))) edwg = EditWidget( self.parent().parent().module, EditWidget.appTree, key=selection[0].data["key"], skelType=skelType) pane.addWidget( edwg ) pane.focus()
def onClick(self, sender=None): pane = Pane(translate("Add"), closeable=True, iconClasses=[ "modul_%s" % self.parent().parent().module, "apptype_hierarchy", "action_add" ]) conf["mainWindow"].stackPane(pane) edwg = EditWidget(self.parent().parent().module, EditWidget.appHierarchy, node=self.parent().parent().rootNode, context=self.parent().parent().context) pane.addWidget(edwg) pane.focus()
def onClick(self, sender=None): pane = Pane(translate("Add"), closeable=True, iconClasses=[ "module_%s" % self.parent().parent().module, "apptype_tree", "action_add_node" ]) conf["mainWindow"].stackPane(pane) edwg = EditWidget(self.parent().parent().module, EditWidget.appTree, node=self.parent().parent().node, skelType="node") pane.addWidget(edwg) pane.focus()
def onClick(self, sender=None): pane = Pane("Add", closeable=True, iconClasses=[ "module_%s" % self.parent().parent().module, "apptype_tree", "action_add_leaf" ]) conf["mainWindow"].stackPane(pane) edwg = EditWidget(self.parent().parent().module, EditWidget.appTree, node=self.parent().parent().node, skelType="leaf", context={"kind": "link"}) pane.addWidget(edwg) pane.focus()
def onSelectionActivated(self, table, selection): if not self.parent().parent().isSelector and len( selection) == 1 and isinstance( selection[0], self.parent().parent().leafWidget): pane = Pane(translate("Edit"), closeable=True, iconClasses=[ "modul_%s" % self.parent().parent().module, "apptype_tree", "action_edit" ]) conf["mainWindow"].stackPane(pane) skelType = "leaf" edwg = EditWidget(self.parent().parent().module, EditWidget.appTree, key=selection[0].data["key"], skelType=skelType) pane.addWidget(edwg) pane.focus()