Virtual MimeTypes support patch

David Faure faure at kde.org
Mon Oct 23 11:59:05 BST 2006


Hi Albert,

KService::virtualMimeType() allows only one virtual mimetype per service; I wonder
if this shouldn't be a list instead, just in case (e.g. someone merges kdvi and kghostview,
you end up with the need to support two virtual mimetypes, from the plugins for both apps).

On Saturday, October 21, 2006 07:10:33 PM Albert Astals Cid wrote:
> +  QMap<QString,QVariant>::const_iterator it = m_mapProps.find( QLatin1String("X-KDE-Virtual-MimeType") );
> +  if (it != m_mapProps.end()) return it.value().toString();
> +  else return QString();

The simpler qt4 way of writing this is
 return m_mapProps.value( QLatin1String("X-KDE-Virtual-MimeType") ).toString();
(if not found, value() returns a QVariant() since the value type is QVariant)

> +            // remove the Application service as it.value()->serviceTypes() already has one
> +            service->accessServiceTypes().removeLast();
Dangerous, the last servicetype might not be Application! A part could use the same "virtual mimetypes" mechanism...
I think this should be generalized into "only add those servicetypes that the service doesn't already have".

> +     if (virtualMimeType.startsWith("virtual/"))
If not, the virtual mimetype is just ignored; I guess this needs a kWarning at least.

To answer Thiago: I still hope that we find the time to switch kde4 to xdg-shared-mime, 
so this mechanism (which, I note, is properly designed for interoperability since it installs
Type=Application desktop files and doesn't reuse the plugin .desktop files - that's good)
should be standardized at the xdg level.
I would add NoDisplay=true to the files though, we don't want them in menus...
Hmm, and they'll still show up in konq's RMB popup, unless we add a check for "Exec not empty".
This is in fact a strange misuse of the desktop file standard (apps without exec), it needs to 
be agreed on at xdg to avoid such side effects.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list