Commit 81c9e553 authored by Karel Slaný's avatar Karel Slaný

Implemented Files::sendAttachmentEmailZfo().

parent b6fa0614
......@@ -167,7 +167,7 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
files.sendAttachmentsWithEmailFromZfo(zfoId, msgAnnotation, emailBody)
files.sendAttachmentEmailZfo(attachmentModel, zfoId, msgAnnotation, emailBody)
}
}
}
......
This diff is collapsed.
......@@ -52,7 +52,8 @@ public:
/*!
* @brief Open attachment in default application.
*/
Q_INVOKABLE void openAttachment(const QString &fileName,
Q_INVOKABLE static
void openAttachment(const QString &fileName,
const QByteArray &base64Data);
/*!
......@@ -64,16 +65,6 @@ public:
Q_INVOKABLE void sendAttachmentsWithEmailFromDb(const QString &userName,
qint64 msgId);
/*!
* @brief Send attachment from zfo with email application.
*
* @param[in] msgId Message id.
* @param[in] subject Email subject.
* @param[in] body Email body.
*/
Q_INVOKABLE void sendAttachmentsWithEmailFromZfo(qint64 msgId,
QString subject, QString body);
/*!
* @brief Save attachments to disk.
*/
......@@ -209,6 +200,24 @@ public:
bool setAttachmentModel(FileListModel &attachModel,
const QString &userName, qint64 msgId);
/*!
* @brief Send attachment from zfo with email application.
*
* @note Some weird stuff happens in QML when passing attachment model
* directly as constant reference. Wrong constructors are called
* and no data are passed. That's because we are using a QVariant.
* Also, QML does not know qint64 therefore we use a QStrting as
* message id.
*
* @param[in] attachModelVariant QVariant holding attachment model.
* @param[in] msgId Message id.
* @param[in] subject Email subject.
* @param[in] body Email body.
*/
Q_INVOKABLE static
void sendAttachmentEmailZfo(const QVariant &attachModelVariant,
const QString &msgIdStr, QString subject, QString body);
/*!
* @brief Delete temporary file from storage.
*
......@@ -265,6 +274,7 @@ private:
* @param[in] body Email body.
* @param[in] msgId Message ID.
*/
static
void sendEmail(const QString &emailMessage, const QStringList &fileList,
const QString &subject, const QString &body, qint64 msgId);
......
......@@ -269,10 +269,8 @@ int main(int argc, char *argv[])
globAccountsModelPtr);
ctx->setContextProperty(globMessagesModel.objectName(),
&globMessagesModel);
globFilesModel.setObjectName("fileListModel");
ctx->setContextProperty(globFilesModel.objectName(), &globFilesModel);
globFilesModelZfo.setObjectName("fileListModelZfo");
ctx->setContextProperty(globFilesModelZfo.objectName(),
&globFilesModelZfo);
/* Localise description in tables. */
accntinfTbl.reloadLocalisedDescription();
......
......@@ -97,13 +97,19 @@ FileListModel globFilesModelZfo;
void FileListModel::declareQML(void)
{
qmlRegisterType<FileListModel>("cz.nic.mobileDatovka.models", 1, 0, "FileListModel");
qRegisterMetaType<FileListModel>();
}
FileListModel::FileListModel(QObject *parent)
: QAbstractListModel(parent)
: QAbstractListModel(parent),
m_files()
{
}
FileListModel::FileListModel(const FileListModel &model, QObject *parent)
: QAbstractListModel(parent),
m_files(model.m_files)
{
/* Used in QML. */
setObjectName("fileListModel");
}
int FileListModel::rowCount(const QModelIndex &parent) const
......
......@@ -76,7 +76,18 @@ public:
*
* @param[in] parent Pointer to parent object.
*/
explicit FileListModel(QObject *parent = 0);
explicit FileListModel(QObject *parent = Q_NULLPTR);
/*!
* @brief Copy constructor.
*
* @note Needed for QVariant conversion.
*
* @param[in] model Model to be copied.
* @param[in] parent Pointer to parent object.
*/
explicit FileListModel(const FileListModel &model,
QObject *parent = Q_NULLPTR);
/*!
* @brief Return number of rows under the given parent.
......@@ -160,6 +171,9 @@ private:
QList<Entry> m_files; /*!< List of attachment entries. */
};
/* QML passes its arguments via QVariant. */
Q_DECLARE_METATYPE(FileListModel)
extern FileListModel globFilesModel;
extern FileListModel globFilesModelZfo;
......
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