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


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

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


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

示例1: mouseMoveEvent

void PlayListView::mouseMoveEvent(QMouseEvent *event){

    // 
    
    // if not left button - return
     if (!(event->buttons() & Qt::LeftButton)) return;
    
    // if no item selected, return (else it would crash)
     if (currentItem() == NULL) return;
    
    QDrag *drag = new QDrag(this);
    QMimeData *mimeData = new QMimeData;
    
    // construct list of QUrls
    // other widgets accept this mime type, we can drop to them
    QList<QUrl> list;
    QString line;
    line = currentItem()->text(0); // 0 == first Column of QTreeWidgetItem
    list.append( QUrl(line) ); // only QUrl in list will be text of actual item
    
    // mime stuff
    mimeData->setUrls(list); 
    //mimeData->setData( line.toUtf8(), "text/uri-list" );
    drag->setMimeData(mimeData);
    
    RG_DEBUG << "Starting drag from PlayListView::mouseMoveEvent() with mime : " << mimeData->formats() << " - " << mimeData->urls()[0] << endl;
    
    // start drag
    drag->start(Qt::CopyAction | Qt::MoveAction);
    
    
}
开发者ID:UIKit0,项目名称:rosegarden,代码行数:32,代码来源:PlayListView.cpp

示例2: handleDrop

void EventPresenter::handleDrop(const QPointF& pos, const QMimeData& mime)
{
  // We don't want to create a new state in BaseScenario
  auto scenar = dynamic_cast<Scenario::ProcessModel*>(m_model.parent());
  // todo Maybe the drop should be handled by the scenario presenter ?? or not

  // If the mime data has states in it we can handle it.
  if (scenar && mime.formats().contains(score::mime::messagelist()))
  {
    Mime<State::MessageList>::Deserializer des{mime};
    State::MessageList ml = des.deserialize();

    RedoMacroCommandDispatcher<Command::AddStateWithData> dispatcher{
        score::IDocument::documentContext(m_model).commandStack};

    auto cmd = new Command::CreateState{
        *scenar,
        m_model.id(),
        pos.y() / m_view->parentItem()->boundingRect().size().height()};
    dispatcher.submit(cmd);
    dispatcher.submit(new Command::AddMessagesToState{
        scenar->states.at(cmd->createdState()), std::move(ml)});

    dispatcher.commit();
  }
}
开发者ID:OSSIA,项目名称:Score,代码行数:26,代码来源:EventPresenter.cpp

示例3: formats

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

    // set text, verify
    mimeData.setData("text/plain", "pirates");
    QCOMPARE(mimeData.formats(), QStringList() << "text/plain");

    // set html, verify
    mimeData.setData("text/html", "ninjas");
    QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html");

    // clear, verify
    mimeData.clear();
    QCOMPARE(mimeData.formats(), QStringList());

    // set an odd format, verify
    mimeData.setData("foo/bar", "somevalue");
    QCOMPARE(mimeData.formats(), QStringList() << "foo/bar");
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:20,代码来源:tst_qmimedata.cpp

示例4:

/*
 * This function is called when a standalone MimeData instance is passed as parameter to push()
 */
QMimeData *QQuickMimeData::toMimeData()
{
    QMimeData *ret = m_mimeData;
    if (!m_refData) {
        m_mimeData = new QMimeData;
        // copy data so we keep the properties as they were
        Q_FOREACH(const QString &format, ret->formats()) {
            m_mimeData->setData(format, ret->data(format));
        }
        // set teh color separately
        m_mimeData->setColorData(ret->colorData());
    }
开发者ID:Aleskey78,项目名称:ubuntu-ui-toolkit-win,代码行数:15,代码来源:qquickmimedata.cpp

示例5: 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

示例6: setInputData

void ActionDialog::setInputData(const QMimeData &data)
{
    delete m_data;
    m_data = cloneData(data);

    QString defaultFormat = ui->comboBoxInputFormat->currentText();
    ui->comboBoxInputFormat->clear();
    QStringList formats = QStringList() << standardFormats << data.formats();
    formats.removeDuplicates();
    ui->comboBoxInputFormat->addItems(formats);
    const int index = qMax(0, ui->comboBoxInputFormat->findText(defaultFormat));
    ui->comboBoxInputFormat->setCurrentIndex(index);

}
开发者ID:pmros,项目名称:CopyQ,代码行数:14,代码来源:actiondialog.cpp

示例7: mimeData

QMimeData* WGMergeProxy::mimeData(const QModelIndexList &indexes) const
{
	QMimeData* data = new QMimeData();

	for(const auto& index : indexes)
	{
		auto pair = mappingFromIndex(index);
		if(pair.first)
		{
			QMimeData* mimeData = pair.first->model_->mimeData({index});
			for (auto& format : mimeData->formats())
			{
				data->setData(format, mimeData->data(format));
			}
		}
	}

	return data;
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:19,代码来源:wg_merge_proxy.cpp

示例8:

QDebug operator<<(QDebug d, const QMimeData &m)
{
    QDebug nospace = d.nospace();
    const QStringList formats = m.formats();
    nospace << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n'
            << "  Text=" << m.hasText() << " HTML=" << m.hasHtml()
            << " Color=" << m.hasColor() << " Image=" << m.hasImage()
            << " URLs=" << m.hasUrls() << '\n';
    if (m.hasText())
        nospace << "  Text: '" << m.text() << "'\n";
    if (m.hasHtml())
        nospace << "  HTML: '" << m.html() << "'\n";
    if (m.hasColor())
        nospace << "  Color: " << qvariant_cast<QColor>(m.colorData()) << '\n';
    if (m.hasImage())
        nospace << "  Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n';
    if (m.hasUrls())
        nospace << "  URLs: " << m.urls() << '\n';
    return d;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:20,代码来源:qwindowsclipboard.cpp

示例9: overrideSelection

void DataDeviceManager::overrideSelection(const QMimeData &mimeData)
{
    QStringList formats = mimeData.formats();
    if (formats.isEmpty())
        return;

    m_retainedData.clear();
    foreach (const QString &format, formats)
        m_retainedData.setData(format, mimeData.data(format));

    m_compositor->feedRetainedSelectionData(&m_retainedData);

    m_compositorOwnsSelection = true;

    InputDevice *dev = m_compositor->defaultInputDevice();
    Surface *focusSurface = dev->keyboardFocus();
    if (focusSurface)
        offerFromCompositorToClient(
                    dev->dataDevice(focusSurface->base()->resource.client)->dataDeviceResource());
}
开发者ID:Distrotech,项目名称:qtwayland,代码行数:20,代码来源:wldatadevicemanager.cpp

示例10: overrideSelection

void DataDeviceManager::overrideSelection(const QMimeData &mimeData)
{
    QStringList formats = mimeData.formats();
    if (formats.isEmpty())
        return;

    m_retainedData.clear();
    foreach (const QString &format, formats)
        m_retainedData.setData(format, mimeData.data(format));

    QWaylandCompositorPrivate::get(m_compositor)->feedRetainedSelectionData(&m_retainedData);

    m_compositorOwnsSelection = true;

    QWaylandSeat *dev = m_compositor->defaultSeat();
    QWaylandSurface *focusSurface = dev->keyboardFocus();
    if (focusSurface)
        offerFromCompositorToClient(
                    QWaylandSeatPrivate::get(dev)->dataDevice()->resourceMap().value(focusSurface->waylandClient())->handle);
}
开发者ID:greenisland,项目名称:greenisland,代码行数:20,代码来源:qwldatadevicemanager.cpp


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