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
aac8bb0e
Commit
aac8bb0e
authored
Feb 02, 2016
by
Laurent Montel
😁
Browse files
Improve it
parent
c1f017ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
akonadi-contact/src/editor/addresseditor/addresseslocationviewer.cpp
View file @
aac8bb0e
...
...
@@ -22,7 +22,10 @@
#include "addresseslocationviewer.h"
#include "addresseslocationgrantleeformater.h"
#include <QUrlQuery>
#include <QWebSettings>
#include <QDebug>
AddressesLocationViewer
::
AddressesLocationViewer
(
QWidget
*
parent
)
:
QWebView
(
parent
),
mAddressesLocationGrantleeFormatter
(
new
AddressesLocationGrantleeFormater
(
this
))
...
...
@@ -43,14 +46,46 @@ AddressesLocationViewer::~AddressesLocationViewer()
void
AddressesLocationViewer
::
slotLinkClicked
(
const
QUrl
&
url
)
{
if
(
url
.
scheme
()
==
QLatin1String
(
"addresslocationaction"
))
{
const
QString
urlPath
(
url
.
path
());
if
(
url
.
hasQuery
())
{
const
QUrlQuery
urlQuery
(
url
);
const
int
addressId
=
urlQuery
.
queryItemValue
(
QStringLiteral
(
"id"
)).
toInt
();
if
(
urlPath
==
QStringLiteral
(
"removeaddress"
))
{
removeAddress
(
addressId
);
}
else
if
(
urlPath
==
QStringLiteral
(
"editaddress"
))
{
editAddress
(
addressId
);
}
else
{
qDebug
()
<<
"Unknown url"
<<
url
;
}
}
}
}
void
AddressesLocationViewer
::
removeAddress
(
int
index
)
{
if
(
index
<
0
)
{
return
;
}
else
if
(
index
<
mAddresses
.
count
())
{
mAddresses
.
remove
(
index
);
updateView
();
}
}
void
AddressesLocationViewer
::
editAddress
(
int
index
)
{
if
(
index
<
0
)
{
return
;
}
else
if
(
index
<
mAddresses
.
count
())
{
//TODO remove it from list ?
editAddress
(
mAddresses
.
at
(
index
));
}
}
void
AddressesLocationViewer
::
updateView
()
{
const
QString
html
=
mAddressesLocationGrantleeFormatter
->
formatAddresses
(
mAddresses
);
//TODO
//TODO
setHtml
(
html
,
QUrl
(
QStringLiteral
(
"file://"
)));
}
void
AddressesLocationViewer
::
addAddress
(
const
KContacts
::
Address
&
address
)
...
...
akonadi-contact/src/editor/addresseditor/addresseslocationviewer.h
View file @
aac8bb0e
...
...
@@ -43,8 +43,13 @@ public:
private
Q_SLOTS
:
void
slotLinkClicked
(
const
QUrl
&
url
);
Q_SIGNALS:
void
editAddress
(
const
KContacts
::
Address
&
address
);
private:
void
updateView
();
void
editAddress
(
int
index
);
void
removeAddress
(
int
index
);
KContacts
::
Address
::
List
mAddresses
;
AddressesLocationGrantleeFormater
*
mAddressesLocationGrantleeFormatter
;
};
...
...
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