QDomElement ImportExport::XMLHandler::save( QDomDocument doc, const DB::ImageInfoPtr& info ) { QDomElement elm = doc.createElement( QString::fromLatin1("image") ); elm.setAttribute( QString::fromLatin1("label"), info->label() ); elm.setAttribute( QString::fromLatin1("description"), info->description() ); DB::ImageDate date = info->date(); QDateTime start = date.start(); QDateTime end = date.end(); elm.setAttribute( QString::fromLatin1("yearFrom"), start.date().year() ); elm.setAttribute( QString::fromLatin1("monthFrom"), start.date().month() ); elm.setAttribute( QString::fromLatin1("dayFrom"), start.date().day() ); elm.setAttribute( QString::fromLatin1("hourFrom"), start.time().hour() ); elm.setAttribute( QString::fromLatin1("minuteFrom"), start.time().minute() ); elm.setAttribute( QString::fromLatin1("secondFrom"), start.time().second() ); elm.setAttribute( QString::fromLatin1("yearTo"), end.date().year() ); elm.setAttribute( QString::fromLatin1("monthTo"), end.date().month() ); elm.setAttribute( QString::fromLatin1("dayTo"), end.date().day() ); elm.setAttribute( QString::fromLatin1( "width" ), info->size().width() ); elm.setAttribute( QString::fromLatin1( "height" ), info->size().height() ); elm.setAttribute( QString::fromLatin1( "md5sum" ), info->MD5Sum().toHexString() ); elm.setAttribute( QString::fromLatin1( "angle" ), info->angle() ); writeCategories( doc, elm, info ); return elm; }
ImportExport::ClashInfo ImportExport::MD5CheckPage::clashes(const ImportSettings& settings) { QStringList myCategories; Q_FOREACH( const CategoryMatchSetting& matcher, settings.categoryMatchSetting() ) { myCategories.append( matcher.DBCategoryName() ); } ClashInfo res( myCategories ); DB::ImageInfoList list = settings.selectedImages(); Q_FOREACH( DB::ImageInfoPtr info, list ) { if ( !DB::ImageDB::instance()->md5Map()->contains(info->MD5Sum()) ) continue; const DB::FileName name = DB::ImageDB::instance()->md5Map()->lookup(info->MD5Sum()); DB::ImageInfoPtr other = DB::ImageDB::instance()->info(name); if ( info->label() != other->label() ) res.label = true; if ( info->description() != other->description() ) res.description = true; if ( info->angle() != other->angle() ) res.orientation = true; if (info->date() != other->date() ) res.date = true; Q_FOREACH( const CategoryMatchSetting& matcher, settings.categoryMatchSetting() ) { const QString XMLFileCategory = matcher.XMLCategoryName(); const QString DBCategory = matcher.DBCategoryName(); if ( mapCategoriesToDB( matcher, info->itemsOfCategory( XMLFileCategory ) ) != other->itemsOfCategory( DBCategory ) ) res.categories[DBCategory] = true; } } return res; }