Commit 366f6471 authored by camilo higuita's avatar camilo higuita

links view now workign again... maybe we shoudl use webview instead of custom...

links view now workign again... maybe we shoudl use webview instead of custom parser... or imporve the parser
parent 14c355e3
......@@ -27,8 +27,7 @@ adddate DATE
);
CREATE TABLE IF NOT EXISTS LINKS (
link TEXT PRIMARY KEY,
url TEXT,
url TEXT PRIMARY KEY,
title TEXT,
preview TEXT,
color TEXT,
......
......@@ -79,8 +79,10 @@ void Linker::extract(const QString &url)
else continue;
}
qDebug() << imgs;
LINK link_data {{FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE], title.trimmed()},
{FMH::MODEL_NAME[FMH::MODEL_KEY::CONTENT], data},
{FMH::MODEL_NAME[FMH::MODEL_KEY::URL], data},
{FMH::MODEL_NAME[FMH::MODEL_KEY::IMG], imgs}};
emit previewReady(link_data);
}
......
......@@ -80,50 +80,28 @@ bool Links::insert(const QVariantMap &link)
{
emit this->preItemAppended();
auto url = link[FMH::MODEL_NAME[FMH::MODEL_KEY::LINK]].toString();
auto color = link[FMH::MODEL_NAME[FMH::MODEL_KEY::COLOR]].toString();
auto pin = link[FMH::MODEL_NAME[FMH::MODEL_KEY::PIN]].toInt();
auto fav = link[FMH::MODEL_NAME[FMH::MODEL_KEY::FAV]].toInt();
auto tags = link[FMH::MODEL_NAME[FMH::MODEL_KEY::TAG]].toStringList();
auto preview = link[FMH::MODEL_NAME[FMH::MODEL_KEY::PREVIEW]].toString();
auto title = link[FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE]].toString();
auto image_path = OWL::saveImage(Linker::getUrl(preview), OWL::LinksPath+QUuid::createUuid().toString());
QVariantMap link_map =
{
{FMH::MODEL_NAME[FMH::MODEL_KEY::LINK], url},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE], title},
{FMH::MODEL_NAME[FMH::MODEL_KEY::PIN], pin},
{FMH::MODEL_NAME[FMH::MODEL_KEY::FAV], fav},
{FMH::MODEL_NAME[FMH::MODEL_KEY::PREVIEW], image_path},
{FMH::MODEL_NAME[FMH::MODEL_KEY::COLOR], color},
{FMH::MODEL_NAME[FMH::MODEL_KEY::ADDDATE], QDateTime::currentDateTime().toString()},
{FMH::MODEL_NAME[FMH::MODEL_KEY::MODIFIED], QDateTime::currentDateTime().toString()}
};
if(this->db->insert(OWL::TABLEMAP[OWL::TABLE::LINKS], link_map))
auto __model = FMH::toModel(link);
__model[FMH::MODEL_KEY::ADDDATE] = QDateTime::currentDateTime().toString();
__model[FMH::MODEL_KEY::MODIFIED] = QDateTime::currentDateTime().toString();
__model[FMH::MODEL_KEY::PREVIEW] = OWL::saveImage(Linker::getUrl(__model[FMH::MODEL_KEY::PREVIEW]), OWL::LinksPath+QUuid::createUuid().toString());
__model = FMH::filterModel(__model, {FMH::MODEL_KEY::URL,
FMH::MODEL_KEY::TITLE,
FMH::MODEL_KEY::PREVIEW,
FMH::MODEL_KEY::COLOR,
FMH::MODEL_KEY::FAVORITE,
FMH::MODEL_KEY::PIN,
FMH::MODEL_KEY::MODIFIED,
FMH::MODEL_KEY::ADDDATE});
if(this->db->insert(OWL::TABLEMAP[OWL::TABLE::LINKS], FMH::toMap(__model)))
{
for(auto tg : tags)
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::LINKS], url, color);
this->links << FMH::MODEL
({
{FMH::MODEL_KEY::LINK, url},
{FMH::MODEL_KEY::TITLE, title},
{FMH::MODEL_KEY::COLOR, color},
{FMH::MODEL_KEY::PREVIEW, image_path},
{FMH::MODEL_KEY::PIN, QString::number(pin)},
{FMH::MODEL_KEY::FAV, QString::number(fav)},
{FMH::MODEL_KEY::MODIFIED, QDateTime::currentDateTime().toString()},
{FMH::MODEL_KEY::ADDDATE, QDateTime::currentDateTime().toString()}
});
for(auto tg : __model[FMH::MODEL_KEY::TAG].split(","))
this->tag->tagAbstract(tg, OWL::TABLEMAP[OWL::TABLE::LINKS], __model[FMH::MODEL_KEY::URL]);
this->links << __model;
emit postItemAppended();
return true;
} else qDebug()<< "LINK COULD NOT BE INSTED";
......
......@@ -21,6 +21,7 @@ Maui.Dialog
y: (parent.height /2 ) - (height / 2)
modal: true
padding: isAndroid ? 1 : undefined
page.padding: 0
Connections
{
......@@ -34,14 +35,35 @@ Maui.Dialog
headBar.visible: previewReady
footBar.visible: previewReady
headBar.leftContent: ToolButton
{
id: pinButton
icon.name: "window-pin"
checkable: true
icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
// onClicked: checked = !checked
}
headBar.leftContent: [
ToolButton
{
id: pinButton
icon.name: "window-pin"
checkable: true
icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
// onClicked: checked = !checked
},
TextField
{
id: title
visible: previewReady
Layout.fillWidth: true
Layout.margins: space.medium
height: 24
placeholderText: qsTr("Title")
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
color: fgColor
background: Rectangle
{
color: "transparent"
}
}
]
headBar.rightContent: ColorsBar
{
......@@ -108,31 +130,13 @@ Maui.Dialog
onAccepted: linker.extract(link.text)
}
TextField
{
id: title
visible: previewReady
Layout.fillWidth: true
Layout.margins: space.medium
height: 24
placeholderText: qsTr("Title")
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
color: fgColor
background: Rectangle
{
color: "transparent"
}
}
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
visible: previewReady
Layout.fillWidth: previewReady
Layout.fillHeight: previewReady
ListView
{
id: previewList
......@@ -180,7 +184,7 @@ Maui.Dialog
{
id: tagBar
visible: previewReady
Layout.fillWidth: true
Layout.fillWidth: visible
allowEditMode: true
list.abstract: true
list.key: "links"
......@@ -203,7 +207,7 @@ Maui.Dialog
function fill(link)
{
title.text = link.title
populatePreviews(link.image)
populatePreviews(link.img)
tagBar.list.lot= link.url
open()
......@@ -221,13 +225,13 @@ Maui.Dialog
function packLink()
{
var data = ({
link : link.text,
url : link.text,
title: title.text,
preview: previewList.count > 0 ? previewList.model.get(previewList.currentIndex).url : "",
color: selectedColor,
tag: tagBar.getTags(),
pin: pinButton.checked,
fav: favButton.checked
color: selectedColor,
tag: tagBar.getTags(),
pin: pinButton.checked,
favorite: favButton.checked
})
linkSaved(data)
}
......
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