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


C++ QMimeData类代码示例

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


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

示例1: Q_ASSERT

// -------------------------------------------------------------------------------
QMimeData* CCollectionModel::mimeData( const QModelIndexList& indexes ) const
// -------------------------------------------------------------------------------
{
   //std::cout<<"CCollectionModel::mimeData()"<<std::endl;
   
   Q_ASSERT( NULLPTR != mpCollection );
   if ( !mpCollection )
      return NULLPTR;


   if ( indexes.isEmpty() )
      return NULLPTR;

   QModelIndex firstIndex = indexes.first();
   if ( !firstIndex.isValid() )
      return NULLPTR;

   CTreeInformationElement* pTIE = mapIndexToIE( firstIndex );
   if ( !pTIE )
      return NULLPTR;


   QByteArray encodedData;
   encodedData.append( mpCollection->toXML( pTIE ).toUtf8() );
   debugTrace( "[CCollectionModel::mimeData] encodedData = '" + encodedData + "'" );
   //std::cout<<"[DragContent]"<<QString(encodedData).toStdString()<<"[/DragContent]"<<std::endl;


   // TODO: Check whether the encoding for umlauts, accents, etc. is correct.
   //       If not it might be accomplished like this:
   //QTextStream t( &encodedData, QIODevice::WriteOnly );
   //t.setCodec( "UTF-8" );
   //t << mpCollection->toXML( pTIE );

   QMimeData* pMimeData = new QMimeData();
   pMimeData->setData( TUXCARDS_DRAGDROP_TYPE, encodedData );
   
   return pMimeData;
}
开发者ID:Morius,项目名称:TuxCards,代码行数:40,代码来源:CCollectionModel.cpp

示例2: itemAt

void SeList::mouseMoveEvent(QMouseEvent* e)
{
	if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
	{
		Mpressed = false;
		QListWidgetItem *item = itemAt(Mpos);
		if (!item)
			return;
		QMimeData *mimeData = new QMimeData;
		QString pageName = item->data(Qt::UserRole).toString();
		mimeData->setData("page/magic", "1" + pageName.toLocal8Bit());
		mimeData->setText("1" + pageName);
		QDrag *dr = new QDrag(this);
		dr->setMimeData(mimeData);
		const QPixmap& pm = IconManager::instance()->loadPixmap("doc.png");
		dr->setPixmap(pm);
	//	dr->setDragCursor(pm, Qt::CopyAction);
	//	dr->setDragCursor(pm, Qt::MoveAction);
		dr->exec(Qt::CopyAction | Qt::MoveAction);
		QApplication::setOverrideCursor(Qt::ArrowCursor);
	}
}
开发者ID:gyuris,项目名称:scribus,代码行数:22,代码来源:pagepalette_widgets.cpp

示例3: cloneData

