Ejemplo n.º 1
0
			self.tabWidget.blockSignals(True)
			self.tabWidget.setCurrentWidget(self.langEdits[lang])
			self.tabWidget.blockSignals(False)

	def unserialize(self, data: dict, errors: List[Dict]) -> None:
		self.setErrors(errors)
		if not data:
			return
		self.lineEdit.setText(str(data))

	def serializeForPost(self) -> dict:
		text = self.lineEdit.text()
		if text:
			return self.lineEdit.text()
		return ""

	def serializeForDocument(self) -> dict:
		return self.serialize()


def CheckForPasswordBone(
		moduleName: str,
		boneName: str,
		skelStucture: Dict[str, Any]) -> bool:
	return skelStucture[boneName]["type"] == "password"


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForPasswordBone, PasswordEditBone)
viewDelegateSelector.insert(2, CheckForPasswordBone, PasswordViewBoneDelegate)
Ejemplo n.º 2
0
			self.entry.setText("")


class FileBoneSelector(TreeBoneSelector):
	displaySourceWidget = FileWidget
	displaySelectionWidget = SelectedFilesWidget

	def keyPressEvent(self, e: QtGui.QKeyEvent) -> None:
		"""Handle multiple selection via return or enter key press"""

		if self.multiple and e.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
			self.selection.extend([item.entryData for item in self.list.selectedItems()])
		else:
			super(FileBoneSelector, self).keyPressEvent(e)

	def prepareDeletion(self) -> None:
		self.selection.prepareDeletion()
		self.list.prepareDeletion()


def CheckForFileBone(
		moduleName: str,
		boneName: str,
		skelStucture: Dict[str, Any]) -> bool:
	return skelStucture[boneName]["type"].startswith("relational.tree.leaf.file")


# Register this Bone in the global queue
editBoneSelector.insert(4, CheckForFileBone, FileItemBone)
# viewDelegateSelector.insert(4, CheckForFileBone, FileViewBoneDelegate)  # Disable the fileViewDelegate
Ejemplo n.º 3
0
            if str(data) in items:
                self.comboBox.setCurrentIndex(
                    self.comboBox.findText(items[str(data)]))
            else:
                self.comboBox.setCurrentIndex(-1)
        else:  # except:
            self.comboBox.setCurrentIndex(-1)

    def serializeForPost(self) -> Dict[str, Any]:
        currentValue = str(self.comboBox.currentText())
        for key, value in self.values:
            if str(value) == currentValue:
                return str(key)
        return None


def CheckForSelectOneBone(moduleName: str, boneName: str,
                          skelStucture: Dict[str, Any]) -> bool:
    isSelect = skelStucture[boneName]["type"] == "select" or skelStucture[
        boneName]["type"].startswith("select.")
    return isSelect and not bool(skelStucture[boneName].get("multiple"))


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForSelectOneBone, SelectOneEditBone)
viewDelegateSelector.insert(2, CheckForSelectOneBone,
                            SelectOneViewBoneDelegate)
extendedSearchWidgetSelector.insert(
    1, ExtendedSelectOneFilterPlugin.canHandleExtension,
    ExtendedSelectOneFilterPlugin)
Ejemplo n.º 4
0
            widgetGen = lambda: ListMultiContainer(preMultiWidgetGen)
        if myStruct.get("languages"):
            preLangWidgetGen = widgetGen
            widgetGen = lambda: LanguageContainer(myStruct["languages"],
                                                  preLangWidgetGen)
        return widgetGen()

    def unserialize(self, data: Dict[str, Any], errors: List[Dict]) -> None:
        self.setErrors(errors)
        if not data:
            return
        try:
            lat, lng = data
        except:
            lat = lng = 0
        self.lat.setValue(lat)
        self.lng.setValue(lng)

    def serializeForPost(self) -> Dict[str, Any]:
        return {"lat": str(self.lat.value()), "lng": str(self.lng.value())}


def CheckForSpatialBone(moduleName: str, boneName: str,
                        skelStucture: Dict[str, Any]) -> bool:
    return (skelStucture[boneName]["type"] == "spatial")


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForSpatialBone, SpatialEditBone)
viewDelegateSelector.insert(2, CheckForSpatialBone, SpatialViewBoneDelegate)
Ejemplo n.º 5
0
			required,
			multiple=False,
			languages=None,
			**kwargs)
		if myStruct.get("multiple"):
			preMultiWidgetGen = widgetGen
			widgetGen = lambda: ListMultiContainer(preMultiWidgetGen)
		if myStruct.get("languages"):
			preLangWidgetGen = widgetGen
			widgetGen = lambda: LanguageContainer(myStruct["languages"], preLangWidgetGen)
		return widgetGen()

	def unserialize(self, data: Dict[str, Any], errors: List[Dict]) -> None:
		self.setErrors(errors)
		if not data:
			return
		self.lineEdit.setText(unescapeHtml(str(data)))

	def serializeForPost(self) -> Dict[str, Any]:
		return self.lineEdit.text()


