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
Akonadi Contacts
Commits
8db6402b
Commit
8db6402b
authored
Feb 02, 2016
by
Laurent Montel
😁
Browse files
Add grantlee here
parent
0402c47c
Changes
4
Hide whitespace changes
Inline
Side-by-side
akonadi-contact/CMakeLists.txt
View file @
8db6402b
...
...
@@ -36,6 +36,7 @@ find_package(KF5KIO ${KF5_VERSION} CONFIG REQUIRED)
find_package
(
KF5Completion
${
KF5_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5Codecs
${
KF5_VERSION
}
CONFIG REQUIRED
)
find_package
(
Phonon4Qt5 CONFIG REQUIRED
)
find_package
(
Grantlee5
"5.0"
CONFIG REQUIRED
)
find_package
(
KF5Contacts
${
KCONTACTS_VERSION
}
CONFIG REQUIRED
)
find_package
(
KF5CalendarCore
${
CALENDARCORE_VERSION
}
CONFIG REQUIRED
)
...
...
akonadi-contact/src/CMakeLists.txt
View file @
8db6402b
...
...
@@ -165,6 +165,7 @@ PRIVATE
KF5::WidgetsAddons
KF5::XmlGui
Phonon::phonon4qt5
Grantlee5::Templates
)
if
(
KF5Prison_FOUND
)
...
...
akonadi-contact/src/editor/addresseditor/addresseslocationgrantleeformater.cpp
View file @
8db6402b
...
...
@@ -22,18 +22,21 @@
#include "addresseslocationgrantleeformater.h"
#include "addressgrantleeobject.h"
#include <grantlee/engine.h>
#include <QVariantList>
AddressesLocationGrantleeFormater
::
AddressesLocationGrantleeFormater
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
),
mEngine
(
new
Grantlee
::
Engine
)
{
mTemplateLoader
=
QSharedPointer
<
Grantlee
::
FileSystemTemplateLoader
>
(
new
Grantlee
::
FileSystemTemplateLoader
);
QString
themePath
;
//TODO
changeGrantleePath
(
themePath
);
}
AddressesLocationGrantleeFormater
::~
AddressesLocationGrantleeFormater
()
{
delete
mEngine
;
}
QString
AddressesLocationGrantleeFormater
::
formatAddresses
(
const
KContacts
::
Address
::
List
&
addresses
)
...
...
@@ -46,5 +49,22 @@ QString AddressesLocationGrantleeFormater::formatAddresses(const KContacts::Addr
addressList
<<
QVariant
::
fromValue
(
static_cast
<
QObject
*>
(
addressObj
));
}
//TODO
return
QString
();
QVariantHash
addressHash
;
Grantlee
::
Context
context
(
addressHash
);
const
QString
contentHtml
=
mSelfcontainedTemplate
->
render
(
&
context
);
return
contentHtml
;
}
void
AddressesLocationGrantleeFormater
::
changeGrantleePath
(
const
QString
&
path
)
{
if
(
!
mTemplateLoader
)
{
mTemplateLoader
=
QSharedPointer
<
Grantlee
::
FileSystemTemplateLoader
>
(
new
Grantlee
::
FileSystemTemplateLoader
);
}
mTemplateLoader
->
setTemplateDirs
(
QStringList
()
<<
path
);
mEngine
->
addTemplateLoader
(
mTemplateLoader
);
mSelfcontainedTemplate
=
mEngine
->
loadByName
(
QStringLiteral
(
"sss"
));
//TODO
if
(
mSelfcontainedTemplate
->
error
())
{
mErrorMessage
+=
mSelfcontainedTemplate
->
errorString
()
+
QLatin1String
(
"<br>"
);
}
}
akonadi-contact/src/editor/addresseditor/addresseslocationgrantleeformater.h
View file @
8db6402b
...
...
@@ -26,7 +26,12 @@
#include <QObject>
#include <KContacts/Address>
#include <QSharedPointer>
#include <grantlee/templateloader.h>
namespace
Grantlee
{
class
Engine
;
}
class
AddressesLocationGrantleeFormater
:
public
QObject
{
Q_OBJECT
...
...
@@ -35,7 +40,12 @@ public:
~
AddressesLocationGrantleeFormater
();
QString
formatAddresses
(
const
KContacts
::
Address
::
List
&
addresses
);
private:
void
changeGrantleePath
(
const
QString
&
path
);
Grantlee
::
Engine
*
mEngine
;
QString
mErrorMessage
;
QSharedPointer
<
Grantlee
::
FileSystemTemplateLoader
>
mTemplateLoader
;
Grantlee
::
Template
mSelfcontainedTemplate
;
};
#endif // ADDRESSESLOCATIONGRANTLEEFORMATER_H
Write
Preview
Markdown
is supported
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