From e9c7736ff83b9003eba960edebd2653bd5a4021f Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Fri, 4 Oct 2024 18:30:17 -0300 Subject: Fix a lot of warnings and add file view --- kodereviewer/qml/Editor.qml | 3 +- kodereviewer/qml/FilesView.qml | 29 +++++------------- kodereviewer/qml/Main.qml | 2 +- kodereviewer/qml/ProjectListPage.qml | 57 +++++++++++++++--------------------- kodereviewer/qml/PullRequestPage.qml | 52 +++++++++++++++++++++++++------- 5 files changed, 75 insertions(+), 68 deletions(-) (limited to 'kodereviewer/qml') diff --git a/kodereviewer/qml/Editor.qml b/kodereviewer/qml/Editor.qml index 9cc6cbf..052933d 100644 --- a/kodereviewer/qml/Editor.qml +++ b/kodereviewer/qml/Editor.qml @@ -35,6 +35,7 @@ TextEdit { LineModel { id: lineModel document: root.textDocument + onDocumentChanged: print('Document changed!') } onWidthChanged: lineModel.resetModel() @@ -82,7 +83,7 @@ TextEdit { } } - onTextChanged: print(root.textDocument) + // onTextChanged: lineModel.document = root.textDocument onFileChanged: { repeater.model.resetModel() diff --git a/kodereviewer/qml/FilesView.qml b/kodereviewer/qml/FilesView.qml index 299c353..1442860 100644 --- a/kodereviewer/qml/FilesView.qml +++ b/kodereviewer/qml/FilesView.qml @@ -14,23 +14,7 @@ QQC2.SplitView { anchors.fill: parent padding: 0 spacing: 0 - ListModel { - id: fileModel - ListElement { - filename: "file1" - status: "added" - additions: 100 - deletions: 40 - patch: "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test" - } - ListElement { - filename: "file2" - status: "added" - additions: 100 - deletions: 40 - patch: "@@ -1,9 +1,9 @@ def something @@ -1000,7 +1000,7 @@ module Test" - } - } + required property FileModel fileModel QQC2.ScrollView { @@ -52,10 +36,11 @@ QQC2.SplitView { } } } - - Editor { - id: textArea - text: "" - file: "" + QQC2.ScrollView { + Editor { + id: textArea + text: "" + file: "" + } } } diff --git a/kodereviewer/qml/Main.qml b/kodereviewer/qml/Main.qml index 827cf59..56248d7 100644 --- a/kodereviewer/qml/Main.qml +++ b/kodereviewer/qml/Main.qml @@ -15,7 +15,7 @@ Kirigami.ApplicationWindow { title: qsTr("Kode Reviewer") minimumWidth: Kirigami.Units.gridUnit * 20 - minimumHeight: Kirigami.Units.gridUnit * 20 + //minimumHeight: Kirigami.Units.gridUnit * 20 width: minimumWidth height: minimumHeight diff --git a/kodereviewer/qml/ProjectListPage.qml b/kodereviewer/qml/ProjectListPage.qml index 2846db1..f156dc1 100644 --- a/kodereviewer/qml/ProjectListPage.qml +++ b/kodereviewer/qml/ProjectListPage.qml @@ -9,7 +9,7 @@ import org.kde.kirigami as Kirigami import org.deprecated.kodereviewer -Kirigami.Page { +Kirigami.ScrollablePage { id: root required property NetworkManager connection @@ -56,43 +56,32 @@ Kirigami.Page { } ] - contentItem: QQC2.StackView { - id: stackView - anchors.fill: parent - - initialItem: pullRequestListView - - Component { - id: pullRequestListView - QQC2.ScrollView { - ListView { - id: view - model: pullRequestModel - clip: true - delegate: Delegates.RoundedItemDelegate { - required property int number - required property string title - required property bool draft - required property int index - - highlighted: ListView.isCurrentItem - - text: `${number} - ${title}` - icon { - name: "vcs-merge-request" - color: draft ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.positiveTextColor - } - - onClicked: { - view.currentIndex = index - root.pullRequestSelected(number) - } - } - } + ListView { + id: view + model: pullRequestModel + clip: true + delegate: Delegates.RoundedItemDelegate { + required property int number + required property string title + required property bool draft + required property int index + + highlighted: ListView.isCurrentItem + + text: `${number} - ${title}` + icon { + name: "vcs-merge-request" + color: draft ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.positiveTextColor + } + + onClicked: { + view.currentIndex = index + root.pullRequestSelected(number) } } } + MouseArea { anchors.top: parent.top anchors.bottom: parent.bottom diff --git a/kodereviewer/qml/PullRequestPage.qml b/kodereviewer/qml/PullRequestPage.qml index e99d81b..219762a 100644 --- a/kodereviewer/qml/PullRequestPage.qml +++ b/kodereviewer/qml/PullRequestPage.qml @@ -56,11 +56,26 @@ Kirigami.ScrollablePage { } } - CommentModel { - id: commentModel - pullRequest: root.pullRequest + Loader { + id: commentModelLoader + active: !!root.pullRequest + sourceComponent: CommentModel { + id: commentModel + pullRequest: root.pullRequest + + onPullRequestChanged: root.connection.getPullRequestComments(root.pullRequest.number) + } + } - onPullRequestChanged: root.connection.getPullRequestComments(root.pullRequest.number) + Loader { + id: fileModelLoader + active: !!root.pullRequest + sourceComponent: FileModel { + id: fileModel + pullRequest: root.pullRequest + + onPullRequestChanged: root.connection.getFiles(root.pullRequest.number) + } } Kirigami.PlaceholderMessage { @@ -89,13 +104,23 @@ Kirigami.ScrollablePage { Kirigami.FormData.isSection: true } + RowLayout { + QQC2.Label { + text: "Author" + elide: Text.ElideRight + } + QQC2.Label { + text: root.pullRequest ? root.pullRequest.username : "" + elide: Text.ElideLeft + } + } RowLayout { QQC2.Label { text: "State: " elide: Text.ElideRight } QQC2.Label { - text: root.pullRequest.state + text: root.pullRequest ? root.pullRequest.state : "" elide: Text.ElideLeft } } @@ -105,16 +130,22 @@ Kirigami.ScrollablePage { elide: Text.ElideRight } QQC2.Label { - text: root.pullRequest.draft ? i18n("Yes") : i18n("No") + text: root.pullRequest ? root.pullRequest.draft ? i18n("Yes") : i18n("No") : "" elide: Text.ElideLeft } } + Loader { + id: labelModelLoader + active: !!root.pullRequest + sourceComponent: LabelModel { + pullRequest: root.pullRequest + } + } + RowLayout { Repeater { - model: LabelModel { - pullRequest: root.pullRequest - } + model: labelModelLoader.item delegate: Rectangle { required property string name required property string labelColor @@ -150,13 +181,14 @@ Kirigami.ScrollablePage { ColumnLayout { visible: !!root.pullRequest && root.currentView == "comments" Repeater { - model: commentModel + model: commentModelLoader.item delegate: CommentDelegate {} } } FilesView { visible: !!root.pullRequest && root.currentView == "files" + fileModel: fileModelLoader.item } footer: Kirigami.NavigationTabBar { -- cgit v1.2.3-70-g09d2