diff --git a/qmlUiKirigami/ImageFolderAlbumView.qml b/qmlUiKirigami/ImageFolderAlbumView.qml new file mode 100644 --- /dev/null +++ b/qmlUiKirigami/ImageFolderAlbumView.qml @@ -0,0 +1,39 @@ +/* + * Copyright 2017 by Atul Sharma + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 + +import org.kde.koko 0.1 as Koko + +AlbumView { + property alias sourceUrl: albumViewFolderModel.url + + model: Koko.SortModel { + sourceModel: Koko.ImageFolderModel { + id: albumViewFolderModel + onRowsInserted: { + if (indexForUrl(imagePathArgument[imagePathArgument.length - 1]) != -1) { + currentImage.model = this + currentImage.index = indexForUrl(imagePathArgument[imagePathArgument.length - 1]) + } + } + } + } + +} diff --git a/qmlUiKirigami/Main.qml b/qmlUiKirigami/Main.qml --- a/qmlUiKirigami/Main.qml +++ b/qmlUiKirigami/Main.qml @@ -44,6 +44,8 @@ pageStack.initialPage: AlbumView { id: albumView + model: imageFolderModel + title: i18n("Folders") } globalDrawer: Sidebar { @@ -110,9 +112,16 @@ * makes sure that operation only occurs after the model is populated */ onRowsInserted: { - if( indexForUrl(imagePathArgument[imagePathArgument.length -1]) != -1) { + for( var i = 1; i < imagePathArgument.length -1 ; i++) { + pageStack.push( Qt.resolvedUrl("ImageFolderAlbumView.qml"), { "sourceUrl": imagePathArgument[i] }) + } + + /** + * To set the currentImage when no folder is pushed + */ + if ( (currentImage.view.model.sourceModel == this) && (indexForUrl(imagePathArgument[imagePathArgument.length - 1]) != -1) ) { currentImage.model = this - currentImage.index = indexForUrl(imagePathArgument[imagePathArgument.length -1]) + currentImage.index = indexForUrl(imagePathArgument[imagePathArgument.length - 1]) } } } @@ -193,9 +202,5 @@ imageHeight: root.height state: imagePathArgument == "" ? "closed" : "open" } - - Component.onCompleted: { - albumView.model = imageFolderModel - albumView.title = i18n("Folders") - } + }