Commit 9531f0e9 authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Removed requested fields from gov services model.

parent 6cdeb80a
......@@ -91,7 +91,7 @@ SOURCES += \
src/accounts.cpp \
src/auxiliaries/attachment_helper.cpp \
src/auxiliaries/email_helper.cpp \
src/datovka_shared/gov_services/model/gov_model.cpp \
src/datovka_shared/gov_services/model/gov_service_list_model.cpp \
src/datovka_shared/gov_services/service/gov_mv_crr_vbh.cpp \
src/datovka_shared/gov_services/service/gov_mv_ir_vp.cpp \
src/datovka_shared/gov_services/service/gov_mv_rt_vt.cpp \
......@@ -210,7 +210,7 @@ HEADERS += \
src/auxiliaries/attachment_helper.h \
src/auxiliaries/email_helper.h \
src/common.h \
src/datovka_shared/gov_services/model/gov_model.h \
src/datovka_shared/gov_services/model/gov_service_list_model.h \
src/datovka_shared/gov_services/service/gov_mv_crr_vbh.h \
src/datovka_shared/gov_services/service/gov_mv_ir_vp.h \
src/datovka_shared/gov_services/service/gov_mv_rt_vt.h \
......
......@@ -31,7 +31,7 @@ ScrollableListView {
delegateHeight: listItemHeight
/* These signals should be captured to implement message interaction. */
signal govServiceClicked(string gsId, string gsName, string gsGovName, string gsReqField)
signal govServiceClicked(string gsInternId, string gsFullName, string gsInstName)
delegate: Rectangle {
height: root.delegateHeight
......@@ -46,15 +46,15 @@ ScrollableListView {
spacing: formItemVerticalSpacing
anchors.verticalCenter: parent.verticalCenter
Text {
text: gsName
text: gsFullName
color: headerColor
font.bold: true
width: parent.width
wrapMode: Text.Wrap
}
Text {
id: govName
text: "DS: " + gsBoxId + " -- " + gsGovName
id: instName
text: "DS: " + gsBoxId + " -- " + gsInstName
color: datovkaPalette.text
font.pointSize: textFontSizeSmall
width: parent.width
......@@ -63,7 +63,7 @@ ScrollableListView {
}
} // Item
Rectangle {
visible: (gsReqField !== "")
visible: (gsInternId !== "")
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent.height
......@@ -86,7 +86,7 @@ ScrollableListView {
MouseArea {
anchors.fill: parent
onClicked: {
govServiceClicked(gsId, gsName, govName.text.toString(), gsReqField)
govServiceClicked(gsInternId, gsFullName, instName.text.toString())
}
}
Rectangle {
......
......@@ -34,9 +34,9 @@ Item {
property var statusBar
property string acntName
property string userName
property string gsId
property string gsName
property string gsGovName
property string gsInternId
property string gsFullName
property string gsInstName
property string gsReqField
Component.onCompleted: {
......@@ -56,7 +56,7 @@ Item {
PageHeader {
id: headerBar
title: qsTr("Service:") + " " + gsId
title: qsTr("Service:") + " " + gsInternId
onBackClicked: {
pageView.pop(StackView.Immediate)
}
......@@ -98,13 +98,13 @@ Item {
font.bold: false
width: parent.width
wrapMode: Text.Wrap
text: qsTr("Request:") + " " + gsName
text: qsTr("Request:") + " " + gsFullName
}
AccessibleText {
font.bold: false
width: parent.width
wrapMode: Text.Wrap
text: gsGovName
text: gsInstName
}
Text {
font.bold: false
......@@ -114,7 +114,7 @@ Item {
font.bold: false
width: parent.width
wrapMode: Text.Wrap
text: qsTr("Follow information must be filled.")
text: qsTr("Following information must be filled:")
}
Text {
font.bold: false
......@@ -231,7 +231,7 @@ Item {
target: isds
onRunSendGovMessageSig: {
actionButton.enabled = false
if (gov.sendGovRequest(userName, gsId, icoText.text, drvlicText.text, fromDateText.text, toDateText.text)) {
if (gov.sendGovRequest(userName, gsInternId, icoText.text, drvlicText.text, fromDateText.text, toDateText.text)) {
pageView.pop(StackView.Immediate)
}
}
......
......@@ -37,7 +37,7 @@ Component {
property string acntName
property string userName
property string gsIdSelected
property string gsInternIdSelected
Component.onCompleted: {
gov.loadGovServicesToModel(govServiceModel)
......@@ -49,7 +49,7 @@ Component {
gov.deleteGovServices()
}
GovListModel {
GovServiceListModel {
id: govServiceModel
Component.onCompleted: {
......@@ -60,9 +60,9 @@ Component {
id: proxyGovServiceModel
Component.onCompleted: {
setFilterRoles([GovListModel.ROLE_GOV_SRVC_NAME,
GovListModel.ROLE_GOV_SRVC_GOVNAME,
GovListModel.ROLE_GOV_SRVC_BOXID])
setFilterRoles([GovServiceListModel.ROLE_GOV_SRVC_NAME,
GovServiceListModel.ROLE_GOV_SRVC_GOVNAME,
GovServiceListModel.ROLE_GOV_SRVC_BOXID])
}
}
PageHeader {
......@@ -144,26 +144,25 @@ Component {
emptyList.visible = (govServiceList.count === 0)
}
onGovServiceClicked: {
if (gsReqField !== "") {
if (gsInternId !== "") {
pageView.push(pageGovService, {
"pageView": pageView,
"statusBar": statusBar,
"acntName" : acntName,
"userName": userName,
"gsId": gsId,
"gsName": gsName,
"gsGovName": gsGovName,
"gsReqField": gsReqField
"gsInternId": gsInternId,
"gsFullName": gsFullName,
"gsInstName": gsInstName
}, StackView.Immediate)
} else {
gsIdSelected = gsId
gsInternIdSelected = gsInternId
isds.doIsdsAction("sendGovMessage", userName)
}
}
Connections {
target: isds
onRunSendGovMessageSig: {
if (gov.sendGovRequest(userName, gsIdSelected, "","","","")) {
if (gov.sendGovRequest(userName, gsInternIdSelected, "","","","")) {
pageView.pop(StackView.Immediate)
}
}
......
......@@ -23,134 +23,120 @@
#include <QQmlEngine> /* qmlRegisterType */
#include "src/datovka_shared/gov_services/model/gov_model.h"
#include "src/datovka_shared/gov_services/model/gov_service_list_model.h"
#include "src/global.h"
GovListModel::Entry::Entry(const Entry &sme)
: m_srvcId(sme.m_srvcId),
m_srvcName(sme.m_srvcName),
m_srvcGov(sme.m_srvcGov),
m_srvcBoxId(sme.m_srvcBoxId),
m_srvcReqField(sme.m_srvcReqField)
GovServiceListModel::Entry::Entry(const Entry &sme)
: m_srvcInternId(sme.m_srvcInternId),
m_srvcFullName(sme.m_srvcFullName),
m_instName(sme.m_instName),
m_srvcBoxId(sme.m_srvcBoxId)
{
}
GovListModel::Entry::Entry(const QString &srvcId, const QString &srvcName,
const QString &srvcGov, const QString &srvcBoxId,
const QString &srvcReqField)
: m_srvcId(srvcId),
m_srvcName(srvcName),
m_srvcGov(srvcGov),
m_srvcBoxId(srvcBoxId),
m_srvcReqField(srvcReqField)
GovServiceListModel::Entry::Entry(const QString &srvcInternId,
const QString &srvcFullName, const QString &instName,
const QString &srvcBoxId)
: m_srvcInternId(srvcInternId),
m_srvcFullName(srvcFullName),
m_instName(instName),
m_srvcBoxId(srvcBoxId)
{
}
QString GovListModel::Entry::srvcId(void) const
const QString &GovServiceListModel::Entry::srvcInternId(void) const
{
return m_srvcId;
return m_srvcInternId;
}
QString GovListModel::Entry::srvcName(void) const
const QString &GovServiceListModel::Entry::srvcFullName(void) const
{
return m_srvcName;
return m_srvcFullName;
}
void GovListModel::Entry::setSrvcName(const QString &srvcName)
void GovServiceListModel::Entry::setSrvcFullName(const QString &fn)
{
m_srvcName = srvcName;
m_srvcFullName = fn;
}
QString GovListModel::Entry::srvcGov(void) const
const QString &GovServiceListModel::Entry::instName(void) const
{
return m_srvcGov;
return m_instName;
}
void GovListModel::Entry::setSrvcGov(const QString &srvcGov)
void GovServiceListModel::Entry::setInstName(const QString &in)
{
m_srvcGov = srvcGov;
m_instName = in;
}
QString GovListModel::Entry::srvcBoxId(void) const
const QString &GovServiceListModel::Entry::srvcBoxId(void) const
{
return m_srvcBoxId;
}
void GovListModel::Entry::setSrvcBoxId(const QString &srvcBoxId)
void GovServiceListModel::Entry::setSrvcBoxId(const QString &bi)
{
m_srvcBoxId = srvcBoxId;
m_srvcBoxId = bi;
}
QString GovListModel::Entry::srvcReqField(void) const
void GovServiceListModel::declareQML(void)
{
return m_srvcReqField;
qmlRegisterType<GovServiceListModel>("cz.nic.mobileDatovka.models", 1, 0, "GovServiceListModel");
qRegisterMetaType<GovServiceListModel>();
}
void GovListModel::Entry::setSrvcReqField(const QString &srvcReqField)
{
m_srvcReqField = srvcReqField;
}
void GovListModel::declareQML(void)
{
qmlRegisterType<GovListModel>("cz.nic.mobileDatovka.models", 1, 0, "GovListModel");
qRegisterMetaType<GovListModel>();
}
GovListModel::GovListModel(QObject *parent)
GovServiceListModel::GovServiceListModel(QObject *parent)
: QAbstractListModel(parent),
m_services()
{
}
GovListModel::GovListModel(const GovListModel &model, QObject *parent)
GovServiceListModel::GovServiceListModel(const GovServiceListModel &model,
QObject *parent)
: QAbstractListModel(parent),
m_services(model.m_services)
{
}
int GovListModel::rowCount(const QModelIndex &parent) const
int GovServiceListModel::rowCount(const QModelIndex &parent) const
{
return !parent.isValid() ? m_services.size() : 0;
}
QHash<int, QByteArray> GovListModel::roleNames(void) const
QHash<int, QByteArray> GovServiceListModel::roleNames(void) const
{
static QHash<int, QByteArray> roles;
if (roles.isEmpty()) {
roles[ROLE_GOV_SRVC_ID] = "gsId";
roles[ROLE_GOV_SRVC_NAME] = "gsName";
roles[ROLE_GOV_SRVC_GOVNAME] = "gsGovName";
roles[ROLE_GOV_SRVC_INTERN_ID] = "gsInternId";
roles[ROLE_GOV_SRVC_FULL_NAME] = "gsFullName";
roles[ROLE_GOV_SRVC_INST_NAME] = "gsInstName";
roles[ROLE_GOV_SRVC_BOXID] = "gsBoxId";
roles[ROLE_GOV_SRVC_REQ_FIELD] = "gsReqField";
}
return roles;
}
QVariant GovListModel::data(const QModelIndex &index, int role) const
QVariant GovServiceListModel::data(const QModelIndex &index, int role) const
{
if ((index.row() < 0) || (index.row() >= m_services.size())) {
Q_ASSERT(0);
return QVariant();
}
const Entry &s(m_services[index.row()]);
switch (role) {
case ROLE_GOV_SRVC_ID:
return s.srvcId();
case ROLE_GOV_SRVC_INTERN_ID:
return s.srvcInternId();
break;
case ROLE_GOV_SRVC_NAME:
return s.srvcName();
case ROLE_GOV_SRVC_FULL_NAME:
return s.srvcFullName();
break;
case ROLE_GOV_SRVC_GOVNAME:
return s.srvcGov();
case ROLE_GOV_SRVC_INST_NAME:
return s.instName();
break;
case ROLE_GOV_SRVC_BOXID:
return s.srvcBoxId();
break;
case ROLE_GOV_SRVC_REQ_FIELD:
return s.srvcReqField();
break;
default:
/* Do nothing. */
break;
......@@ -159,50 +145,42 @@ QVariant GovListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
QList<GovListModel::Entry> GovListModel::allEntries(void) const
QList<GovServiceListModel::Entry> GovServiceListModel::allEntries(void) const
{
QList<GovListModel::Entry> entries;
QList<Entry> entries;
foreach (const GovListModel::Entry &s, m_services) {
entries.append(s);
foreach (const Entry &e, m_services) {
entries.append(e);
}
return entries;
}
QString GovListModel::govServFromRow(int row)
{
if ((row < 0) || (row >= m_services.size())) {
return QString();
}
return m_services[row].srvcId();
}
Qt::ItemFlags GovListModel::flags(const QModelIndex &index) const
Qt::ItemFlags GovServiceListModel::flags(const QModelIndex &index) const
{
return QAbstractListModel::flags(index);
}
void GovListModel::appendEntry(const Entry &entry)
void GovServiceListModel::appendEntry(const Entry &entry)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_services.append(entry);
endInsertRows();
}
void GovListModel::clearAll(void)
void GovServiceListModel::clearAll(void)
{
beginResetModel();
m_services.clear();
endResetModel();
}
GovListModel *GovListModel::fromVariant(const QVariant &modelVariant)
GovServiceListModel *GovServiceListModel::fromVariant(
const QVariant &modelVariant)
{
if (!modelVariant.canConvert<QObject *>()) {
return Q_NULLPTR;
}
QObject *obj = qvariant_cast<QObject *>(modelVariant);
return qobject_cast<GovListModel *>(obj);
return qobject_cast<GovServiceListModel *>(obj);
}
......@@ -26,45 +26,39 @@
#include <QAbstractListModel>
#include <QString>
class GovListModel : public QAbstractListModel {
class GovServiceListModel : public QAbstractListModel {
Q_OBJECT
public:
class Entry {
public:
Entry(const Entry &sme);
Entry(const QString &srvcId, const QString &srvcName,
const QString &srvcGov, const QString &srvcBoxId,
const QString &srvcReqField);
QString srvcId(void) const;
QString srvcName(void) const;
void setSrvcName(const QString &srvcName);
QString srvcGov(void) const;
void setSrvcGov(const QString &srvcGov);
QString srvcBoxId(void) const;
void setSrvcBoxId(const QString &srvcBoxId);
QString srvcReqField(void) const;
void setSrvcReqField(const QString &srvcReqField);
Entry(const QString &srvcInternId, const QString &srvcFullName,
const QString &instName, const QString &srvcBoxId);
const QString &srvcInternId(void) const;
const QString &srvcFullName(void) const;
void setSrvcFullName(const QString &fn);
const QString &instName(void) const;
void setInstName(const QString &in);
const QString &srvcBoxId(void) const;
void setSrvcBoxId(const QString &bi);
private:
QString m_srvcId; /*!< Short gov service identifier. */
QString m_srvcName; /*!< Gov service full name. */
QString m_srvcGov; /*!< Gov institute. */
QString m_srvcInternId; /*!< Short unique internal gov service identifier. */
QString m_srvcFullName; /*!< Gov service full name. */
QString m_instName; /*!< Gov institute name. */
QString m_srvcBoxId; /*!< Gov institute databox ID */
QString m_srvcReqField; /*!< Service required additional information. */
};
/*!
* @brief Roles which this model supports.
*/
enum Roles {
ROLE_GOV_SRVC_ID = Qt::UserRole,
ROLE_GOV_SRVC_NAME,
ROLE_GOV_SRVC_GOVNAME,
ROLE_GOV_SRVC_BOXID,
ROLE_GOV_SRVC_REQ_FIELD
ROLE_GOV_SRVC_INTERN_ID = Qt::UserRole,
ROLE_GOV_SRVC_FULL_NAME,
ROLE_GOV_SRVC_INST_NAME,
ROLE_GOV_SRVC_BOXID
};
/* Don't forget to declare various properties to the QML system. */
......@@ -76,7 +70,7 @@ public:
*
* @param[in] parent Pointer to parent object.
*/
explicit GovListModel(QObject *parent = Q_NULLPTR);
explicit GovServiceListModel(QObject *parent = Q_NULLPTR);
/*!
* @brief Copy constructor.
......@@ -86,7 +80,7 @@ public:
* @param[in] model Model to be copied.
* @param[in] parent Pointer to parent object.
*/
explicit GovListModel(const GovListModel &model,
explicit GovServiceListModel(const GovServiceListModel &model,
QObject *parent = Q_NULLPTR);
/*!
......@@ -122,16 +116,7 @@ public:
*
* @return List of all entries.
*/
QList<GovListModel::Entry> allEntries(void) const;
/*!
* @brief Return service id from model.
*
* @param[in] row Row specifying the item.
* @return Service id string.
*/
Q_INVOKABLE
QString govServFromRow(int row);
QList<Entry> allEntries(void) const;
/*!
* @brief Returns item flags for given index.
......@@ -167,11 +152,11 @@ public:
* @return Pointer to model if it could be acquired, Q_NULLPTR else.
*/
static
GovListModel *fromVariant(const QVariant &modelVariant);
GovServiceListModel *fromVariant(const QVariant &modelVariant);
private:
QList<Entry> m_services; /*!< List of service entries. */
};
/* QML passes its arguments via QVariant. */
Q_DECLARE_METATYPE(GovListModel)
Q_DECLARE_METATYPE(GovServiceListModel)
......@@ -21,7 +21,7 @@
* the two.
*/
#include "src/datovka_shared/gov_services/model/gov_model.h"
#include "src/datovka_shared/gov_services/model/gov_service_list_model.h"
#include "src/datovka_shared/gov_services/service/gov_mv_crr_vbh.h"
#include "src/datovka_shared/gov_services/service/gov_mv_ir_vp.h"
#include "src/datovka_shared/gov_services/service/gov_mv_rt_vt.h"
......@@ -46,6 +46,7 @@ Gov::Gov(IsdsWrapper *isds, QObject *parent)
m_govServices(),
m_isds(isds)
{
initGovServices();
}
void Gov::deleteGovServices(void)
......@@ -79,7 +80,14 @@ void Gov::initGovServices(void)
/* Výpis bodového hodnocení z Centrálního registru řidičů */
GovMvCrrVbh *gs4 = new (std::nothrow) GovMvCrrVbh;
if (gs4 != Q_NULLPTR) {
m_govServices.insert(gs4->internalId(), gs4);
const QString &key(gs4->internalId());
if (!m_govServices.contains(key)) {
m_govServices.insert(key, gs4);
} else {
logError(
"Key '%s' already exists in gov services container.",
key.toUtf8().constData());
}
}
/* Výpis z Rejstříku trestů právnických osob */
......@@ -111,26 +119,22 @@ void Gov::loadGovServicesToModel(const QVariant &govModelVariant)
{
debugFuncCall();
GovListModel *govModel =
GovListModel::fromVariant(govModelVariant);
if (govModel == Q_NULLPTR) {
GovServiceListModel *govModel =
GovServiceListModel::fromVariant(govModelVariant);
if (Q_UNLIKELY(govModel == Q_NULLPTR)) {
Q_ASSERT(0);
logErrorNL("%s", "Cannot access gov model.");
logErrorNL("%s", "Cannot access gov services model.");
return;
}
initGovServices();
govModel->clearAll();
QStringList keys = m_govServices.keys();
foreach (const QString &key, keys) {
govModel->appendEntry(GovListModel::Entry(
m_govServices.value(key)->serviceId(),
m_govServices.value(key)->serviceFullName(),
m_govServices.value(key)->serviceGovName(),
m_govServices.value(key)->serviceDbId(),
m_govServices.value(key)->serviceReqField()
foreach (const QString &key, m_govServices.keys()) {
govModel->appendEntry(GovServiceListModel::Entry(
m_govServices.value(key)->internalId(),
m_govServices.value(key)->fullName(),
m_govServices.value(key)->instituteName(),
m_govServices.value(key)->boxId()
));
}
}
......
......@@ -37,7 +37,7 @@
#include "src/accounts.h"
#include "src/datovka_shared/crypto/crypto_trusted_certs.h"
#include "src/datovka_shared/gov_services/model/gov_model.h"
#include "src/datovka_shared/gov_services/model/gov_service_list_model.h"
#include "src/datovka_shared/io/records_management_db.h"
#include "src/datovka_shared/localisation/localisation.h"
#include "src/datovka_shared/log/log.h"
......@@ -485,7 +485,7 @@ int main(int argc, char *argv[])
Dialogues::declareQML();
FileListModel::declareQML();
Files::declareQML();
GovListModel::declareQML();
GovServiceListModel::declareQML();
InteractionFilesystem::declareQML();
ListSortFilterProxyModel::declareQML();
MessageListModel::declareQML();
......
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