本文整理汇总了C++中kmimetype::Ptr::parentMimeType方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::parentMimeType方法的具体用法?C++ Ptr::parentMimeType怎么用?C++ Ptr::parentMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmimetype::Ptr
的用法示例。
在下文中一共展示了Ptr::parentMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startPreview
void PreviewJob::startPreview()
{
// Load the list of plugins to determine which mimetypes are supported
TDETrader::OfferList plugins = TDETrader::self()->query("ThumbCreator");
TQMap<TQString, KService::Ptr> mimeMap;
for (TDETrader::OfferList::ConstIterator it = plugins.begin(); it != plugins.end(); ++it)
if (!d->enabledPlugins || d->enabledPlugins->contains((*it)->desktopEntryName()))
{
TQStringList mimeTypes = (*it)->property("MimeTypes").toStringList();
for (TQStringList::ConstIterator mt = mimeTypes.begin(); mt != mimeTypes.end(); ++mt)
mimeMap.insert(*mt, *it);
}
// Look for images and store the items in our todo list :)
bool bNeedCache = false;
for (KFileItemListIterator it(d->initialItems); it.current(); ++it )
{
PreviewItem item;
item.item = it.current();
TQMap<TQString, KService::Ptr>::ConstIterator plugin = mimeMap.find(it.current()->mimetype());
if (plugin == mimeMap.end()
&& (it.current()->mimetype() != "application/x-desktop")
&& (it.current()->mimetype() != "media/builtin-mydocuments")
&& (it.current()->mimetype() != "media/builtin-mycomputer")
&& (it.current()->mimetype() != "media/builtin-mynetworkplaces")
&& (it.current()->mimetype() != "media/builtin-printers")
&& (it.current()->mimetype() != "media/builtin-trash")
&& (it.current()->mimetype() != "media/builtin-webbrowser"))
{
TQString mimeType = it.current()->mimetype();
plugin = mimeMap.find(mimeType.replace(TQRegExp("/.*"), "/*"));
if (plugin == mimeMap.end())
{
// check mime type inheritance
KMimeType::Ptr mimeInfo = KMimeType::mimeType(it.current()->mimetype());
TQString parentMimeType = mimeInfo->parentMimeType();
while (!parentMimeType.isEmpty())
{
plugin = mimeMap.find(parentMimeType);
if (plugin != mimeMap.end()) break;
KMimeType::Ptr parentMimeInfo = KMimeType::mimeType(parentMimeType);
if (!parentMimeInfo) break;
parentMimeType = parentMimeInfo->parentMimeType();
}
}
if (plugin == mimeMap.end())
{
// check X-TDE-Text property
KMimeType::Ptr mimeInfo = KMimeType::mimeType(it.current()->mimetype());
TQVariant textProperty = mimeInfo->property("X-TDE-text");
if (textProperty.isValid() && textProperty.type() == TQVariant::Bool)
{
if (textProperty.toBool())
{
plugin = mimeMap.find("text/plain");
if (plugin == mimeMap.end())
{
plugin = mimeMap.find( "text/*" );
}
}
}
}
}
if (plugin != mimeMap.end())
{
item.plugin = *plugin;
d->items.append(item);
if (!bNeedCache && d->bSave &&
(it.current()->url().protocol() != "file" ||
!it.current()->url().directory( false ).startsWith(d->thumbRoot)) &&
(*plugin)->property("CacheThumbnail").toBool())
bNeedCache = true;
}
else
{
emitFailed(it.current());
if (d->deleteItems)
delete it.current();
}
}
// Read configuration value for the maximum allowed size
TDEConfig * config = TDEGlobal::config();
TDEConfigGroupSaver cgs( config, "PreviewSettings" );
d->maximumSize = config->readNumEntry( "MaximumSize", 1024*1024 /* 1MB */ );
if (bNeedCache)
{
if (d->width <= 128 && d->height <= 128) d->cacheWidth = d->cacheHeight = 128;
else d->cacheWidth = d->cacheHeight = 256;
d->thumbPath = d->thumbRoot + (d->cacheWidth == 128 ? "normal/" : "large/");
TDEStandardDirs::makeDir(d->thumbPath, 0700);
}
else
//.........这里部分代码省略.........
示例2: createAudioPreview
KPreviewWidgetBase * KFileMetaPreview::previewProviderFor( const TQString& mimeType )
{
// tqDebug("### looking for: %s", mimeType.latin1());
// often the first highlighted item, where we can be sure, there is no plugin
// (this "folders reflect icons" is a konq-specific thing, right?)
if ( mimeType == "inode/directory" )
return 0L;
KPreviewWidgetBase *provider = m_previewProviders.find( mimeType );
if ( provider )
return provider;
//tqDebug("#### didn't find anything for: %s", mimeType.latin1());
if ( s_tryAudioPreview &&
!mimeType.startsWith("text/") && !mimeType.startsWith("image/") )
{
if ( !haveAudioPreview )
{
KPreviewWidgetBase *audioPreview = createAudioPreview( m_stack );
if ( audioPreview )
{
haveAudioPreview = true;
(void) m_stack->addWidget( audioPreview );
TQStringList mimeTypes = audioPreview->supportedMimeTypes();
TQStringList::ConstIterator it = mimeTypes.begin();
for ( ; it != mimeTypes.end(); ++it )
m_previewProviders.insert( *it, audioPreview );
}
}
}
// with the new mimetypes from the audio-preview, try again
provider = m_previewProviders.find( mimeType );
if ( provider )
return provider;
// ### mimetype may be image/* for example, try that
int index = mimeType.find( '/' );
if ( index > 0 )
{
provider = m_previewProviders.find( mimeType.left( index + 1 ) + "*" );
if ( provider )
return provider;
}
KMimeType::Ptr mimeInfo = KMimeType::mimeType( mimeType );
if ( mimeInfo )
{
// check mime type inheritance
TQString parentMimeType = mimeInfo->parentMimeType();
while ( !parentMimeType.isEmpty() )
{
provider = m_previewProviders.find( parentMimeType );
if ( provider )
return provider;
KMimeType::Ptr parentMimeInfo = KMimeType::mimeType( parentMimeType );
if ( !parentMimeInfo ) break;
parentMimeType = parentMimeInfo->parentMimeType();
}
// check X-TDE-Text property
TQVariant textProperty = mimeInfo->property( "X-TDE-text" );
if ( textProperty.isValid() && textProperty.type() == TQVariant::Bool )
{
if ( textProperty.toBool() )
{
provider = m_previewProviders.find( "text/plain" );
if ( provider )
return provider;
provider = m_previewProviders.find( "text/*" );
if ( provider )
return provider;
}
}
}
return 0L;
}
示例3: offers
KService::List KServiceType::offers(const QString &_servicetype)
{
QDict< KService > dict(53);
KService::List lst;
// Services associated directly with this servicetype (the normal case)
KServiceType::Ptr serv = KServiceTypeFactory::self()->findServiceTypeByName(_servicetype);
if(serv)
addUnique(lst, dict, KServiceFactory::self()->offers(serv->offset()), false);
else
kdWarning(7009) << "KServiceType::offers : servicetype " << _servicetype << " not found" << endl;
// Find services associated with any mimetype parents. e.g. text/x-java -> text/plain
KMimeType::Ptr mime = dynamic_cast< KMimeType * >(static_cast< KServiceType * >(serv));
bool isAMimeType = (mime != 0);
if(mime)
{
while(true)
{
QString parent = mime->parentMimeType();
if(parent.isEmpty())
break;
mime = dynamic_cast< KMimeType * >(KServiceTypeFactory::self()->findServiceTypeByName(parent));
if(!mime)
break;
addUnique(lst, dict, KServiceFactory::self()->offers(mime->offset()), false);
}
}
serv = mime = 0;
// QValueListIterator<KService::Ptr> it = lst.begin();
// for( ; it != lst.end(); ++it )
// kdDebug() << (*it).data() << " " << (*it)->name() << endl;
// Support for all/* is deactivated by KServiceTypeProfile::configurationMode()
// (and makes no sense when querying for an "all" servicetype itself
// nor for non-mimetypes service types)
if(!KServiceTypeProfile::configurationMode() && isAMimeType && _servicetype.left(4) != "all/")
{
// Support for services associated with "all"
KServiceType *servAll = KServiceTypeFactory::self()->findServiceTypeByName("all/all");
if(servAll)
{
addUnique(lst, dict, KServiceFactory::self()->offers(servAll->offset()), true);
}
else
kdWarning(7009) << "KServiceType::offers : servicetype all/all not found" << endl;
delete servAll;
// Support for services associated with "allfiles"
if(_servicetype != "inode/directory" && _servicetype != "inode/directory-locked")
{
KServiceType *servAllFiles = KServiceTypeFactory::self()->findServiceTypeByName("all/allfiles");
if(servAllFiles)
{
addUnique(lst, dict, KServiceFactory::self()->offers(servAllFiles->offset()), true);
}
else
kdWarning(7009) << "KServiceType::offers : servicetype all/allfiles not found" << endl;
delete servAllFiles;
}
}
return lst;
}