summaryrefslogtreecommitdiff
path: root/kodereviewer/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'kodereviewer/project.py')
-rw-r--r--kodereviewer/project.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/kodereviewer/project.py b/kodereviewer/project.py
new file mode 100644
index 0000000..669ee90
--- /dev/null
+++ b/kodereviewer/project.py
@@ -0,0 +1,49 @@
+import json
+from PySide6.QtCore import QByteArray, QObject, QUrl, Signal, Slot, Property
+from PySide6.QtQml import QmlElement
+
+from kodereviewer.data import PullRequest
+
+QML_IMPORT_NAME = "org.deprecated.kodereviewer"
+QML_IMPORT_MAJOR_VERSION = 1
+
+@QmlElement
+class Project(QObject):
+ """Represents a github project"""
+
+ _name: str
+ _owner: str
+ _url: QUrl
+ _pull_requests: list[PullRequest]
+
+ pullRequestChanged = Signal()
+
+ def __init__(self, name: str, owner: str, url: QUrl):
+ super().__init__()
+ self._name = name
+ self._owner = owner
+ self._url = url
+ self._pull_requests = []
+
+ @Property(str)
+ def name(self) -> str:
+ return self._name
+
+ @Property(str)
+ def owner(self) -> str:
+ return self._owner
+
+ @Property(QUrl)
+ def url(self) -> QUrl:
+ return self._url
+
+ @Property(list)
+ def pullRequests(self) -> list[PullRequest]:
+ return self._pull_requests
+
+ def load_pull_requests(self, response: QByteArray) -> None:
+ data = json.loads(response.toStdString())
+ self._pull_requests = [
+ PullRequest(pr) for pr in data
+ ]
+ self.pullRequestChanged.emit()