diff --git a/app/qml/BooksDragArea.qml b/app/qml/BooksDragArea.qml index ca98271..1d136a6 100644 --- a/app/qml/BooksDragArea.qml +++ b/app/qml/BooksDragArea.qml @@ -130,10 +130,7 @@ MouseArea { } onPressAndHold: { if (!shelfView.editMode) { - var index = gridView.indexAt(mouseX + gridView.contentX, mouseY + currentShelfView.contentY) - if (index === pressedItemIndex) { - shelfView.startEditing() - } + shelfView.startEditing() } } onPositionChanged: { diff --git a/app/qml/BooksShelfFooter.qml b/app/qml/BooksShelfFooter.qml index 9e7697c..8610672 100644 --- a/app/qml/BooksShelfFooter.qml +++ b/app/qml/BooksShelfFooter.qml @@ -47,7 +47,7 @@ Item { //% "No books" text: qsTrId("shelf-view-no-books") - visible: footerState == 2 + visible: footerState == 2 && !editMode anchors.centerIn: parent } diff --git a/app/qml/BooksShelfTitle.qml b/app/qml/BooksShelfTitle.qml index bbcddb8..4e1c899 100644 --- a/app/qml/BooksShelfTitle.qml +++ b/app/qml/BooksShelfTitle.qml @@ -32,10 +32,14 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -BackgroundItem { +MouseArea { id: root implicitHeight: column.implicitHeight property alias text: label.text + property bool currentFolder + property bool _highlighted: pressed + property color _highlightedColor: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) + property bool _showPress: !currentFolder && (_highlighted || pressTimer.running) Column { id: column @@ -74,7 +78,7 @@ BackgroundItem { leftMargin: Theme.paddingMedium verticalCenter: parent.verticalCenter } - color: (!root.enabled || pressed) ? Theme.highlightColor : Theme.primaryColor + color: (currentFolder || pressed) ? Theme.highlightColor : Theme.primaryColor Behavior on color { ColorAnimation { duration: 100 } } } } @@ -129,4 +133,17 @@ BackgroundItem { } */ } + + onPressed: pressTimer.start() + onCanceled: pressTimer.stop() + + Rectangle { + anchors.fill: parent + color: _showPress ? _highlightedColor : "transparent" + } + + Timer { + id: pressTimer + interval: 50 + } } diff --git a/app/qml/BooksShelfView.qml b/app/qml/BooksShelfView.qml index 3acffc0..89c43ba 100644 --- a/app/qml/BooksShelfView.qml +++ b/app/qml/BooksShelfView.qml @@ -175,10 +175,16 @@ SilicaFlickable { BooksShelfTitle { width: grid.width text: model.name - enabled: model.index < (pathModel.count-1) + currentFolder: model.index === (pathModel.count-1) onClicked: { - console.log("switching to", model.path) - shelfModel.relativePath = model.path + if (currentFolder) { + if (editMode) { + console.log("how about renaming", model.name) + } + } else { + console.log("switching to", model.path) + shelfModel.relativePath = model.path + } } } } diff --git a/app/src/BooksShelf.cpp b/app/src/BooksShelf.cpp index cc0413a..b672901 100644 --- a/app/src/BooksShelf.cpp +++ b/app/src/BooksShelf.cpp @@ -519,6 +519,7 @@ void BooksShelf::Counts::emitSignals(BooksShelf* aShelf) BooksShelf::BooksShelf(QObject* aParent) : QAbstractListModel(aParent), + iLoadBookList(true), iLoadTask(NULL), iDummyItemIndex(-1), iEditMode(false), @@ -531,6 +532,7 @@ BooksShelf::BooksShelf(QObject* aParent) : } BooksShelf::BooksShelf(BooksStorage aStorage, QString aRelativePath) : + iLoadBookList(false), iLoadTask(NULL), iRelativePath(aRelativePath), iStorage(aStorage), @@ -614,7 +616,7 @@ void BooksShelf::updatePath() endRemoveRows(); } iDummyItemIndex = -1; - if (!iPath.isEmpty()) loadBookList(); + if (!iPath.isEmpty() && iLoadBookList) loadBookList(); Q_EMIT pathChanged(); if (oldDummyItemIndex != iDummyItemIndex) { Q_EMIT dummyItemIndexChanged(); diff --git a/app/src/BooksShelf.h b/app/src/BooksShelf.h index bd3ec11..d1b09c7 100644 --- a/app/src/BooksShelf.h +++ b/app/src/BooksShelf.h @@ -165,6 +165,7 @@ private: class DeleteTask; friend class Counts; + bool iLoadBookList; QList iList; QList iDeleteTasks; LoadTask* iLoadTask;