本文整理汇总了C++中kmimetype::Ptr::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::isNull方法的具体用法?C++ Ptr::isNull怎么用?C++ Ptr::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmimetype::Ptr
的用法示例。
在下文中一共展示了Ptr::isNull方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iconNameFor
// at first, tries to find the iconname in the cache
// if not available, tries to find the pixmap for the mimetype of url
// if that fails, gets the icon for the protocol
// finally, inserts the url/icon pair into the cache
QString KonqPixmapProvider::iconNameFor( const KUrl& url )
{
QMap<KUrl,QString>::iterator it = iconMap.find( url );
QString icon;
if ( it != iconMap.end() ) {
icon = it.value();
if ( !icon.isEmpty() )
return icon;
}
if ( url.url().isEmpty() ) {
// Use the folder icon for the empty URL
const KMimeType::Ptr directoryType = KMimeType::mimeType( "inode/directory" );
if( directoryType.isNull() ) // no mimetypes installed!
return QString();
icon = directoryType->iconName();
Q_ASSERT( !icon.isEmpty() );
}
else
{
icon = KMimeType::iconNameForUrl( url );
Q_ASSERT( !icon.isEmpty() );
}
// cache the icon found for url
iconMap.insert( url, icon );
return icon;
}
示例2: isWantedCollection
bool MimeTypeChecker::isWantedCollection( const Collection &collection, const QString &wantedMimeType )
{
if ( wantedMimeType.isEmpty() || !collection.isValid() )
return false;
const QStringList contentMimeTypes = collection.contentMimeTypes();
if ( contentMimeTypes.isEmpty() )
return false;
foreach ( const QString &mimeType, contentMimeTypes ) {
if ( mimeType.isEmpty() )
continue;
if ( mimeType == wantedMimeType )
return true;
KMimeType::Ptr mimeTypePtr = KMimeType::mimeType( mimeType, KMimeType::ResolveAliases );
if ( mimeTypePtr.isNull() )
continue;
if ( mimeTypePtr->is( wantedMimeType ) )
return true;
}
return false;
}
示例3: setupIntro
//===========================================================
//
void ImportWizard::setupIntro()
{
m_introPage = new QWidget(this);
Q3VBoxLayout *vbox = new Q3VBoxLayout(m_introPage, KDialog::marginHint());
QLabel *lblIntro = new QLabel(m_introPage);
lblIntro->setAlignment(Qt::AlignTop | Qt::AlignLeft);
lblIntro->setWordWrap(true);
QString msg;
if (m_predefinedConnectionData) { //predefined import: server source
msg = i18n("<qt>Database Importing wizard is about to import \"%1\" database "
"<nobr>(connection %2)</nobr> into a Kexi database.</qt>",
m_predefinedDatabaseName, m_predefinedConnectionData->serverInfoString());
} else if (!m_predefinedDatabaseName.isEmpty()) { //predefined import: file source
//! @todo this message is currently ok for files only
KMimeType::Ptr mimeTypePtr = KMimeType::mimeType(m_predefinedMimeType);
if (mimeTypePtr.isNull())
KexiDBWarn << QString("'%1' mimetype not installed!").arg(m_predefinedMimeType);
msg = i18n(
"<qt>Database Importing wizard is about to import <nobr>\"%1\"</nobr> file "
"of type \"%2\" into a Kexi database.</qt>",
QDir::convertSeparators(m_predefinedDatabaseName), mimeTypePtr ? mimeTypePtr->comment() : "???");
} else {
msg = i18n("Database Importing wizard allows you to import an existing database "
"into a Kexi database.");
}
lblIntro->setText(msg + "\n\n"
+ i18n("Click \"Next\" button to continue or \"Cancel\" button to exit this wizard."));
vbox->addWidget(lblIntro);
addPage(m_introPage, i18n("Welcome to the Database Importing Wizard"));
}
示例4: iconForContent
KIcon iconForContent( KMime::Content *content )
{
if ( !content->contentType( false ) )
return KIcon();
KMimeType::Ptr mimeType = KMimeType::mimeType( QString::fromLatin1( content->contentType()->mimeType() ) );
if ( mimeType.isNull() || mimeType->iconName().isEmpty() )
return KIcon();
return KIcon( mimeType->iconName() );
}
示例5: typeForContent
QString typeForContent( KMime::Content *content )
{
if ( !content->contentType( false ) )
return QString();
KMimeType::Ptr mimeType = KMimeType::mimeType( QString::fromLatin1( content->contentType()->mimeType() ) );
if ( mimeType.isNull() )
return QString::fromLatin1( content->contentType()->mimeType() );
return mimeType->comment();
}
示例6: isWantedItem
bool MimeTypeChecker::isWantedItem( const Item &item, const QString &wantedMimeType )
{
if ( wantedMimeType.isEmpty() || !item.isValid() )
return false;
const QString mimeType = item.mimeType();
if ( mimeType.isEmpty() )
return false;
if ( mimeType == wantedMimeType )
return true;
KMimeType::Ptr mimeTypePtr = KMimeType::mimeType( mimeType, KMimeType::ResolveAliases );
if ( mimeTypePtr.isNull() )
return false;
return mimeTypePtr->is( wantedMimeType );
}
示例7: slotMimeTypeChanged
void KMMsgPartDialog::slotMimeTypeChanged( const QString & mimeType ) {
// message subparts MUST have 7bit or 8bit encoding...
#if 0
// ...but until KMail can recode 8bit messages on attach, so that
// they can be signed, we can't enforce this :-(
if ( mimeType.startsWith("message/") ) {
setEncoding( SevenBit );
mEncoding->setEnabled( false );
} else {
mEncoding->setEnabled( !mReadOnly );
}
#endif
// find a mimetype icon:
KMimeType::Ptr mt = KMimeType::mimeType( mimeType, KMimeType::ResolveAliases );
if ( !mt.isNull() )
mIcon->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mt->iconName(),
KIconLoader::Desktop ) );
else
mIcon->setPixmap( DesktopIcon("unknown") );
}
示例8: KPageDialog
PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
: KPageDialog( parent ), m_document( doc ), m_fontPage( 0 ),
m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ),
m_fontScanStarted( false )
{
setFaceType( Tabbed );
setCaption( i18n( "Unknown File" ) );
setButtons( Ok );
// PROPERTIES
QFrame *page = new QFrame();
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
item->setIcon( KIcon( "document-properties" ) );
// get document info
const Okular::DocumentInfo info = doc->documentInfo();
QFormLayout *layout = new QFormLayout( page );
// mime name based on mimetype id
QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( '/', -1 ).toUpper();
setCaption( i18n( "%1 Properties", mimeName ) );
int valMaxWidth = 100;
/* obtains the properties list, conveniently ordered */
QStringList orderedProperties;
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
ks <= Okular::DocumentInfo::Keywords;
ks = Okular::DocumentInfo::Key( ks+1 ) )
{
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
}
foreach( const QString &ks, info.keys()) {
if ( !orderedProperties.contains( ks ) ) {
orderedProperties << ks;
}
}
for ( QStringList::Iterator it = orderedProperties.begin();
it != orderedProperties.end();
++it )
{
const QString key = *it;
const QString titleString = info.getKeyTitle( key );
const QString valueString = info.get( key );
if ( titleString.isNull() || valueString.isNull() )
continue;
// create labels and layout them
QWidget *value = NULL;
if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
/// for mime type fields, show icon as well
value = new QWidget( page );
/// place icon left of mime type's name
QHBoxLayout *hboxLayout = new QHBoxLayout( value );
hboxLayout->setMargin( 0 );
/// retrieve icon and place it in a QLabel
KMimeType::Ptr mimeType = KMimeType::mimeType( valueString );
KSqueezedTextLabel *squeezed;
if (!mimeType.isNull()) {
/// retrieve icon and place it in a QLabel
QLabel *pixmapLabel = new QLabel( value );
hboxLayout->addWidget( pixmapLabel, 0 );
pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) );
/// mime type's name and label
squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType->comment(), valueString ), value );
} else {
/// only mime type name
squeezed = new KSqueezedTextLabel( valueString, value );
}
squeezed->setTextInteractionFlags( Qt::TextSelectableByMouse );
hboxLayout->addWidget( squeezed, 1 );
} else {
/// default for any other document information
KSqueezedTextLabel *label = new KSqueezedTextLabel( valueString, page );
label->setTextInteractionFlags( Qt::TextSelectableByMouse );
value = label;
}
layout->addRow( new QLabel( i18n( "%1:", titleString ) ), value);
// refine maximum width of 'value' labels
valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) );
}
// FONTS
QVBoxLayout *page2Layout = 0;
if ( doc->canProvideFontInformation() ) {
// create fonts tab and layout it
QFrame *page2 = new QFrame();
m_fontPage = addPage(page2, i18n("&Fonts"));
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
page2Layout = new QVBoxLayout(page2);
page2Layout->setMargin(marginHint());
page2Layout->setSpacing(spacingHint());
// add a tree view
QTreeView *view = new QTreeView(page2);
view->setContextMenuPolicy(Qt::CustomContextMenu);
//.........这里部分代码省略.........