Commit 5f8590ad authored by Camilo Higuita's avatar Camilo Higuita

push changes

parent 2f94eba2
......@@ -7,5 +7,6 @@
<file>Bomb.png</file>
<file>E-reading.png</file>
<file>Astronaut.png</file>
<file>Faq.png</file>
</qresource>
</RCC>
......@@ -15,8 +15,10 @@ Maui.ApplicationWindow
/***** PROPS *****/
floatingBar: true
accentColor : "#8981d8"
footBarOverlap: true
accentColor : "#8981d8"
menuDrawer.bannerImageSource: "qrc:/Faq.png"
property int currentView : views.notes
property var views : ({
notes: 0,
......@@ -63,6 +65,7 @@ Maui.ApplicationWindow
}
]
footBarMargins: space.huge
footBarAligment: Qt.AlignRight
footBar.middleContent: [
......@@ -114,11 +117,10 @@ Maui.ApplicationWindow
}
}
NewLinkDialog
{
id: newLinkDialog
onLinkSaved: owl.insertLink(note.link, note.title.trim(), note.preview, note.color, note.tags)
onLinkSaved: owl.insertLink(link)
}
/***** VIEWS *****/
......@@ -180,6 +182,7 @@ Maui.ApplicationWindow
{
var tags = owl.getLinkTags(link.link)
link.tags = tags
linksView.previewer.show(link)
}
}
......@@ -15,5 +15,7 @@
<file>src/views/books/BooksView.qml</file>
<file>src/widgets/ColorsBar.qml</file>
<file>src/widgets/CardsList.qml</file>
<file>src/widgets/CardMenu.qml</file>
<file>src/utils/owl.js</file>
</qresource>
</RCC>
......@@ -182,7 +182,6 @@ bool DB::update(const QString &tableName, const QVariantMap &updateData, const Q
}
QStringList set;
for (auto key : updateData.keys())
set.append(key+" = ?");
......@@ -209,7 +208,7 @@ bool DB::update(const QString &table, const QString &column, const QVariant &new
return query.exec();
}
bool DB::remove(const QString &tableName, const OWL::DB &removeData)
bool DB::remove(const QString &tableName, const QVariantMap &removeData)
{
if (tableName.isEmpty())
{
......@@ -222,19 +221,21 @@ bool DB::remove(const QString &tableName, const OWL::DB &removeData)
return false;
}
QString strValues;
auto i = 0;
for (auto key : removeData.keys())
{
strValues.append(QString("%1 = \"%2\"").arg(OWL::KEYMAP[key], removeData[key]));
i++;
if(removeData.keys().size() > 1 && i<removeData.keys().size())
strValues.append(" AND ");
}
QStringList set;
for (auto key : removeData.keys())
set.append(key+" = ?");
QString sqlQueryString = "DELETE FROM " + tableName + " WHERE " + strValues;
QString sqlQueryString = "DELETE FROM " + tableName + " WHERE " + QString(set.join(" AND "));
qDebug()<< sqlQueryString;
return this->getQuery(sqlQueryString).exec();
auto query = this->getQuery(sqlQueryString);
QVariantList values = removeData.values();
int k = 0;
foreach (const QVariant &value, values)
query.bindValue(k++, value);
return query.exec();
}
......@@ -63,7 +63,7 @@ protected:
bool insert(const QString &tableName, const QVariantMap &insertData);
bool update(const QString &tableName, const QVariantMap &updateData, const QVariantMap &where);
bool update(const QString &table, const QString &column, const QVariant &newValue, const QVariant &op, const QString &id);
bool remove(const QString &tableName, const OWL::DB &removeData);
bool remove(const QString &tableName, const QVariantMap &removeData);
signals:
......
......@@ -103,8 +103,8 @@ bool DBActions::insertNote(const QVariantMap &note)
{OWL::KEYMAP[OWL::KEY::COLOR], color},
{OWL::KEYMAP[OWL::KEY::PIN], pin},
{OWL::KEYMAP[OWL::KEY::FAV], fav},
{OWL::KEYMAP[OWL::KEY::UPDATED], QDateTime::currentDateTime()},
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime()}
{OWL::KEYMAP[OWL::KEY::UPDATED], QDateTime::currentDateTime().toString()},
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime().toString()}
};
if(this->insert(OWL::TABLEMAP[OWL::TABLE::NOTES], note_map))
......@@ -145,6 +145,12 @@ bool DBActions::updateNote(const QVariantMap &note)
return this->update(OWL::TABLEMAP[OWL::TABLE::NOTES], note_map, {{OWL::KEYMAP[OWL::KEY::ID], id}} );
}
bool DBActions::removeNote(const QVariantMap &note)
{
qDebug()<<note;
return this->remove(OWL::TABLEMAP[OWL::TABLE::NOTES], note);
}
QVariantList DBActions::getNotes()
{
return this->get("select * from notes");
......@@ -155,23 +161,35 @@ 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)
bool DBActions::insertLink(const QVariantMap &link)
{
auto url = link[OWL::KEYMAP[OWL::KEY::LINK]].toString();
auto color = link[OWL::KEYMAP[OWL::KEY::COLOR]].toString();
auto pin = link[OWL::KEYMAP[OWL::KEY::PIN]].toInt();
auto fav = link[OWL::KEYMAP[OWL::KEY::FAV]].toInt();
auto tags = link[OWL::KEYMAP[OWL::KEY::TAG]].toStringList();
auto preview = link[OWL::KEYMAP[OWL::KEY::PREVIEW]].toString();
auto title = link[OWL::KEYMAP[OWL::KEY::TITLE]].toString();
auto image_path = OWL::saveImage(Linker::getUrl(preview), OWL::LinksPath+QUuid::createUuid().toString());
QVariantMap link_map =
{
{OWL::KEYMAP[OWL::KEY::LINK], link},
{OWL::KEYMAP[OWL::KEY::LINK], url},
{OWL::KEYMAP[OWL::KEY::TITLE], title},
{OWL::KEYMAP[OWL::KEY::PIN], pin},
{OWL::KEYMAP[OWL::KEY::FAV], fav},
{OWL::KEYMAP[OWL::KEY::PREVIEW], image_path},
{OWL::KEYMAP[OWL::KEY::COLOR], color},
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime()}
{OWL::KEYMAP[OWL::KEY::ADD_DATE], QDateTime::currentDateTime().toString()},
{OWL::KEYMAP[OWL::KEY::UPDATED], QDateTime::currentDateTime().toString()}
};
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->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::LINKS], url, color);
this->linkInserted(link_map);
return true;
......@@ -180,6 +198,34 @@ bool DBActions::insertLink(const QString &link, const QString &title, const QStr
return false;
}
bool DBActions::updateLink(const QVariantMap &link)
{
auto url = link[OWL::KEYMAP[OWL::KEY::LINK]].toString();
auto color = link[OWL::KEYMAP[OWL::KEY::COLOR]].toString();
auto pin = link[OWL::KEYMAP[OWL::KEY::PIN]].toInt();
auto fav = link[OWL::KEYMAP[OWL::KEY::FAV]].toInt();
auto tags = link[OWL::KEYMAP[OWL::KEY::TAG]].toStringList();
QVariantMap link_map =
{
{OWL::KEYMAP[OWL::KEY::COLOR], color},
{OWL::KEYMAP[OWL::KEY::PIN], pin},
{OWL::KEYMAP[OWL::KEY::FAV], fav},
{OWL::KEYMAP[OWL::KEY::UPDATED], QDateTime::currentDateTime().toString()},
};
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::LINKS], url, color);
return this->update(OWL::TABLEMAP[OWL::TABLE::LINKS], link_map, {{OWL::KEYMAP[OWL::KEY::LINK], url}} );
}
bool DBActions::removeLink(const QVariantMap &link)
{
return this->remove(OWL::TABLEMAP[OWL::TABLE::LINKS], link);
}
QVariantList DBActions::getLinks()
{
return this->get("select * from links");
......@@ -196,3 +242,8 @@ bool DBActions::execQuery(const QString &queryTxt)
return query.exec();
}
void DBActions::removeAbtractTags(const QString &key, const QString &lot)
{
}
......@@ -37,10 +37,14 @@ public:
/*main actions*/
Q_INVOKABLE bool insertNote(const QVariantMap &note);
Q_INVOKABLE bool updateNote(const QVariantMap &note);
Q_INVOKABLE bool removeNote(const QVariantMap &note);
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 QStringList &tags = QStringList());
Q_INVOKABLE bool insertLink(const QVariantMap &link);
Q_INVOKABLE bool updateLink(const QVariantMap &link);
Q_INVOKABLE bool removeLink(const QVariantMap &link);
Q_INVOKABLE QVariantList getLinks();
Q_INVOKABLE QVariantList getLinkTags(const QString &link);
......@@ -49,6 +53,8 @@ protected:
bool execQuery(const QString &queryTxt);
Tagging *tag;
void removeAbtractTags(const QString &key, const QString &lot);
signals:
void noteInserted(QVariantMap note);
void linkInserted(QVariantMap link);
......
......@@ -23,5 +23,8 @@ url TEXT,
title TEXT,
preview TEXT,
color TEXT,
addDate DATE
fav INT,
pin INT,
addDate DATE,
updated DATE
);
......@@ -2,3 +2,15 @@ function saveNote(title, body, color, tags)
{
return owl.insertNote(title, body, color, tags)
}
function removeNote(note)
{
var map = {id: note.id }
return owl.removeNote(map)
}
function removeLink(link)
{
var map = {link: link.link }
return owl.removeLink(map)
}
import QtQuick 2.9
import "../../widgets"
import org.kde.maui 1.0 as Maui
import "../../utils/owl.js" as O
Maui.Page
{
......@@ -14,6 +15,7 @@ Maui.Page
margins: isMobile ? space.big : space.enormus
headBarExit: false
headBarTitle : cardsView.count + " links"
headBar.leftContent: [
Maui.ToolButton
{
......@@ -57,10 +59,11 @@ Maui.Page
}
]
Previewer
{
id: previewer
onLinkSaved: if(owl.updateLink(link))
cardsView.currentItem.update(link)
}
CardsView
......@@ -73,11 +76,19 @@ Maui.Page
holder.title : "No Links!"
holder.body: "Click here to save a new link"
holder.emojiSize: iconSizes.huge
Connections
{
target: cardsView.holder
onActionTriggered: newLink()
}
Connections
{
target: cardsView.menu
onDeleteClicked: if(O.removeLink(cardsView.model.get(cardsView.currentIndex)))
cardsView.model.remove(cardsView.currentIndex)
}
}
function populate()
......
......@@ -2,7 +2,7 @@ import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import org.kde.maui 1.0 as Maui
import "../../widgets"
Popup
{
......@@ -16,25 +16,23 @@ Popup
padding: isAndroid ? 2 : "undefined"
property alias webView: webViewer.item
signal linkSaved(var link)
Maui.Page
{
anchors.fill: parent
margins: 0
padding: 0
onExit: close()
headBar.leftContent: Maui.ToolButton
{
iconName: "document-share"
onClicked: isAndroid ? Maui.Android.shareLink(webView.url) :
shareDialog.show(webView.url)
}
headBar.rightContent: [
headBarExit: false
headBar.leftContent: [
Maui.ToolButton
{
iconName: "entry-delete"
id: pinButton
iconName: "window-pin"
checkable: true
iconColor: checked ? highlightColor : textColor
// onClicked: checked = !checked
},
Maui.ToolButton
......@@ -49,31 +47,88 @@ Popup
}
]
headBar.rightContent: ColorsBar
{
id: colorBar
}
footBar.leftContent: [
Maui.ToolButton
{
id: favButton
iconName: "love"
checkable: true
iconColor: checked ? "#ff007f" : textColor
},
Maui.ToolButton
{
iconName: "document-share"
onClicked: isAndroid ? Maui.Android.shareLink(webView.url) :
shareDialog.show(webView.url)
},
Maui.ToolButton
{
iconName: "document-export"
},
Maui.ToolButton
{
iconName: "entry-delete"
}
]
footBar.rightContent: Row
{
spacing: space.medium
Button
{
id: discard
text: qsTr("Discard")
onClicked: close()
}
Button
{
id: save
text: qsTr("Save")
onClicked:
{
packLink()
close()
}
}
}
ColumnLayout
{
anchors.fill: parent
// Item
// {
// Layout.fillWidth: true
// height: rowHeightAlt
// Label
// {
// clip: true
// text: webView.title
// width: parent.width
// height: parent.height
// horizontalAlignment: Qt.AlignHCenter
// verticalAlignment: Qt.AlignVCenter
// font.bold: true
// font.pointSize: fontSizes.big
// font.weight: Font.Bold
// elide: Label.ElideRight
// }
// }
// Item
// {
// Layout.fillWidth: true
// height: rowHeightAlt
// Label
// {
// clip: true
// text: webView.title
// width: parent.width
// height: parent.height
// horizontalAlignment: Qt.AlignHCenter
// verticalAlignment: Qt.AlignVCenter
// font.bold: true
// font.pointSize: fontSizes.big
// font.weight: Font.Bold
// elide: Label.ElideRight
// }
// }
Loader
{
......@@ -110,6 +165,19 @@ Popup
{
webView.url = link.link
tagBar.populate(link.tags)
pinButton.checked = link.pin == 1
favButton.checked = link.fav == 1
open()
}
function packLink()
{
linkSaved({
link: webView.url,
color: colorBar.currentColor,
tag: tagBar.getTags(),
pin: pinButton.checked,
fav: favButton.checked
})
}
}
......@@ -4,7 +4,6 @@ import QtWebView 1.1
WebView
{
id: webView
clip: true
onLoadingChanged:
{
......
......@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
import "../../widgets"
import org.kde.maui 1.0 as Maui
import org.kde.kirigami 2.2 as Kirigami
import "../../utils/owl.js" as O
Maui.Page
......@@ -14,6 +15,7 @@ Maui.Page
headBarExit : false
headBarVisible: !cardsView.holder.visible
headBarTitle : cardsView.count + " notes"
headBar.leftContent: [
Maui.ToolButton
......@@ -64,6 +66,7 @@ Maui.Page
{
anchors.fill: parent
spacing: 0
CardsList
{
id: pinnedList
......@@ -90,6 +93,7 @@ Maui.Page
id: cardsView
Layout.fillHeight: true
Layout.fillWidth: true
width: parent.width
Layout.margins: isMobile ? space.big : space.enormus
onItemClicked: noteClicked(cardsView.model.get(index))
holder.emoji: "qrc:/Type.png"
......@@ -103,6 +107,13 @@ Maui.Page
target: cardsView.holder
onActionTriggered: newNote()
}
Connections
{
target: cardsView.menu
onDeleteClicked: if(O.removeNote(cardsView.model.get(cardsView.currentIndex)))
cardsView.model.remove(cardsView.currentIndex)
}
}
}
......
......@@ -15,6 +15,10 @@ ItemDelegate
property bool condition : true
signal rightClicked();
visible: condition
width: cardWidth
height: cardHeight
hoverEnabled: !isMobile
......@@ -23,7 +27,16 @@ ItemDelegate
color: "transparent"
}
visible: condition
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked:
{
if(!isMobile && mouse.button === Qt.RightButton)
rightClicked()
}
}
DropShadow
{
......@@ -69,7 +82,7 @@ ItemDelegate
Label
{
id: title
padding: 0
visible: title.text.length > 0
Layout.leftMargin: space.medium
Layout.topMargin: space.medium
......@@ -159,13 +172,13 @@ ItemDelegate
}
}
function update(note)
function update(item)
{
console.log("UPDATE NOTES", note.pin)
model.title = note.title
model.body = note.body
model.color = note.color
model.pin = note.pin ? 1 : 0
model.fav = note.fav ? 1 : 0
console.log("update link color", item.color)
model.title = item.title
model.body = item.body
model.color = item.color
model.pin = item.pin ? 1 : 0
model.fav = item.fav ? 1 : 0
}
}
import QtQuick 2.9
import QtQuick.Controls 2.3
Menu
{
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
modal: true
focus: true
parent: ApplicationWindow.overlay
margins: 1
padding: 2
signal deleteClicked()
signal colorClicked()
MenuItem
{
text: qsTr("Fav")
onTriggered:
{
close()
}
}
MenuItem
{
text: qsTr("Pin")
onTriggered:
{
close()
}
}
MenuItem
{
text: qsTr("Share")
onTriggered:
{
close()
}
}
MenuItem
{
text: qsTr("Edit")
onTriggered:
{
close()
}
}
MenuItem
{
text: qsTr("Export")
onTriggered:
{
close()
}
}
MenuItem
{
text: qsTr("Delete")
onTriggered:
{
deleteClicked()
close()
}
}
MenuItem
{
width: parent.width
ColorsBar
{
width: parent.width
size: iconSizes.small
onColorPicked: colorClicked(color)
}
}
}
......@@ -8,8 +8,9 @@ GridView
property bool gridView : true
property alias holder : holder
property alias menu : cardMenu
readonly property int defaultSize : unit * 200
property int itemWidth : !gridView ? parent.width * 0.9 :
property int itemWidth : !gridView ? width :
isMobile? (width-itemSpacing) * 0.42 : unit * 200
property int itemHeight: unit * 120
property int itemSpacing: space.huge
......@@ -24,7 +25,12 @@ GridView
Maui.Holder
{
id: holder
visible: count < 1
visible: count < 1
}
CardMenu
{
id: cardMenu
}
model: ListModel { id: cardsModel}
......@@ -40,6 +46,18 @@ GridView
currentIndex = index
itemClicked(index)
}
onRightClicked:
{
currentIndex = index
cardMenu.popup()
}
onPressAndHold:
{
currentIndex = index
cardMenu.popup()
}
}
// onWidthChanged: if(!isMobile && gridView) adaptGrid()
......
......@@ -6,20 +6,26 @@ Row
signal colorPicked(color color)
anchors.verticalCenter: parent.verticalCenter
spacing: space.medium
property string currentColor
property int size : iconSizes.medium
Rectangle