Process headlines in a different qml component
This commit is contained in:
parent
ba93367c96
commit
6544071718
3 changed files with 48 additions and 5 deletions
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
(define-roles #.|Qt.UserRole|
|
||||
+nodetype-role+
|
||||
+content-role+)
|
||||
+content-role+
|
||||
+depth-role+)
|
||||
|
||||
(defvar *current-pathname* nil)
|
||||
|
||||
|
|
@ -91,12 +92,14 @@
|
|||
(qvariant-from-value (string-downcase (symbol-name (type-of item)))
|
||||
"QString"))
|
||||
(#.+content-role+
|
||||
(progn
|
||||
(qvariant-from-value (raw-text-of item) "QString")))))))))
|
||||
(qvariant-from-value (raw-text-of item) "QString"))
|
||||
(#.+depth-role+
|
||||
(qvariant-from-value (depth-of item) "int"))))))))
|
||||
(qoverride model "roleNames()"
|
||||
(lambda ()
|
||||
(list (cons +nodetype-role+ "nodeType")
|
||||
(cons +content-role+ "content"))))
|
||||
(cons +content-role+ "content")
|
||||
(cons +depth-role+ "depth"))))
|
||||
(when *org-model*
|
||||
(qdelete *org-model*))
|
||||
(setf *org-model* model)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ ListItem {
|
|||
if (nodeType == "org-line")
|
||||
return "OrgLine.qml";
|
||||
else if (nodeType == "org-headline")
|
||||
return "OrgLine.qml";
|
||||
return "OrgHeadline.qml";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
40
qml/components/OrgHeadline.qml
Normal file
40
qml/components/OrgHeadline.qml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Item {
|
||||
id: orgHeadline
|
||||
|
||||
height: label.visible ? label.contentHeight : edit.height
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
Label {
|
||||
id: label
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
rightMargin: Theme.paddingSmall
|
||||
}
|
||||
|
||||
font {
|
||||
pixelSize: depth == 1 ? Theme.fontSizeExtraLarge : Theme.fontSizeLarge
|
||||
family: Theme.fontFamilyHeading
|
||||
}
|
||||
|
||||
visible: !orgItem.focused
|
||||
text: edit.getText()
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
OrgEdit {
|
||||
id: edit
|
||||
visible: !label.visible
|
||||
}
|
||||
|
||||
function forceCommit () { edit.forceCommit() }
|
||||
function setCursorPositionAt (x, y) { edit.setCursorPositionAt(x, y) }
|
||||
function setCursorPositionAtEnd (fix) { edit.setCursorPositionAtEnd(fix) }
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue