• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ kmimetype::Ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中kmimetype::Ptr的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: testAllMimeTypes

void KMimeTypeTest::testAllMimeTypes()
{
    const KMimeType::List lst = KMimeType::allMimeTypes(); // does NOT include aliases
    QVERIFY(!lst.isEmpty());

    for (KMimeType::List::ConstIterator it = lst.begin();
            it != lst.end(); ++it) {
        const KMimeType::Ptr mime = (*it);
        const QString name = mime->name();
        //qDebug( "%s", qPrintable( name ) );
        QVERIFY(!name.isEmpty());
        QCOMPARE(name.count('/'), 1);

        const KMimeType::Ptr lookedupMime = KMimeType::mimeType(name);
        QVERIFY(lookedupMime);   // not null
        if (name != "application/vnd.ms-word" && name != "application/x-pkcs7-certificates"
                && name != "application/x-x509-ca-cert"
                && name != "application/x-vnd.kde.kexi" // due to /usr/share/mime/packages/kde.xml from KDE4
                && name != "application/x-kexiproject-sqlite" // due to /usr/share/mime/packages/kde.xml from KDE4
                && name != "application/vnd.sun.xml.base" // libreoffice.xml messing things up yet again
           ) {
            QCOMPARE(lookedupMime->name(), name);
            // if this fails, you have an alias defined as a real mimetype too!
            //
            // Note: this also happens with x-win-lnk when your kde.xml defines it as an alias, while
            // /usr/share/mime/packages/kde.xml defines it as a real mimetype. This is a false positive,
            // remove one of the kde.xml files.
            //
            // It also happens with application/x-pkcs7-certificates due to
            // /usr/share/mime/packages/gcr-crypto-types.xml. Remove that file and run
            // `update-mime-database /usr/share/mime`.
        }
    }
}
开发者ID:KDE,项目名称:kdelibs4support,代码行数:34,代码来源:kmimetypetest.cpp


示例2: testMimeTypeInheritancePerformance

void KMimeTypeTest::testMimeTypeInheritancePerformance()
{
    // Check performance of is(). In kde3 the list of mimetypes with previews had 63 items...
    // We could get it with KServiceTypeTrader::self()->query("ThumbCreator") and the "MimeTypes"
    // property, but this would give variable results and requires other modules installed.
    QStringList mimeTypes; mimeTypes << "image/jpeg" << "image/png" << "image/tiff" << "text/plain" << "text/html";
    mimeTypes += mimeTypes;
    mimeTypes += mimeTypes;
    mimeTypes += mimeTypes;
    QCOMPARE(mimeTypes.count(), 40);
    KMimeType::Ptr mime = KMimeType::mimeType("text/x-chdr");
    QVERIFY(mime);
    QTime dt; dt.start();
    QBENCHMARK {
        QString match;
        foreach (const QString &mt, mimeTypes)
        {
            if (mime->is(mt)) {
                match = mt;
                // of course there would normally be a "break" here, but we're testing worse-case
                // performance here
            }
        }
        QCOMPARE(match, QString("text/plain"));
    }
    // Results on David's machine (April 2009):
    // With the KMimeType::is() code that loaded every parent KMimeType:
    // 3.5 msec / 7,000,000 ticks / 5,021,498 instr. loads per iteration
    // After the QHash for parent mimetypes in ksycoca, removing the need to load full mimetypes:
    // 0.57 msec / 1,115,000 ticks / 938,356 instr. loads per iteration
    // After converting the QMap for aliases into a QHash too:
    // 0.48 msec / 960,000 ticks / 791,404 instr. loads per iteration
    // July 2010: After moving KMimeType out of ksycoca:
    // 0.21 msec / 494,000 ticks / 568,345 instr. loads per iteration
}
开发者ID:KDE,项目名称:kdelibs4support,代码行数:35,代码来源:kmimetypetest.cpp


示例3: result

bool Cb7Creator::create( const QString &path, int width, int height, QImage &img )
{
    Q_UNUSED(width);
    Q_UNUSED(height);

    bool result( false );

    // Detect mime type.
    const KMimeType::Ptr mime = KMimeType::findByFileContent( path );

    if ( mime->is( "application/x-cb7" ) || mime->name() == "application/x-7z-compressed" ) {
        // 7Z archive.
        result = Cb7Creator::extract7zImage( path );
    } else {
        result = false;
    }

    if( !m_comicCover || !result ) {
        kDebug( KIO_THUMB )<<"Error creating the cb7 thumbnail.";
        return false;
    }

    // Copy the extracted image over to KIO::ThumbCreator's img reference.
    img = m_comicCover->copy();
    delete m_comicCover;

    return result;
}
开发者ID:developer000,项目名称:cb7thumbnails,代码行数:28,代码来源:cb7creator.cpp


