Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Datovka projects
mobile Datovka
Commits
cd00dbe6
Commit
cd00dbe6
authored
Oct 23, 2017
by
Karel Slaný
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'contact-list' into 'develop'
Added contact list See merge request
!78
parents
c880fbfd
a4009fb8
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
312 additions
and
1 deletion
+312
-1
qml/components/DataboxList.qml
qml/components/DataboxList.qml
+35
-0
qml/main.qml
qml/main.qml
+1
-0
qml/pages/PageContactList.qml
qml/pages/PageContactList.qml
+150
-0
qml/pages/PageSendMessage.qml
qml/pages/PageSendMessage.qml
+16
-1
res/qml.qrc
res/qml.qrc
+1
-0
src/accounts.cpp
src/accounts.cpp
+5
-0
src/accounts.h
src/accounts.h
+9
-0
src/main.cpp
src/main.cpp
+1
-0
src/messages.cpp
src/messages.cpp
+26
-0
src/messages.h
src/messages.h
+11
-0
src/qml_interaction/attachment_data.h
src/qml_interaction/attachment_data.h
+10
-0
src/qml_interaction/message_envelope.h
src/qml_interaction/message_envelope.h
+10
-0
src/sqlite/message_db.cpp
src/sqlite/message_db.cpp
+28
-0
src/sqlite/message_db.h
src/sqlite/message_db.h
+9
-0
No files found.
qml/components/DataboxList.qml
View file @
cd00dbe6
...
...
@@ -36,6 +36,8 @@ ListView {
property
bool
canSelectBoxes
:
false
// enables selecting of entries
property
bool
canDeselectBoxes
:
false
// enables deselecting of entries
property
bool
canRemoveBoxes
:
false
// enables removing of entries
property
bool
localContactFormat
:
false
// false - format of contacts obtained from ISDS server
// true - contacts gathered from local storage
/* This signal should be captured to implement model interaction. */
signal
boxDetail
(
string
boxId
)
...
...
@@ -54,6 +56,7 @@ ListView {
anchors.margins
:
defaultMargin
GridLayout
{
id
:
gridSearchDatabox
visible
:
!
localContactFormat
columns
:
2
rows
:
3
rowSpacing
:
defaultMargin
*
0.6
...
...
@@ -95,6 +98,38 @@ ListView {
text
:
rDbEffectiveOvm
}
}
// GridLayout
GridLayout
{
id
:
gridRecipientOrContaxtDatabox
visible
:
localContactFormat
columns
:
1
rows
:
3
rowSpacing
:
defaultMargin
*
0.6
columnSpacing
:
defaultMargin
*
2
anchors.verticalCenter
:
parent
.
verticalCenter
Text
{
id
:
r1c1c
text
:
rDbName
color
:
headerColor
font.bold
:
true
}
Text
{
id
:
r2c1c
text
:
rDbAddress
}
Text
{
id
:
r3c1c
font.pointSize
:
textFontSizeSmall
text
:
if
(
rDbIc
!=
""
&&
rDbType
!=
""
)
{
"
ID:
"
+
rDbID
+
"
(
"
+
rDbType
+
"
) IČ:
"
+
rDbIc
}
else
if
(
rDbIc
==
""
&&
rDbType
!=
""
)
{
"
ID:
"
+
rDbID
+
"
(
"
+
rDbType
+
"
)
"
}
else
if
(
rDbIc
!=
""
&&
rDbType
==
""
)
{
"
ID:
"
+
rDbID
+
"
IČ:
"
+
rDbIc
}
else
{
"
ID:
"
+
rDbID
}
}
}
// GridLayout
}
// Item
MouseArea
{
anchors.fill
:
parent
...
...
qml/main.qml
View file @
cd00dbe6
...
...
@@ -62,6 +62,7 @@ ApplicationWindow {
property
Component
pageAboutApp
:
PageAboutApp
{}
property
Component
pageAccountDetail
:
PageAccountDetail
{}
property
Component
pageChangePassword
:
PageChangePassword
{}
property
Component
pageContactList
:
PageContactList
{}
property
Component
pageDataboxDetail
:
PageDataboxDetail
{}
property
Component
pageDataboxSearch
:
PageDataboxSearch
{}
property
Component
pageMenuAccount
:
PageMenuAccount
{}
...
...
qml/pages/PageContactList.qml
0 → 100644
View file @
cd00dbe6
/*
* Copyright (C) 2014-2017 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
import
QtQuick
.
Controls
2.1
import
QtQuick
.
Layouts
1.3
import
cz
.
nic
.
mobileDatovka
1.0
import
cz
.
nic
.
mobileDatovka
.
models
1.0
/*
* Roles are defined in DataboxListModel::roleNames() and are accessed directly
* via their names.
*/
Item
{
id
:
pageContactList
/* These properties must be set by caller. */
property
var
pageView
property
var
statusBar
property
string
userName
// recipBoxModel (if not null) holds recipient list of send message page
property
var
recipBoxModel
:
null
Component.onCompleted
:
{
var
currentBoxId
=
accounts
.
boxId
(
userName
)
messages
.
fillContactList
(
foundBoxModel
,
userName
,
currentBoxId
)
if
(
recipBoxModel
!=
null
)
{
foundBoxModel
.
selectEntries
(
recipBoxModel
.
boxIds
(),
true
)
}
proxyDataboxModel
.
setSourceModel
(
foundBoxModel
)
emptyList
.
visible
=
(
databoxList
.
count
===
0
)
}
DataboxListModel
{
id
:
foundBoxModel
Component.onCompleted
:
{
}
}
ListSortFilterProxyModel
{
id
:
proxyDataboxModel
Component.onCompleted
:
{
setFilterRoles
([
DataboxListModel
.
ROLE_DB_NAME
,
DataboxListModel
.
ROLE_DB_ADDRESS
,
DataboxListModel
.
ROLE_DB_ID
])
}
}
PageHeader
{
id
:
headerBar
title
:
qsTr
(
"
Contacts
"
)
+
"
(
"
+
userName
+
"
)
"
Item
{
anchors.left
:
parent
.
left
width
:
parent
.
width
*
0.5
height
:
parent
.
height
MouseArea
{
anchors.fill
:
parent
onClicked
:
{
statusBar
.
visible
=
false
pageView
.
pop
(
StackView
.
Immediate
)
}
}
}
TextField
{
id
:
filterPhraseText
placeholderText
:
qsTr
(
"
Set filter
"
)
width
:
headerBar
.
width
*
0.3
anchors.right
:
parent
.
right
anchors.rightMargin
:
defaultMargin
anchors.verticalCenter
:
parent
.
verticalCenter
font.pointSize
:
defaultTextFont
.
font
.
pointSize
inputMethodHints
:
Qt
.
ImhNoPredictiveText
/*
* Using explicit top, left, ... padding because plain padding
* does not centre the text properly.
*/
topPadding
:
8.0
bottomPadding
:
8.0
leftPadding
:
8.0
rightPadding
:
8.0
/* TODO - remove background if used materials */
background
:
Rectangle
{
anchors.fill
:
parent
color
:
(
filterPhraseText
.
text
.
length
==
0
)
?
datovkaPalette
.
alternateBase
:
(
databoxList
.
count
>
0
)
?
"
#afffaf
"
:
"
#ffafaf
"
border.color
:
filterPhraseText
.
activeFocus
?
"
#0066ff
"
:
"
#bdbebf
"
}
onTextChanged
:
{
proxyDataboxModel
.
setFilterRegExpStr
(
filterPhraseText
.
text
)
}
}
}
// PageHeader
Text
{
id
:
emptyList
visible
:
false
color
:
datovkaPalette
.
text
anchors.centerIn
:
parent
wrapMode
:
Text
.
Wrap
text
:
qsTr
(
"
No databox found in contacts.
"
)
}
DataboxList
{
id
:
databoxList
anchors.top
:
headerBar
.
bottom
anchors.bottom
:
parent
.
bottom
clip
:
true
spacing
:
1
opacity
:
1
visible
:
true
width
:
parent
.
width
interactive
:
true
model
:
proxyDataboxModel
canDetailBoxes
:
recipBoxModel
==
null
canSelectBoxes
:
recipBoxModel
!=
null
canDeselectBoxes
:
recipBoxModel
!=
null
localContactFormat
:
true
onBoxSelect
:
{
var
boxEntry
=
foundBoxModel
.
entry
(
boxId
)
statusBar
.
visible
=
false
if
(
recipBoxModel
!=
null
)
{
foundBoxModel
.
selectEntry
(
boxEntry
.
dbID
,
true
)
recipBoxModel
.
addEntry
(
boxEntry
)
}
}
onBoxDeselect
:
{
statusBar
.
visible
=
false
if
(
recipBoxModel
!=
null
)
{
foundBoxModel
.
selectEntry
(
boxId
,
false
)
recipBoxModel
.
removeEntry
(
boxId
)
}
}
}
// DataboxList
}
// Item
qml/pages/PageSendMessage.qml
View file @
cd00dbe6
...
...
@@ -278,11 +278,25 @@ Item {
Row
{
spacing
:
formItemVerticalSpacing
*
5
anchors.horizontalCenter
:
parent
.
horizontalCenter
Button
{
id
:
addContact
height
:
inputItemHeight
font.pointSize
:
defaultTextFont
.
font
.
pointSize
text
:
qsTr
(
"
Add
"
)
onClicked
:
{
pageView
.
push
(
pageContactList
,
{
"
pageView
"
:
pageView
,
"
statusBar
"
:
statusBar
,
"
userName
"
:
userName
,
"
recipBoxModel
"
:
recipBoxModel
},
StackView
.
Immediate
)
}
}
Button
{
id
:
findDS
height
:
inputItemHeight
font.pointSize
:
defaultTextFont
.
font
.
pointSize
text
:
qsTr
(
"
Find
databox
"
)
text
:
qsTr
(
"
Find
"
)
onClicked
:
{
pageView
.
push
(
pageDataboxSearch
,
{
"
pageView
"
:
pageView
,
...
...
@@ -307,6 +321,7 @@ Item {
interactive
:
true
model
:
recipBoxModel
canRemoveBoxes
:
true
localContactFormat
:
true
onCountChanged
:
{
mainPanel
.
areReguiredFieldsFilled
()
}
...
...
res/qml.qrc
View file @
cd00dbe6
...
...
@@ -113,6 +113,7 @@
<file>../qml/pages/PageAccountDetail.qml</file>
<file>../qml/pages/PageAccountList.qml</file>
<file>../qml/pages/PageChangePassword.qml</file>
<file>../qml/pages/PageContactList.qml</file>
<file>../qml/pages/PageDataboxDetail.qml</file>
<file>../qml/pages/PageDataboxSearch.qml</file>
<file>../qml/pages/PageMenuAccount.qml</file>
...
...
src/accounts.cpp
View file @
cd00dbe6
...
...
@@ -40,6 +40,11 @@ Accounts::Accounts(QObject *parent)
{
}
QString
Accounts
::
boxId
(
const
QString
&
userName
)
{
return
globAccountDbPtr
->
dbId
(
userName
);
}
bool
Accounts
::
boxEffectiveOVM
(
const
QString
&
userName
)
{
return
globAccountDbPtr
->
boxEffectiveOVM
(
userName
);
...
...
src/accounts.h
View file @
cd00dbe6
...
...
@@ -52,6 +52,15 @@ class Accounts : public QObject {
public:
Accounts
(
QObject
*
parent
=
Q_NULLPTR
);
/*!
* @brief Get account data box ID from database.
*
* @param[in] userName User name identifying account.
* @return Databox id string.
*/
Q_INVOKABLE
QString
boxId
(
const
QString
&
userName
);
/*!
* @brief Check whether data box has effective OVM.
*
...
...
src/main.cpp
View file @
cd00dbe6
...
...
@@ -87,6 +87,7 @@ const struct QmlTypeEntry qmlPages[] = {
{
"PageAccountDetail"
,
1
,
0
},
{
"PageAccountList"
,
1
,
0
},
{
"PageChangePassword"
,
1
,
0
},
{
"PageContactList"
,
1
,
0
},
{
"PageDataboxDetail"
,
1
,
0
},
{
"PageDataboxSearch"
,
1
,
0
},
{
"PageMenuAccount"
,
1
,
0
},
...
...
src/messages.cpp
View file @
cd00dbe6
...
...
@@ -32,6 +32,7 @@
#include "src/messages.h"
#include "src/settings.h"
#include "src/models/accountmodel.h"
#include "src/models/databoxmodel.h"
#include "src/models/messagemodel.h"
#include "src/sqlite/message_db_container.h"
#include "src/sqlite/file_db_container.h"
...
...
@@ -70,6 +71,31 @@ enum MessageDb::MessageType enumToDbRepr(enum Messages::MessageType msgType)
}
}
void
Messages
::
fillContactList
(
const
QVariant
&
dbModelVariant
,
const
QString
&
userName
,
const
QString
&
dbId
)
{
qDebug
(
"%s()"
,
__func__
);
DataboxListModel
*
databoxModel
=
DataboxListModel
::
fromVariant
(
dbModelVariant
);
if
(
databoxModel
==
Q_NULLPTR
)
{
Q_ASSERT
(
0
);
qCritical
(
"%s"
,
"Cannot access databox model."
);
return
;
}
MessageDb
*
msgDb
=
globMessageDbsPtr
->
accessMessageDb
(
globSet
.
dbsLocation
,
userName
,
AccountListModel
::
globAccounts
[
userName
].
storeToDisk
());
if
(
msgDb
==
Q_NULLPTR
)
{
qCritical
(
"%s"
,
"Cannot open message database."
);
return
;
}
databoxModel
->
clearAll
();
msgDb
->
getContactsFromDb
(
databoxModel
,
dbId
);
}
void
Messages
::
fillMessageList
(
const
QVariant
&
msgModelVariant
,
const
QString
&
userName
,
enum
MessageType
msgType
)
{
...
...
src/messages.h
View file @
cd00dbe6
...
...
@@ -49,6 +49,17 @@ public:
Messages
(
QObject
*
parent
=
Q_NULLPTR
);
/*!
* @brief Load contacts from database and fill QML listview via model.
*
* @param[in,out] dbModelVariant QVariant holding databox model to be set.
* @param[in] userName User name identifying account.
* @param[in] dbId Account databox ID.
*/
Q_INVOKABLE
static
void
fillContactList
(
const
QVariant
&
dbModelVariant
,
const
QString
&
userName
,
const
QString
&
dbId
);
/*!
* @brief Load messages from database and fill QML listview via model.
*
...
...
src/qml_interaction/attachment_data.h
View file @
cd00dbe6
...
...
@@ -75,6 +75,16 @@ public:
const
QString
&
_dmFileSize
,
const
QString
&
_dmDownloadDate
,
const
QString
&
_icon
,
QObject
*
parent
=
Q_NULLPTR
);
/*!
* @brief Assignment operator.
*
* @note gcc 5.4 bitches about missing operator= declaration.
*
* @param[in] data Attachment data.
* @return Reference to itself.
*/
AttachmentData
&
operator
=
(
const
AttachmentData
&
data
);
int
fileId
(
void
)
const
;
void
setFileId
(
int
fileId
);
qint64
dmId
(
void
)
const
;
...
...
src/qml_interaction/message_envelope.h
View file @
cd00dbe6
...
...
@@ -143,6 +143,16 @@ public:
bool
_dmReadLocally
,
QObject
*
parent
=
Q_NULLPTR
);
/*!
* @brief Assignment operator.
*
* @note gcc 5.4 bitches about missing operator= declaration.
*
* @param[in] envel Message envelope.
* @return Reference to itself.
*/
MsgEnvelope
&
operator
=
(
const
MsgEnvelope
&
envel
);
qint64
dmID
(
void
)
const
;
void
setDmID
(
qint64
dmID
);
QString
dmAnnotation
(
void
)
const
;
...
...
src/sqlite/message_db.cpp
View file @
cd00dbe6
...
...
@@ -181,6 +181,34 @@ bool MessageDb::deleteMsgFromDb(qint64 msgId)
return
true
;
}
void
MessageDb
::
getContactsFromDb
(
DataboxListModel
*
dbModel
,
const
QString
&
dbId
)
{
if
(
dbModel
==
Q_NULLPTR
)
{
Q_ASSERT
(
0
);
return
;
}
QSqlQuery
query
(
m_db
);
QString
queryStr
=
"SELECT "
"dbIDRecipient, dmRecipient, dmRecipientAddress FROM messages "
"WHERE (dmRecipientAddress IS NOT NULL) "
" UNION SELECT "
"dbIDSender, dmSender, dmSenderAddress FROM messages "
"WHERE (dmSenderAddress IS NOT NULL) "
"ORDER BY dmRecipient, dmSender DESC"
;
if
(
!
query
.
prepare
(
queryStr
))
{
qCritical
()
<<
"Cannot prepare SQL query:"
<<
query
.
lastError
().
text
().
toUtf8
().
constData
();
return
;
}
if
(
query
.
exec
()
&&
query
.
isActive
())
{
dbModel
->
setQuery
(
query
,
dbId
,
false
);
}
}
int
MessageDb
::
getDbSizeInBytes
(
void
)
{
QFileInfo
fi
(
m_db
.
databaseName
());
...
...
src/sqlite/message_db.h
View file @
cd00dbe6
...
...
@@ -31,6 +31,7 @@
#include "src/common.h"
#include "src/io/sqlite/db.h"
#include "src/messages.h"
#include "src/models/databoxmodel.h"
#include "src/qml_interaction/message_envelope.h"
class
MessageListModel
;
/* Forward declaration. */
...
...
@@ -96,6 +97,14 @@ public:
*/
bool
deleteMsgFromDb
(
qint64
msgId
);
/*!
* @brief Get list of databoxes from db.
*
* @param[in,out] dbModel Databox model to append databox info.
* @param[in] dbId Account databox ID.
*/
void
getContactsFromDb
(
DataboxListModel
*
dbModel
,
const
QString
&
dbId
);
/*!
* @brief Get count of new messages.
*
...
...
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