def CheckForStringBone(moduleName: str, boneName: str, skelStucture: Dict[str, Any]) -> bool:
	return skelStucture[boneName]["type"] == "str" or skelStucture[boneName]["type"].startswith("str.")


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForStringBone, StringEditBone)
viewDelegateSelector.insert(2, CheckForStringBone, StringViewBoneDelegate)
extendedSearchWidgetSelector.insert(1, ExtendedStringFilterPlugin.canHandleExtension, ExtendedStringFilterPlugin)
Ejemplo n.º 6
0
    displaySelectionWidget = TreeSelectedEntities

    def onSourceItemDoubleClicked(self,
                                  item: QtWidgets.QListWidgetItem) -> None:
        """
			An item has been doubleClicked in our listWidget.
			Read its properties and add them to our selection.
		"""
        return

    def onSourceItemClicked(self, item: QtWidgets.QListWidgetItem) -> None:
        if not isinstance(item, self.list.getNodeItemClass()):
            return

        data = item.entryData
        selection = self.selection.get()
        if data in selection:
            self.selection.set([])
        else:
            self.selection.set([data])


def CheckForTreeDirBone(moduleName: str, boneName: str,
                        skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"].startswith("treedir.")


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForTreeDirBone, TreeDirBone)
viewDelegateSelector.insert(2, CheckForTreeDirBone, TreeDirViewBoneDelegate)
Ejemplo n.º 7
0
    def showDialog(self) -> None:
        acolor = QtWidgets.QColorDialog.getColor(
            QtGui.QColor(self.lineEdit.displayText()), self.lineEdit,
            self.skelStructure[self.boneName]["descr"])
        if acolor.isValid():
            self.lineEdit.setText(acolor.name())
            self.refreshColor()

    def refreshColor(self) -> None:
        self.colordisplay.setStyleSheet("QWidget { background-color: %s }" %
                                        str(self.lineEdit.displayText()))

    def unserialize(self, data: dict, errors: List[Dict]) -> None:
        self.setErrors(errors)
        data = str(data) if data else ""
        self.lineEdit.setText(data)
        self.colordisplay.setStyleSheet("QWidget { background-color: %s }" %
                                        data)

    def serializeForPost(self) -> dict:
        return str(self.lineEdit.displayText())


def CheckForColorBone(moduleName: str, boneName: str,
                      skelStucture: Dict[str, Any]) -> bool:
    res = skelStucture[boneName]["type"] == "color"
    return res


editBoneSelector.insert(2, CheckForColorBone, ColorEditBone)
Ejemplo n.º 8
0
        self.ui.setupUi(self)
        self.setTitle(extension["name"])
        self.ui.values.addItem("", None)
        for userData, text in extension["values"].items():
            self.ui.values.addItem(text, userData)

    @staticmethod
    def canHandleExtension(extension: Dict[str, Any]) -> bool:
        return (isinstance(extension, dict) and "type" in extension
                and (((extension["type"] == "select"
                       or extension["type"].startswith("select."))
                      and extension.get("multiple", True)) or
                     (extension["type"] == "selectmulti"
                      or extension["type"].startswith("selectmulti."))))


def CheckForSelectMultiBone(moduleName: str, boneName: str,
                            skelStucture: Dict[str, Any]) -> bool:
    isSelect = skelStucture[boneName]["type"] == "select" or skelStucture[
        boneName]["type"].startswith("select.")
    return isSelect and bool(skelStucture[boneName].get("multiple"))


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForSelectMultiBone, SelectMultiEditBone)
viewDelegateSelector.insert(2, CheckForSelectMultiBone,
                            SelectMultiViewBoneDelegate)
extendedSearchWidgetSelector.insert(
    1, ExtendedSelectMultiFilterPlugin.canHandleExtension,
    ExtendedSelectMultiFilterPlugin)