示例4: 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());
}
开发者ID:KDE,项目名称:kdelibs4support,代码行数:32,代码来源:kmimetypetest.cpp


示例5: setData

void BinaryWidget::setData( const QByteArray &data )
{
  delete mMainWidget;

  QString mimetype;
  KMimeType::Ptr mime = KMimeType::findByContent( data );
  if ( mime && !mime->isDefault() )
    mimetype = mime->name();

  if ( !mimetype.isEmpty() ) {
    KParts::ReadOnlyPart *part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString(), this, this );
    if ( part ) {
      KTemporaryFile file;
      file.setAutoRemove(false);
      file.open();
      file.write( data );
      file.flush();
      part->openUrl( KUrl( file.fileName() ) );
      mMainWidget = part->widget();
    } else {
      mMainWidget = new QLabel( i18n( "No part found for visualization of mimetype %1", mimetype ), this );
    }

    mData = data;
    mSaveButton->setEnabled( true );
  } else {
    mMainWidget = new QLabel( i18n( "Got data of unknown mimetype" ), this );
  }

  mLayout->addWidget( mMainWidget, 0, 0, 3, 1);
  mMainWidget->show();
}
开发者ID:cornelius,项目名称:kode,代码行数:32,代码来源:binaryinputfield.cpp


示例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() ) );
        }
开发者ID:fluxer,项目名称:kde-workspace,代码行数:60,代码来源:urlgrabber.cpp


示例7: testFromThread

void KMimeTypeTest::testFromThread()
{
    // Some simple tests to test more API from testThreads without using _data()
    KMimeType::Ptr mime = KMimeType::mimeType("application/pdf");
    QVERIFY(mime);
    QCOMPARE(mime->mainExtension(), QString::fromLatin1(".pdf"));
}
开发者ID:vasi,项目名称:kdelibs,代码行数:7,代码来源:kmimetypetest.cpp


示例8: testPatterns

void KMimeTypeTest::testPatterns()
{
    QFETCH(QString, mimeType);
    QFETCH(QString, patterns);
    QFETCH(QString, mainExtension);
    KMimeType::Ptr mime = KMimeType::mimeType( mimeType );
    QVERIFY(mime);
    // Sort both lists; order is unreliable since shared-mime-info uses hashes internally.
    QStringList expectedPatterns = patterns.split(';');
    expectedPatterns.sort();
    QStringList mimePatterns = mime->patterns();

    if (mimeType == "application/vnd.oasis.opendocument.text" && mimePatterns.contains("*.fodt")) {
        QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242", SkipSingle);
    }

    if (mimeType == "application/vnd.oasis.opendocument.presentation" && mimePatterns.contains("*.fodp")) {
        QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242", SkipSingle);
    }

    // shared-mime-info 0.30 adds *,v to text/plain, let's add it from this test so that it works
    // with older versions too.
    if (mimeType == "text/plain" && !mimePatterns.contains("*,v"))
        mimePatterns.append("*,v");
    mimePatterns.sort();
    QCOMPARE(mimePatterns.join(";"), expectedPatterns.join(";"));

    QCOMPARE(mime->mainExtension(), mainExtension);
}
开发者ID:vasi,项目名称:kdelibs,代码行数:29,代码来源:kmimetypetest.cpp


示例9: testFindByUrl