QVariantMap cloneData(const QMimeData &data)
{
    QStringList formats;

    for ( const auto &mime : data.formats() ) {
        // ignore uppercase mimetypes (e.g. UTF8_STRING, TARGETS, TIMESTAMP)
        // and internal type to check clipboard owner
        if ( !mime.isEmpty() && mime[0].isLower() )
            formats.append(mime);
    }

    return cloneData(data, formats);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:13,代码来源:common.cpp

示例4: foreach

//virtual
QMimeData * EffectsListWidget::mimeData(const QList<QTreeWidgetItem *> list) const
{
    QDomDocument doc;
    bool transitionMode = false;
    foreach(QTreeWidgetItem *item, list) {
        if (item->flags() & Qt::ItemIsDragEnabled) {
            int type = item->data(0, TypeRole).toInt();
            if (type == EffectsList::TRANSITION_TYPE) {
                transitionMode = true;
            }
            QStringList info = item->data(0, IdRole).toStringList();
            const QDomElement e = itemEffect(type, info);
            if (!e.isNull())
                doc.appendChild(doc.importNode(e, true));
        }
    }
    QMimeData *mime = new QMimeData;
    QByteArray data;
    data.append(doc.toString().toUtf8());
    mime->setData(transitionMode ? "kdenlive/transitionslist" : "kdenlive/effectslist", data);
    return mime;
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:23,代码来源:effectslistwidget.cpp

示例5: dataStream

void DummyBlock::mousePressEvent(QMouseEvent *event)
{
    cout << "Starting Drag" << endl;

    QByteArray itemData;

    QDataStream dataStream(&itemData, QIODevice::WriteOnly);

    dataStream << QPoint(event->pos());

    QMimeData *mimeData = new QMimeData;
    mimeData->setData("application/x-dnditemdata", itemData);

    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setHotSpot(event->pos());
    drag->setPixmap(this->grab());
    if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
    {
//        this->close();
    }
}
开发者ID:dtormoen,项目名称:BlockEditor,代码行数:22,代码来源:block.cpp

示例6: QMimeData

QMimeData *TableModelAnovaWithinSubjectCells::mimeData(const QModelIndexList &indexes) const
{
	QMimeData *mimeData = new QMimeData();
	QByteArray encodedData;

	QDataStream dataStream(&encodedData, QIODevice::WriteOnly);

	dataStream << indexes.length();

	foreach (const QModelIndex &index, indexes)
	{
		if (index.isValid())
		{
			Term term = _variables.at(index.row());
			dataStream << term.asQString();
		}
	}

	mimeData->setData("application/vnd.list.variable", encodedData);

	return mimeData;
}
开发者ID:AlexanderLyNL,项目名称:jasp-desktop,代码行数:22,代码来源:tablemodelanovawithinsubjectcells.cpp

示例7: QByteArray

QMimeData* BasketTreeListView::mimeData(const QList<QTreeWidgetItem *> items) const
{
    QString mimeType = TREE_ITEM_MIME_STRING;

    QByteArray data = QByteArray();
    QDataStream out(&data, QIODevice::WriteOnly);

    if(items.isEmpty())
        return new QMimeData();


    for (int i = 0; i < items.count(); ++i) {
        BasketListViewItem *basketItem = static_cast<BasketListViewItem*>(items[i]);
        out << basketItem->basket()->basketName() << basketItem->basket()->folderName()
                << basketItem->basket()->icon();
    }

    QMimeData *mimeData = new QMimeData();

    mimeData->setData(mimeType, data);
    return mimeData;
}
开发者ID:bewitchingme,项目名称:basket,代码行数:22,代码来源:basketlistview.cpp

示例8: testCut

void KIOPasteTest::testCut()
{
    QMimeData *mimeData = new QMimeData;

    QUrl localURL1(QStringLiteral("file:///tmp/Mat%C3%A9riel"));
    QUrl localURL2(QStringLiteral("file:///tmp"));
    QList<QUrl> localURLs; localURLs << localURL1 << localURL2;

    KUrlMimeData::setUrls(QList<QUrl>(), localURLs, mimeData);
    KIO::setClipboardDataCut(mimeData, true);

    QVERIFY(mimeData->hasUrls());
    const QList<QUrl> lst = KUrlMimeData::urlsFromMimeData(mimeData);
    QCOMPARE(lst.count(), 2);
    QCOMPARE(lst[0].url(), localURL1.url());
    QCOMPARE(lst[1].url(), localURL2.url());

    const bool isCut = KIO::isClipboardDataCut(mimeData);
    QVERIFY(isCut);

    delete mimeData;
}
开发者ID:KDE,项目名称:kio,代码行数:22,代码来源:pastetest.cpp

示例9: QDrag

void QtRosterWidget::mouseMoveEvent(QMouseEvent *event)
 {
	if (!(event->buttons() & Qt::LeftButton)) {
		return;
	}
	if ((event->pos() - dragStartPosition).manhattanLength()< QApplication::startDragDistance()) {
		return;
	}
	clickedIndex=indexAt(event->pos());
	if (!clickedIndex.isValid()) {
		return;
	}
	QDrag *drag = new QDrag(this);
	QMimeData *mimeData = new QMimeData();
	RosterItem* item = static_cast<RosterItem*>(clickedIndex.internalPointer());
	ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
	std::string jid=contact->getJID().toString();
	QString str=QString::P2QSTRING(jid);
	mimeData->setText(str);
	drag->setMimeData(mimeData);
	drag->exec(Qt::CopyAction | Qt::MoveAction);     
 }
开发者ID:smuralireddy,项目名称:swift,代码行数:22,代码来源:QtRosterWidget.cpp

示例10: mousePressEvent

void DragableLabel::mousePressEvent(QMouseEvent *event)
{
    QPoint hotSpot = event->pos();

    QMimeData *mimeData = new QMimeData;
    mimeData->setText(this->text());
    mimeData->setData("application/x-hotspot",
                      QByteArray::number(hotSpot.x()) + " " + QByteArray::number(hotSpot.y()));

    QPixmap pixmap(this->size());
    this->render(&pixmap);

    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(pixmap);
    drag->setHotSpot(hotSpot);

    Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);

    if (dropAction == Qt::MoveAction)
        this->close();
}
开发者ID:xmd-project,项目名称:prototype,代码行数:22,代码来源:dragablelabel.cpp

示例11: testPopulate

void KIOPasteTest::testPopulate()
{
    QMimeData *mimeData = new QMimeData;

    // Those URLs don't have to exist.
    QUrl mediaURL(QStringLiteral("media:/hda1/tmp/Mat%C3%A9riel"));
    QUrl localURL(QStringLiteral("file:///tmp/Mat%C3%A9riel"));
    QList<QUrl> kdeURLs; kdeURLs << mediaURL;
    QList<QUrl> mostLocalURLs; mostLocalURLs << localURL;

    KUrlMimeData::setUrls(kdeURLs, mostLocalURLs, mimeData);

    QVERIFY(mimeData->hasUrls());
    const QList<QUrl> lst = KUrlMimeData::urlsFromMimeData(mimeData);
    QCOMPARE(lst.count(), 1);
    QCOMPARE(lst[0].url(), mediaURL.url());

    const bool isCut = KIO::isClipboardDataCut(mimeData);
    QVERIFY(!isCut);

    delete mimeData;
}
开发者ID:KDE,项目名称:kio,代码行数:22,代码来源:pastetest.cpp

示例12: lock

QMimeData* DisplayModel::mimeData(const QModelIndexList& indexes) const
{

	DatabaseLocker lock(db_);

	QMimeData *mimeData = new QMimeData();
	QList<QUrl> list;
	for (const QModelIndex &index: indexes)
	{
		if (index.isValid())
		{
			QStandardItem* qitem = this->itemFromIndex(index);
			file_hash_t hash = qitem->data(IMAGE_QVARIANT_ROLE).value<file_hash_t>();
			ImageDescription_ptr desc = db_->images().get_image_description(hash);

			list << QUrl("file:///" + db_->images().storage_location() + "/" + desc->path);
		}
	}
	mimeData->setUrls(list);

	return mimeData;
}
开发者ID:gawron89,项目名称:bulma,代码行数:22,代码来源:display_model.cpp

示例13: QMimeData

QMimeData *StatsListModel::mimeData(const QModelIndexList &indexes) const
{
    QMimeData *mimeData = new QMimeData();
    QByteArray encodedData;

    QDataStream stream(&encodedData, QIODevice::WriteOnly);

    foreach (QModelIndex index, indexes) {
        if (index.isValid()) {
            int ind = data(index, Qt::UserRole).toInt();
            int alpha = data(index, Qt::UserRole+1).toInt();
            QModelIndex checkindex = StatsListModel::createIndex(index.row(), 1, 999);
            bool draw = data(checkindex, Qt::CheckStateRole).toBool();
            bool drawgrid = data(index, Qt::UserRole+2).toBool();
            QString name = data(index, Qt::DisplayRole).toString();
            stream << ind << alpha << draw << drawgrid << name;
        }
    }

    mimeData->setData("application/YUView-Statistics", encodedData);
    return mimeData;
}
开发者ID:garyshaw2016,项目名称:YUView,代码行数:22,代码来源:statslistmodel.cpp

示例14: QMimeData

QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const
{
    QMimeData *mimeData = new QMimeData();
    QByteArray data;
    QDataStream stream(&data, QIODevice::WriteOnly);
    QList<QUrl> urls;
    foreach (const QModelIndex &index, indexes) {
        if (index.column() != 0 || !index.isValid())
            continue;
        QByteArray encodedData;
        QBuffer buffer(&encodedData);
        buffer.open(QBuffer::ReadWrite);
        XbelWriter writer;
        const BookmarkNode *parentNode = node(index);
        writer.write(&buffer, parentNode);
        stream << encodedData;
        urls.append(index.data(BookmarksModel::UrlRole).toUrl());
    }
    mimeData->setData(MIMETYPE, data);
    mimeData->setUrls(urls);
    return mimeData;
}
开发者ID:eborges,项目名称:arora,代码行数:22,代码来源:bookmarksmodel.cpp

示例15: QMimeData

QMimeData *GraphModel::mimeData(const QModelIndexList &indexes) const
{
	if(QApplication::keyboardModifiers() & Qt::ShiftModifier)
	{
		QMimeData *mimeData = new QMimeData();
		QByteArray encodedData;

		QDataStream stream(&encodedData, QIODevice::WriteOnly);

		foreach (const QModelIndex &index, indexes)
		{
			if (index.isValid())
			{
				GraphItem *item = static_cast<GraphItem *>(index.internalPointer());
				QVariant uData = PointerHolder<GraphItem *>::ToQVariant(item);
				stream << uData;
			}
		}

		mimeData->setData("application/tree.userdata", encodedData);
		return mimeData;
	}
开发者ID:droidenko,项目名称:dava.framework,代码行数:22,代码来源:GraphModel.cpp


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