Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mobile Datovka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Datovka projects
mobile Datovka
Commits
4f786fb1
Commit
4f786fb1
authored
Jan 23, 2018
by
Karel Slaný
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Derived DataboxList from ScrollableListView.
parent
d3c2e65f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
63 deletions
+85
-63
qml/components/AccessibleMenu.qml
qml/components/AccessibleMenu.qml
+5
-30
qml/components/DataboxList.qml
qml/components/DataboxList.qml
+11
-3
qml/components/MessageList.qml
qml/components/MessageList.qml
+5
-30
qml/components/ScrollableListView.qml
qml/components/ScrollableListView.qml
+62
-0
res/qml.qrc
res/qml.qrc
+1
-0
src/main.cpp
src/main.cpp
+1
-0
No files found.
qml/components/AccessibleMenu.qml
View file @
4f786fb1
...
...
@@ -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
{
Scrollable
ListView
{
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
?
header
Height
:
0
/* Collapse when not visible. */
height
:
showEntry
?
root
.
delegate
Height
:
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
}
qml/components/DataboxList.qml
View file @
4f786fb1
...
...
@@ -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
{
Scrollable
ListView
{
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
:
listItem
Height
height
:
root
.
delegate
Height
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
()
}
...
...
qml/components/MessageList.qml
View file @
4f786fb1
...
...
@@ -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
{
Scrollable
ListView
{
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
:
listItem
Height
height
:
root
.
delegate
Height
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
qml/components/ScrollableListView.qml
0 → 100644
View file @
4f786fb1
/*
* 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
()
}
}
res/qml.qrc
View file @
4f786fb1
...
...
@@ -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>
...
...
src/main.cpp
View file @
4f786fb1
...
...
@@ -141,6 +141,7 @@ const struct QmlTypeEntry qmlComponents[] = {
{
"OverlaidImage"
,
1
,
0
},
{
"PageHeader"
,
1
,
0
},
{
"ProgressBar"
,
1
,
0
},
{
"ScrollableListView"
,
1
,
0
},
{
NULL
,
0
,
0
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment