Commit 500509f9 authored by Martin Straka's avatar Martin Straka

Added listview model for zfo files

parent 4baa7adb
......@@ -180,7 +180,7 @@ Component {
visible: true
width: parent.width
interactive: true
model: fileListModel
model: fileListModelZfo
delegate: Rectangle {
id: attachmentItem
width: parent.width
......
......@@ -648,7 +648,8 @@ bool Files::parseXMLData(QByteArray data)
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmDm") {
success = xmlLayer.completeMessageParse(xml, msg, fileList);
success = xmlLayer.completeMessageParse(xml,
msg, fileList);
}
}
}
......@@ -657,8 +658,6 @@ bool Files::parseXMLData(QByteArray data)
return success;
}
emit pushNewMessageDeatilPage(QString::number(msg.dmID));
QString html = divStart;
html += "<h3>" + QObject::tr("General") + "</h3>";
......@@ -680,8 +679,52 @@ bool Files::parseXMLData(QByteArray data)
html += strongInfoLine(QObject::tr("Databox ID"), msg.dbIDRecipient);
html += strongInfoLine(QObject::tr("Name"), msg.dmRecipient);
html += strongInfoLine(QObject::tr("Address"),msg.dmRecipientAddress);
if (!msg.dmToHands.isEmpty()) {
html += strongInfoLine(QObject::tr("To hands"),
msg.dmToHands);
}
/* TODO - add additional information to html */
QString tmpHtml;
if (!msg.dmSenderIdent.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Our file mark"),
msg.dmSenderIdent);
}
if (!msg.dmSenderRefNumber.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Our reference number"),
msg.dmSenderRefNumber);
}
if (!msg.dmRecipientIdent.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Your file mark"),
msg.dmRecipientIdent);
}
if (!msg.dmRecipientRefNumber.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Your reference number"),
msg.dmRecipientRefNumber);
}
if (!msg.dmLegalTitleLaw.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Law"),
msg.dmLegalTitleLaw);
}
if (!msg.dmLegalTitleYear.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Year"),
msg.dmLegalTitleYear);
}
if (!msg.dmLegalTitleSect.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Section"),
msg.dmLegalTitleSect);
}
if (!msg.dmLegalTitlePar.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Paragraph"),
msg.dmLegalTitlePar);
}
if (!msg.dmLegalTitlePoint.isEmpty()) {
tmpHtml += strongInfoLine(QObject::tr("Letter"),
msg.dmLegalTitlePoint);
}
if (!tmpHtml.isEmpty()) {
html += "<h3>" + QObject::tr("Additional info") + "</h3>";
html += tmpHtml;
}
html += "<h3>" + QObject::tr("Message state") + "</h3>";
html += strongInfoLine(QObject::tr("Delivery time"),
......@@ -697,6 +740,12 @@ bool Files::parseXMLData(QByteArray data)
html += divEnd;
globFilesModelZfo.setZfoFilesToModel(fileList);
foreach (const Files::File &file, fileList) {
qDebug() << file.dmID << file.dmFileDescr << file._dmFileSize << file._icon;
}
emit pushNewMessageDeatilPage(QString::number(msg.dmID));
emit messageDetailChanged(html);
return success;
......
......@@ -220,6 +220,9 @@ int main(int argc, char *argv[])
ctx->setContextProperty(globMessagesModel.objectName(),
&globMessagesModel);
ctx->setContextProperty(globFilesModel.objectName(), &globFilesModel);
globFilesModelZfo.setObjectName("fileListModelZfo");
ctx->setContextProperty(globFilesModelZfo.objectName(),
&globFilesModelZfo);
/* Localise description in tables. */
accntinfTbl.reloadLocalisedDescription();
......
......@@ -79,6 +79,7 @@ void FileModelEntry::setIcon(const QString &icon)
}
FileListModel globFilesModel;
FileListModel globFilesModelZfo;
FileListModel::FileListModel(QObject *parent)
: QAbstractListModel(parent)
......@@ -163,6 +164,22 @@ void FileListModel::setQuery(QSqlQuery &query)
endResetModel();
}
void FileListModel::setZfoFilesToModel(const QList<Files::File> &fileList)
{
beginResetModel();
m_files.clear();
foreach (const Files::File &file, fileList) {
m_files.append(FileModelEntry(file.id,
file.dmFileDescr, file._dmFileSize, file._icon));
}
endResetModel();
}
void FileListModel::clearAll(void)
{
beginResetModel();
......
......@@ -27,6 +27,8 @@
#include <QAbstractListModel>
#include <QSqlQuery>
#include "src/files.h"
class FileModelEntry {
public:
FileModelEntry(const FileModelEntry &fme);
......@@ -114,6 +116,13 @@ public:
*/
void setQuery(QSqlQuery &query);
/*!
* @brief Sets the content of the model according files from zfo.
*
* @param[in] File data list.
*/
void setZfoFilesToModel(const QList<Files::File> &fileList);
/*!
* @brief Clears the model.
*/
......@@ -124,5 +133,6 @@ private:
};
extern FileListModel globFilesModel;
extern FileListModel globFilesModelZfo;
#endif // FILEMODEL_H
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