void ImagePropertiesGPSTab::setMetadata(const DMetadata& meta, const KUrl& url) { double lat, lng; const bool haveCoordinates = meta.getGPSLatitudeNumber(&lat) && meta.getGPSLongitudeNumber(&lng); if (haveCoordinates) { double alt; const bool haveAlt = meta.getGPSAltitude(&alt); KGeoMap::GeoCoordinates coordinates(lat, lng); if (haveAlt) { coordinates.setAlt(alt); } GPSImageInfo gpsInfo; gpsInfo.coordinates = coordinates; gpsInfo.dateTime = meta.getImageDateTime(); gpsInfo.rating = meta.getImageRating(); gpsInfo.url = url; setGPSInfoList(GPSImageInfo::List() << gpsInfo); } else { clearGPSInfo(); } }
void ShowFoto::openUrls(const QList<QUrl> &urls) { if (!urls.isEmpty()) { ShowfotoItemInfoList infos; ShowfotoItemInfo iteminfo; DMetadata meta; for (QList<QUrl>::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it) { QFileInfo fi((*it).toLocalFile()); iteminfo.name = fi.fileName(); iteminfo.mime = fi.suffix(); iteminfo.size = fi.size(); iteminfo.url = QUrl::fromLocalFile(fi.filePath()); iteminfo.folder = fi.path(); iteminfo.dtime = fi.created(); meta.load(fi.filePath()); iteminfo.ctime = meta.getImageDateTime(); iteminfo.width = meta.getImageDimensions().width(); iteminfo.height = meta.getImageDimensions().height(); iteminfo.photoInfo = meta.getPhotographInformation(); infos.append(iteminfo); } if (d->droppedUrls) { //replace the equal sign with "<<" to keep the previous pics in the list d->infoList << infos; } else { d->infoList = infos; d->model->clearShowfotoItemInfos(); emit signalInfoList(d->infoList); slotOpenUrl(d->thumbBar->currentInfo()); } } }
/** * @brief This function finds the best representative marker from a group of markers. This is needed to display a thumbnail for a marker group. * @param indices A list containing markers. * @param sortKey Determines the sorting options and is actually of type GPSImageInfoSorter::SortOptions * @return Returns the index of the marker. */ QPersistentModelIndex MapViewModelHelper::bestRepresentativeIndexFromList(const QList<QPersistentModelIndex>& list, const int sortKey) { if (list.isEmpty()) { return QPersistentModelIndex(); } // first convert from QPersistentModelIndex to QModelIndex QList<QModelIndex> indexList; QModelIndex bestIndex; for (int i=0; i < list.count(); ++i) { const QModelIndex newIndex(list.at(i)); indexList.append(newIndex); } switch (d->application) { case MapWidgetView::ApplicationDigikam: { // now get the ImageInfos and convert them to GPSImageInfos const QList<ImageInfo> imageInfoList = d->model->imageInfos(indexList); GPSImageInfo::List gpsImageInfoList; foreach(const ImageInfo& imageInfo, imageInfoList) { GPSImageInfo gpsImageInfo; if (ImagePropertiesSideBarDB::GPSImageInfofromImageInfo(imageInfo, &gpsImageInfo)) { gpsImageInfoList << gpsImageInfo; } } if (gpsImageInfoList.size()!=indexList.size()) { // this is a problem, and unexpected return indexList.first(); } // now determine the best available index bestIndex = indexList.first(); GPSImageInfo bestGPSImageInfo = gpsImageInfoList.first(); for (int i=1; i < gpsImageInfoList.count(); ++i) { const GPSImageInfo& currentInfo = gpsImageInfoList.at(i); if (GPSImageInfoSorter::fitsBetter(bestGPSImageInfo, GeoIface::SelectedNone, currentInfo, GeoIface::SelectedNone, GeoIface::SelectedNone, GPSImageInfoSorter::SortOptions(sortKey))) { bestIndex = indexList.at(i); bestGPSImageInfo = currentInfo; } } break; } case MapWidgetView::ApplicationImportUI: { // now get the CamItemInfo and convert them to GPSImageInfos const QList<CamItemInfo> imageInfoList = d->importModel->camItemInfos(indexList); GPSImageInfo::List gpsImageInfoList; foreach(const CamItemInfo& imageInfo, imageInfoList) { const DMetadata meta(imageInfo.url().toLocalFile()); double lat, lng; const bool hasCoordinates = meta.getGPSLatitudeNumber(&lat) && meta.getGPSLongitudeNumber(&lng); if (!hasCoordinates) { continue; } GeoIface::GeoCoordinates coordinates(lat, lng); double alt; const bool haveAlt = meta.getGPSAltitude(&alt); if (haveAlt) { coordinates.setAlt(alt); } GPSImageInfo gpsImageInfo; gpsImageInfo.coordinates = coordinates; gpsImageInfo.dateTime = meta.getImageDateTime(); gpsImageInfo.rating = meta.getImageRating(); gpsImageInfo.url = imageInfo.url(); gpsImageInfoList << gpsImageInfo; } if (gpsImageInfoList.size()!=indexList.size()) { // this is a problem, and unexpected return indexList.first(); } // now determine the best available index bestIndex = indexList.first(); GPSImageInfo bestGPSImageInfo = gpsImageInfoList.first(); for (int i=1; i < gpsImageInfoList.count(); ++i) { const GPSImageInfo& currentInfo = gpsImageInfoList.at(i); if (GPSImageInfoSorter::fitsBetter(bestGPSImageInfo, GeoIface::SelectedNone, currentInfo, GeoIface::SelectedNone, GeoIface::SelectedNone, GPSImageInfoSorter::SortOptions(sortKey))) { bestIndex = indexList.at(i); bestGPSImageInfo = currentInfo; } } break; } }
void ShowFoto::openFolder(const QUrl& url) { if (!url.isValid() || !url.isLocalFile()) { return; } // Parse image IO mime types registration to get files filter pattern. QString filter; QStringList mimeTypes = supportedImageMimeTypes(QIODevice::ReadOnly, filter); QString patterns = filter.toLower(); patterns.append (QLatin1String(" ")); patterns.append (filter.toUpper()); qCDebug(DIGIKAM_SHOWFOTO_LOG) << "patterns=" << patterns; // Get all image files from directory. QDir dir(url.toLocalFile(), patterns); dir.setFilter(QDir::Files); if (!dir.exists()) { return; } QFileInfoList fileinfolist = dir.entryInfoList(); if (fileinfolist.isEmpty()) { //emit signalSorry(); return; } QFileInfoList::const_iterator fi; ShowfotoItemInfoList infos; ShowfotoItemInfo iteminfo; DMetadata meta; // And open all items in image editor. for (fi = fileinfolist.constBegin(); fi != fileinfolist.constEnd(); ++fi) { iteminfo.name = (*fi).fileName(); iteminfo.mime = (*fi).suffix(); iteminfo.size = (*fi).size(); iteminfo.folder = (*fi).path(); iteminfo.url = QUrl::fromLocalFile((*fi).filePath()); iteminfo.dtime = (*fi).created(); meta.load((*fi).filePath()); iteminfo.ctime = meta.getImageDateTime(); iteminfo.width = meta.getImageDimensions().width(); iteminfo.height = meta.getImageDimensions().height(); iteminfo.photoInfo = meta.getPhotographInformation(); infos.append(iteminfo); } if (d->droppedUrls) { d->infoList << infos; } else { d->infoList = infos; d->model->clearShowfotoItemInfos(); emit signalInfoList(d->infoList); slotOpenUrl(d->thumbBar->currentInfo()); } d->lastOpenedDirectory = QUrl::fromLocalFile(dir.absolutePath()); }