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
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
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
2b4e7f55
Commit
2b4e7f55
authored
Nov 28, 2018
by
Karel Slaný
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added FileListModel::dataSizeSum().
parent
b3c24925
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
18 deletions
+16
-18
qml/pages/PageSendMessage.qml
qml/pages/PageSendMessage.qml
+5
-7
src/models/filemodel.cpp
src/models/filemodel.cpp
+8
-7
src/models/filemodel.h
src/models/filemodel.h
+3
-4
No files found.
qml/pages/PageSendMessage.qml
View file @
2b4e7f55
...
...
@@ -98,7 +98,7 @@ Item {
return
true
}
if
(
totalAttachmentSizeBytes
>=
1024
)
{
attachmentsSizeLabel
.
text
=
qsTr
(
"
Total size of attachments is ~%1
K
B.
"
).
arg
(
Math
.
ceil
(
totalAttachmentSizeBytes
/
1024
))
attachmentsSizeLabel
.
text
=
qsTr
(
"
Total size of attachments is ~%1
k
B.
"
).
arg
(
Math
.
ceil
(
totalAttachmentSizeBytes
/
1024
))
}
else
{
attachmentsSizeLabel
.
text
=
qsTr
(
"
Total size of attachments is %1 B.
"
).
arg
(
totalAttachmentSizeBytes
)
}
...
...
@@ -147,9 +147,7 @@ Item {
dmRecipientIdent
.
text
=
isdsEnvelope
.
dmRecipientIdent
setMandate
(
isdsEnvelope
)
sendMsgAttachmentModel
.
setFromDb
(
userName
,
msgId
,
true
)
// true = real file size will calculate from file content
for
(
var
i
=
0
;
i
<
sendMsgAttachmentModel
.
rowCount
();
i
++
)
{
totalAttachmentSizeBytes
+=
sendMsgAttachmentModel
.
fileSizeBytesFromRow
(
i
)
}
totalAttachmentSizeBytes
=
sendMsgAttachmentModel
.
dataSizeSum
()
checkAttachmentSizes
()
}
...
...
@@ -162,8 +160,8 @@ Item {
var
zfoSize
=
zfo
.
getZfoSizeFromDb
(
userName
,
msgId
)
// Zfo file must exist in the local database so zfoSize must be > 0
if
(
zfoSize
>
0
)
{
totalAttachmentSizeBytes
+=
zfoSize
;
sendMsgAttachmentModel
.
appendFileFromPath
(
FileIdType
.
DB_ZFO_ID
,
fileName
,
""
,
zfoSize
)
totalAttachmentSizeBytes
=
sendMsgAttachmentModel
.
dataSizeSum
()
}
else
{
mainPanel
.
visible
=
false
errorText
.
text
=
qsTr
(
"
ZFO file of message %1 is not available. Download complete message to get it before forwarding.
"
).
arg
(
msgId
)
...
...
@@ -215,9 +213,9 @@ Item {
if
(
!
isInFiletList
)
{
var
fileName
=
getFileNameFromPath
(
pathListModel
.
get
(
j
).
path
)
var
fileSizeBytes
=
files
.
getAttachmentSizeInBytes
(
pathListModel
.
get
(
j
).
path
)
totalAttachmentSizeBytes
+=
fileSizeBytes
;
sendMsgAttachmentModel
.
appendFileFromPath
(
FileIdType
.
NO_FILE_ID
,
fileName
,
pathListModel
.
get
(
j
).
path
,
fileSizeBytes
)
totalAttachmentSizeBytes
=
sendMsgAttachmentModel
.
dataSizeSum
()
}
}
pathListModel
.
clear
()
...
...
@@ -611,8 +609,8 @@ Item {
}
MouseArea
{
function
handleClick
()
{
totalAttachmentSizeBytes
-=
sendMsgAttachmentModel
.
fileSizeBytesFromRow
(
index
)
sendMsgAttachmentModel
.
removeItem
(
index
)
totalAttachmentSizeBytes
=
sendMsgAttachmentModel
.
dataSizeSum
()
}
anchors.fill
:
parent
...
...
src/models/filemodel.cpp
View file @
2b4e7f55
...
...
@@ -200,22 +200,23 @@ QList<FileListModel::Entry> FileListModel::allEntries(void) const
return
entries
;
}
QString
FileListModel
::
filePathFromRow
(
int
row
)
QString
FileListModel
::
filePathFromRow
(
int
row
)
const
{
if
((
row
<
0
)
||
(
row
>=
m_files
.
size
()))
{
if
(
Q_UNLIKELY
((
row
<
0
)
||
(
row
>=
m_files
.
size
())))
{
Q_ASSERT
(
0
);
return
QString
();
}
return
m_files
[
row
].
filePath
();
}
qint64
FileListModel
::
fileSizeBytesFromRow
(
int
row
)
qint64
FileListModel
::
dataSizeSum
(
void
)
const
{
if
((
row
<
0
)
||
(
row
>=
m_files
.
size
()))
{
return
0
;
qint64
sum
=
0
;
foreach
(
const
Entry
&
entry
,
m_files
)
{
sum
+=
entry
.
fileSize
();
}
return
m_files
[
row
].
fileSize
();
return
sum
;
}
Qt
::
ItemFlags
FileListModel
::
flags
(
const
QModelIndex
&
index
)
const
...
...
src/models/filemodel.h
View file @
2b4e7f55
...
...
@@ -132,16 +132,15 @@ public:
* @return File path string.
*/
Q_INVOKABLE
QString
filePathFromRow
(
int
row
);
QString
filePathFromRow
(
int
row
)
const
;
/*!
* @brief
Return real file size in bytes from attachment model
.
* @brief
Compute the sum of sizes of all data
.
*
* @param[in] row Row specifying the item.
* @return Real file size in bytes.
*/
Q_INVOKABLE
qint64
fileSizeBytesFromRow
(
int
row
)
;
qint64
dataSizeSum
(
void
)
const
;
/*!
* @brief Returns item flags for given index.
...
...
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