From kde-commits Fri Oct 22 18:17:12 2010 From: Jesper Pedersen Date: Fri, 22 Oct 2010 18:17:12 +0000 To: kde-commits Subject: extragear/graphics/kphotoalbum Message-Id: <20101022181712.24F4CAC897 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128777229402598 SVN commit 1188584 by blackie: I don't remember if I actually sent this in. If you right click on an image in the viewer and accidentally hover over Run Program (on the selection), it is extremely slow. I tracked that down to the Run Program code looking at all the files to determine the set of MIME types in order to select appropriate programs to populate the menu with. If we make the assumption that MIME type is determined solely by the extension (which is probably reasonable for this purpose), we can speed matters up tremendously. M +6 -0 ChangeLog M +8 -1 MainWindow/ExternalPopup.cpp --- trunk/extragear/graphics/kphotoalbum/ChangeLog #1188583:1188584 @@ -1,3 +1,9 @@ +2010-10-22 Jesper K. Pedersen + + * Bugfix: If you right click on an + image in the viewer and accidentally hover over Run Program (on the + selection), it is extremely slow. Thanks to Robert Krawitz for a patch + 2010-09-08 Miika Turkia * Patch to display filter button correctly, enable collapsing super --- trunk/extragear/graphics/kphotoalbum/MainWindow/ExternalPopup.cpp #1188583:1188584 @@ -167,15 +167,22 @@ QString MainWindow::ExternalPopup::mimeType( const QString& file ) { - return KFileItem( KFileItem::Unknown, KFileItem::Unknown, KUrl(file) ).mimetype(); + return KMimeType::findByPath(file, 0, true)->name(); } Utilities::StringSet MainWindow::ExternalPopup::mimeTypes( const QStringList& files ) { StringSet res; + StringSet extensions; for( QStringList::ConstIterator fileIt = files.begin(); fileIt != files.end(); ++fileIt ) { + QString baseFileName = *fileIt; + int extStart = baseFileName.lastIndexOf(QChar::fromLatin1('.')); + baseFileName.remove(0, extStart); + if (! extensions.contains(baseFileName)) { res.insert( mimeType( *fileIt ) ); + extensions.insert( baseFileName ); } + } return res; }