*
*/
+#include <QtCore/QDebug>
+#include <QtCore/QList>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+#include <QtDBus/QDBusArgument>
+#include <QtDBus/QDBusMetaType>
#include <QtGui/QMessageBox>
#include <QtGui/QLabel>
#include <QtGui/QClipboard>
#include <QtGui/QDialogButtonBox>
+#include <QtGui/QApplication>
#include <QMaemo5ValueButton>
#include <QMaemo5InformationBox>
-#include <QApplication>
-#include <QDebug>
#include "detailwindow.h"
#include "contactmanager.h"
+#include "ovimaps.h"
DetailWindow::DetailWindow(QWidget* parent): QMainWindow(parent), addDialog_(0)
{
nameButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_default_avatar"),
tr("Name"), this);
- streetButton_ = new QMaemo5ValueButton(tr("Street"), this);
+ streetButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_map"),
+ tr("Street"), this);
cityButton_ = new QMaemo5ValueButton(tr("City"), this);
numberButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_call"),
tr("Phone number"), this);
connect(numberButton_, SIGNAL(pressed()), this, SLOT(makeCall()));
+ connect(streetButton_, SIGNAL(pressed()), this, SLOT(openMaps()));
top->addWidget(nameButton_);
bottom->addWidget(streetButton_);
setCentralWidget(area_);
}
-void DetailWindow::loadData(Eniro::Result const& details)
+void DetailWindow::loadData(Source::Result const& details)
{
setWindowTitle(details.name);
nameButton_->setValueText(details.name);
streetButton_->setValueText(details.street);
cityButton_->setValueText(details.city);
numberButton_->setValueText(details.number);
+ country_ = details.country;
show();
}
void DetailWindow::addToContacts()
{
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+
ContactManager cm;
ContactManager::Contact contact;
contact.name = addContactInput_->text();
QMessageBox::critical(this, tr("Error"), tr("Unable to add contact."));
}
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+
}
void DetailWindow::copyToClipboard()
}
}
+
+void DetailWindow::openMaps()
+{
+ QString street = streetButton_->valueText();
+ QString city = cityButton_->valueText();
+ QString number;
+ QString zip;
+
+ if(street.isEmpty() && city.isEmpty())
+ {
+ return;
+ }
+
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+
+ int pos = 0;
+
+ QStringList words = street.split(" ", QString::SkipEmptyParts);
+
+ static QRegExp numberCheck("([0-9-]+)");
+
+ bool numberFound = false;
+ bool numberSet = false;
+
+ QString streetStr;
+ QString numberStr;
+
+ for(int i = 0; i < words.size(); i++)
+ {
+ if(i > 0 && numberCheck.exactMatch(words.at(i)))
+ {
+ numberFound = true;
+ }
+
+ if(numberFound)
+ {
+ if(!numberSet)
+ {
+ numberStr = words.at(i);
+ numberSet = true;
+ }
+ }
+ else
+ {
+ streetStr += words.at(i) + " ";
+ }
+ }
+
+ number = numberStr.trimmed();
+ street = streetStr.trimmed();
+
+ if((pos = city.indexOf(" ")) > 0)
+ {
+ if(numberCheck.exactMatch(city.left(pos)))
+ {
+ zip = city.left(pos);
+ city = city.mid(pos + 1);
+ }
+ }
+
+ OviMaps maps;
+
+ OviMaps::Address addr;
+ addr.street = street;
+ addr.number = number;
+ addr.zipCode = zip;
+ addr.city = city;
+ addr.country = country_;
+
+ if(!maps.openMaps(addr))
+ {
+ QMaemo5InformationBox::information(this, tr("Unable to find coordinates for address."));
+ }
+
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+}