当前位置: 首页>>代码示例>>C++>>正文


C++ QMimeData::hasFormat方法代码示例

本文整理汇总了C++中QMimeData::hasFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::hasFormat方法的具体用法?C++ QMimeData::hasFormat怎么用?C++ QMimeData::hasFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMimeData的用法示例。


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

示例1: testMostLocalUrlList

void KUrlMimeTest::testMostLocalUrlList()
{
    QMimeData* mimeData = new QMimeData;
    KUrl::List urls;
    urls.append(KUrl("desktop:/foo"));
    urls.append(KUrl("desktop:/bar"));
    KUrl::List localUrls;
    localUrls.append(KUrl("file:/home/dfaure/Desktop/foo"));
    localUrls.append(KUrl("file:/home/dfaure/Desktop/bar"));

    urls.populateMimeData(localUrls, mimeData);

    QVERIFY(KUrl::List::canDecode(mimeData));
    QVERIFY(mimeData->hasUrls());
    QVERIFY(mimeData->hasText());
    QVERIFY(mimeData->hasFormat("text/plain"));

    // KUrl decodes the real "kde" urls by default
    KUrl::List decodedURLs = KUrl::List::fromMimeData(mimeData);
    QVERIFY(!decodedURLs.isEmpty());
    QCOMPARE(decodedURLs.toStringList().join(" "), urls.toStringList().join(" ") );

    // KUrl can also be told to decode the "most local" urls
    decodedURLs = KUrl::List::fromMimeData(mimeData, 0, KUrl::List::PreferLocalUrls);
    QVERIFY(!decodedURLs.isEmpty());
    QCOMPARE(decodedURLs.toStringList().join(" "), localUrls.toStringList().join(" ") );

    // QMimeData decodes the "most local" urls
    const QList<QUrl> qurls = mimeData->urls();
    QCOMPARE(qurls.count(), localUrls.count());
    for (int i = 0; i < qurls.count(); ++i )
        QCOMPARE(qurls[i], static_cast<QUrl>(localUrls[i]));

}
开发者ID:fluxer,项目名称:kdelibs,代码行数:34,代码来源:kurlmimetest.cpp

示例2: hasFormat

void tst_QMimeData::hasFormat() const
{
    QMimeData mimeData;

    // initial state
    QVERIFY(mimeData.hasFormat("text/plain") == false);

    // add, verify
    mimeData.setData("text/plain", "pirates");
    QVERIFY(mimeData.hasFormat("text/plain"));
    QVERIFY(mimeData.hasFormat("text/html") == false);

    // clear, verify
    mimeData.clear();
    QVERIFY(mimeData.hasFormat("text/plain") == false);
    QVERIFY(mimeData.hasFormat("text/html") == false);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:17,代码来源:tst_qmimedata.cpp

示例3: if

void
TreeView::startDrag( Qt::DropActions supportedActions )
{
    QList<QPersistentModelIndex> pindexes;
    QModelIndexList indexes;
    foreach( const QModelIndex& idx, selectedIndexes() )
    {
        if ( ( m_proxyModel->flags( idx ) & Qt::ItemIsDragEnabled ) )
        {
            indexes << idx;
            pindexes << idx;
        }
    }

    if ( indexes.count() == 0 )
        return;

    qDebug() << "Dragging" << indexes.count() << "indexes";
    QMimeData* data = m_proxyModel->mimeData( indexes );
    if ( !data )
        return;

    QDrag* drag = new QDrag( this );
    drag->setMimeData( data );

    QPixmap p;
    if ( data->hasFormat( "application/tomahawk.metadata.artist" ) )
        p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeArtist, indexes.count() );
    else if ( data->hasFormat( "application/tomahawk.metadata.album" ) )
        p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeAlbum, indexes.count() );
    else
        p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack, indexes.count() );

    drag->setPixmap( p );
    drag->setHotSpot( QPoint( -20, -20 ) );

    drag->exec( supportedActions, Qt::CopyAction );
}
开发者ID:mokerjoke,项目名称:tomahawk,代码行数:38,代码来源:TreeView.cpp

示例4: saveHelper

SectionContainer::SectionContainer(const SectionContainer& _rhs, Section* _section) : m_section(0), m_layer(0), m_rootSection(0), m_sectionModel(0)
{
    initContainer(_section, _rhs.m_rootSection);
    KoShapeOdfSaveHelper saveHelper(_rhs.m_layer->shapes());
    KoDrag drag;
    drag.setOdf(KoOdf::mimeType(KoOdf::Text), saveHelper);
    QMimeData* mimeData = drag.mimeData();

    Q_ASSERT(mimeData->hasFormat(KoOdf::mimeType(KoOdf::Text)));

    SectionContainerShapePaste paste(this, m_layer, _section->layout());
    bool success = paste.paste(KoOdf::Text, mimeData);
    Q_ASSERT(success); Q_UNUSED(success)

    delete mimeData;
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:16,代码来源:SectionContainer.cpp

示例5: PasteData

 void PasteData(const QMimeData& data)
 {
   if (data.hasUrls())
   {
     const QList<QUrl>& urls = data.urls();
     QStringList files;
     std::for_each(urls.begin(), urls.end(),
       boost::bind(&QStringList::push_back, &files,
         boost::bind(&QUrl::toLocalFile, _1)));
     AddItems(files);
   }
   else if (data.hasFormat(ITEMS_MIMETYPE))
   {
     const QByteArray& encodedData = data.data(ITEMS_MIMETYPE);
     QStringList items;
     {
       QDataStream stream(encodedData);
       stream >> items;
     }
     //pasting is done immediately, so update UI right here
     const Playlist::Scanner::Ptr scanner = Controller->GetScanner();
     scanner->PasteItems(items);
   }
   else if (data.hasText())
开发者ID:vitamin-caig,项目名称:zxtune,代码行数:24,代码来源:playlist_view.cpp

示例6: removeFormat

void tst_QMimeData::removeFormat() const
{
    QMimeData mimeData;

    // add, verify
    mimeData.setData("text/plain", "pirates");
    QVERIFY(mimeData.hasFormat("text/plain"));

    // add another, verify
    mimeData.setData("text/html", "ninjas");
    QVERIFY(mimeData.hasFormat("text/html"));

    // remove, verify
    mimeData.removeFormat("text/plain");
    QVERIFY(mimeData.hasFormat("text/plain") == false);
    QVERIFY(mimeData.hasFormat("text/html"));

    // remove, verify
    mimeData.removeFormat("text/html");
    QVERIFY(mimeData.hasFormat("text/plain") == false);
    QVERIFY(mimeData.hasFormat("text/html") == false);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:22,代码来源:tst_qmimedata.cpp


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