Commit 03b50f6a authored by Camilo higuita's avatar Camilo higuita

almost ready the tagging modeling

parent e6a32e51
......@@ -48,9 +48,7 @@ public:
/* actions on model */
bool addTag(const QString &tag);
bool albumTag(const QString &tag, const QString &album);
bool removePicTag(const QString &tag, const QString &url);
bool removeAlbumTag(const QString &tag, const QString &album);
bool cleanTags();
bool addAlbum(const QString &album);
......@@ -65,6 +63,9 @@ public:
public slots:
QVariantList get(const QString &queryTxt);
bool albumTag(const QString &tag, const QString &album);
bool removeAlbumTag(const QString &tag, const QString &album);
bool favPic(const QString &url, const bool &fav);
bool isFav(const QString &url);
bool deletePic(const QString &url);
......
......@@ -297,6 +297,5 @@ Maui.ApplicationWindow
target: pix
onRefreshViews: PIX.refreshViews()
onViewPics: VIEWER.openExternalPics(pics, 0)
onNewPic: console.log(pic.url)
}
}
......@@ -185,7 +185,14 @@ void Gallery::append(const QVariantMap &pic)
for(auto key : pic.keys())
this->list << PIX::DB {{PIX::MAPKEY[key], pic[key].toString()}};
emit this->postItemAppended();
}
void Gallery::append(const QString &url)
{
emit this->preItemAppended();
qDebug()<< QString("select * from images where url = '%1'").arg(url);
this->list << this->dba->getDBData(QString("select * from images where url = '%1'").arg(url));
emit this->postItemAppended();
}
......@@ -193,3 +200,10 @@ void Gallery::refresh()
{
this->setList();
}
void Gallery::clear()
{
emit this->preListChanged();
this->list.clear();
emit this->postListChanged();
}
......@@ -47,7 +47,9 @@ public slots:
bool deleteAt(const int &index);
bool fav(const int &index, const bool &value);
void append(const QVariantMap &pic);
void append(const QString &url);
void refresh();
void clear();
};
#endif // GALLERY_H
......@@ -81,7 +81,6 @@ Maui.SelectionBar
Maui.MenuItem
{
text: qsTr("Show in folder...")
enabled: !isMultiple
onTriggered: pix.showInFolder(selectedPaths)
}
......
......@@ -13,12 +13,12 @@ Maui.Dialog
property bool forAlbum : false
signal picTagged(string tag, string url)
signal tagsAdded(var tags, var urls)
defaultButtons: true
maxHeight: unit * 500
onAccepted: setTags()
onRejected: close()
onOpened: populate()
ColumnLayout
{
......@@ -29,13 +29,13 @@ Maui.Dialog
Layout.fillWidth: true
TagsList
{
id: tagsList
id: _tagsList
width: parent.width
height: parent.height
onTagClicked:
{
tagListComposer.model.insert(0, {tag: tagsList.model.get(index).tag})
tagListComposer.list.append(tagsList.get(index).tag)
}
}
}
......@@ -52,11 +52,8 @@ Maui.Dialog
for(var i in tags)
{
var myTag = tags[i].trim()
if(!tag.tagExists(myTag, true))
tagsList.model.insert(0, {tag: myTag})
tagListComposer.model.insert(0, {tag: myTag})
tagsList.insert(myTag)
tagListComposer.list.append(myTag)
}
clear()
}
......@@ -69,13 +66,11 @@ Maui.Dialog
Layout.fillWidth: true
Layout.leftMargin: contentMargins
Layout.rightMargin: contentMargins
height: 64
width: parent.width
onTagRemoved:
{
pix.removePicTag(model.get(index).tag, pixViewer.currentPic.url)
tagListComposer.model.remove(index)
list.removeFrom(index, pixViewer.currentPic.url)
}
}
}
......@@ -83,6 +78,11 @@ Maui.Dialog
function show(urls)
{
picUrls = urls
if(forAlbum)
tag.getAbstractTags("album", picUrls[0], true)
else
tagListComposer.list.urls = picUrls
open()
}
......@@ -90,8 +90,8 @@ Maui.Dialog
{
var tags = []
for(var i = 0; i < tagListComposer.model.count; i++)
tags.push(tagListComposer.model.get(i).tag)
for(var i = 0; i < tagListComposer.count; i++)
tags.push(tagListComposer.list.get(i).tag)
tagsAdded(tags, picUrls)
}
......@@ -103,8 +103,8 @@ Maui.Dialog
var url = urls[j]
if(tags.length > 0)
{
if(!pix.checkExistance("images", "url", url))
if(!pix.addPic(url))
if(!dba.checkExistance("images", "url", url))
if(!dba.addPic(url))
return
for(var i in tags)
......@@ -114,20 +114,5 @@ Maui.Dialog
}
close()
}
function populate()
{
tagsList.model.clear()
var tags = tag.getUrlsTags()
if(tags.length > 0)
for(var i in tags)
tagsList.model.append(tags[i])
if(picUrls.length === 1)
tagListComposer.populate(forAlbum ? tag.getAbstractTags("album", picUrls[0], true) :
tag.getUrlTags(picUrls[0], true))
}
}
}
......@@ -26,7 +26,7 @@ ListView
emojiSize: iconSizes.huge
}
model: ListModel{}
model: tagsModel
delegate: Maui.ListDelegate
{
id: delegate
......
......@@ -94,16 +94,15 @@ Kirigami.PageRow
footer: Maui.TagsBar
{
id: tagBar
list.abstract: true
list.key: "album"
width: picsView.width
allowEditMode: true
onAddClicked: tagsDialog.show(albumGrid.currentAlbum)
onTagsEdited: addTagsToAlbum(albumGrid.currentAlbum, tags)
onTagRemovedClicked: if(pix.removeAlbumTag(tagsList.model.get(index).tag, albumGrid.currentAlbum))
tagsList.model.remove(index)
onTagRemovedClicked: list.removeFrom(index, list.key, list.lot)
}
}
// function populate()
......@@ -125,7 +124,6 @@ Kirigami.PageRow
function filter(album)
{
albumGrid.currentAlbum = album
tagBar.tagsList.model.clear()
tagBar.visible = false
switch(album)
......@@ -138,12 +136,18 @@ Kirigami.PageRow
break
default:
populateAlbum(Q.Query.albumPics_.arg(album))
var tags = tag.getAbstractTags("album", album, true)
for(var i in tags)
albumsGrid.list.append(tag.getUrls(tags[i].tag)) //create an append function in gallery.cpp
tagBar.visible = true
tagBar.tagsList.populate(tags)
tagBar.list.lot = album
for(var i = 0; i < tagBar.count; i++)
{
var _tag = tagBar.list.get(i).tag
var urls = tag.getUrls(_tag)
for(var j in urls)
picsView.list.append(urls[j].url)
}
break
}
}
......@@ -152,6 +156,7 @@ Kirigami.PageRow
{
albumsPageRoot.currentIndex = 1
picsView.list.query = query
}
function addAlbum(album)
......@@ -165,7 +170,7 @@ Kirigami.PageRow
if(tags.length > 0)
for(var i in tags)
if(PIX.addTagToAlbum(tags[i], album))
tagBar.append({"tag": tags[i]})
tagBar.list.append(tags[i])
}
}
......@@ -95,8 +95,6 @@ Kirigami.PageRow
holder.emojiSize: iconSizes.huge
}
Component.onCompleted: populate()
function refresh()
{
foldersList.refresh()
......
......@@ -14,7 +14,7 @@ function addTagToPic(myTag, url)
function addTagToAlbum(tag, url)
{
return pix.albumTag(tag, url)
return dba.albumTag(tag, url)
}
function removePics(urls)
......
......@@ -5,7 +5,6 @@ import org.kde.mauikit 1.0 as Maui
Maui.Page
{
property alias list : tagsList
margins:0
headBarExit: false
headBarTitle: qsTr("Tags")
......@@ -26,7 +25,7 @@ Maui.Page
Maui.Holder
{
visible: tagsList.count === 0
visible: _tagsList.count === 0
emoji: "qrc:/img/assets/Rainbow.png"
isMask: false
title : "No Tags!"
......@@ -37,7 +36,7 @@ Maui.Page
Maui.SideBar
{
id: tagsList
id: _tagsList
anchors.fill: parent
model: tagsModel
delegate: Maui.ListDelegate
......@@ -50,8 +49,8 @@ Maui.Page
target: delegate
onClicked:
{
tagsList.currentIndex = index
currentTag = tagsList.model.get(index).tag
_tagsList.currentIndex = index
currentTag = tagsList.get(index).tag
populateGrid(currentTag)
}
}
......
......@@ -19,11 +19,6 @@ Kirigami.PageRow
property string currentTag : ""
Connections
{
target: pix
onTagAdded: tagsSidebar.list.model.insert(tagsSidebar.list.count, {"tag": tag})
}
Maui.NewDialog
{
......@@ -34,6 +29,7 @@ Kirigami.PageRow
tagsList.insert(text)
}
}
TagsSidebar
{
id: tagsSidebar
......@@ -59,15 +55,15 @@ Kirigami.PageRow
function populateGrid(myTag)
{
tagsGrid.list.clear()
if(!wideMode && currentIndex === 0)
currentIndex = 1
tagsGrid.model.clear()
var tags = tag.getUrls(myTag);
var urls = tag.getUrls(myTag);
if(tags.length > 0)
for(var i in tags)
tagsGrid.model.append(tags[i])
if(urls.length > 0)
for(var i in urls)
tagsGrid.list.append(urls[i].url)
}
}
......@@ -199,6 +199,7 @@ Maui.Page
Layout.fillWidth: true
bgColor: viewerBackgroundColor
allowEditMode: true
list.urls: [currentPic.url]
onTagClicked: PIX.searchFor(tag)
onAddClicked:
{
......@@ -210,7 +211,7 @@ Maui.Page
onTagsEdited:
{
PIX.updatePicTags(tags, pixViewer.currentPic.url)
VIEWER.setCurrentPicTags()
list.refresh()
}
}
}
......
......@@ -28,19 +28,11 @@ function view(index)
console.log("CURRENT PIC FAV", pixViewer.currentPic.fav)
pixViewer.currentPicFav = dba.isFav(pixViewer.currentPic.url)
setCurrentPicTags()
root.title = pixViewer.currentPic.title
pixViewer.roll.position(pixViewer.currentPicIndex)
}
function setCurrentPicTags()
{
pixViewer.tagBar.populate(tag.getUrlTags(pixViewer.currentPic.url))
}
function next()
{
if(pixViewer.viewer.count > 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