本文整理汇总了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);
}
示例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();
}
}
示例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");
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}