Commit bc005163 authored by Camilo Higuita's avatar Camilo Higuita

fav marking pictures from the viewer #3

parent 8ed1cc36
......@@ -106,6 +106,21 @@ void DBActions::addPic(const PIX::DB &img)
}
bool DBActions::favPic(const QString &url, const bool &fav )
{
PIX::DB favedPic = {{PIX::KEY::FAV, fav ? "1" : "0"}};
return this->update(PIX::TABLEMAP[PIX::TABLE::IMAGES], favedPic, QVariantMap({{PIX::KEYMAP[PIX::KEY::URL], url}}) );
}
bool DBActions::isFav(const QString &url)
{
auto data = this->getDBData(QString("select * from images where url = '%1'").arg(url));
if (data.isEmpty()) return false;
return data.first()[PIX::KEY::FAV] == "1" ? true : false;
}
QVariantList DBActions::getFolders()
{
QVariantList res;
......
......@@ -17,6 +17,10 @@ class DBActions : public DB
void addPic(const PIX::DB &img);
/* actions on model */
Q_INVOKABLE bool favPic(const QString &url, const bool &fav);
Q_INVOKABLE bool isFav(const QString &url);
/* utils */
Q_INVOKABLE QVariantList getFolders();
Q_INVOKABLE QVariantList get(const QString &queryTxt);
......
......@@ -25,5 +25,6 @@
<file>widgets/views/Viewer/EditTools.qml</file>
<file>widgets/views/Viewer/Viewer.qml</file>
<file>widgets/views/Viewer/Viewer.js</file>
<file>widgets/views/Folders/PicsView.qml</file>
</qresource>
</RCC>
......@@ -11,6 +11,11 @@ ItemDelegate
height: folderSize*2
width: folderSize*2
background: Rectangle
{
color: "transparent"
}
ColumnLayout
{
anchors.fill: parent
......
......@@ -6,9 +6,9 @@ GridView
{
id: folderGridRoot
property int gridSize : 64
clip: true
height: parent.height
width: parent.width
clip: true
height: parent.height
width: parent.width
cellHeight: gridSize+contentMargins
cellWidth: gridSize+contentMargins
......
import QtQuick 2.0
Item {
}
......@@ -28,6 +28,6 @@ PixGrid
for(var i = 0; i < grid.model.count; i++)
data.push(grid.model.get(i))
VIEWER.view(data, index)
VIEWER.open(data, index)
}
}
......@@ -8,7 +8,7 @@ PixPage
{
property alias viewer : viewer
property bool currentPicFav: false
property var currentPic : ({})
property var picContext : []
property int currentPicIndex : 0
......@@ -104,15 +104,20 @@ PixPage
PixButton
{
id: favIcon
anchors.centerIn: parent
iconName: "love"
iconColor: currentPicFav? pix.pixColor() : textColor
hoverEnabled: !isMobile
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Fav")
onClicked: currentPicFav = VIEWER.fav(currentPic.url)
}
}
......
function view(model, index)
function open(model, index)
{
console.log(model.length, index)
pixViewer.currentPicIndex = index
pixViewer.picContext = model
console.log(pixViewer.picContext.length, pixViewer.currentPicIndex)
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
console.log(model[7].url)
view(pixViewer.currentPicIndex)
if(currentView !== views.viewer)
currentView = views.viewer
}
function fullscreen()
function view(index)
{
pixViewer.currentPic = pixViewer.picContext[index]
pixViewer.currentPicFav = pix.isFav(pixViewer.currentPic.url)
}
function fullscreen(state)
{
}
......@@ -25,7 +30,7 @@ function next()
else
pixViewer.currentPicIndex = 0
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
view(pixViewer.currentPicIndex)
}
}
......@@ -38,12 +43,14 @@ function previous()
else
pixViewer.currentPicIndex = pixViewer.picContext.length-1
pixViewer.currentPic = pixViewer.picContext[pixViewer.currentPicIndex]
view(pixViewer.currentPicIndex)
}
}
function fav(url)
{
var faved = pix.isFav(url);
if(pix.favPic(url, !faved))
return !faved
}
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