summaryrefslogtreecommitdiff
path: root/kodereviewer/qml
diff options
context:
space:
mode:
authorMatias Linares <matias.linares@comprandoengrupo.net>2024-10-03 10:49:18 -0300
committerMatias Linares <matias.linares@comprandoengrupo.net>2024-10-03 10:49:18 -0300
commit332828d03ae455c9a3ada0f57a08bf0942082824 (patch)
treec757472e22ec8c3bd3553288da8bc9554005e43d /kodereviewer/qml
parent440fd1dd8c194e4e02fc47725296812fba31df5d (diff)
downloadkodereviewer-332828d03ae455c9a3ada0f57a08bf0942082824.tar.gz
Add missing modules
Diffstat (limited to 'kodereviewer/qml')
-rw-r--r--kodereviewer/qml/Editor.qml100
-rw-r--r--kodereviewer/qml/FilesView.qml61
-rw-r--r--kodereviewer/qml/MarkdownTextArea.qml20
3 files changed, 181 insertions, 0 deletions
diff --git a/kodereviewer/qml/Editor.qml b/kodereviewer/qml/Editor.qml
new file mode 100644
index 0000000..9cc6cbf
--- /dev/null
+++ b/kodereviewer/qml/Editor.qml
@@ -0,0 +1,100 @@
+pragma ComponentBehavior: Bound
+import QtQuick 6.7
+import QtQuick.Controls 6.7 as QQC2
+import QtQuick.Layouts 6.7
+
+import org.kde.kirigami as Kirigami
+
+import org.kde.syntaxhighlighting
+
+import org.deprecated.kodereviewer
+
+TextEdit {
+
+ id: root
+
+ required property string file
+
+ signal commentClicked(string path, int startLine, int endLine)
+ signal newComment(string path, int startLine, int endLine)
+
+ property string filename: "A.patch"
+
+ property int lineHeight: contentHeight / lineCount
+
+ leftPadding: lineNumberColumn.width + lineNumberColumn.anchors.leftMargin + Kirigami.Units.smallSpacing * 2
+
+ readOnly: true
+ textFormat: TextEdit.PlainText
+ wrapMode: TextEdit.Wrap
+ color: Kirigami.Theme.textColor
+ selectionColor: Kirigami.Theme.highlightColor
+ font.family: "monospace"
+ Kirigami.SpellCheck.enabled: false
+
+ LineModel {
+ id: lineModel
+ document: root.textDocument
+ }
+
+ onWidthChanged: lineModel.resetModel()
+ onHeightChanged: lineModel.resetModel()
+
+ SyntaxHighlighter {
+ id: highlighter
+ textEdit: root
+ definition: Repository.definitionForFileName(root.filename)
+ }
+
+ Kirigami.Separator {
+ anchors {
+ top: root.top
+ bottom: root.bottom
+ left: lineNumberColumn.right
+ leftMargin: Kirigami.Units.smallSpacing
+ }
+ }
+
+ ColumnLayout {
+ id: lineNumberColumn
+ anchors {
+ top: root.top
+ topMargin: root.topPadding
+ left: root.left
+ leftMargin: Kirigami.Units.smallSpacing
+ }
+ spacing: 0
+ Repeater {
+ id: repeater
+ model: lineModel
+ delegate: QQC2.Label {
+ id: label
+ required property int index
+ required property int lineHeight
+ Layout.fillWidth: true
+ Layout.preferredHeight: lineHeight
+ horizontalAlignment: Text.AlignRight
+ text: index + 1
+ color: Kirigami.Theme.disabledTextColor
+
+ font.family: "monospace"
+ }
+ }
+ }
+
+ onTextChanged: print(root.textDocument)
+
+ onFileChanged: {
+ repeater.model.resetModel()
+ }
+
+ function selectionStartLine() {
+ const beforeText = text.toString().substr(0, selectionStart)
+ return beforeText.split("\n").length
+ }
+
+ function selectionEndLine() {
+ const beforeText = text.toString().substr(0, selectionEnd)
+ return beforeText.split("\n").length
+ }
+}
diff --git a/kodereviewer/qml/FilesView.qml b/kodereviewer/qml/FilesView.qml
new file mode 100644
index 0000000..299c353
--- /dev/null
+++ b/kodereviewer/qml/FilesView.qml
@@ -0,0 +1,61 @@
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtCore
+import QtQuick.Controls as QQC2
+import QtQuick.Layouts
+
+import org.kde.kirigami as Kirigami
+import org.kde.kirigamiaddons.delegates as Delegates
+
+import org.deprecated.kodereviewer 1.0
+
+QQC2.SplitView {
+ id: root
+ 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"
+ }
+ }
+
+
+ QQC2.ScrollView {
+ SplitView.preferredWidth: 200
+ implicitWidth: 200
+ SplitView.maximumWidth: 400
+ ListView {
+ model: fileModel
+ delegate: Delegates.RoundedItemDelegate {
+ required property string filename
+ required property string patch
+ highlighted: ListView.isCurrentItem
+ text: filename
+
+ onClicked: {
+ textArea.text = patch
+ textArea.file = filename
+ }
+ }
+ }
+ }
+
+ Editor {
+ id: textArea
+ text: ""
+ file: ""
+ }
+}
diff --git a/kodereviewer/qml/MarkdownTextArea.qml b/kodereviewer/qml/MarkdownTextArea.qml
new file mode 100644
index 0000000..966b209
--- /dev/null
+++ b/kodereviewer/qml/MarkdownTextArea.qml
@@ -0,0 +1,20 @@
+import QtQml
+import QtQuick 6.7
+import QtQuick.Controls 6.7 as QQC2
+import org.kde.kirigami as Kirigami
+import org.kde.syntaxhighlighting 1
+
+QQC2.TextArea {
+ id: root
+
+ placeholderText: "Leave a comment"
+ wrapMode: TextEdit.Wrap
+
+ Kirigami.SpellCheck.enabled: true
+ SyntaxHighlighter {
+ id: hightlighter
+ textEdit: root
+ repository: Repository
+ definition: Repository.definitionForFileName("la.md")
+ }
+}