Ejemplo n.º 9
0
        return widgetGen()

    def unserialize(self, data: Dict[str, Any], errors: List[Dict]) -> None:
        self.setErrors(errors)
        return self.internalEdit.unserialize(
            data or {}, errors)  # New, non-multipe record-bones may be none

    def serializeForPost(self) -> dict:
        return self.internalEdit.serializeForPost()

    def setErrors(self, errorList):  # Just forward to internalEdit
        self.internalEdit.setErrors(errorList)

    def getEffectiveMaximumBoneError(
        self,
        inOptionalContainer: bool = False
    ) -> int:  # Just forward to internalEdit
        return self.internalEdit.getEffectiveMaximumBoneError(
            inOptionalContainer or not self.required)


def CheckForRecordBoneBone(moduleName: str, boneName: str,
                           skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"] == "record" or skelStucture[
        boneName]["type"].startswith("record.")


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForRecordBoneBone, RecordEditBone)
viewDelegateSelector.insert(2, CheckForRecordBoneBone, RecordViewBoneDelegate)
Ejemplo n.º 10
0
				self.lineEdit.setDateTime(
					QtCore.QDateTime(
						QtCore.QDate(self.dt.year, self.dt.month, self.dt.day),
						QtCore.QTime(self.dt.hour, self.dt.minute, self.dt.second)))
			elif self.date:  # date only
				self.lineEdit.setDate(QtCore.QDate(self.dt.year, self.dt.month, self.dt.day))
			else:
				self.lineEdit.setTime(QtCore.QTime(self.dt.hour, self.dt.minute, self.dt.second))


	def serializeForPost(self) -> dict:
		# FIXME: what's about deleted or not set date / times?
		if self.time and self.date:  # date AND time
			arg = self.lineEdit.dateTime().toString(QtCore.Qt.ISODate)
		elif self.date:  # date only
			arg = self.lineEdit.date().toString("dd.MM.yyyy")
		else:  # time only
			arg = self.lineEdit.time().toString("hh:mm:ss")
		return arg

	def serializeForDocument(self) -> dict:
		return self.serialize()


def CheckForDateBone(moduleName: str, boneName: str, skelStucture: Dict[str, Any]) -> bool:
	return skelStucture[boneName]["type"] == "date"


editBoneSelector.insert(2, CheckForDateBone, DateEditBone)
extendedSearchWidgetSelector.insert(1, DateRangeFilterPlugin.canHandleExtension, DateRangeFilterPlugin)
Ejemplo n.º 11
0
		except AttributeError:
			pass
		self.selectionChanged.emit(self.selection.get())
		event.emit("popWidget", self)

	def onBtnCancelReleased(self, *args: Any, **kwargs: Any) -> None:
		logger.debug("onBtnCancelReleased")
		try:
			self.selection.prepareDeletion()
		except AttributeError:
			pass
		event.emit("popWidget", self)

	def getFilter(self) -> Dict[str, Any]:
		return self.list.getFilter()

	def setFilter(self, queryFilter: Dict[str, Any]) -> None:
		return self.list.setFilter(queryFilter)

	def getModul(self) -> str:
		return self.list.getModul()


def CheckForRelationalicBone(moduleName: str, boneName: str, skelStucture: Dict[str, Any]) -> bool:
	return skelStucture[boneName]["type"].startswith("relational.")


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForRelationalicBone, RelationalEditBone)
viewDelegateSelector.insert(2, CheckForRelationalicBone, RelationalViewBoneDelegate)
Ejemplo n.º 12
0
            widgetGen = lambda: ListMultiContainer(preMultiWidgetGen)
        if myStruct.get("languages"):
            preLangWidgetGen = widgetGen
            widgetGen = lambda: LanguageContainer(myStruct["languages"],
                                                  preLangWidgetGen)
        return widgetGen()

    def unserialize(self, data: dict, errors: List[Dict]) -> None:
        self.setErrors(errors)
        if data:
            self.checkBox.setChecked(True)

    def serializeForPost(self) -> dict:
        return "1" if self.checkBox.isChecked() else "0"

    def serializeForDocument(self) -> dict:
        return self.serialize()


def CheckForBooleanBone(moduleName: str, boneName: str,
                        skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"] == "bool"


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForBooleanBone, BooleanEditBone)
viewDelegateSelector.insert(2, CheckForBooleanBone, BooleanViewBoneDelegate)
extendedSearchWidgetSelector.insert(
    1, ExtendedBooleanFilterPlugin.canHandleExtension,
    ExtendedBooleanFilterPlugin)
