DB_LIST;
static const DB KEYMAP =
{
+ {KEY::ID, "id"},
+ {KEY::BODY, "body"},
+ {KEY::UPDATED, "updated"},
+ {KEY::TITLE, "title"},
{KEY::URL, "url"},
{KEY::FAV, "fav"},
{KEY::COLOR, "color"},
{KEY::ADD_DATE, "addDate"},
{KEY::TAG, "tag"}
};
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/";
const QString NotesPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/notes/";
const QString BooksPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/books/";
const QString LinksPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/links/";
const QString App = "Buho";
const QString version = "1.0";
const QString DBName = "collection.db";
inline bool fileExists(const QString &url)
{
QFileInfo path(url);
if (path.exists()) return true;
else return false;
}
inline void saveJson(QJsonDocument document, QString fileName)
{
QFile jsonFile(fileName);
jsonFile.open(QFile::WriteOnly);
jsonFile.write(document.toJson());
}
inline QVariantMap openJson(const QString &url)
{
QString val;
QFile file;
file.setFileName(url);
file.open(QIODevice::ReadOnly | QIODevice::Text);
val = file.readAll();
file.close();
QJsonDocument d = QJsonDocument::fromJson(val.toUtf8());
QJsonObject obj = d.object();
return obj.toVariantMap();
}
}
#endif // OWL_H
diff --git a/src/views/notes/NotesView.qml b/src/views/notes/NotesView.qml
index 3f1b273..397c436 100644
--- a/src/views/notes/NotesView.qml
+++ b/src/views/notes/NotesView.qml
@@ -1,20 +1,29 @@
import QtQuick 2.9
import "../../widgets"
import org.kde.maui 1.0 as Maui
Maui.Page
{
+ 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)
- cardsView.model.append(data[i])
+ append(data[i])
+ }
+
+ function append(note)
+ {
+ cardsView.model.append(note)
}
}
diff --git a/src/widgets/CardsView.qml b/src/widgets/CardsView.qml
index 34114a4..5d81255 100644
--- a/src/widgets/CardsView.qml
+++ b/src/widgets/CardsView.qml
@@ -1,50 +1,55 @@
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 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
"
}
model: ListModel
{
ListElement {title: "Hteu"; body: "lalajsjsjdjdjdjd djdjdjdj sjsjsjsj"}
ListElement {title: "Hteu"; body: "lalajsjsjdjdjdjd djdjdjdj sjsjsjsj"}
ListElement {title: "Hteu"; body: "lalajsjsjdjdjdjd djdjdjdj sjsjsjsj"}
ListElement {title: "Hteu"; body: "lalajsjsjdjdjdjd djdjdjdj sjsjsjsj"}
}
delegate: CardDelegate
{
id: delegate
cardWidth: itemWidth
cardHeight: itemHeight
+
+ onClicked: 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 5454810..7634e06 100644
--- a/src/widgets/NewNoteDialog.qml
+++ b/src/widgets/NewNoteDialog.qml
@@ -1,223 +1,237 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import org.kde.maui 1.0 as Maui
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"
},
Maui.ToolButton
{
iconName: "format-text-italic-symbolic"
},
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"
}
}
ScrollView
{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.margins: space.medium
TextArea
{
id: body
placeholderText: qsTr("Body")
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:
{
- if(owl.insertNote(title.text, body.text))
- close()
+ close()
+ noteSaved({
+ title: title.text,
+ body: body.text,
+ color: selectedColor,
+ tags: ""
+ })
+ clearNote()
+
}
}
Button
{
id: discard
text: qsTr("Discard")
onClicked:
{
- clearNote()
close()
+ clearNote()
}
}
}
}
- onOpened: clearNote()
function clearNote()
{
title.clear()
body.clear()
}
+
+ function fill(note)
+ {
+ title.text = note.title
+ body.text = note.body
+
+ open()
+ }
}