void ExtractOneVideoFrame::markShortVideo(const DB::FileName &fileName) { if (s_tokenForShortVideos.isNull()) { Utilities::StringSet usedTokens = MainWindow::TokenEditor::tokensInUse().toSet(); for ( int ch = 'A'; ch <= 'Z'; ++ch ) { QString token = QChar::fromLatin1( (char) ch ); if (!usedTokens.contains(token)) { s_tokenForShortVideos = token; break; } } if (s_tokenForShortVideos.isNull()) { // Hmmm, no free token. OK lets just skip setting tokens. return; } KMessageBox::information(MainWindow::Window::theMainWindow(), i18n("Unable to extract video thumbnails from some files. " "Either the file is damaged in some way, or the video is ultra short. " "For your convenience, the token '%1' " "has been set on those videos.\n\n" "(You might need to wait till the video extraction led in your status bar has stopped blinking, " "to see all affected videos.)", s_tokenForShortVideos)); } DB::ImageInfoPtr info = DB::ImageDB::instance()->info(fileName); DB::CategoryPtr tokensCategory = DB::ImageDB::instance()->categoryCollection()->categoryForSpecial(DB::Category::TokensCategory); info->addCategoryInfo(tokensCategory->name(), s_tokenForShortVideos); MainWindow::DirtyIndicator::markDirty(); }
Utilities::StringSet ImportExport::MD5CheckPage::mapCategoriesToDB( const CategoryMatchSetting& matcher, const Utilities::StringSet& items ) { Utilities::StringSet res; Q_FOREACH( const QString& item, items ) { if ( matcher.XMLtoDB().contains( item ) ) res.insert(matcher.XMLtoDB()[item]); } return res; }
/** * I was considering merging the two calls to this method (one for images, one for video), but then I * realized that all the work is really done after the check for whether the given * imageInfo is of the right type, and as a match can't be both, this really * would buy me nothing. */ QMap<QString,uint> XMLDB::Database::classify( const DB::ImageSearchInfo& info, const QString &category, DB::MediaType typemask ) { QMap<QString, uint> map; DB::GroupCounter counter( category ); Utilities::StringSet alreadyMatched = info.findAlreadyMatched( category ); DB::ImageSearchInfo noMatchInfo = info; QString currentMatchTxt = noMatchInfo.categoryMatchText( category ); if ( currentMatchTxt.isEmpty() ) noMatchInfo.setCategoryMatchText( category, DB::ImageDB::NONE() ); else noMatchInfo.setCategoryMatchText( category, QString::fromLatin1( "%1 & %2" ).arg(currentMatchTxt).arg(DB::ImageDB::NONE()) ); // Iterate through the whole database of images. for( DB::ImageInfoListConstIterator it = m_images.constBegin(); it != m_images.constEnd(); ++it ) { bool match = ( (*it)->mediaType() & typemask ) && !(*it)->isLocked() && info.match( *it ) && rangeInclude( *it ); if ( match ) { // If the given image is currently matched. // Now iterate through all the categories the current image // contains, and increase them in the map mapping from category // to count. StringSet items = (*it)->itemsOfCategory(category); counter.count( items ); for( StringSet::const_iterator it2 = items.begin(); it2 != items.end(); ++it2 ) { if ( !alreadyMatched.contains(*it2) ) // We do not want to match "Jesper & Jesper" map[*it2]++; } // Find those with no other matches if ( noMatchInfo.match( *it ) ) map[DB::ImageDB::NONE()]++; } } QMap<QString,uint> groups = counter.result(); for( QMap<QString,uint>::iterator it= groups.begin(); it != groups.end(); ++it ) { map[it.key()] = it.value(); } return map; }