Commit 15942220 authored by Miika Turkia's avatar Miika Turkia
Browse files

Warning for multi-image annotation

A warning added for multiple image annotation when the write would
overwrite individual descriptions. Logic follows Jesper's correction
suggestion.

BUG: 182054
parent 3eb7eacb
......@@ -74,7 +74,9 @@ using Utilities::StringSet;
*/
AnnotationDialog::Dialog::Dialog( QWidget* parent )
: QDialog( parent ), _ratingChanged(false)
: QDialog( parent ),
_ratingChanged( false ),
conflictText( QString::fromLatin1("(different text on individual images, setting text here will override them all)" ) )
{
Utilities::ShowBusyCursor dummy;
ShortCutManager shortCutManager;
......@@ -462,6 +464,8 @@ int AnnotationDialog::Dialog::configure( DB::ImageInfoList list, bool oneAtATime
load();
}
else {
uint descrCount = 0;
uint matchCount = 0;
_preview->configure( &_editList, false );
_startDate->setDate( QDate() );
_endDate->setDate( QDate() );
......@@ -476,8 +480,26 @@ int AnnotationDialog::Dialog::configure( DB::ImageInfoList list, bool oneAtATime
setUpCategoryListBoxForMultiImageSelection( *it, list );
_imageLabel->setText( QString::fromLatin1("") );
_description->setPlainText( QString::fromLatin1("") );
// Checking all the description fields if there is text and whether the descriptions mach
Q_FOREACH( DB::ImageInfo info, _editList ) {
descrCount++;
if ( !info.description().isEmpty() ) {
if ( firstDescription.isEmpty() ) {
firstDescription = info.description();
matchCount++;
} else if ( !firstDescription.compare( info.description() ) ) {
matchCount++;
}
}
}
if ( !firstDescription.isEmpty() ) {
if ( descrCount == matchCount )
_description->setPlainText( firstDescription );
else
_description->setPlainText( conflictText );
} else
_description->setPlainText( QString::fromLatin1( "" ) );
}
showHelpDialog( oneAtATime ? InputSingleImageConfigMode : InputMultiImageConfigMode );
......@@ -574,7 +596,6 @@ void AnnotationDialog::Dialog::loadInfo( const DB::ImageSearchInfo& info )
}
_imageLabel->setText( info.label() );
_description->setPlainText( info.description() );
}
void AnnotationDialog::Dialog::slotOptions()
......@@ -615,6 +636,7 @@ void AnnotationDialog::Dialog::slotSaveWindowSetup()
void AnnotationDialog::Dialog::closeEvent( QCloseEvent* e )
{
e->ignore();
firstDescription.clear();
reject();
}
......@@ -700,7 +722,7 @@ bool AnnotationDialog::Dialog::hasChanges()
}
changed |= ( !_imageLabel->text().isEmpty() );
changed |= ( !_description->toPlainText().isEmpty() );
changed |= ( !_description->toPlainText().isEmpty() && _description->toPlainText().compare( conflictText ) && _description->toPlainText().compare( firstDescription ));
changed |= _ratingChanged;
}
return changed;
......@@ -1013,7 +1035,7 @@ void AnnotationDialog::Dialog::saveAndClose()
}
if ( !_description->toPlainText().isEmpty() ) {
if ( !_description->toPlainText().isEmpty() && _description->toPlainText().compare( conflictText ) ) {
info->setDescription( _description->toPlainText() );
}
......@@ -1025,6 +1047,7 @@ void AnnotationDialog::Dialog::saveAndClose()
#endif
info->delaySavingChanges(false);
firstDescription.clear();
}
#ifdef HAVE_NEPOMUK
_ratingChanged = false;
......
......@@ -163,6 +163,8 @@ private:
QSpinBox* _megapixel;
QLabel* _megapixelLabel;
QCheckBox* _searchRAW;
QString conflictText;
QString firstDescription;
KActionCollection* _actions;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment