#include "db.h"
class DBActions : public DB
{
Q_OBJECT
public:
explicit DBActions(QObject *parent = nullptr);
~DBActions();
Q_INVOKABLE QVariantList get(const QString &queryTxt);
/*main actions*/
Q_INVOKABLE bool insertNote(const QString &title, const QString &body, const QString &color = QString(), const QString &tags = QString());
Q_INVOKABLE bool updateNote(const QString &id, const QString &title, const QString &body, const QString &color = QString(), const QString &tags = QString());
Q_INVOKABLE QVariantList getNotes();
protected:
OWL::DB_LIST getDBData(const QString &queryTxt);
bool execQuery(const QString &queryTxt);
signals:
- void tagAdded(QString tag);
+ void noteInserted(QVariantMap note);
+
};
#endif // DBACTIONS_H
diff --git a/src/views/notes/NotesView.qml b/src/views/notes/NotesView.qml
index 2d554b2..a91f5fb 100644
--- a/src/views/notes/NotesView.qml
+++ b/src/views/notes/NotesView.qml
@@ -1,32 +1,33 @@
import QtQuick 2.9
import "../../widgets"
import org.kde.maui 1.0 as Maui
Maui.Page
{
+ property alias cardsView : cardsView
property var currentNote : ({})
signal noteClicked(var note)
headBarVisible: false
CardsView
{
id: cardsView
anchors.fill: parent
onItemClicked: noteClicked(cardsView.model.get(index))
}
function populate()
{
var data = owl.getNotes()
for(var i in data)
{
console.log("OCLOR", data[i].color)
append(data[i])
}
}
function append(note)
{
cardsView.model.append(note)
}
}
diff --git a/src/widgets/CardDelegate.qml b/src/widgets/CardDelegate.qml
index 196a5bf..850544d 100644
--- a/src/widgets/CardDelegate.qml
+++ b/src/widgets/CardDelegate.qml
@@ -1,82 +1,106 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import org.kde.kirigami 2.2 as Kirigami
ItemDelegate
{
id: control
property string noteColor : color ? color : "pink"
property int cardWidth: Kirigami.Units.devicePixelRatio*200
property int cardHeight: Kirigami.Units.devicePixelRatio*120
width: cardWidth
height: cardHeight
background: Rectangle
{
color: "transparent"
}
DropShadow
{
anchors.fill: card
visible: card.visible
horizontalOffset: 0
verticalOffset: 3
radius: 8.0
samples: 17
color: "#80000000"
source: card
}
Rectangle
{
id: card
z: -999
anchors.centerIn: control
anchors.fill: control
+ border.color: Qt.darker(noteColor, 1.2)
color: noteColor
radius: Kirigami.Units.devicePixelRatio*3
}
ColumnLayout
{
anchors.fill: parent
spacing: 0
Label
{
+ id: title
+
+ visible: title.text.length > 0
Layout.leftMargin: space.medium
Layout.topMargin: space.medium
Layout.rightMargin: space.medium
Layout.fillWidth: true
text: model.title
font.weight: Font.Bold
font.bold: true
+ font.pointSize: fontSizes.large
}
TextArea
{
+ id: body
+
Layout.leftMargin: space.medium
Layout.bottomMargin: space.medium
Layout.rightMargin: space.medium
+ Layout.topMargin: title.visible ? 0 : space.medium
Layout.fillHeight: true
Layout.fillWidth: true
enabled: false
text: model.body
textFormat: TextEdit.RichText
+ font.pointSize: fontSizes.big
background: Rectangle
{
color: "transparent"
}
}
- }
+ Item
+ {
+ id: preview
+ Image
+ {
+ id: img
+ }
+ }
+ }
+
+ function update(note)
+ {
+ title.text = note.title
+ body.text = note.body
+ noteColor = note.color
+ }
}
diff --git a/src/widgets/CardsView.qml b/src/widgets/CardsView.qml
index 6923276..39caabf 100644
--- a/src/widgets/CardsView.qml
+++ b/src/widgets/CardsView.qml
@@ -1,48 +1,53 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import org.kde.kirigami 2.2 as Kirigami
import org.kde.maui 1.0 as Maui
GridView
{
property alias holder : holder
property int itemWidth : Kirigami.Units.devicePixelRatio * 200
property int itemHeight: Kirigami.Units.devicePixelRatio * 120
property int itemSpacing: space.huge
signal itemClicked(int index)
cellWidth: itemWidth + itemSpacing
cellHeight: itemHeight + itemSpacing
Maui.Holder
{
id: holder
visible: count < 1
- message: "No notes!
You can create new notes from the add button
"
+ message: "No notes!
You can create new notes
links and books
"
}
model: ListModel { }
delegate: CardDelegate
{
id: delegate
cardWidth: itemWidth
cardHeight: itemHeight
- onClicked: itemClicked(index)
+ onClicked:
+ {
+ currentIndex = index
+ itemClicked(index)
+
+ }
}
onWidthChanged: adaptGrid()
function adaptGrid()
{
var amount = parseInt(width/(itemWidth + itemSpacing),10)
var leftSpace = parseInt(width-(amount*(itemWidth + itemSpacing)), 10)
var size = parseInt((itemWidth + itemSpacing)+(parseInt(leftSpace/amount, 10)), 10)
size = size > itemWidth + itemSpacing ? size : itemWidth + itemSpacing
cellWidth = size
}
}
diff --git a/src/widgets/NewNoteDialog.qml b/src/widgets/NewNoteDialog.qml
index c222379..f2338c7 100644
--- a/src/widgets/NewNoteDialog.qml
+++ b/src/widgets/NewNoteDialog.qml
@@ -1,269 +1,275 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import org.kde.maui 1.0 as Maui
import org.buho.editor 1.0
Popup
{
parent: ApplicationWindow.overlay
height: parent.height * (isMobile ? 0.8 : 0.7)
width: parent.width * (isMobile ? 0.9 : 0.7)
property string selectedColor : "#ffffe6"
signal noteSaved(var note)
x: (parent.width / 2) - (width / 2)
y: (parent.height /2 ) - (height / 2)
padding: 1
Rectangle
{
id: bg
color: selectedColor
z: -1
anchors.fill: parent
}
ColumnLayout
{
anchors.fill: parent
Maui.ToolBar
{
Layout.fillWidth: true
leftContent: [
Maui.ToolButton
{
iconName: "format-text-bold"
focusPolicy: Qt.TabFocus
+ iconColor: checked ? highlightColor : textColor
checkable: true
checked: document.bold
onClicked: document.bold = !document.bold
},
Maui.ToolButton
{
iconName: "format-text-italic-symbolic"
+ iconColor: checked ? highlightColor : textColor
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.italic
+ onClicked: document.italic = !document.italic
},
Maui.ToolButton
{
iconName: "format-text-underline-symbolic"
},
Maui.ToolButton
{
iconName: "format-text-uppercase"
}
]
rightContent: Row
{
spacing: space.medium
Rectangle
{
color:"#ffded4"
anchors.verticalCenter: parent.verticalCenter
height: iconSizes.medium
width: height
radius: Math.max(height, width)
border.color: borderColor
MouseArea
{
anchors.fill: parent
onClicked: selectedColor = parent.color
}
}
Rectangle
{
color:"#d3ffda"
anchors.verticalCenter: parent.verticalCenter
height: iconSizes.medium
width: height
radius: Math.max(height, width)
border.color: borderColor
MouseArea
{
anchors.fill: parent
onClicked: selectedColor = parent.color
}
}
Rectangle
{
color:"#caf3ff"
anchors.verticalCenter: parent.verticalCenter
height: iconSizes.medium
width: height
radius: Math.max(height, width)
border.color: borderColor
MouseArea
{
anchors.fill: parent
onClicked: selectedColor = parent.color
}
}
Rectangle
{
color:"#ccc1ff"
anchors.verticalCenter: parent.verticalCenter
height: iconSizes.medium
width: height
radius: Math.max(height, width)
border.color: borderColor
MouseArea
{
anchors.fill: parent
onClicked: selectedColor = parent.color
}
}
Rectangle
{
color:"#ffcdf4"
anchors.verticalCenter: parent.verticalCenter
height: iconSizes.medium
width: height
radius: Math.max(height, width)
border.color: borderColor
MouseArea
{
anchors.fill: parent
onClicked: selectedColor = parent.color
}
}
Maui.ToolButton
{
iconName: "overflow-menu"
}
}
}
TextField
{
id: title
Layout.fillWidth: true
Layout.margins: space.medium
height: 24
placeholderText: qsTr("Title")
font.weight: Font.Bold
font.bold: true
background: Rectangle
{
color: "transparent"
}
}
DocumentHandler
{
id: document
document: body.textDocument
cursorPosition: body.cursorPosition
selectionStart: body.selectionStart
selectionEnd: body.selectionEnd
// textColor: TODO
// onLoaded: {
// body.text = text
// }
onError: {
body.text = message
body.visible = true
}
}
ScrollView
{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.margins: space.medium
TextArea
{
id: body
placeholderText: qsTr("Body")
selectByKeyboard :!isMobile
selectByMouse : !isMobile
- textFormat : TextEdit.RichText
+ textFormat : TextEdit.AutoText
background: Rectangle
{
color: "transparent"
}
}
}
Row
{
Layout.fillWidth: true
width: parent.width
Layout.margins: space.medium
Layout.alignment: Qt.AlignRight
spacing: space.medium
Button
{
id: save
text: qsTr("Save")
onClicked:
{
close()
noteSaved({
title: title.text,
body: body.text,
color: selectedColor,
tags: ""
})
clearNote()
}
}
Button
{
id: discard
text: qsTr("Discard")
onClicked:
{
close()
clearNote()
}
}
}
}
function clearNote()
{
title.clear()
body.clear()
}
function fill(note)
{
document.load("qrc:/texteditor.html")
title.text = note.title
body.text = note.body
selectedColor = note.color
open()
}
function bold()
{
// body.sele
}
}