Commit 4f786fb1 authored by Karel Slaný's avatar Karel Slaný

Derived DataboxList from ScrollableListView.

parent d3c2e65f
......@@ -23,6 +23,7 @@
import QtGraphicalEffects 1.0
import QtQuick 2.7
import cz.nic.mobileDatovka 1.0
/*
* Accessible menu component.
......@@ -30,9 +31,11 @@ import QtQuick 2.7
* An object containing functions to be called and a model in specified form
* must be provided.
*/
ListView {
ScrollableListView {
id: root
delegateHeight: headerHeight
/* These properties must be set by caller. */
property var funcArr: null /* https://stackoverflow.com/a/24376300 */
......@@ -97,7 +100,7 @@ ListView {
Rectangle {
visible: showEntry
color: datovkaPalette.base
height: showEntry ? headerHeight : 0 /* Collapse when not visible. */
height: showEntry ? root.delegateHeight : 0 /* Collapse when not visible. */
width: parent.width
Image {
id: menuImage
......@@ -176,33 +179,5 @@ ListView {
}
}
/*
* Scroll list down.
*/
function scrollDown() {
var numViewed = Math.ceil(root.height / (2 * headerHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtTop = root.indexAt(1, 1 + root.contentY)
indexAtTop = (indexAtTop >= 0) ? (indexAtTop + numViewed) : 0
root.positionViewAtIndex(indexAtTop, ListView.Beginning)
root.returnToBounds()
}
/*
* Scroll list up.
*/
function scrollUp() {
var numViewed = Math.ceil(root.height / (2 * headerHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtBottom = root.indexAt(1, root.height - 2 + root.contentY)
indexAtBottom = (indexAtBottom >= 0) ? (indexAtBottom - numViewed) : 0
root.positionViewAtIndex(indexAtBottom, ListView.End)
root.returnToBounds()
}
delegate: menuDelegate
}
......@@ -25,12 +25,14 @@ import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.modelEntries 1.0
ListView {
ScrollableListView {
id: root
delegateHeight: listItemHeight
/* These properties must be set by caller. */
property bool canDetailBoxes: false // enables viewing of box details
property bool canSelectBoxes: false // enables selecting of entries
......@@ -47,7 +49,7 @@ ListView {
delegate: Rectangle {
id: dbItem
height: listItemHeight
height: root.delegateHeight
width: parent.width
color: rDbSelected ? readBgColor : datovkaPalette.base
Item {
......@@ -194,6 +196,12 @@ ListView {
Accessible.role: Accessible.Button
Accessible.name: accessibleText()
Accessible.onScrollDownAction: {
root.scrollDown()
}
Accessible.onScrollUpAction: {
root.scrollUp()
}
Accessible.onPressAction: {
handleClick()
}
......
......@@ -25,18 +25,21 @@ import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.messages 1.0
ListView {
ScrollableListView {
id: root
delegateHeight: listItemHeight
/* These signals should be captured to implement message interaction. */
signal msgClicked(string userName, int msgType, string msgId)
signal msgPressAndHold(string userName, int msgType, string msgId, bool canDelete)
delegate: Rectangle {
id: messageItem
height: listItemHeight
height: root.delegateHeight
width: parent.width
color: (rMsgType == MessageType.TYPE_RECEIVED && !rReadLocally) ? datovkaPalette.base : readBgColor
Item {
......@@ -177,33 +180,5 @@ ListView {
}
} // Rectangle
/*
* Scroll list down.
*/
function scrollDown() {
var numViewed = Math.ceil(root.height / (2 * listItemHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtTop = root.indexAt(1, 1 + root.contentY)
indexAtTop = (indexAtTop >= 0) ? (indexAtTop + numViewed) : 0
root.positionViewAtIndex(indexAtTop, ListView.Beginning)
root.returnToBounds()
}
/*
* Scroll list up.
*/
function scrollUp() {
var numViewed = Math.ceil(root.height / (2 * listItemHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtBottom = root.indexAt(1, root.height - 2 + root.contentY)
indexAtBottom = (indexAtBottom >= 0) ? (indexAtBottom - numViewed) : 0
root.positionViewAtIndex(indexAtBottom, ListView.End)
root.returnToBounds()
}
ScrollIndicator.vertical: ScrollIndicator {}
} // ListView
/*
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
/*
* List view that can be scrolled programmatically.
*/
ListView {
id: root
/* These properties must be set by caller. */
property real delegateHeight: 1.0
/*
* Scroll list down.
*/
function scrollDown() {
var numViewed = Math.ceil(root.height / (2 * delegateHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtTop = root.indexAt(1, 1 + root.contentY)
indexAtTop = (indexAtTop >= 0) ? (indexAtTop + numViewed) : 0
root.positionViewAtIndex(indexAtTop, ListView.Beginning)
root.returnToBounds()
}
/*
* Scroll list up.
*/
function scrollUp() {
var numViewed = Math.ceil(root.height / (2 * delegateHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtBottom = root.indexAt(1, root.height - 2 + root.contentY)
indexAtBottom = (indexAtBottom >= 0) ? (indexAtBottom - numViewed) : 0
root.positionViewAtIndex(indexAtBottom, ListView.End)
root.returnToBounds()
}
}
......@@ -118,6 +118,7 @@
<file>../qml/components/OverlaidImage.qml</file>
<file>../qml/components/PageHeader.qml</file>
<file>../qml/components/ProgressBar.qml</file>
<file>../qml/components/ScrollableListView.qml</file>
<file>../qml/dialogues/InputDialogue.qml</file>
<file>../qml/dialogues/FileDialogue.qml</file>
<file>../qml/dialogues/MessageDialogue.qml</file>
......
......@@ -141,6 +141,7 @@ const struct QmlTypeEntry qmlComponents[] = {
{ "OverlaidImage", 1, 0 },
{ "PageHeader", 1, 0 },
{ "ProgressBar", 1, 0 },
{ "ScrollableListView", 1, 0 },
{ NULL, 0, 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