Ejemplo n.º 13
0
		"""
        if not self.multiple:
            self.entry.setReadOnly(True)


class HierarchyBoneSelector(RelationalBoneSelector):
    displaySourceWidget = HierarchyWidget

    def onSourceItemDoubleClicked(self,
                                  item: QtWidgets.QListWidgetItem) -> None:
        """
			An item has been doubleClicked in our listWidget.
			Read its properties and add them to our selection.
		"""
        data = item.entryData
        if self.multiple:
            self.selection.extend([data])
        else:
            self.selectionChanged.emit([data])
            event.emit("popWidget", self)


def CheckForHierarchyItemBone(moduleName: str, boneName: str,
                              skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"].startswith("hierarchy.")


viewDelegateSelector.insert(1, CheckForHierarchyItemBone,
                            HierarchyItemViewBoneDelegate)
editBoneSelector.insert(1, CheckForHierarchyItemBone, HierarchyItemBone)
Ejemplo n.º 14
0
        for module in self.modules:
            self.checkmodulesbox(module)

    def serializeForPost(self) -> Dict[str, Any]:
        ret = []

        for name in self.flags:
            if self.checkboxes[name].isChecked():
                ret.append(name)

        for module in self.modules:
            for state in self.states:
                if self.modules[module][state][0].isChecked():
                    ret.append("%s-%s" % (module, state))

        return {self.boneName: ret}

    def serializeForDocument(self) -> Dict[str, Any]:
        return self.serialize()


def CheckForAccessSelectMultiBone(moduleName: str, boneName: str,
                                  skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"] in ("select.access",
                                              "selectmulti.access")


# Register this Bone in the global queue
editBoneSelector.insert(4, CheckForAccessSelectMultiBone,
                        AccessSelectMultiEditBone)
Ejemplo n.º 15
0
    skelType = "leaf"


class TreeBoneSelector(RelationalBoneSelector):
    displaySourceWidget = TreeWidget
    displaySelectionWidget = TreeSelectedEntities

    def onSourceItemDoubleClicked(self,
                                  item: QtWidgets.QListWidgetItem) -> None:
        """
			An item has been doubleClicked in our listWidget.
			Read its properties and add them to our selection.
		"""
        if not isinstance(item, self.list.getLeafItemClass()):
            return
        data = item.entryData
        if self.multiple:
            self.selection.extend([data])
        else:
            self.selectionChanged.emit([data])
            event.emit("popWidget", self)


def CheckForTreeItemBone(moduleName: str, boneName: str,
                         skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"].startswith("relational.treeitem.")


editBoneSelector.insert(2, CheckForTreeItemBone, TreeItemBone)
viewDelegateSelector.insert(2, CheckForTreeItemBone, TreeItemViewBoneDelegate)
Ejemplo n.º 16
0
            else:
                self.webView.setHtml(text)

    def unserialize(self, data: dict, errors: List[Dict]) -> None:
        self.setErrors(errors)
        self.html = str(data).replace("target=\"_blank\" href=\"",
                                      "href=\"!") if (data) else ""
        if isPyodide:
            self.webView.setText(self.html)
        else:
            self.webView.setHtml(self.html)

    def serializeForPost(self) -> Dict[str, Any]:
        return self.html.replace("href=\"!", "target=\"_blank\" href=\"")

    def serializeForDocument(self) -> dict:
        return self.serialize()

    def remove(self) -> None:
        pass


def CheckForTextBone(moduleName: str, boneName: str,
                     skelStucture: Dict[str, Any]) -> bool:
    return skelStucture[boneName]["type"] == "text"


# Register this Bone in the global queue
editBoneSelector.insert(2, CheckForTextBone, TextEditBone)
viewDelegateSelector.insert(2, CheckForTextBone, TextViewBoneDelegate)
Ejemplo n.º 17
0
        self.setParams()
        self.lineEdit.show()

    def setParams(self) -> None:
        self.setEnabled(not self.readOnly)

    @staticmethod
    def fromSkelStructure(moduleName: str, boneName: str, skelStructure: dict,
                          **kwargs: Any) -> Any:
        readOnly = "readonly" in skelStructure[boneName] and skelStructure[
            boneName]["readonly"]
        required = "required" in skelStructure[boneName] and skelStructure[
            boneName]["required"]
        return BaseEditBone(moduleName, boneName, readOnly, required, **kwargs)

    def unserialize(self, data: dict, errors: List[Dict]) -> None:
        self.setErrors(errors)
        self.lineEdit.setText(str(data) if data else "")

    def serializeForPost(self) -> dict:
        return self.lineEdit.displayText()

    def serializeForDocument(self) -> dict:
        return self.serialize()


# Register this Bone in the global queue
editBoneSelector.insert(0, lambda *args, **kwargs: True, BaseEditBone)
viewDelegateSelector.insert(0, lambda *args, **kwargs: True,
                            BaseViewBoneDelegate)