forked from AG_QGIS/Plugin_SN_Basis
Angefangen, DataGrabber anzulegen (Grundlagen gelegt, noch nicht lauffähig)
This commit is contained in:
@@ -32,6 +32,7 @@ QTabWidget: type
|
||||
QToolButton: Type[Any]
|
||||
QSizePolicy: Type[Any]
|
||||
Qt: Type[Any]
|
||||
ComboBox: Type[Any]
|
||||
|
||||
YES: Optional[Any] = None
|
||||
NO: Optional[Any] = None
|
||||
@@ -68,6 +69,7 @@ try:
|
||||
QTabWidget as _QTabWidget,# type: ignore
|
||||
QToolButton as _QToolButton,#type:ignore
|
||||
QSizePolicy as _QSizePolicy,#type:ignore
|
||||
QComboBox as _QComboBox,
|
||||
|
||||
)
|
||||
|
||||
@@ -107,6 +109,7 @@ try:
|
||||
QTabWidget = _QTabWidget
|
||||
QToolButton=_QToolButton
|
||||
QSizePolicy=_QSizePolicy
|
||||
QComboBox=_QComboBox
|
||||
|
||||
YES = QMessageBox.StandardButton.Yes
|
||||
NO = QMessageBox.StandardButton.No
|
||||
@@ -148,7 +151,7 @@ try:
|
||||
|
||||
except Exception:
|
||||
try:
|
||||
from PyQt5.QtWidgets import (
|
||||
from PyQt5.QtWidgets import (# type: ignore
|
||||
QMessageBox as _QMessageBox,
|
||||
QFileDialog as _QFileDialog,
|
||||
QWidget as _QWidget,
|
||||
@@ -166,18 +169,20 @@ except Exception:
|
||||
QTabWidget as _QTabWidget,
|
||||
QToolButton as _QToolButton,
|
||||
QSizePolicy as _QSizePolicy,
|
||||
QComboBox as _QComboBox,
|
||||
)
|
||||
from PyQt5.QtCore import (
|
||||
from PyQt5.QtCore import (# type: ignore
|
||||
QEventLoop as _QEventLoop,
|
||||
QUrl as _QUrl,
|
||||
QCoreApplication as _QCoreApplication,
|
||||
Qt as _Qt,
|
||||
)
|
||||
from PyQt5.QtNetwork import (
|
||||
from PyQt5.QtNetwork import (# type: ignore
|
||||
QNetworkRequest as _QNetworkRequest,
|
||||
QNetworkReply as _QNetworkReply,
|
||||
)
|
||||
|
||||
|
||||
QMessageBox = _QMessageBox
|
||||
QFileDialog = _QFileDialog
|
||||
QEventLoop = _QEventLoop
|
||||
@@ -203,6 +208,7 @@ except Exception:
|
||||
QTabWidget = _QTabWidget
|
||||
QToolButton=_QToolButton
|
||||
QSizePolicy=_QSizePolicy
|
||||
ComboBox=_QComboBox
|
||||
|
||||
YES = QMessageBox.Yes
|
||||
NO = QMessageBox.No
|
||||
@@ -210,6 +216,8 @@ except Exception:
|
||||
ICON_QUESTION = QMessageBox.Question
|
||||
|
||||
QT_VERSION = 5
|
||||
|
||||
# then try next backend
|
||||
# ---------------------------------------------------------
|
||||
# Qt5 Enum-Aliase (vereinheitlicht)
|
||||
# ---------------------------------------------------------
|
||||
@@ -246,7 +254,7 @@ except Exception:
|
||||
QT_VERSION = 0
|
||||
|
||||
class FakeEnum(int):
|
||||
def __or__(self, other: "FakeEnum") -> "FakeEnum":
|
||||
def __or__(self, other: int) -> "FakeEnum":
|
||||
return FakeEnum(int(self) | int(other))
|
||||
|
||||
YES = FakeEnum(1)
|
||||
@@ -518,3 +526,55 @@ except Exception:
|
||||
self._tabs.append((widget, title))
|
||||
QTabWidget = _MockTabWidget
|
||||
|
||||
# -------------------------
|
||||
# Mock ComboBox Implementation
|
||||
# -------------------------
|
||||
class _MockSignal:
|
||||
def __init__(self):
|
||||
self._slots = []
|
||||
|
||||
def connect(self, cb):
|
||||
self._slots.append(cb)
|
||||
|
||||
def emit(self, value):
|
||||
for s in list(self._slots):
|
||||
try:
|
||||
s(value)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
class _MockComboBox:
|
||||
def __init__(self, parent=None):
|
||||
self._items = []
|
||||
self._index = -1
|
||||
self.currentTextChanged = _MockSignal()
|
||||
|
||||
def addItem(self, text: str) -> None:
|
||||
self._items.append(text)
|
||||
|
||||
def addItems(self, items):
|
||||
for it in items:
|
||||
self.addItem(it)
|
||||
|
||||
def findText(self, text: str) -> int:
|
||||
try:
|
||||
return self._items.index(text)
|
||||
except ValueError:
|
||||
return -1
|
||||
|
||||
def setCurrentIndex(self, idx: int) -> None:
|
||||
if 0 <= idx < len(self._items):
|
||||
self._index = idx
|
||||
self.currentTextChanged.emit(self.currentText())
|
||||
|
||||
def setCurrentText(self, text: str) -> None:
|
||||
idx = self.findText(text)
|
||||
if idx >= 0:
|
||||
self.setCurrentIndex(idx)
|
||||
|
||||
def currentText(self) -> str:
|
||||
if 0 <= self._index < len(self._items):
|
||||
return self._items[self._index]
|
||||
return ""
|
||||
|
||||
ComboBox = _MockComboBox
|
||||
|
||||
Reference in New Issue
Block a user