Beispiel #1
0
	def openEditor(self, item: Dict[str, Any], clone: bool = False) -> None:
		"""
			Open a new Editor-Widget for the given entity.
			@param item: Entity to open the editor for
			@type item: Dict
			@param clone: Clone the given entry?
			@type clone: Bool
		"""
		myHandler = WidgetHandler.mainWindow.handlerForWidget(self)  # Always stack them as my child
		assert myHandler is not None
		if clone:
			icon = loadIcon("clone")
			if self.list.module in conf.serverConfig["modules"] and "name" in conf.serverConfig["modules"][
				self.list.module]:
				descr = QtCore.QCoreApplication.translate("List", "Clone: %s") % \
				        conf.serverConfig["modules"][self.list.module]["name"]
			else:
				descr = QtCore.QCoreApplication.translate("List", "Clone entry")
		else:
			icon = loadIcon("edit")
			if self.list.module in conf.serverConfig["modules"] and "name" in conf.serverConfig["modules"][
				self.list.module]:
				descr = QtCore.QCoreApplication.translate("List", "Edit: %s") % \
				        conf.serverConfig["modules"][self.list.module]["name"]
			else:
				descr = QtCore.QCoreApplication.translate("List", "Edit entry")
		modul = self.list.module
		key = item["key"]
		handler = WidgetHandler(lambda: EditWidget(modul, ApplicationType.LIST, key, clone=clone), descr, icon)
		handler.mainWindow.addHandler(handler, myHandler)
		handler.focus()
Beispiel #2
0
 def onTriggered(self) -> None:
     name = QtCore.QCoreApplication.translate("TreeHandler",
                                              "Add leaf entry")
     modul = self.parent().tree.module
     node = self.parent().getNode()
     widget = lambda: EditWidget(
         modul, ApplicationType.TREE, node=node, skelType="leaf")
     handler = WidgetHandler(widget, descr=name, icon=loadIcon("add"))
     #event.emit(QtCore.pyqtSignal('stackHandler(PyQt_PyObject)'), handler)
     handler.stackHandler()
Beispiel #3
0
 def onTriggered(self) -> None:
     parent = self.parent()
     for item in parent.hierarchy.selectedItems():
         modul = self.parent().getModul()
         key = item.entryData["key"]
         widget = lambda: EditWidget(modul, ApplicationType.HIERARCHY, key)
         handler = WidgetHandler(widget,
                                 descr=QtCore.QCoreApplication.translate(
                                     "Hierarchy", "Edit entry"),
                                 icon=loadIcon("edit"))
         handler.stackHandler()
Beispiel #4
0
 def listWidgetItemDoubleClicked(self,
                                 item: QtWidgets.QListWidgetItem) -> None:
     if isinstance(item, self.leafItem) and self.editOnDoubleClick:
         descr = QtCore.QCoreApplication.translate("TreeWidget",
                                                   "Edit entry")
         handler = WidgetHandler(
             lambda: EditWidget(self.module, EditWidget.appTree, item.
                                entryData["key"]), descr)
         handler.stackHandler()
     elif isinstance(item, NodeItem):
         self.path.append(item.dirName)
         self.loadData()
Beispiel #5
0
    def onTriggered(self) -> None:
        # config = conf.serverConfig["modules"][ self.parent().module ]
        modul = self.parent().getModul()
        node = self.parent().hierarchy.rootNode

        def widgetFactory() -> EditWidget:
            return EditWidget(modul, ApplicationType.HIERARCHY, node=node)

        handler = WidgetHandler(widgetFactory,
                                descr=QtCore.QCoreApplication.translate(
                                    "Hierarchy", "Add entry"),
                                icon=loadIcon("add"))
        handler.stackHandler()
Beispiel #6
0
 def onTriggered(self) -> None:
     name = QtCore.QCoreApplication.translate("TreeHandler", "Edit entry")
     nodes = []
     leafs = []
     for item in self.parent().selectedItems():
         if isinstance(item, self.parent().getLeafItemClass()):
             leafs.append(item.entryData)
         else:
             nodes.append(item.entryData)
     for entry in leafs:
         skelType = "leaf"
         modul = self.parent().module
         key = entry["key"]
         widget = lambda: EditWidget(
             modul, ApplicationType.TREE, key, skelType=skelType)
         handler = WidgetHandler(widget, descr=name, icon=loadIcon("edit"))
         handler.stackHandler()
     for entry in nodes:
         skelType = "node"
         modul = self.parent().module
         key = entry["key"]
         widget = lambda: EditWidget(
             modul, ApplicationType.TREE, key, skelType=skelType)
         handler = WidgetHandler(widget, descr=name, icon=loadIcon("edit"))
         handler.stackHandler()
Beispiel #7
0
    def onTriggered(self, result: bool) -> None:
        parent = self.parent()
        modul = self.parent().getModul()
        for item in parent.hierarchy.selectedItems():
            key = item.entryData["key"]

            def widgetFactory() -> EditWidget:
                node = parent.getRootNode()
                print("clone factory", modul, key, node)
                return EditWidget(modul,
                                  ApplicationType.HIERARCHY,
                                  key,
                                  node=node,
                                  clone=True)

            handler = WidgetHandler(widgetFactory,
                                    descr=QtCore.QCoreApplication.translate(
                                        "Hierarchy", "Clone entry"),
                                    icon=loadIcon("clone"))
            handler.stackHandler()