Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Messagelib
Commits
19f78a52
Commit
19f78a52
authored
Apr 01, 2016
by
Laurent Montel
😁
Browse files
Add support for embedeed part (cid image)
parent
f71a5fe0
Changes
4
Hide whitespace changes
Inline
Side-by-side
messageviewer/src/htmlwriter/autotests/webengineembedparttest.cpp
0 → 100644
View file @
19f78a52
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include
"webengineembedparttest.h"
#include
"../webengineembedpart.h"
#include
<QTest>
WebEngineEmbedPartTest
::
WebEngineEmbedPartTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
WebEngineEmbedPartTest
::~
WebEngineEmbedPartTest
()
{
}
void
WebEngineEmbedPartTest
::
shouldHaveDefaultValue
()
{
MessageViewer
::
WebEngineEmbedPart
part
;
QVERIFY
(
part
.
isEmpty
());
}
void
WebEngineEmbedPartTest
::
shouldClearValue
()
{
MessageViewer
::
WebEngineEmbedPart
part
;
part
.
addEmbedPart
(
QByteArrayLiteral
(
"foo"
),
QStringLiteral
(
"bla"
));
QVERIFY
(
!
part
.
isEmpty
());
QCOMPARE
(
part
.
embeddedPartMap
().
count
(),
1
);
part
.
clear
();
QVERIFY
(
part
.
isEmpty
());
}
void
WebEngineEmbedPartTest
::
shouldAddValues
()
{
MessageViewer
::
WebEngineEmbedPart
part
;
part
.
addEmbedPart
(
QByteArrayLiteral
(
"foo"
),
QStringLiteral
(
"bla"
));
QVERIFY
(
!
part
.
isEmpty
());
QCOMPARE
(
part
.
embeddedPartMap
().
count
(),
1
);
part
.
addEmbedPart
(
QByteArrayLiteral
(
"foo1"
),
QStringLiteral
(
"bla"
));
QCOMPARE
(
part
.
embeddedPartMap
().
count
(),
2
);
}
void
WebEngineEmbedPartTest
::
shouldAddTwoIdenticalValues
()
{
MessageViewer
::
WebEngineEmbedPart
part
;
part
.
addEmbedPart
(
QByteArrayLiteral
(
"foo"
),
QStringLiteral
(
"bla"
));
QVERIFY
(
!
part
.
isEmpty
());
QCOMPARE
(
part
.
embeddedPartMap
().
count
(),
1
);
part
.
addEmbedPart
(
QByteArrayLiteral
(
"foo"
),
QStringLiteral
(
"bla"
));
QCOMPARE
(
part
.
embeddedPartMap
().
count
(),
1
);
}
QTEST_MAIN
(
WebEngineEmbedPartTest
)
messageviewer/src/htmlwriter/autotests/webengineembedparttest.h
0 → 100644
View file @
19f78a52
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WEBENGINEEMBEDPARTTEST_H
#define WEBENGINEEMBEDPARTTEST_H
#include
<QObject>
class
WebEngineEmbedPartTest
:
public
QObject
{
Q_OBJECT
public:
explicit
WebEngineEmbedPartTest
(
QObject
*
parent
=
Q_NULLPTR
);
~
WebEngineEmbedPartTest
();
private
Q_SLOTS
:
void
shouldHaveDefaultValue
();
void
shouldClearValue
();
void
shouldAddValues
();
void
shouldAddTwoIdenticalValues
();
};
#endif // WEBENGINEEMBEDPARTTEST_H
messageviewer/src/htmlwriter/webengineembedpart.cpp
0 → 100644
View file @
19f78a52
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include
"webengineembedpart.h"
using
namespace
MessageViewer
;
class
WebEngineEmbedPartInstancePrivate
{
public:
WebEngineEmbedPartInstancePrivate
()
:
webEngineEmbedPart
(
new
WebEngineEmbedPart
)
{
}
~
WebEngineEmbedPartInstancePrivate
()
{
delete
webEngineEmbedPart
;
}
WebEngineEmbedPart
*
webEngineEmbedPart
;
};
Q_GLOBAL_STATIC
(
WebEngineEmbedPartInstancePrivate
,
sInstance
)
WebEngineEmbedPart
::
WebEngineEmbedPart
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
WebEngineEmbedPart
::~
WebEngineEmbedPart
()
{
}
WebEngineEmbedPart
*
WebEngineEmbedPart
::
self
()
{
return
sInstance
->
webEngineEmbedPart
;
}
QString
WebEngineEmbedPart
::
contentUrl
(
const
QString
&
contentId
)
const
{
return
mEmbeddedPartMap
.
value
(
contentId
);
}
void
WebEngineEmbedPart
::
addEmbedPart
(
const
QByteArray
&
contentId
,
const
QString
&
contentURL
)
{
mEmbeddedPartMap
[
QLatin1String
(
contentId
)]
=
contentURL
;
}
void
WebEngineEmbedPart
::
clear
()
{
mEmbeddedPartMap
.
clear
();
}
bool
WebEngineEmbedPart
::
isEmpty
()
const
{
return
mEmbeddedPartMap
.
isEmpty
();
}
QMap
<
QString
,
QString
>
WebEngineEmbedPart
::
embeddedPartMap
()
const
{
return
mEmbeddedPartMap
;
}
messageviewer/src/htmlwriter/webengineembedpart.h
0 → 100644
View file @
19f78a52
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WEBENGINEEMBEDPART_H
#define WEBENGINEEMBEDPART_H
#include
<QObject>
#include
<QMap>
namespace
MessageViewer
{
class
WebEngineEmbedPart
:
public
QObject
{
Q_OBJECT
public:
explicit
WebEngineEmbedPart
(
QObject
*
parent
=
Q_NULLPTR
);
~
WebEngineEmbedPart
();
void
clear
();
bool
isEmpty
()
const
;
QMap
<
QString
,
QString
>
embeddedPartMap
()
const
;
void
addEmbedPart
(
const
QByteArray
&
contentId
,
const
QString
&
contentURL
);
QString
contentUrl
(
const
QString
&
contentId
)
const
;
static
WebEngineEmbedPart
*
self
();
private:
// Key is Content-Id, value is URL
QMap
<
QString
,
QString
>
mEmbeddedPartMap
;
};
}
#endif // WEBENGINEEMBEDPART_H
Write
Preview
Supports
Markdown
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