void KMimeTypeTest::testFindByUrl()
{
    // Tests with local files are already done in testFindByPath,
    // here we test for remote urls only.
    KMimeType::Ptr mime;
    QVERIFY( KProtocolInfo::isKnownProtocol(KUrl("http:/")) );
    QVERIFY( KProtocolInfo::isKnownProtocol(KUrl("file:/")) );
    mime = KMimeType::findByUrl( KUrl("http://foo/bar.png") );
    QVERIFY( mime );

    QCOMPARE( mime->name(), QString::fromLatin1( "application/octet-stream" ) ); // HTTP can't know before downloading

    if ( !KProtocolInfo::isKnownProtocol(KUrl("man:/")) )
        QSKIP( "man protocol not installed", SkipSingle );

    mime = KMimeType::findByUrl( KUrl("man:/ls") );
    QVERIFY( mime );
    QCOMPARE( mime->name(), QString::fromLatin1("text/html") );

    mime = KMimeType::findByUrl( KUrl("man:/ls/") );
    QVERIFY( mime );
    QCOMPARE( mime->name(), QString::fromLatin1("text/html") );

    mime = KMimeType::findByUrl(KUrl("fish://host/test1")); // like fish does, to test for known extensions
    QVERIFY(mime);
    QCOMPARE(mime->name(), QString::fromLatin1("application/octet-stream"));
}
开发者ID:vasi,项目名称:kdelibs,代码行数:27,代码来源:kmimetypetest.cpp


示例10: testPatterns

void KMimeTypeTest::testPatterns()
{
    QFETCH(QString, mimeType);
    QFETCH(QString, patterns);
    QFETCH(QString, mainExtension);
    KMimeType::Ptr mime = KMimeType::mimeType(mimeType);
    QVERIFY(mime);
    // Sort both lists; order is unreliable since shared-mime-info uses hashes internally.
    QStringList expectedPatterns = patterns.split(';', QString::SkipEmptyParts);
    expectedPatterns.sort();
    QStringList mimePatterns = mime->patterns();

    if (mimeType == "application/vnd.oasis.opendocument.text" && mimePatterns.contains("*.fodt")) {
        QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242");
    }

    if (mimeType == "application/vnd.oasis.opendocument.presentation" && mimePatterns.contains("*.fodp")) {
        QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242");
    }

    // shared-mime-info 0.30 adds *,v to text/plain, let's add it from this test so that it works
    // with older versions too.
    if (mimeType == "text/plain" && !mimePatterns.contains("*,v")) {
        mimePatterns.append("*,v");
    }
    mimePatterns.sort();
    // Not robust enough, other packages can add additional patterns, like libfm.xml adds *.inf to text/plain
    //QCOMPARE(mimePatterns.join(";"), expectedPatterns.join(";"));
    Q_FOREACH (const QString &expected, expectedPatterns) {
        QVERIFY2(mimePatterns.contains(expected), qPrintable(mimeType + " did not have pattern " + expected));
    }
开发者ID:KDE,项目名称:kdelibs4support,代码行数:31,代码来源:kmimetypetest.cpp


示例11: slotClicked

void ProjectView::slotClicked(QTreeWidgetItem *item)
{
	if(!item) {
		item = currentItem();
	}

	ProjectViewItem *itm = static_cast<ProjectViewItem*>(item);
	if(itm) {
		if(itm->type() == KileType::File) {
			emit(fileSelected(itm->url()));
		}
		else if(itm->type() == KileType::ProjectItem) {
			emit(fileSelected(itm->projectItem()));
		}
		else if(itm->type() != KileType::Folder) {
			// don't open project configuration files (*.kilepr)
			if(itm->url().toLocalFile().right(7) != ".kilepr") {
				//determine mimeType and open file with preferred application
				KMimeType::Ptr pMime = KMimeType::findByUrl(itm->url());
				if(pMime->name().startsWith("text/")) {
					emit(fileSelected(itm->url()));
				}
				else {
					KRun::runUrl(itm->url(), pMime->name(), this);
				}
			}
		}
		clearSelection();
	}
}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:30,代码来源:projectview.cpp


示例12: readAttachment

    void readAttachment()
    {
      if ( mAttachment->label().isEmpty() ) {
        if ( mAttachment->isUri() ) {
          setText( mAttachment->uri() );
        } else {
          setText( i18nc( "@label attachment contains binary data", "[Binary data]" ) );
        }
      } else {
        setText( mAttachment->label() );
      }

      setRenameEnabled( true );

      if ( mAttachment->mimeType().isEmpty() ||
           !( KMimeType::mimeType( mAttachment->mimeType() ) ) ) {
        KMimeType::Ptr mimeType;
        if ( mAttachment->isUri() ) {
          mimeType = KMimeType::findByUrl( mAttachment->uri() );
        } else {
          mimeType = KMimeType::findByContent( mAttachment->decodedData() );
        }
        mAttachment->setMimeType( mimeType->name() );
      }

      setPixmap( icon() );
    }
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:27,代码来源:koeditorattachments.cpp


示例13: slotFixOpenWithMenu

void KateFileTree::slotFixOpenWithMenu()
{
  QMenu *menu = (QMenu*)sender();
  menu->clear();
  
   KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
  if (!doc) return;

  // get a list of appropriate services.
  KMimeType::Ptr mime = KMimeType::mimeType(doc->mimeType());
  //kDebug(13001) << "mime type: " << mime->name();

  QAction *a = 0;
  KService::List offers = KMimeTypeTrader::self()->query(mime->name(), "Application");
  // for each one, insert a menu item...
  for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it)
  {
    KService::Ptr service = *it;
    if (service->name() == "Kate") continue;
    a = menu->addAction(KIcon(service->icon()), service->name());
    a->setData(service->entryPath());
  }
  // append "Other..." to call the KDE "open with" dialog.
  a = menu->addAction(i18n("&Other..."));
  a->setData(QString());
}
开发者ID:azat-archive,项目名称:kate,代码行数:26,代码来源:katefiletree.cpp


