本文整理汇总了C++中kurl::List::populateMimeData方法的典型用法代码示例。如果您正苦于以下问题:C++ List::populateMimeData方法的具体用法?C++ List::populateMimeData怎么用?C++ List::populateMimeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kurl::List
的用法示例。
在下文中一共展示了List::populateMimeData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]));
}
示例2: tempFileForAttachment
QMimeData *mimeData()
{
// create a list of the URL:s that we want to drag
KUrl::List urls;
QStringList labels;
for ( Q3IconViewItem *it = firstItem(); it; it = it->nextItem() ) {
if ( it->isSelected() ) {
AttachmentIconItem *item = static_cast<AttachmentIconItem *>( it );
if ( item->isBinary() ) {
urls.append( tempFileForAttachment( item->attachment() ) );
} else {
urls.append( item->uri() );
}
labels.append( KUrl::toPercentEncoding( item->label() ) );
}
}
if ( selectionMode() == Q3IconView::NoSelection ) {
AttachmentIconItem *item = static_cast<AttachmentIconItem *>( currentItem() );
if ( item ) {
urls.append( item->uri() );
labels.append( KUrl::toPercentEncoding( item->label() ) );
}
}
QMap<QString, QString> metadata;
metadata["labels"] = labels.join( ":" );
QMimeData *mimeData = new QMimeData;
urls.populateMimeData( mimeData, metadata );
return mimeData;
}
示例3: QMimeData
QMimeData *CollectionModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *data = new QMimeData();
KUrl::List urls;
foreach ( const QModelIndex &index, indexes ) {
if ( index.column() != 0 ) {
continue;
}
urls << Collection( index.internalId() ).url();
}
urls.populateMimeData( data );
return data;
}
示例4: initiateDrag
void TabWidget::initiateDrag(int tab)
{
Frame* frame = d->frames.value(widget(tab));
if (frame && frame->url().isValid())
{
KUrl::List lst;
lst.append( frame->url() );
QDrag* drag = new QDrag( this );
QMimeData *md = new QMimeData;
drag->setMimeData( md );
lst.populateMimeData( md );
drag->setPixmap( KIO::pixmapForUrl( lst.first(), 0, KIconLoader::Small ) );
drag->start();
}
}
示例5: viewDragRequested
void KTNEFMain::viewDragRequested( const QList<KTNEFAttach *>& list )
{
KUrl::List urlList;
QList<KTNEFAttach *>::ConstIterator end( list.constEnd() );
for ( QList<KTNEFAttach *>::ConstIterator it = list.constBegin();
it != end; ++it ) {
urlList << KUrl( extractTemp( *it ) );
}
if ( !list.isEmpty() ) {
QMimeData *mimeData = new QMimeData;
urlList.populateMimeData( mimeData );
QDrag *drag = new QDrag( this );
drag->setMimeData( mimeData );
}
}
示例6: mouseMoveEvent
void ThemeListBox::mouseMoveEvent(QMouseEvent *e)
{
if (((e->buttons() & Qt::LeftButton) != 0) && !mDragFile.isEmpty())
{
int delay = KGlobalSettings::dndEventDelay();
QPoint newPos = e->globalPos();
if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
{
KUrl url;
url.setPath(mDragFile);
KUrl::List urls;
urls.append(url);
QDrag *drag = new QDrag(this);
QMimeData *mime = new QMimeData();
urls.populateMimeData(mime);
drag->setMimeData(mime);
drag->start();
}
}
KListWidget::mouseMoveEvent(e);
}
示例7: testURLList
void KUrlMimeTest::testURLList()
{
QMimeData* mimeData = new QMimeData;
QVERIFY( !KUrl::List::canDecode( mimeData ) );
QVERIFY(!mimeData->hasUrls());
KUrl::List urls;
urls.append( KUrl( "http://www.kde.org" ) );
urls.append( KUrl( "http://wstephenson:[email protected]/path" ) );
urls.append( KUrl( "file:///home/dfaure/konqtests/Mat%C3%A9riel" ) );
QMap<QString, QString> metaData;
metaData["key"] = "value";
metaData["key2"] = "value2";
urls.populateMimeData( mimeData, metaData );
QVERIFY(KUrl::List::canDecode( mimeData ));
QVERIFY(mimeData->hasUrls());
QVERIFY(mimeData->hasText());
QMap<QString, QString> decodedMetaData;
KUrl::List decodedURLs = KUrl::List::fromMimeData( mimeData, &decodedMetaData );
QVERIFY( !decodedURLs.isEmpty() );
KUrl::List expectedUrls = urls;
expectedUrls[1] = KUrl("http://[email protected]/path"); // password removed
QCOMPARE( expectedUrls.toStringList().join(" "), decodedURLs.toStringList().join(" ") );
const QList<QUrl> qurls = mimeData->urls();
QCOMPARE(qurls.count(), urls.count());
for (int i = 0; i < qurls.count(); ++i )
QCOMPARE(qurls[i], static_cast<QUrl>(decodedURLs[i]));
QVERIFY( !decodedMetaData.isEmpty() );
QCOMPARE( decodedMetaData["key"], QString( "value" ) );
QCOMPARE( decodedMetaData["key2"], QString( "value2" ) );
delete mimeData;
}
示例8: foreach
QMimeData * KFindItemModel::mimeData(const QModelIndexList &indexes) const
{
KUrl::List uris;
foreach ( const QModelIndex & index, indexes )
{
if( index.isValid())
{
if( index.column() == 0 ) //Only use the first column item
{
uris.append( m_itemList.at( index.row() ).getFileItem().url() );
}
}
}
if ( uris.count() <= 0 )
return 0;
QMimeData * mimeData = new QMimeData();
uris.populateMimeData( mimeData );
return mimeData;
}
示例9: mimeData
QMimeData* PlaylistModel::mimeData(const QModelIndexList &indexes) const
{
KUrl::List urls;
QStringList rows;
const int column = (indexes.isEmpty()?-1:indexes.first().column());
foreach (const QModelIndex &index, indexes)
{
if (index.isValid() && index.column() == column)
{
urls.append(KUrl(m_tracks.at(index.row())));
rows.append(QString::number(index.row()));
}
}
QMimeData *mimeData = new QMimeData();
mimeData->setData("text/x-plasma-miniplayer-tracklist", rows.join(QChar(',')).toAscii());
mimeData->setData("text/x-plasma-miniplayer-playlist", QString::number(m_id).toAscii());
urls.populateMimeData(mimeData);
return mimeData;
}