void GPSCorrelatorWidget::slotAllItemsCorrelated() { if (d->correlationCorrelatedCount == 0) { QMessageBox::warning(this, i18n("Correlation failed"), i18n("Could not correlate any image - please make sure the timezone and gap settings are correct.")); } else if (d->correlationCorrelatedCount == d->correlationTotalCount) { QMessageBox::information(this, i18n("Correlation succeeded"), i18n("All images have been correlated. You can now check their position on the map.")); } else { // note: no need for i18np here, because the case of correlationTotalCount==1 is covered in the other two cases. QMessageBox::warning(this, i18n("Correlation finished"), i18n("%1 out of %2 images have been correlated. Please check the timezone and gap settings if you think that more images should have been correlated.", d->correlationCorrelatedCount, d->correlationTotalCount)); } if (d->correlationCorrelatedCount == 0) { delete d->correlationUndoCommand; } else { d->correlationUndoCommand->setText(i18np("1 image correlated", "%1 images correlated", d->correlationCorrelatedCount)); emit(signalUndoCommand(d->correlationUndoCommand)); } // enable the UI: emit(signalSetUIEnabled(true)); }
void GPSCorrelatorWidget::slotCorrelationCanceled() { d->correlationUndoCommand->undo(); delete d->correlationUndoCommand; emit(signalSetUIEnabled(true)); }
void GPSCorrelatorWidget::slotCorrelate() { // disable the UI of the entire dialog: emit(signalSetUIEnabled(false, this, SLOT(slotCancelCorrelation()))); // store the options: GPSDataParser::GPXCorrelationOptions options; options.maxGapTime = d->maxGapInput->value(); options.photosHaveSystemTimeZone = (d->timeZoneGroup->checkedId() == 1); if (!options.photosHaveSystemTimeZone) { const QString tz = d->timeZoneCB->currentText(); const int hh = QString(QString(tz[4])+QString(tz[5])).toInt(); const int mm = QString(QString(tz[7])+QString(tz[8])).toInt(); int timeZoneOffset = hh*3600 + mm*60; if (tz[3] == QChar('-')) { timeZoneOffset = (-1) * timeZoneOffset; } options.secondsOffset+= timeZoneOffset; } if (d->offsetEnabled->isChecked()) { int userOffset = d->offsetMin->value() * 60 + d->offsetSec->value(); if (d->offsetSign->currentText() == "-") { userOffset = (-1) * userOffset; } options.secondsOffset+=userOffset; } options.interpolate = d->interpolateBox->isChecked(); options.interpolationDstTime = d->maxTimeInput->value()*60; // create a list of items to be correlated GPSDataParser::GPXCorrelation::List itemList; const int imageCount = d->imageModel->rowCount(); for (int i = 0; i<imageCount; ++i) { QPersistentModelIndex imageIndex = d->imageModel->index(i, 0); KipiImageItem* const imageItem = d->imageModel->itemFromIndex(imageIndex); if (!imageItem) continue; GPSDataParser::GPXCorrelation correlationItem; correlationItem.userData = QVariant::fromValue(imageIndex); correlationItem.dateTime = imageItem->dateTime(); itemList << correlationItem; } d->correlationTotalCount = imageCount; d->correlationCorrelatedCount = 0; d->correlationTriedCount = 0; d->correlationUndoCommand = new GPSUndoCommand; emit(signalProgressSetup(imageCount, i18n("Correlating images - %p%"))); d->gpsDataParser->correlate(itemList, options); // results will be sent to slotItemsCorrelated and slotAllItemsCorrelated }
void GPSReverseGeocodingWidget::slotRGCanceled() { if (!d->undoCommand) { // the undo command object is not available, therefore // RG has probably been finished already return; } if (d->receivedRGCount>0) { // Before we abort, ask the user whether he wants to discard // the information obtained so far. // ATTENTION: While we ask the question, the RG backend continues running // and sends information about new images to this widget. // This means that RG might finish while we ask the question!!! d->currentlyAskingCancelQuestion = true; const QString question = i18n("%1 out of %2 images have been reverse geocoded. Would you like to keep the tags which were already obtained or discard them?", d->receivedRGCount, d->requestedRGCount); const int result = KMessageBox::questionYesNoCancel( this, question, i18n("Abort reverse geocoding?"), KGuiItem(i18n("Keep tags")), KGuiItem(i18n("Discard tags")), KGuiItem(i18n("Continue")) ); d->currentlyAskingCancelQuestion = false; if (result==KMessageBox::Cancel) { // continue // did RG finish while we asked the question? if (d->receivedRGCount==d->requestedRGCount) { // the undo data was delayed, now send it if (d->undoCommand) { emit(signalUndoCommand(d->undoCommand)); d->undoCommand = 0; } // unlock the UI emit(signalSetUIEnabled(true)); } return; } if (result==KMessageBox::No) { // discard the tags d->undoCommand->undo(); } if (result==KMessageBox::Yes) { if (d->undoCommand) { emit(signalUndoCommand(d->undoCommand)); d->undoCommand = 0; } } } // clean up the RG request: d->currentBackend->cancelRequests(); if (d->undoCommand) { delete d->undoCommand; d->undoCommand = 0; } emit(signalSetUIEnabled(true)); }