示例14: 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."));
}
开发者ID:,项目名称:,代码行数:32,代码来源:


示例15: 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"));
}
开发者ID:,项目名称:,代码行数:31,代码来源:


示例16: 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();
}
开发者ID:vasi,项目名称:kdelibs,代码行数:28,代码来源:kfileitem.cpp


示例17: saveFile

QString saveFile(KoDocument *document, const QString &filename, const QString &outname)
{
    QString saveAs = outname;
    // use the name and add -roundtrip
    if (outname.isEmpty()) {
        saveAs = filename;
        int dotPos = saveAs.lastIndexOf('.');
        if (dotPos != -1) {
            saveAs.truncate(dotPos);
        }
        saveAs += "-roundtrip";
    }

    QByteArray mimetype = document->nativeFormatMimeType();
    KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
    Q_ASSERT(mime);
    QString extension = mime->mainExtension();
    saveAs += extension;

    KUrl url;
    url.setPath(saveAs);
    document->setOutputMimeType(mimetype, 0);
    document->saveAs(url);
    kDebug(31000) << "save done";
    return saveAs;
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:26,代码来源:cstester.cpp


示例18: addFile

bool MPForm::addFile(const QString& name, const QString& path)
{
    KMimeType::Ptr ptr = KMimeType::findByUrl(path);
    QString mime       = ptr->name();
    if (mime.isEmpty())
        return false;

    QFile imageFile(path);
    if (!imageFile.open(QIODevice::ReadOnly))
        return false;
    QByteArray imageData = imageFile.readAll();

    //QString file_size = QString::number(imageFile.size());
    imageFile.close();

    QByteArray str;
    str += "--";
    str += m_boundary;
    str += "\r\n";
    str += "Content-Disposition: form-data; filename=\"";
    str += QFile::encodeName(name);
    str += "\"\r\n";
    //str += "Content-Length: ";
    //str += file_size.toAscii();
    //str += "\r\n";
    str += "Content-Type: ";
    str += mime.toAscii();
    str += "\r\n\r\n";

    m_buffer.append(str);
    m_buffer.append(imageData);
    m_buffer.append("\r\n");

    return true;
}
开发者ID:UIKit0,项目名称:digikam,代码行数:35,代码来源:mpform.cpp


示例19: 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;
}
开发者ID:blue-shell,项目名称:folderview,代码行数:33,代码来源:konqpixmapprovider.cpp


示例20: execute

	bool Script::execute()
	{
		if (!bt::Exists(file) || action)
			return false;
		
		KMimeType::Ptr mt = KMimeType::findByPath(file);
		QString name = QFileInfo(file).fileName();
		action = new Kross::Action(this,name);
		action->setText(name);
		action->setDescription(name);
		action->setFile(file);
		action->setIconName(mt->iconName());
		QString interpreter = Kross::Manager::self().interpreternameForFile(file);
		if (interpreter.isNull())
		{
			delete action;
			action = 0;
			return false;
		}
		else
		{
			action->setInterpreter(interpreter);
			Kross::Manager::self().actionCollection()->addAction(file,action);
			action->trigger();
			executing = true;
			return true;
		}
	}
开发者ID:ashl1,项目名称:ktorrent-stream,代码行数:28,代码来源:script.cpp



注:本文中的kmimetype::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ kode::Code类代码示例发布时间:2022-05-31
下一篇:
C++ klayge::UISlider类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap