void BackendGoogleMaps::releaseWidget(KGeoMapInternalWidgetInfo* const info) { // clear all tracks d->htmlWidget->runScript(QString::fromLatin1("kgeomapClearTracks();")); disconnect(d->htmlWidget, SIGNAL(signalJavaScriptReady()), this, SLOT(slotHTMLInitialized())); disconnect(d->htmlWidget, SIGNAL(signalHTMLEvents(QStringList)), this, SLOT(slotHTMLEvents(QStringList))); disconnect(d->htmlWidget, SIGNAL(selectionHasBeenMade(KGeoMap::GeoCoordinates::Pair)), this, SLOT(slotSelectionHasBeenMade(KGeoMap::GeoCoordinates::Pair))); d->htmlWidget->setSharedKGeoMapObject(0); d->htmlWidgetWrapper->removeEventFilter(this); d->htmlWidget = 0; d->htmlWidgetWrapper = 0; info->currentOwner = 0; info->state = KGeoMapInternalWidgetInfo::InternalWidgetReleased; d->isReady = false; emit(signalBackendReadyChanged(backendName())); }
QWidget* BackendGoogleMaps::mapWidget() { if (!d->htmlWidgetWrapper) { KGeoMapGlobalObject* const go = KGeoMapGlobalObject::instance(); KGeoMapInternalWidgetInfo info; bool foundReusableWidget = go->getInternalWidgetFromPool(this, &info); if (foundReusableWidget) { d->htmlWidgetWrapper = info.widget; const GMInternalWidgetInfo intInfo = info.backendData.value<GMInternalWidgetInfo>(); d->htmlWidget = intInfo.htmlWidget; } else { // the widget has not been created yet, create it now: d->htmlWidgetWrapper = new QWidget(); d->htmlWidgetWrapper->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->htmlWidget = new HTMLWidget(d->htmlWidgetWrapper); d->htmlWidgetWrapper->resize(400,400); } connect(d->htmlWidget, SIGNAL(signalJavaScriptReady()), this, SLOT(slotHTMLInitialized())); connect(d->htmlWidget, SIGNAL(signalHTMLEvents(QStringList)), this, SLOT(slotHTMLEvents(QStringList))); connect(d->htmlWidget, SIGNAL(selectionHasBeenMade(KGeoMap::GeoCoordinates::Pair)), this, SLOT(slotSelectionHasBeenMade(KGeoMap::GeoCoordinates::Pair))); d->htmlWidget->setSharedKGeoMapObject(s.data()); d->htmlWidgetWrapper->installEventFilter(this); if (foundReusableWidget) { slotHTMLInitialized(); } else { const KUrl htmlUrl = KGeoMapGlobalObject::instance()->locateDataFile(QLatin1String("backend-googlemaps.html")); d->htmlWidget->openUrl(htmlUrl); } } return d->htmlWidgetWrapper.data(); }
BackendOSM::BackendOSM(const QExplicitlySharedDataPointer<KGeoMapSharedData>& sharedData, QObject* const parent) : MapBackend(sharedData, parent), d(new Private()) { d->htmlWidgetWrapper = new QWidget(); d->htmlWidgetWrapper->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->htmlWidget = new HTMLWidget(d->htmlWidgetWrapper); d->htmlWidgetWrapper->resize(400, 400); connect(d->htmlWidget, SIGNAL(signalJavaScriptReady()), this, SLOT(slotHTMLInitialized())); connect(d->htmlWidget, SIGNAL(signalHTMLEvents(QStringList)), this, SLOT(slotHTMLEvents(QStringList))); loadInitialHTML(); }