22#include "showaddressaction.h"
24#include "contactactionssettings.h"
26#include <kabc/address.h>
28#include <ktoolinvocation.h>
32static void replaceArguments(QString &templateStr,
const KABC::Address &address)
34 templateStr.replace(QLatin1String(
"%s"), address.street()).
35 replace(QLatin1String(
"%r"), address.region()).
36 replace(QLatin1String(
"%l"), address.locality()).
37 replace(QLatin1String(
"%z"), address.postalCode()).
38 replace(QLatin1String(
"%n"), address.country()).
39 replace(QLatin1String(
"%c"), address.countryToISO(address.country()));
42void ShowAddressAction::showAddress(
const KABC::Address &address)
45 ContactActionsSettings::self()->readConfig();
47 if (ContactActionsSettings::self()->showAddressAction() == ContactActionsSettings::UseBrowser) {
48 QString urlTemplate = ContactActionsSettings::self()->addressUrl();
49 replaceArguments(urlTemplate, address);
50 if (!urlTemplate.isEmpty()) {
51 KToolInvocation::invokeBrowser(urlTemplate);
53 }
else if (ContactActionsSettings::self()->showAddressAction() == ContactActionsSettings::UseExternalAddressApplication) {
54 QString commandTemplate = ContactActionsSettings::self()->addressCommand();
55 replaceArguments(commandTemplate, address);
57 if (!commandTemplate.isEmpty()) {
58 KRun::runCommand(commandTemplate, 0);
60 }
else if (ContactActionsSettings::self()->showAddressAction() == ContactActionsSettings::UseGooglemap) {
61 QString urlTemplate = QLatin1String(
"https://maps.google.com/maps?q=%s,%l,%c");
62 replaceArguments(urlTemplate, address);
63 if (!urlTemplate.isEmpty()) {
64 KToolInvocation::invokeBrowser(urlTemplate);
66 }
else if (ContactActionsSettings::self()->showAddressAction() == ContactActionsSettings::UseMapquest) {
67 QString urlTemplate = QLatin1String(
"http://open.mapquest.com/?q=%s,%l,%c");
68 replaceArguments(urlTemplate, address);
69 if (!urlTemplate.isEmpty()) {
70 KToolInvocation::invokeBrowser(urlTemplate);
FreeBusyManager::Singleton.