void UploadDialog::loadImagesFromCurrentSelection() { #if KIPI_PLUGIN /// add selected items to the ImageList ImageCollection images = iface()->currentSelection(); if( images.isValid() ) { KUrl::List selected = images.images(); for( KUrl::List::Iterator it = selected.begin(); it != selected.end(); ++it ) { addUrlToList( (*it).path() ); } } #endif }
/*! \fn KmlExport::generate() */ void KmlExport::generate() { //! @todo perform a test here before continuing. createDir(QString(m_tempDestDir + m_imageDir)); m_progressDialog->show(); ImageCollection selection = m_interface->currentSelection(); ImageCollection album = m_interface->currentAlbum(); // create the document, and it's root m_kmlDocument = new QDomDocument(""); QDomImplementation impl; QDomProcessingInstruction instr = m_kmlDocument->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); m_kmlDocument->appendChild(instr); QDomElement kmlRoot = m_kmlDocument->createElementNS("http://www.opengis.net/kml/2.2", "kml"); m_kmlDocument->appendChild( kmlRoot ); QDomElement kmlAlbum = addKmlElement(kmlRoot, "Document"); QDomElement kmlName = addKmlTextElement(kmlAlbum, "name", album.name()); QDomElement kmlDescription = addKmlHtmlElement(kmlAlbum, "description", "Created with kmlexport <a href=\"http://www.digikam.org/\">kipi-plugin</a>"); if (m_GPXtracks) { addTrack(kmlAlbum); } KPMetadata meta; KUrl::List images = selection.images(); int defectImage = 0; int pos = 1; int count = images.count(); KUrl::List::ConstIterator imagesEnd (images.constEnd()); for( KUrl::List::ConstIterator selIt = images.constBegin(); selIt != imagesEnd; ++selIt, ++pos) { double alt, lat, lng; KUrl url = *selIt; KPImageInfo info(url); bool hasGPSInfo = info.hasGeolocationInfo(); if (hasGPSInfo) { lat = info.latitude(); lng = info.longitude(); alt = info.altitude(); } else { meta.load(url.path()); hasGPSInfo = meta.getGPSInfo(alt, lat, lng); } if ( hasGPSInfo ) { // generation de l'image et de l'icone generateImagesthumb(url, kmlAlbum); } else { logWarning(i18n("No position data for '%1'", info.name())); defectImage++; } m_progressDialog->progressWidget()->setProgress(pos, count); kapp->processEvents(); } if (defectImage) { /** @todo if defectImage==count there are no pictures exported, does is it worth to continue? */ KMessageBox::information(kapp->activeWindow(), i18np("No position data for 1 picture", "No position data for %1 pictures", defectImage)); } /** @todo change to kml or kmz if compressed */ QFile file( m_tempDestDir + m_KMLFileName + ".kml"); /** @todo handle file opening problems */ file.open( QIODevice::WriteOnly ); QTextStream stream( &file ); // we will serialize the data into the file stream << m_kmlDocument->toString(); file.close(); delete m_kmlDocument; m_kmlDocument = 0; KIO::moveAs(m_tempDestDir, m_baseDestDir, KIO::HideProgressInfo | KIO::Overwrite); logInfo(i18n("Move to final directory")); m_progressDialog->close(); }