Commit bff55dea authored by Martin Straka's avatar Martin Straka
Browse files

Updated data box model for pdz payment methods.

parent 83e33814
......@@ -42,7 +42,7 @@ Item {
property var recipBoxModel: null
Component.onCompleted: {
var currentBoxId = accounts.boxId(acntId)
var currentBoxId = accounts.dbId(acntId)
messages.fillContactList(foundBoxModel, acntId, currentBoxId)
if (foundBoxModel.rowCount() === 0) {
emptyList.visible = true
......@@ -122,7 +122,6 @@ Item {
if (recipBoxModel != null) {
foundBoxModel.selectEntry(boxEntry.dbID, true)
recipBoxModel.addEntry(boxEntry)
isds.pdzSendInfo(acntId, boxEntry.dbID);
}
}
onBoxDeselect: {
......
......@@ -121,12 +121,12 @@ Item {
dmSenderIdent.text = isdsEnvelope.dmRecipientIdent
dmRecipientRefNumber.text = isdsEnvelope.dmSenderRefNumber
dmRecipientIdent.text = isdsEnvelope.dmSenderIdent
setMandate(isdsEnvelope)
if (isdsEnvelope.dmType === "I") {
dmType = "O"
isds.pdzSendInfo(acntId, isdsEnvelope.dbIDSender, true);
} else {
dmType = ""
isds.pdzSendInfo(acntId, isdsEnvelope.dbIDSender, false);
}
setMandate(isdsEnvelope)
}
/* Set message envelope data and files to attachment model*/
......@@ -192,13 +192,13 @@ Item {
Component.onCompleted: {
iOS = iOSHelper.isIos()
var boxEffectiveOVM = accounts.boxEffectiveOVM(acntId)
dmAllowSubstDelivery.visible = boxEffectiveOVM
var dbID = accounts.boxId(acntId);
var boxOVM = accounts.isOvm(acntId)
var dbID = accounts.dbId(acntId);
var dbType = accounts.dbType(acntId);
databoxInfo.text = qsTr("Databox: %1 (%2)").arg(dbID).arg(dbType)
dmAllowSubstDelivery.visible = boxOVM
if (!boxEffectiveOVM) {
if (!boxOVM) {
isds.doIsdsAction("pdzInfo", acntId);
}
......@@ -488,7 +488,7 @@ Item {
width: parent.width
height: inputItemHeight
font.pointSize: defaultTextFont.font.pointSize
placeholderText: qsTr("Enter subject")
placeholderText: qsTr("Enter subject. Mandatory")
InputLineMenu {
id: subjectMenu
inputTextControl: dmAnnotation
......@@ -1031,7 +1031,7 @@ Item {
function onRunPdzInfoSig(userName, testing) {
actionAcntId.username = userName
actionAcntId.testing = testing
var dbID = accounts.boxId(actionAcntId);
var dbID = accounts.dbId(actionAcntId);
databoxInfo.text = databoxInfo.text + isds.pdzInfo(actionAcntId, dbID);
}
} // Connections
......
......@@ -215,8 +215,9 @@ long int Isds::Tasks::findDataboxFulltext(const AcntId &acntId,
foreach (const DbResult2 &db, dbList) {
databoxModel->addEntry(DataboxModelEntry(db.dbID(),
Isds::dbType2Str(db.dbType()), db.dbName(), db.dbAddress(),
db.ic(), "0", dbSendOptions2str(db.active(),
db.publicSending(), db.commercialSending())));
db.ic(), dbSendOptions2str(db.active(),
db.publicSending(), db.commercialSending()), false,
QList<enum Isds::Type::DmType>()));
}
return databoxModel->rowCount();
......
......@@ -619,7 +619,8 @@ QList<Isds::Type::DmType> setPossiblePdzPaymentMethods(
return dmPaymentTypes;
}
int IsdsWrapper::pdzSendInfo(const QmlAcntId *qAcntId, const QString &dbID)
int IsdsWrapper::pdzSendInfo(const QmlAcntId *qAcntId, const QString &dbID,
bool canUseInitReply)
{
if (Q_UNLIKELY((qAcntId == Q_NULLPTR) || (dbID.isEmpty()))) {
Q_ASSERT(0);
......@@ -642,7 +643,7 @@ int IsdsWrapper::pdzSendInfo(const QmlAcntId *qAcntId, const QString &dbID)
QList<Isds::Type::DmType> dmTypes;
dmTypes = setPossiblePdzPaymentMethods(m_pdzInfos,
canSendNormal, canSendInitiatory, /*canUseInitReply*/ false);
canSendNormal, canSendInitiatory, canUseInitReply);
return pdzCnt;
}
......
......@@ -310,10 +310,12 @@ public:
*
* @param[in] qAcntId Account identifier.
* @param[in] dbID Data box ID.
* @param[in] canUseInitReply True if can use reply on initiatory message.
* @return Number of pdz messages which can be sent to recipient.
*/
Q_INVOKABLE
int pdzSendInfo(const QmlAcntId *qAcntId, const QString &dbID);
int pdzSendInfo(const QmlAcntId *qAcntId, const QString &dbID,
bool canUseInitReply);
public slots:
/*!
......
......@@ -199,12 +199,17 @@ QmlIsdsEnvelope *Messages::getMsgEnvelopeDataAndSetRecipient(
Isds::Envelope envelope = msgDb->getMessageEnvelopeFromDb(msgId);
/* TODO - remove */
QList<enum Isds::Type::DmType> dmTypes;
// Add recipient to model
if (databoxModel != Q_NULLPTR) {
DataboxModelEntry dbEntry;
dbEntry.setDbID(envelope.dbIDSender());
dbEntry.setDbName(envelope.dmSender());
dbEntry.setDbAddress(envelope.dmSenderAddress());
dbEntry.setPdz(true);
dbEntry.setDmTypes(dmTypes);
databoxModel->addEntry(dbEntry);
}
......
......@@ -42,8 +42,9 @@ DataboxModelEntry::DataboxModelEntry(QObject *parent)
m_dbName(),
m_dbAddress(),
m_dbIC(),
m_dbEffectiveOVM(),
m_dbSendOptions()
m_dbSendOptions(),
m_pdz(false),
m_dmTypes()
{
}
......@@ -54,22 +55,25 @@ DataboxModelEntry::DataboxModelEntry(const DataboxModelEntry &dme)
m_dbName(dme.m_dbName),
m_dbAddress(dme.m_dbAddress),
m_dbIC(dme.m_dbIC),
m_dbEffectiveOVM(dme.m_dbEffectiveOVM),
m_dbSendOptions(dme.m_dbSendOptions)
m_dbSendOptions(dme.m_dbSendOptions),
m_pdz(dme.m_pdz),
m_dmTypes(dme.m_dmTypes)
{
}
DataboxModelEntry::DataboxModelEntry(const QString &dbID, const QString &dbType,
const QString &dbName, const QString &dbAddress, const QString &dbIC,
const QString &dbEffectiveOVM, const QString &dbSendOptions)
const QString &dbSendOptions, bool pdz,
const QList<enum Isds::Type::DmType> &dmTypes)
: QObject(Q_NULLPTR),
m_dbID(dbID),
m_dbType(dbType),
m_dbName(dbName),
m_dbAddress(dbAddress),
m_dbIC(dbIC),
m_dbEffectiveOVM(dbEffectiveOVM),
m_dbSendOptions(dbSendOptions)
m_dbSendOptions(dbSendOptions),
m_pdz(pdz),
m_dmTypes(dmTypes)
{
}
......@@ -80,8 +84,9 @@ DataboxModelEntry &DataboxModelEntry::operator=(const DataboxModelEntry &entry)
m_dbName = entry.m_dbName;
m_dbAddress = entry.m_dbAddress;
m_dbIC = entry.m_dbIC;
m_dbEffectiveOVM = entry.m_dbEffectiveOVM;
m_dbSendOptions = entry.m_dbSendOptions;
m_pdz = entry.m_pdz;
m_dmTypes = entry.m_dmTypes;
return *this;
}
......@@ -136,24 +141,34 @@ void DataboxModelEntry::setDbIC(const QString &dbIC)
m_dbIC = dbIC;
}
QString DataboxModelEntry::dbEffectiveOVM(void) const
QString DataboxModelEntry::dbSendOptions(void) const
{
return m_dbEffectiveOVM;
return m_dbSendOptions;
}
void DataboxModelEntry::setDbEffectiveOVM(const QString &dbEffectiveOVM)
void DataboxModelEntry::setDbSendOptions(const QString &dbSendOptions)
{
m_dbEffectiveOVM = dbEffectiveOVM;
m_dbSendOptions = dbSendOptions;
}
QString DataboxModelEntry::dbSendOptions(void) const
bool DataboxModelEntry::pdz(void) const
{
return m_dbSendOptions;
return m_pdz;
}
void DataboxModelEntry::setDbSendOptions(const QString &dbSendOptions)
void DataboxModelEntry::setPdz(bool pdz)
{
m_dbSendOptions = dbSendOptions;
m_pdz = pdz;
}
QList<enum Isds::Type::DmType> DataboxModelEntry::dmTypes(void) const
{
return m_dmTypes;
}
void DataboxModelEntry::setDmTypes(const QList<enum Isds::Type::DmType> &dmTypes)
{
m_dmTypes = dmTypes;
}
DataboxModelEntry *DataboxModelEntry::fromVariant(const QVariant &entryVariant)
......@@ -204,8 +219,9 @@ QHash<int, QByteArray> DataboxListModel::roleNames(void) const
roles[ROLE_DB_NAME] = "rDbName";
roles[ROLE_DB_ADDRESS] = "rDbAddress";
roles[ROLE_DB_IC] = "rDbIc";
roles[ROLE_DB_EFFECTIVE_OVM] = "rDbEffectiveOvm";
roles[ROLE_DB_SEND_OPTION] = "rDbSendOption";
roles[ROLE_PDZ] = "rPdz";
roles[ROLE_PDZ_LIST] = "rPdzList";
roles[ROLE_DB_SELECTED] = "rDbSelected";
}
return roles;
......@@ -236,12 +252,21 @@ QVariant DataboxListModel::data(const QModelIndex &index, int role) const
case ROLE_DB_IC:
return entry.dbIC();
break;
case ROLE_DB_EFFECTIVE_OVM:
return entry.dbEffectiveOVM();
break;
case ROLE_DB_SEND_OPTION:
return entry.dbSendOptions();
break;
case ROLE_PDZ:
return entry.pdz();
break;
case ROLE_PDZ_LIST:
{
QList<QVariant> entries;
foreach (const Isds::Type::DmType &dmType, entry.dmTypes()) {
entries.append(dmType);
}
return entries;
}
break;
case ROLE_DB_SELECTED:
return m_entries[boxId].selected;
break;
......@@ -405,7 +430,8 @@ int DataboxListModel::setQuery(QSqlQuery &query, const QString &dbId,
DataboxModelEntry entry(
query.value(0).toString(), QString(),
query.value(1).toString(), query.value(2).toString(),
QString(), QString(), QString());
QString(), QString(), false,
QList<enum Isds::Type::DmType>());
m_boxIds.append(entry.dbID());
m_entries[entry.dbID()] = InternalEntry(entry, false);
databoxCnt++;
......
......@@ -27,6 +27,8 @@
#include <QObject>
#include <QSqlQuery>
#include "src/datovka_shared/isds/types.h"
class DataboxModelEntry : public QObject {
Q_OBJECT
Q_PROPERTY(QString dbID READ dbID WRITE setDbID NOTIFY dbIDChanged)
......@@ -34,8 +36,8 @@ class DataboxModelEntry : public QObject {
Q_PROPERTY(QString dbName READ dbName WRITE setDbName NOTIFY dbNameChanged)
Q_PROPERTY(QString dbAddress READ dbAddress WRITE setDbAddress NOTIFY dbAddressChanged)
Q_PROPERTY(QString dbIC READ dbIC WRITE setDbIC NOTIFY dbICChanged)
Q_PROPERTY(QString dbEffectiveOVM READ dbEffectiveOVM WRITE setDbEffectiveOVM NOTIFY dbEffectiveOVMChanged)
Q_PROPERTY(QString dbSendOptions READ dbSendOptions WRITE setDbSendOptions NOTIFY dbSendOptionsChanged)
Q_PROPERTY(bool pdz READ pdz WRITE setPdz NOTIFY pdzChanged)
public:
/* Don't forget to declare various properties to the QML system. */
......@@ -63,7 +65,8 @@ public:
*/
DataboxModelEntry(const QString &dbID, const QString &dbType,
const QString &dbName, const QString &dbAddress, const QString &dbIC,
const QString &dbEffectiveOVM, const QString &dbSendOptions);
const QString &dbSendOptions, bool pdz,
const QList<enum Isds::Type::DmType> &dmTypes);
/*!
* @brief Assignment operator.
......@@ -88,12 +91,15 @@ public:
QString dbIC(void) const;
void setDbIC(const QString &dbIC);
QString dbEffectiveOVM(void) const;
void setDbEffectiveOVM(const QString &dbEffectiveOVM);
QString dbSendOptions(void) const;
void setDbSendOptions(const QString &dbSendOptions);
bool pdz(void) const;
void setPdz(bool pdz);
QList<enum Isds::Type::DmType> dmTypes(void) const;
void setDmTypes(const QList<enum Isds::Type::DmType> &dmTypes);
/*!
* @brief Converts QVariant (obtained from QML) into a pointer.
*
......@@ -123,8 +129,8 @@ signals:
void dbNameChanged(const QString *newDbName);
void dbAddressChanged(const QString &newDbAddress);
void dbICChanged(const QString &newDbIC);
void dbEffectiveOVMChanged(const QString &newDbEffectiveOVM);
void dbSendOptionsChanged(const QString &newDbSendOptions);
void pdzChanged(bool newPdz);
private:
QString m_dbID; /*!< Databox identifier. */
......@@ -132,8 +138,9 @@ private:
QString m_dbName; /*!< Databox owner name. */
QString m_dbAddress; /*!< Databox owner address. */
QString m_dbIC; /*!< Databox owner IC. */
QString m_dbEffectiveOVM; /*!< Flag effective OVM (see IDSD documentation). */
QString m_dbSendOptions; /*!< Flag send option (see IDSD documentation). */
bool m_pdz; /*!< True if message is commercial. */
QList<enum Isds::Type::DmType> m_dmTypes; /*!< Commercial message types. */
};
/* QML passes its arguments via QVariant. */
......@@ -152,8 +159,9 @@ public:
ROLE_DB_NAME,
ROLE_DB_ADDRESS,
ROLE_DB_IC,
ROLE_DB_EFFECTIVE_OVM,
ROLE_DB_SEND_OPTION,
ROLE_PDZ,
ROLE_PDZ_LIST,
ROLE_DB_SELECTED /* TODO -- See whether ItemSelectionModel can be used instead. */
};
Q_ENUM(Roles)
......
......@@ -119,7 +119,7 @@ fail:
return defaultValue;
}
bool AccountDb::boxEffectiveOVM(const QString &userName) const
bool AccountDb::isOvm(const QString &userName) const
{
QMutexLocker locker(&m_lock);
QSqlQuery query(m_db);
......
......@@ -71,7 +71,7 @@ public:
* @param[in] userName User name identifying account.
* @return True if databox is OVM.
*/
bool boxEffectiveOVM(const QString &userName) const;
bool isOvm(const QString &userName) const;
/*!
* @brief Delete account info from db.
......
......@@ -55,7 +55,7 @@ QString Accounts::dbType(const QmlAcntId *qAcntId)
}
}
QString Accounts::boxId(const QmlAcntId *qAcntId)
QString Accounts::dbId(const QmlAcntId *qAcntId)
{
if ((GlobInstcs::accountDbPtr != Q_NULLPTR) && (qAcntId != Q_NULLPTR)) {
return GlobInstcs::accountDbPtr->dbId(qAcntId->username());
......@@ -65,11 +65,10 @@ QString Accounts::boxId(const QmlAcntId *qAcntId)
}
}
bool Accounts::boxEffectiveOVM(const QmlAcntId *qAcntId)
bool Accounts::isOvm(const QmlAcntId *qAcntId)
{
if ((GlobInstcs::accountDbPtr != Q_NULLPTR) && (qAcntId != Q_NULLPTR)) {
return GlobInstcs::accountDbPtr->boxEffectiveOVM(
qAcntId->username());
return GlobInstcs::accountDbPtr->isOvm(qAcntId->username());
} else {
Q_ASSERT(0);
return false;
......@@ -139,7 +138,7 @@ int Accounts::actDTType(const QmlAcntId *qAcntId)
return -1;
}
QString dbID = boxId(qAcntId);
QString dbID = dbId(qAcntId);
Isds::DTInfoOutput dtInfo(GlobInstcs::accountDbPtr->getDTInfo(dbID));
......@@ -159,7 +158,7 @@ bool Accounts::isDTCapacityFull(const QmlAcntId *qAcntId)
return false;
}
QString dbID = boxId(qAcntId);
QString dbID = dbId(qAcntId);
Isds::DTInfoOutput dtInfo(GlobInstcs::accountDbPtr->getDTInfo(dbID));
......
......@@ -57,16 +57,16 @@ public:
* @return Databox id string.
*/
Q_INVOKABLE static
QString boxId(const QmlAcntId *qAcntId);
QString dbId(const QmlAcntId *qAcntId);
/*!
* @brief Check whether data box has effective OVM.
* @brief Check whether data box is OVM or sub-OVM.
*
* @param[in] qAcntId Account identifier.
* @return True if data box has effective OVM.
* @return True if data box OVM or sub-OVM.
*/
Q_INVOKABLE static
bool boxEffectiveOVM(const QmlAcntId *qAcntId);
bool isOvm(const QmlAcntId *qAcntId);
/*!
* @brief Update message counters for the account.
......
Supports Markdown
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