Commit 5be1d5b7 authored by camilo higuita's avatar camilo higuita

intial work on db to allow sync tags and albums and images notes #23 #22

parent b7bb6278
......@@ -7,5 +7,10 @@ var Query = {
allTags : "select * from tags",
allAlbums : "select * from albums order by strftime(\"%s\", addDate) desc",
albumPics_ : "select i.* from images_albums ia inner join images i on i.url = ia.url where ia.album = \"%1\" order by strftime(\"%s\", ia.addDate) desc"
albumPics_ : "select i.* from images_albums ia inner join images i on i.url = ia.url where ia.album = \"%1\" order by strftime(\"%s\", ia.addDate) desc",
favPics: "select * from images where fav = 1",
recentPics: "select * from images order by strftime(\"%s\", addDate) desc limit 50"
}
......@@ -31,7 +31,7 @@ FOREIGN KEY(sources_url) REFERENCES SOURCES(url)
CREATE TABLE IF NOT EXISTS IMAGES_TAGS (
tag TEXT NOT NULL,
url VARCHAR(150) NOT NULL,
url TEXT NOT NULL,
PRIMARY KEY (tag, url),
FOREIGN KEY(tag) REFERENCES TAGS(tag),
FOREIGN KEY(url) REFERENCES IMAGES(url)
......@@ -41,8 +41,24 @@ CREATE TABLE IF NOT EXISTS IMAGES_ALBUMS (
album TEXT NOT NULL,
url TEXT NOT NULL,
addDate DATE,
PRIMARY KEY (album, url),
FOREIGN KEY(album) REFERENCES ALBUMS(album),
FOREIGN KEY(url) REFERENCES IMAGES(url)
);
CREATE TABLE IF NOT EXISTS ALBUMS_TAGS (
tag TEXT NOT NULL,
album TEXT NOT NULL,
PRIMARY KEY (tag, album),
FOREIGN KEY(tag) REFERENCES TAGS(tag),
FOREIGN KEY(album) REFERENCES ALBUMS(album)
);
CREATE TABLE IF NOT EXISTS ALBUMS_NOTES (
note TEXT NOT NULL,
album TEXT NOT NULL,
PRIMARY KEY (note, album),
FOREIGN KEY(album) REFERENCES ALBUMS(album)
);
......@@ -12,6 +12,7 @@ import "widgets/views/Tags"
import "widgets/views/Viewer"
import "view_models"
import "widgets/dialogs/share"
import "widgets/views/Pix.js" as PIX
......@@ -90,6 +91,11 @@ Kirigami.ApplicationWindow
{
}
ShareDialog
{
id: shareDialog
}
SwipeView
{
id: swipeView
......
......@@ -50,7 +50,7 @@ Pix::~Pix()
void Pix::refreshCollection()
{
this->populateDB({PIX::PicturesPath, PIX::DownloadsPath});
this->populateDB({PIX::PicturesPath, PIX::DownloadsPath, PIX::DocumentsPath});
}
QVariantList Pix::getList(const QStringList &urls)
......
......@@ -143,6 +143,7 @@ namespace PIX
const QString PicturesPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
const QString DownloadsPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString DocumentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
const QString HomePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString SettingPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/pix/";
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/pix/";
......
......@@ -11,10 +11,19 @@ PixPage
property int picRadius : 4
property alias grid: grid
property alias holder: holder
/*signals*/
signal picClicked(int index)
PixHolder
{
id: holder
message: "<h2>No Pics!</h2><p>There's not images in here</p>"
emoji: "qrc:/img/assets/face-hug.png"
visible: grid.count === 0
}
headerbarTitle: gridModel.count+" "+qsTr("images")
headerBarRight: [
......
......@@ -3,18 +3,12 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../view_models"
import "../widgets/views/Viewer/Viewer.js" as VIEWER
import "dialogs/share"
ToolBar
{
id: footerToolbar
visible: !pixViewer.holder.visible && currentView === views.viewer
position: ToolBar.Footer
ShareDialog
{
id: shareDialog
}
RowLayout
{
anchors.fill: parent
......
......@@ -3,13 +3,14 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../../view_models"
Rectangle
Item
{
color: "transparent"
clip : true
property alias tagsList : tagsList
RowLayout
{
anchors.fill: parent
......@@ -36,6 +37,16 @@ Rectangle
onTagRemoved: if(pix.removePicTag(tagsList.model.get(index).tag, pixViewer.currentPic.url))
tagsList.model.remove(index)
Label
{
height: parent.height
width: parent.width
text: qsTr("Add tags...")
opacity: 0.5
visible: tagsList.count === 0
font.pointSize: fontSizes.default
}
}
}
}
......@@ -8,7 +8,7 @@ ListView
spacing: contentMargins
signal tagRemoved(int index)
model: ListModel{ ListElement{tag: "test"}}
model: ListModel{}
delegate: TagDelegate
{
......
......@@ -2,6 +2,8 @@ import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
import "../../../db/Query.js" as Q
import "../../../widgets/views/Viewer/Viewer.js" as VIEWER
import "../../dialogs/Albums"
PixPage
......@@ -10,12 +12,12 @@ PixPage
headerbarExit: stackView.currentItem === picsView
headerbarExitIcon: "go-previous"
headerbarTitle: albumGrid.count+qsTr(" Albums")
headerbarTitle: stackView.currentItem === picsView ? "undefined" : albumGrid.count+qsTr(" Albums")
onExit:
{
stackView.pop(albumGrid)
headerbarTitle: albumGrid.count+qsTr(" Albums")
headerbarTitle = "Albums"
}
headerBarRight: [
......@@ -53,13 +55,26 @@ PixPage
{
id: albumGrid
onAlbumClicked: populateAlbum(model.get(index).album)
onAlbumClicked: filter(model.get(index).album)
}
PixGrid
{
id: picsView
headerbarVisible: false
onPicClicked: openPic(index)
holder.message: "<h2>No Pics!</h2><p>This albums is empty</p>"
holder.emoji: "qrc:/img/assets/face-sleeping.png"
function openPic(index)
{
var data = []
for(var i = 0; i < grid.model.count; i++)
data.push(grid.model.get(i))
VIEWER.open(data, index)
}
}
}
......@@ -78,12 +93,29 @@ PixPage
albumGrid.model.clear()
}
function populateAlbum(album)
function filter(album)
{
headerbarTitle = album
picsView.clear()
var pics = pix.get(Q.Query.albumPics_.arg(album))
switch(album)
{
case "Favs":
populateAlbum(Q.Query.favPics)
break
case "Recent":
populateAlbum(Q.Query.recentPics)
break
default:
populateAlbum(Q.Query.albumPics_.arg(album))
break
}
}
function populateAlbum(query)
{
var pics = pix.get(query)
if(pics.length > 0)
for(var i in pics)
......
......@@ -59,7 +59,7 @@ PixPage
footer: ToolBar
{
position: ToolBar.Footer
visible: !holder.visible
TagBar
{
id: tagBar
......@@ -82,7 +82,7 @@ PixPage
PixHolder
{
id: holder
message: "<h2>No Pic!</h2><p>Select or open an image from yuor gallery</p>"
message: "<h2>No Pic!</h2><p>Open an image from your collection</p>"
emoji: "qrc:/img/assets/face-hug.png"
visible: Object.keys(currentPic).length === 0
}
......
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