GeoDonkey for QGIS 1.12
This commit is contained in:
commit
20ab32da30
63 files changed
+11157
No files matched your search
@@ -0,0 +1,65 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
from qgis.PyQt.QtWidgets import QAction
|
||||
except ImportError:
|
||||
from qgis.PyQt.QtGui import QAction # noqa: F401
|
||||
|
||||
try:
|
||||
from qgis.PyQt.QtWidgets import QShortcut # noqa: F401
|
||||
except ImportError:
|
||||
try:
|
||||
from qgis.PyQt.QtGui import QShortcut # noqa: F401
|
||||
except ImportError:
|
||||
QShortcut = None # noqa: N816
|
||||
|
||||
PLUGIN_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def icon_path(name: str) -> str:
|
||||
return os.path.join(PLUGIN_DIR, "icons", name)
|
||||
|
||||
|
||||
def icon(name: str):
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
return QIcon(icon_path(name))
|
||||
|
||||
|
||||
FIELD_TYPES = {
|
||||
"string": ("QString", "String"),
|
||||
"double": ("Double", "Double"),
|
||||
"integer": ("Int", "Int"),
|
||||
"boolean": ("Bool", "Bool"),
|
||||
}
|
||||
|
||||
|
||||
def field(name: str, kind: str = "string"):
|
||||
from qgis.core import QgsField
|
||||
|
||||
modern, legacy = FIELD_TYPES.get(kind, FIELD_TYPES["string"])
|
||||
try:
|
||||
from qgis.PyQt.QtCore import QMetaType
|
||||
|
||||
return QgsField(name, getattr(QMetaType.Type, modern))
|
||||
except (ImportError, AttributeError, TypeError):
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
|
||||
return QgsField(name, getattr(QVariant, legacy))
|
||||
|
||||
|
||||
def string_field(name: str):
|
||||
return field(name, "string")
|
||||
|
||||
|
||||
def pixels():
|
||||
try:
|
||||
from qgis.core import Qgis
|
||||
|
||||
return Qgis.RenderUnit.Pixels
|
||||
except (ImportError, AttributeError):
|
||||
from qgis.core import QgsUnitTypes
|
||||
|
||||
return QgsUnitTypes.RenderUnit.RenderPixels
|
||||
Reference in new issue
Block a user