本文整理汇总了C++中kmimetype::Ptr::comment方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::comment方法的具体用法?C++ Ptr::comment怎么用?C++ Ptr::comment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmimetype::Ptr
的用法示例。
在下文中一共展示了Ptr::comment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifyFinished
// This can happen after openUrl returns, or directly from m_image->ref()
void KHTMLImage::notifyFinished( khtml::CachedObject *o )
{
if ( !m_image || o != m_image )
return;
//const QPixmap &pix = m_image->pixmap();
QString caption;
KMimeType::Ptr mimeType;
if ( !m_mimeType.isEmpty() )
mimeType = KMimeType::mimeType(m_mimeType, KMimeType::ResolveAliases);
if ( mimeType ) {
if ( !m_image->suggestedTitle().isEmpty() ) {
caption = i18n( "%1 (%2 - %3x%4 Pixels)", m_image->suggestedTitle(), mimeType->comment(), m_image->pixmap_size().width(), m_image->pixmap_size().height() );
} else {
caption = i18n( "%1 - %2x%3 Pixels" , mimeType->comment() ,
m_image->pixmap_size().width() , m_image->pixmap_size().height() );
}
} else {
if ( !m_image->suggestedTitle().isEmpty() ) {
caption = i18n( "%1 (%2x%3 Pixels)" , m_image->suggestedTitle(), m_image->pixmap_size().width() , m_image->pixmap_size().height() );
} else {
caption = i18n( "Image - %1x%2 Pixels" , m_image->pixmap_size().width() , m_image->pixmap_size().height() );
}
}
emit setWindowCaption( caption );
emit completed();
emit setStatusBarText(i18n("Done."));
}
示例2: setIconAndTextForType
void KMMimePartTreeItem::setIconAndTextForType( const QString & mime )
{
QString mimetype = mime.lower();
if ( mimetype.startsWith( "multipart/" ) ) {
setText( 1, mimetype );
setPixmap( 0, SmallIcon("folder") );
} else if ( mimetype == "application/octet-stream" ) {
setText( 1, i18n("Unspecified Binary Data") ); // don't show "Unknown"...
setPixmap( 0, SmallIcon("unknown") );
} else {
KMimeType::Ptr mtp = KMimeType::mimeType( mimetype );
setText( 1, (mtp && !mtp->comment().isEmpty()) ? mtp->comment() : mimetype );
setPixmap( 0, mtp ? mtp->pixmap( KIcon::Small) : SmallIcon("unknown") );
}
}
示例3: setMimeFilter
void KFileFilterCombo::setMimeFilter(const QStringList &types, const QString &defaultType)
{
clear();
filters.clear();
QString delim = QString::fromLatin1(", ");
d->hasAllSupportedFiles = false;
m_allTypes = defaultType.isEmpty() && (types.count() > 1);
QString allComments, allTypes;
int i = 0;
for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it, ++i)
{
if(m_allTypes && it != types.begin())
{
allComments += delim;
allTypes += ' ';
}
kdDebug(kfile_area) << *it << endl;
KMimeType::Ptr type = KMimeType::mimeType(*it);
filters.append(type->name());
if(m_allTypes)
{
allTypes += type->name();
allComments += type->comment();
}
insertItem(type->comment());
if(type->name() == defaultType)
setCurrentItem(i);
}
if(m_allTypes)
{
if(i < 3) // show the mime-comments of at max 3 types
insertItem(allComments, 0);
else
{
insertItem(i18n("All Supported Files"), 0);
d->hasAllSupportedFiles = true;
}
filters.prepend(allTypes);
}
d->lastFilter = currentText();
d->isMimeFilter = true;
}
示例4: mimeComment
QString KFileItem::mimeComment() const
{
const QString displayType = d->m_entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_TYPE );
if (!displayType.isEmpty())
return displayType;
KMimeType::Ptr mType = determineMimeType();
bool isLocalUrl;
KUrl url = mostLocalUrl(isLocalUrl);
KMimeType::Ptr mime = mimeTypePtr();
// This cannot move to kio_file (with UDS_DISPLAY_TYPE) because it needs
// the mimetype to be determined, which is done here, and possibly delayed...
if (isLocalUrl && mime->is("application/x-desktop")) {
KDesktopFile cfg( url.toLocalFile() );
QString comment = cfg.desktopGroup().readEntry( "Comment" );
if (!comment.isEmpty())
return comment;
}
QString comment = mType->comment( url );
//kDebug() << "finding comment for " << url.url() << " : " << d->m_pMimeType->name();
if (!comment.isEmpty())
return comment;
else
return mType->name();
}
示例5: testByName
void KMimeTypeTest::testByName()
{
KMimeType::Ptr s0 = KMimeType::mimeType("application/x-zerosize");
QVERIFY(s0);
QCOMPARE(s0->name(), QString::fromLatin1("application/x-zerosize"));
QCOMPARE(s0->comment(), QString::fromLatin1("empty document"));
KMimeType::Ptr s0Again = KMimeType::mimeType("application/x-zerosize");
QCOMPARE(s0Again->name(), s0->name());
QVERIFY(s0Again != s0);
KMimeType::Ptr s1 = KMimeType::mimeType("text/plain");
QVERIFY(s1);
QCOMPARE(s1->name(), QString::fromLatin1("text/plain"));
//qDebug("Comment is %s", qPrintable(s1->comment()) );
KMimeType::Ptr krita = KMimeType::mimeType("application/x-krita");
QVERIFY(krita);
// Test <comment> parsing with application/rdf+xml which has the english comment after the other ones
KMimeType::Ptr rdf = KMimeType::mimeType("application/rdf+xml");
QVERIFY(rdf);
QCOMPARE(rdf->comment(), QString::fromLatin1("RDF file"));
KMimeType::Ptr bzip2 = KMimeType::mimeType("application/x-bzip2");
QVERIFY(bzip2);
QCOMPARE(bzip2->comment(), QString::fromLatin1("Bzip archive"));
KMimeType::Ptr defaultMime = KMimeType::mimeType("application/octet-stream");
QVERIFY(defaultMime);
QVERIFY(defaultMime->isDefault());
}
示例6: matchingMimeActions
void URLGrabber::matchingMimeActions(const QString& clipData)
{
KUrl url(clipData);
KConfigGroup cg(KGlobal::config(), "Actions");
if(!cg.readEntry("EnableMagicMimeActions",true)) {
//kDebug() << "skipping mime magic due to configuration";
return;
}
if(!url.isValid()) {
//kDebug() << "skipping mime magic due to invalid url";
return;
}
if(url.isRelative()) { //openinng a relative path will just not work. what path should be used?
//kDebug() << "skipping mime magic due to relative url";
return;
}
if(url.isLocalFile()) {
if ( clipData == "//") {
//kDebug() << "skipping mime magic due to C++ comment //";
return;
}
if(!QFile::exists(url.toLocalFile())) {
//kDebug() << "skipping mime magic due to nonexistent localfile";
return;
}
}
// try to figure out if clipData contains a filename
KMimeType::Ptr mimetype = KMimeType::findByUrl( url, 0,
false,
true /*fast mode*/ );
// let's see if we found some reasonable mimetype.
// If we do we'll populate menu with actions for apps
// that can handle that mimetype
// first: if clipboard contents starts with http, let's assume it's "text/html".
// That is even if we've url like "http://www.kde.org/somescript.pl", we'll
// still treat that as html page, because determining a mimetype using kio
// might take a long time, and i want this function to be quick!
if ( ( clipData.startsWith( QLatin1String("http://") ) || clipData.startsWith( QLatin1String("https://") ) )
&& mimetype->name() != "text/html" )
{
// use a fake path to create a mimetype that corresponds to "text/html"
mimetype = KMimeType::findByPath( "/tmp/klipper.html", 0, true /*fast mode*/ );
}
if ( !mimetype->isDefault() ) {
ClipAction* action = new ClipAction( QString(), mimetype->comment() );
KService::List lst = KMimeTypeTrader::self()->query( mimetype->name(), "Application" );
foreach( const KService::Ptr &service, lst ) {
QHash<QChar,QString> map;
map.insert( 'i', "--icon " + service->icon() );
map.insert( 'c', service->name() );
QString exec = service->exec();
exec = KMacroExpander::expandMacros( exec, map ).trimmed();
action->addCommand( ClipCommand( exec, service->name(), true, service->icon() ) );
}
示例7: setupIntro
//===========================================================
//
void ImportWizard::setupIntro()
{
m_introPage = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout(m_introPage, KDialog::marginHint());
QLabel *lblIntro = new QLabel(m_introPage);
lblIntro->setAlignment( Qt::AlignTop | Qt::AlignLeft | Qt::WordBreak );
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>")
.arg(m_predefinedDatabaseName).arg(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);
msg = i18n("<qt>Database Importing wizard is about to import <nobr>\"%1\"</nobr> file "
"of type \"%2\" into a Kexi database.</qt>")
.arg(QDir::convertSeparators(m_predefinedDatabaseName)).arg(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"));
}
示例8: 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();
}
示例9: printMimeTypes
static void printMimeTypes( const TDECmdLineArgs *args )
{
for ( int i = 0; i < args->count(); i++ )
{
KURL url = args->url( i );
KMimeType::Ptr mt = KMimeType::findByURL( url );
cout << args->arg(i) << ": " << mt->comment().local8Bit().data() << " ("
<< mt->name().local8Bit().data() << ")" << endl;
}
}
示例10: mimeComment
QString KFileItem::mimeComment()
{
KMimeType::Ptr mType = determineMimeType();
bool isLocalURL;
KURL url = mostLocalURL(isLocalURL);
QString comment = mType->comment( url, isLocalURL );
//kdDebug() << "finding comment for " << url.url() << " : " << m_pMimeType->name() << endl;
if (!comment.isEmpty())
return comment;
else
return mType->name();
}
示例11: slotPartLoadingErrorNotify
void RenderPartObject::slotPartLoadingErrorNotify()
{
#if APPLE_CHANGES
// FIXME: What are we going to do for this case?
#else
// First we need to find out the servicetype - again - this code is too duplicated !
HTMLEmbedElementImpl *embed = 0;
QString serviceType;
if( element()->id()==ID_OBJECT ) {
// check for embed child object
HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(element());
serviceType = o->serviceType;
NodeImpl *child = o->firstChild();
while ( child ) {
if ( child->id() == ID_EMBED )
embed = static_cast<HTMLEmbedElementImpl *>( child );
child = child->nextSibling();
}
} else if( element()->id()==ID_EMBED ) {
embed = static_cast<HTMLEmbedElementImpl *>(element());
}
if ( embed )
serviceType = embed->serviceType;
KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
KParts::BrowserExtension *ext = part->browserExtension();
if( embed && !embed->pluginPage.isEmpty() && ext ) {
// Prepare the mimetype to show in the question (comment if available, name as fallback)
QString mimeName = serviceType;
KMimeType::Ptr mime = KMimeType::mimeType(serviceType);
if ( mime->name() != KMimeType::defaultMimeType() )
mimeName = mime->comment();
// Prepare the URL to show in the question (host only if http, to make it short)
KURL pluginPageURL( embed->pluginPage );
QString shortURL = pluginPageURL.protocol() == "http" ? pluginPageURL.host() : pluginPageURL.prettyURL();
int res = KMessageBox::questionYesNo( m_view,
i18n("No plugin found for '%1'.\nDo you want to download one from %2?").arg(mimeName).arg(shortURL),
i18n("Missing plugin"), QString::null, QString::null, QString("plugin-")+serviceType);
if ( res == KMessageBox::Yes )
{
// Display vendor download page
ext->createNewWindow( pluginPageURL );
}
}
#endif // APPLE_CHANGES
}
示例12: KDialog
KoFilterChooser::KoFilterChooser(QWidget *parent, const QStringList &mimeTypes, const QString &nativeFormat, const KUrl &url)
: KDialog(parent),
m_mimeTypes(mimeTypes)
{
setObjectName("kofilterchooser");
setInitialSize(QSize(300, 350));
setButtons(KDialog::Ok|KDialog::Cancel);
setDefaultButton(KDialog::Ok);
setCaption(i18n("Choose Filter"));
setModal(true);
QWidget *page = new QWidget(this);
setMainWidget(page);
QVBoxLayout *layout = new QVBoxLayout(page);
if (url.isValid()) {
KSqueezedTextLabel *l = new KSqueezedTextLabel(url.path(), page);
layout->addWidget(l);
}
m_filterList = new QListWidget(page);
layout->addWidget(m_filterList);
page->setLayout(layout);
Q_ASSERT(!m_mimeTypes.isEmpty());
for (QStringList::ConstIterator it = m_mimeTypes.constBegin();
it != m_mimeTypes.constEnd();
it++) {
KMimeType::Ptr mime = KMimeType::mimeType(*it);
const QString name = mime ? mime->comment() : *it;
if (! name.isEmpty())
m_filterList->addItem(name);
}
if (nativeFormat == "application/x-kword") {
const int index = m_mimeTypes.indexOf("text/plain");
if (index > -1)
m_filterList->setCurrentRow(index);
}
if (m_filterList->currentRow() == -1)
m_filterList->setCurrentRow(0);
m_filterList->setFocus();
connect(m_filterList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(accept()));
resize(QSize(520, 400));//.expandedTo(minimumSizeHint()));
}
示例13: installExtraMimes
void Wizard::installExtraMimes(QString baseName, QStringList globs)
{
QString mimefile = baseName;
mimefile.replace('/', '-');
KMimeType::Ptr mime = KMimeType::mimeType(baseName);
if (!mime) {
kDebug() << "KMimeTypeTrader: mimeType " << baseName << " not found";
} else {
QStringList extensions = mime->patterns();
QString comment = mime->comment();
foreach(const QString &glob, globs) {
if (!extensions.contains(glob)) extensions << glob;
}
kDebug() << "EXTS: " << extensions;
QString packageFileName = KStandardDirs::locateLocal("xdgdata-mime", "packages/" + mimefile + ".xml");
kDebug() << "INSTALLING NEW MIME TO: " << packageFileName;
QFile packageFile(packageFileName);
if (!packageFile.open(QIODevice::WriteOnly)) {
kError() << "Couldn't open" << packageFileName << "for writing";
return;
}
QXmlStreamWriter writer(&packageFile);
writer.setAutoFormatting(true);
writer.writeStartDocument();
const QString nsUri = "http://www.freedesktop.org/standards/shared-mime-info";
writer.writeDefaultNamespace(nsUri);
writer.writeStartElement("mime-info");
writer.writeStartElement(nsUri, "mime-type");
writer.writeAttribute("type", baseName);
if (!comment.isEmpty()) {
writer.writeStartElement(nsUri, "comment");
writer.writeCharacters(comment);
writer.writeEndElement(); // comment
}
foreach(const QString& pattern, extensions) {
writer.writeStartElement(nsUri, "glob");
writer.writeAttribute("pattern", pattern);
writer.writeEndElement(); // glob
}
writer.writeEndElement(); // mime-info
writer.writeEndElement(); // mime-type
writer.writeEndDocument();
}
示例14: dialogText
static KIO::CopyJob *chooseAndPaste(const KURL &u, QMimeSource *data, const QValueVector< QCString > &formats, const QString &text, QWidget *widget,
bool clipboard)
{
QStringList formatLabels;
for(uint i = 0; i < formats.size(); ++i)
{
const QCString &fmt = formats[i];
KMimeType::Ptr mime = KMimeType::mimeType(fmt);
if(mime != KMimeType::defaultMimeTypePtr())
formatLabels.append(i18n("%1 (%2)").arg(mime->comment()).arg(fmt));
else
formatLabels.append(fmt);
}
QString dialogText(text);
if(dialogText.isEmpty())
dialogText = i18n("Filename for clipboard content:");
KIO::PasteDialog dlg(QString::null, dialogText, QString::null, formatLabels, widget, clipboard);
if(dlg.exec() != KDialogBase::Accepted)
return 0;
if(clipboard && dlg.clipboardChanged())
{
KMessageBox::sorry(widget, i18n("The clipboard has changed since you used 'paste': "
"the chosen data format is no longer applicable. "
"Please copy again what you wanted to paste."));
return 0;
}
const QString result = dlg.lineEditText();
const QCString chosenFormat = formats[dlg.comboItem()];
kdDebug() << " result=" << result << " chosenFormat=" << chosenFormat << endl;
KURL new_url(u);
new_url.addPath(result);
// if "data" came from QClipboard, then it was deleted already - by a nice 0-seconds timer
// In that case, get it again. Let's hope the user didn't copy something else meanwhile :/
if(clipboard)
{
data = QApplication::clipboard()->data();
}
const QByteArray ba = data->encodedData(chosenFormat);
return pasteDataAsyncTo(new_url, ba);
}
示例15: viewInInternalViewer
bool ArkViewer::viewInInternalViewer(const QString& fileName, const KMimeType::Ptr& mimeType)
{
const KUrl fileUrl(fileName);
setCaption(fileUrl.fileName());
restoreDialogSize(KGlobal::config()->group("Viewer"));
QFrame *header = new QFrame(m_widget);
QHBoxLayout *headerLayout = new QHBoxLayout(header);
QLabel *iconLabel = new QLabel(header);
headerLayout->addWidget(iconLabel);
iconLabel->setPixmap(KIconLoader::global()->loadMimeTypeIcon(mimeType->iconName(), KIconLoader::Desktop));
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
KVBox *headerRight = new KVBox(header);
headerLayout->addWidget(headerRight);
new QLabel(QString(QLatin1String( "<qt><b>%1</b></qt>" ))
.arg(fileUrl.fileName()), headerRight
);
new QLabel(mimeType->comment(), headerRight);
header->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
m_part = KMimeTypeTrader::self()->createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType->name(),
m_widget,
this);
if (!m_part.data()) {
return false;
}
if (m_part.data()->browserExtension()) {
connect(m_part.data()->browserExtension(),
SIGNAL(openUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
SLOT(slotOpenUrlRequestDelayed(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));
}
m_part.data()->openUrl(fileUrl);
return true;
}