Commit 88abf0e0 authored by Camilo Higuita's avatar Camilo Higuita

actually save tags and display them when needed

parent 632785c1
QT += androidextras webview
DISTFILES += \
$$PWD/qtquickcontrols2.conf
......
......@@ -37,6 +37,8 @@ include($$PWD/QGumboParser/QGumboParser.pri)
linux:unix:!android {
message(Building for Linux KDE)
QT += webengine
} else:android {
......
......@@ -47,8 +47,10 @@ int main(int argc, char *argv[])
context->setContextProperty("owl", &owl);
Linker linker;
auto tag = owl.getTagging();
context->setContextProperty("linker", &linker);
context->setContextProperty("tag", tag);
qmlRegisterType<DocumentHandler>("org.buho.editor", 1, 0, "DocumentHandler");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
......
......@@ -6,6 +6,7 @@ import org.kde.maui 1.0 as Maui
import "src/widgets"
import "src/views/notes"
import "src/views/links"
import "src/views/books"
Maui.ApplicationWindow
{
......@@ -20,12 +21,12 @@ Maui.ApplicationWindow
property var views : ({
notes: 0,
links: 1,
books: 2
books: 2,
tags: 3,
search: 4
})
headBar.middleContent: Row
{
spacing: space.medium
headBar.middleContent: [
Maui.ToolButton
{
display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
......@@ -33,7 +34,7 @@ Maui.ApplicationWindow
iconColor: currentView === views.notes? accentColor : textColor
iconName: "draw-text"
text: qsTr("Notes")
}
},
Maui.ToolButton
{
......@@ -42,7 +43,7 @@ Maui.ApplicationWindow
iconColor: currentView === views.links? accentColor : textColor
iconName: "link"
text: qsTr("Links")
}
},
Maui.ToolButton
{
......@@ -50,8 +51,16 @@ Maui.ApplicationWindow
iconColor: currentView === views.books? accentColor : textColor
iconName: "document-new"
text: qsTr("Books")
},
Maui.ToolButton
{
display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
iconColor: currentView === views.tags? accentColor : textColor
iconName: "tag"
text: qsTr("Tags")
}
}
]
footBar.middleContent: [
......@@ -102,7 +111,6 @@ Maui.ApplicationWindow
}
}
}
]
/***** COMPONENTS *****/
......@@ -146,7 +154,6 @@ Maui.ApplicationWindow
currentIndex: currentView
onCurrentIndexChanged: currentView = currentIndex
NotesView
{
id: notesView
......@@ -156,6 +163,13 @@ Maui.ApplicationWindow
LinksView
{
id: linksView
onLinkClicked: previewLink(link)
}
BooksView
{
id: booksView
}
}
......@@ -168,7 +182,16 @@ Maui.ApplicationWindow
function setNote(note)
{
var tags = owl.getNoteTags(note.id)
note.tags = tags
notesView.currentNote = note
editNote.fill(note)
}
function previewLink(link)
{
var tags = owl.getLinkTags(link.link)
link.tags = tags
linksView.previewer.show(link)
}
}
......@@ -9,5 +9,9 @@
<file>src/widgets/NewLinkDialog.qml</file>
<file>src/views/links/LinksView.qml</file>
<file>utils.js</file>
<file>src/views/links/WebViewAndroid.qml</file>
<file>src/views/links/WebViewLinux.qml</file>
<file>src/views/links/Previewer.qml</file>
<file>src/views/books/BooksView.qml</file>
</qresource>
</RCC>
......@@ -5,6 +5,11 @@ Buho::Buho(QObject *parent) : DBActions(parent)
this->setFolders();
}
Tagging *Buho::getTagging()
{
return this->tag;
}
void Buho::setFolders()
{
QDir notes_path(OWL::NotesPath);
......
......@@ -3,12 +3,14 @@
#include <QObject>
#include "db/dbactions.h"
#include "tagging.h"
class Buho : public DBActions
{
Q_OBJECT
public:
explicit Buho(QObject *parent = nullptr);
Tagging* getTagging();
private:
void setFolders();
......
......@@ -30,6 +30,8 @@ DBActions::DBActions(QObject *parent) : DB(parent)
qDebug() << "Getting collectionDB info from: " << OWL::CollectionDBPath;
qDebug()<< "Starting DBActions";
this->tag = Tagging::getInstance(OWL::App, OWL::version, "org.kde.buho", OWL::comment);
}
DBActions::~DBActions() {}
......@@ -80,8 +82,10 @@ QVariantList DBActions::get(const QString &queryTxt)
return mapList;
}
bool DBActions::insertNote(const QString &title, const QString &body, const QString &color, const QString &tags)
bool DBActions::insertNote(const QString &title, const QString &body, const QString &color, const QStringList &tags)
{
qDebug()<<"TAGS"<< tags;
auto id = QUuid::createUuid().toString();
QVariantMap note_map =
......@@ -94,21 +98,11 @@ bool DBActions::insertNote(const QString &title, const QString &body, const QStr
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime()}
};
// if(!tags.isEmpty())
// {
// for(auto tag : tags.split(","))
// {
// this->insert(OWL::TABLEMAP[OWL::TABLE::TAGS], {{OWL::KEYMAP[OWL::KEY::TAG], tag}});
// this->insert(OWL::TABLEMAP[OWL::TABLE::NOTES_TAGS],
// {
// {OWL::KEYMAP[OWL::KEY::TAG], tag},
// {OWL::KEYMAP[OWL::KEY::URL], note_url}
// });
// }
// }
if(this->insert(OWL::TABLEMAP[OWL::TABLE::NOTES], note_map))
{
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::NOTES], id, color);
this->noteInserted(note_map);
return true;
}
......@@ -116,7 +110,7 @@ bool DBActions::insertNote(const QString &title, const QString &body, const QStr
return false;
}
bool DBActions::updateNote(const QString &id, const QString &title, const QString &body, const QString &color, const QString &tags)
bool DBActions::updateNote(const QString &id, const QString &title, const QString &body, const QString &color, const QStringList &tags)
{
OWL::DB note =
{
......@@ -126,6 +120,9 @@ bool DBActions::updateNote(const QString &id, const QString &title, const QStrin
{OWL::KEY::UPDATED, QDateTime::currentDateTime().toString()}
};
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::NOTES], id, color);
return this->update(OWL::TABLEMAP[OWL::TABLE::NOTES], note, {{OWL::KEYMAP[OWL::KEY::ID], id}} );
}
......@@ -134,7 +131,12 @@ QVariantList DBActions::getNotes()
return this->get("select * from notes");
}
bool DBActions::insertLink(const QString &link, const QString &title, const QString &preview, const QString &color, const QString &tags)
QVariantList DBActions::getNoteTags(const QString &id)
{
return this->tag->getAbstractTags(OWL::TABLEMAP[OWL::TABLE::NOTES], id);
}
bool DBActions::insertLink(const QString &link, const QString &title, const QString &preview, const QString &color, const QStringList &tags)
{
auto image_path = OWL::saveImage(Linker::getUrl(preview), OWL::LinksPath+QUuid::createUuid().toString());
......@@ -147,9 +149,11 @@ bool DBActions::insertLink(const QString &link, const QString &title, const QStr
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime()}
};
qDebug()<< link_map;
if(this->insert(OWL::TABLEMAP[OWL::TABLE::LINKS], link_map))
{
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::LINKS], link, color);
this->linkInserted(link_map);
return true;
}
......@@ -162,6 +166,11 @@ QVariantList DBActions::getLinks()
return this->get("select * from links");
}
QVariantList DBActions::getLinkTags(const QString &link)
{
return this->tag->getAbstractTags(OWL::TABLEMAP[OWL::TABLE::LINKS], link);
}
bool DBActions::execQuery(const QString &queryTxt)
{
auto query = this->getQuery(queryTxt);
......
......@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
#include "db.h"
#include "tagging.h"
class DBActions : public DB
{
......@@ -34,17 +35,19 @@ public:
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 bool insertNote(const QString &title, const QString &body, const QString &color = QString(), const QStringList &tags = QStringList());
Q_INVOKABLE bool updateNote(const QString &id, const QString &title, const QString &body, const QString &color = QString(), const QStringList &tags = QStringList());
Q_INVOKABLE QVariantList getNotes();
Q_INVOKABLE QVariantList getNoteTags(const QString &id);
Q_INVOKABLE bool insertLink(const QString &link, const QString &title, const QString &preview, const QString &color = QString(), const QString &tags = QString());
Q_INVOKABLE bool insertLink(const QString &link, const QString &title, const QString &preview, const QString &color = QString(), const QStringList &tags = QStringList());
Q_INVOKABLE QVariantList getLinks();
Q_INVOKABLE QVariantList getLinkTags(const QString &link);
protected:
OWL::DB_LIST getDBData(const QString &queryTxt);
bool execQuery(const QString &queryTxt);
Tagging *tag;
signals:
void noteInserted(QVariantMap note);
......
......@@ -123,6 +123,7 @@ namespace OWL
const QString LinksPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/links/";
const QString App = "Buho";
const QString version = "1.0";
const QString comment = "Notes taking and link collector manager";
const QString DBName = "collection.db";
inline bool fileExists(const QString &url)
......@@ -166,7 +167,7 @@ namespace OWL
name.replace("&", "-");
QString format = "JPEG";
if (img.save(path+".jpg", format.toLatin1(), 100))
return path;
return path+".jpg";
else qDebug() << "couldn't save artwork";
}else qDebug()<<"array is empty";
......
import QtQuick 2.9
import "../../widgets"
import org.kde.maui 1.0 as Maui
Maui.Page
{
id: control
property alias cardsView : cardsView
headBarVisible: false
margins: isMobile ? space.big : space.enormus
CardsView
{
id: cardsView
anchors.fill: parent
// onItemClicked: linkClicked(cardsView.model.get(index))
holder.message: "<h3>No Books!</h3><p>You can create new notes<br>links and books</p>"
}
}
......@@ -7,12 +7,18 @@ Maui.Page
id: control
property alias cardsView : cardsView
property alias previewer : previewer
property var currentLink : ({})
signal linkClicked(var note)
signal linkClicked(var link)
headBarVisible: false
margins: isMobile ? space.big : space.enormus
Previewer
{
id: previewer
}
CardsView
{
id: cardsView
......
import QtQuick 2.0
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 * 0.9
width: parent.width * (isMobile ? 0.9 : 0.7)
x: (parent.width / 2) - (width / 2)
y: (parent.height /2 ) - (height / 2)
modal: true
clip: true
padding: isAndroid ? 2 : "undefined"
property alias webView: webViewer.item
Maui.Page
{
anchors.fill: parent
margins: 0
padding: 0
onExit: close()
headBar.rightContent: [
Maui.ToolButton
{
iconName: "entry-delete"
},
Maui.ToolButton
{
iconName: "document-save"
},
Maui.ToolButton
{
iconName: "view-fullscreen"
}
]
headBar.middleContent: Label
{
clip: true
text: webView.title
horizontalAlignment: Qt.AlignHCenter
font.bold: true
font.pointSize: fontSizes.big
font.weight: Font.Bold
wrapMode: Label.WrapAnywhere
}
ColumnLayout
{
anchors.fill: parent
Loader
{
id: webViewer
Layout.fillWidth: true
Layout.fillHeight: true
source: isAndroid ? "qrc:/src/views/links/WebViewAndroid.qml" :
"qrc:/src/views/links/WebViewLinux.qml"
onVisibleChanged:
{
if(!visible) webView.url = "about:blank"
console.log(webView.url, visible)
}
}
Maui.TagsBar
{
id: tagBar
Layout.fillWidth: true
allowEditMode: true
onTagsEdited:
{
for(var i in tags)
append({tag : tags[i]})
}
}
}
}
function show(link)
{
webView.url = link.link
tagBar.populate(link.tags)
open()
}
}
import QtQuick 2.0
import QtWebView 1.1
WebView
{
id: webView
clip: true
onLoadingChanged:
{
if (loadRequest.errorString)
console.error(loadRequest.errorString);
}
}
import QtQuick 2.0
import QtWebEngine 1.5
WebEngineView
{
id: webView
onLoadingChanged:
{
if (loadRequest.errorString)
console.error(loadRequest.errorString);
}
onRecentlyAudibleChanged:
{
console.log("is playing", recentlyAudible)
if(recentlyAudible && isPlaying)
{
wasPlaying = isPlaying
Player.pauseTrack()
}
if(!recentlyAudible && wasPlaying)
Player.resumeTrack()
}
}
......@@ -105,8 +105,10 @@ ItemDelegate
id: preview
Layout.fillHeight: true
Layout.fillWidth: true
Layout.margins: unit
clip: true
Layout.topMargin: space.medium
visible: img.status === Image.Ready
Image
{
......
......@@ -8,13 +8,14 @@ GridView
property bool gridView : true
property alias holder : holder
readonly property int defaultSize : Kirigami.Units.devicePixelRatio * 200
readonly property int defaultSize : unit * 200
property int itemWidth : !gridView ? parent.width :
isMobile? (width-itemSpacing) * 0.42 : Kirigami.Units.devicePixelRatio * 200
property int itemHeight: Kirigami.Units.devicePixelRatio * 120
isMobile? (width-itemSpacing) * 0.42 : unit * 200
property int itemHeight: unit * 120
property int itemSpacing: space.huge
signal itemClicked(int index)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
cellWidth: itemWidth + itemSpacing
cellHeight: itemHeight + itemSpacing
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment