QMimeData *QgsGraduatedSymbolRendererModel::mimeData( const QModelIndexList &indexes ) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream( &encodedData, QIODevice::WriteOnly ); // Create list of rows Q_FOREACH ( const QModelIndex &index, indexes ) { if ( !index.isValid() || index.column() != 0 ) continue; stream << index.row(); } mimeData->setData( mMimeFormat, encodedData ); return 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; }
void ClsQNeuronStateVariableDisplay::startDragging(bool bCopy) { #ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY cout << "ClsQNeuronStateVariableDisplay::startDragging()" << endl; #endif QDrag *drag = new QDrag(this); string strParamList=getSelectedStatesAsString(); string str = ""; str = ClsDragDropDeEncoder::encode(ClsFESystemManager::ITEM_GROUP, clsFEGroup->getGroupID(), strParamList, strSelectedIndices); QMimeData *mimeData = new QMimeData; mimeData->setData("text/iqr-plot", str.c_str()); drag->setMimeData(mimeData); Qt::DropAction dropAction = drag->exec(); };
QMimeData *ObjectModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodeData; qDebug() << "mimeData"; QDataStream stream(&encodeData, QIODevice::WriteOnly); foreach (const QModelIndex &index, indexes) { if (index.isValid()) { stream << reinterpret_cast<quint64>(index.internalPointer()); qDebug() << reinterpret_cast<quint64>(index.internalPointer()); } } mimeData->setData("AnimationCreator/object.item.list", encodeData); return mimeData; }
void IPProcessList::startDrag(Qt::DropActions) { QListWidgetItem* item = currentItem(); QMimeData* mimeData = new QMimeData; QByteArray processID; processID.append(item->toolTip()); mimeData->setData("application/x-imageplay", processID); QPixmap dragPixmap = item->icon().pixmap(32,32); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(dragPixmap); drag->setHotSpot(QPoint(16,16)); drag->exec(Qt::MoveAction); //QListWidget::startDrag(supportedActions); }
void tst_QMimeData::hasImage() const { QMimeData mimeData; // initial state QVERIFY(mimeData.hasImage() == false); // add text, verify false mimeData.setData("text/plain", "pirates"); QVERIFY(mimeData.hasImage() == false); // add image mimeData.setImageData(QImage()); QVERIFY(mimeData.hasImage()); // clear, verify mimeData.clear(); QVERIFY(mimeData.hasImage() == false); }
void Palette::mouseMoveEvent(QMouseEvent* ev) { if ((currentIdx != -1) && (dragIdx == currentIdx) && (ev->buttons() & Qt::LeftButton) && (ev->pos() - dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { PaletteCell* cell = cells[currentIdx]; if (cell && cell->element) { QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; Element* el = cell->element; qreal mag = PALETTE_SPATIUM * extraMag / gscore->spatium(); QPointF spos = QPointF(dragStartPosition) / mag; spos -= QPointF(cells[currentIdx]->x, cells[currentIdx]->y); // DEBUG: spos.setX(0.0); mimeData->setData(mimeSymbolFormat, el->mimeData(spos)); drag->setMimeData(mimeData); dragSrcIdx = currentIdx; emit startDragElement(el); if (_readOnly) { drag->start(Qt::CopyAction); } else { /*Qt::DropAction action = */ drag->start(Qt::DropActions(Qt::CopyAction | Qt::MoveAction)); } } } else { QRect r; if (currentIdx != -1) r = idxRect(currentIdx); currentIdx = idx(ev->pos()); if (currentIdx != -1) { if (cells[currentIdx] == 0) currentIdx = -1; else r |= idxRect(currentIdx); } update(r); } }
void wid_stranke::on_btn_kopiraj_clicked() { QClipboard *odlozisce = QApplication::clipboard(); QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows(); QString html_besedilo = "<table>"; html_besedilo += "<tr>"; html_besedilo += "<th>ID</th>"; html_besedilo += "<th>Ime/Naziv</th>"; html_besedilo += "<th>Priimek/Polni naziv</th>"; html_besedilo += "<th>Telefon</th>"; html_besedilo += "<th>GSM</th>"; html_besedilo += "<th>Elektronski naslov</th>"; html_besedilo += "<th>Izobrazevalna ustanova</th>"; html_besedilo += "<th>Tip stranke</th>"; html_besedilo += "</tr>"; for( int i = 0; i < selectedList.count(); i++) { html_besedilo += "<tr>"; for ( int a = 0; a < 8; a++ ) { html_besedilo += "<td>"; html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text(); html_besedilo += "</td>"; } html_besedilo += "</tr>"; } html_besedilo += "</table>"; QTextEdit *textedit = new QTextEdit; textedit->setHtml(html_besedilo); html_besedilo = textedit->toHtml(); odlozisce->clear(); QMimeData *mimeData = new QMimeData(); mimeData->setData("text/html", html_besedilo.toUtf8()); odlozisce->setMimeData(mimeData, QClipboard::Clipboard); }
void BlocksTree::mouseMoveEvent( QMouseEvent *event ) { if ( event->buttons() & Qt::LeftButton ) { QTreeWidgetItem *tWI = itemAt( event->pos() ); if ( tWI && tWI->parent() && tWI->isSelected() ) { QMimeData *mimeData = new QMimeData; Block *block = ( Block * )tWI->data( 0, Qt::UserRole ).value< quintptr >(); mimeData->setData( "Block", QByteArray( ( const char * )&block, sizeof block ) ); QDrag *drag = new QDrag( this ); drag->setPixmap( tWI->data( 0, Qt::DecorationRole ).value< QPixmap >() ); drag->setMimeData( mimeData ); drag->exec(); } } QTreeWidget::mouseMoveEvent( event ); }
void DockedWindow::dragMouseMove(QPoint pos) { if (m_dragMouseDown) { if ((pos - m_dragStartPos).manhattanLength() < QApplication::startDragDistance()) { return; } QDrag *drag = new QDrag(d_app); QMimeData *mimeData = new QMimeData; MdiSubWindow *ptr = mdiSubWindow(); auto d = QByteArray::fromRawData((const char *)ptr, 1); mimeData->setData("TiledWindow", d); drag->setMimeData(mimeData); Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); (void)dropAction; } }
QMimeData* ClipEditorModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); // mimeData index is not the index of the actual item // index is the index of the first entry in the group // index.row() is the row of our actual index in the group // So you need index.parent()->child(index.row(),0) to get the actual index! foreach (QModelIndex index, indexes) { if (index.isValid() && index.column() == 0) { stream << index.internalId() << index.row(); } } mimeData->setData("x-index", encodedData); return mimeData; }
QMimeData* KBModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); foreach (const QModelIndex &index, indexes) { if (index.isValid()) { const KBViewItem* item = static_cast<const KBViewItem*>(index.internalPointer()); item->append_binary_layerout(stream); } } mimeData->setData("application/lain.local_binary_objects", encodedData); return mimeData; }
QMimeData* PrintQueueModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); foreach (const QModelIndex &index, indexes) { if (index.isValid() && index.column() == 0) { // serialize the jobId and fromDestName stream << data(index, JobId).toInt() << data(index, DestName).toString() << item(index.row(), ColName)->text(); } } mimeData->setData("application/x-cupsjobs", encodedData); return mimeData; }
QMimeData * SensorBrowserModel::mimeData ( const QModelIndexList & indexes ) const { //virtual QMimeData *mimeData = new QMimeData(); if(indexes.size() != 1) return mimeData; SensorInfo *sensor = getSensorInfo(indexes[0]); if(!sensor) return mimeData; // Create text drag object as // "<hostname> <sensorname> <sensortype> <sensordescription>". // Only the description may contain blanks. Q_ASSERT(sensor); Q_ASSERT(sensor->hostInfo()); QString mDragText = sensor->hostInfo()->hostName() + ' ' + sensor->name() + ' ' + sensor->type()+ ' ' + sensor->description(); mimeData->setData( "application/x-ksysguard", mDragText.toUtf8() ); return mimeData; }
// static QMimeData *KLFAbstractLibEntryMimeEncoder::createMimeData(const KLFLibEntryList& entryList, const QVariantMap& metaData) { QMimeData *mime = new QMimeData; int k, j; for (k = 0; k < staticEncoderList.size(); ++k) { QStringList mimeTypeList = staticEncoderList[k]->supportedEncodingMimeTypes(); for (j = 0; j < mimeTypeList.size(); ++j) { QByteArray data = staticEncoderList[k]->encodeMime(entryList, metaData, mimeTypeList[j]); if (data.isEmpty()) { klfDbg("Skipping mime type "<<mimeTypeList[k]<<" because it did not provide any data."); } else { mime->setData(mimeTypeList[j], data); } } } return mime; }
QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); foreach (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; } mimeData->setData(MIMETYPE, data); return mimeData; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FilterListWidget::performDrag() { QListWidgetItem* item = currentItem(); if(item) { QJsonObject obj; obj[item->text()] = item->data(Qt::UserRole).toString(); QJsonDocument doc(obj); QByteArray jsonArray = doc.toJson(); QMimeData* mimeData = new QMimeData; mimeData->setData(SIMPL::DragAndDrop::FilterItem, jsonArray); QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); drag->exec(Qt::CopyAction); } }
void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { QMimeData* md = new QMimeData; QString text = frame->selectedText(); text.replace(QChar(0xa0), QLatin1Char(' ')); md->setText(text); QString html = QLatin1String("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>"); html += createMarkup(selectedRange, 0, AnnotateForInterchange); html += QLatin1String("</body></html>"); md->setHtml(html); #ifndef QT_NO_CLIPBOARD QApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard); #endif if (canSmartCopyOrDelete) md->setData("application/vnd.qtwebkit.smartpaste", QByteArray()); }
void tst_QMimeData::hasColor() const { QMimeData mimeData; // initial state QVERIFY(mimeData.hasColor() == false); // set, verify mimeData.setColorData(QColor(Qt::red)); QVERIFY(mimeData.hasColor()); // clear, verify mimeData.clear(); QVERIFY(mimeData.hasColor() == false); // set something else, verify mimeData.setData("text/plain", "pirates"); QVERIFY(mimeData.hasColor() == false); }
void TestGui::dragAndDropGroup(const QModelIndex& sourceIndex, const QModelIndex& targetIndex, int row, bool expectedResult, const QString& expectedParentName, int expectedPos) { QVERIFY(sourceIndex.isValid()); QVERIFY(targetIndex.isValid()); GroupModel* groupModel = qobject_cast<GroupModel*>(m_dbWidget->findChild<GroupView*>("groupView")->model()); QMimeData mimeData; QByteArray encoded; QDataStream stream(&encoded, QIODevice::WriteOnly); Group* group = groupModel->groupFromIndex(sourceIndex); stream << group->database()->uuid() << group->uuid(); mimeData.setData("application/x-keepassx-group", encoded); QCOMPARE(groupModel->dropMimeData(&mimeData, Qt::MoveAction, row, 0, targetIndex), expectedResult); QCOMPARE(group->parentGroup()->name(), expectedParentName); QCOMPARE(group->parentGroup()->children().indexOf(group), expectedPos); }
void ModulesList::mouseMoveEvent(QMouseEvent* inEvent) { if((inEvent->buttons() & Qt::LeftButton) && ((inEvent->pos() - mDragStartPos).manhattanLength() >= QApplication::startDragDistance()) && currentItem()) { QDrag* lDrag = new QDrag(this); QMimeData* lMimeData = new QMimeData(); lMimeData->setData("vipers/module-name", currentItem()->data(Qt::UserRole).toString().toAscii()); lDrag->setMimeData(lMimeData); lDrag->setPixmap(currentItem()->icon().pixmap(QSize(32,32))); lDrag->exec(Qt::CopyAction); inEvent->accept(); } else { QListWidget::mouseMoveEvent(inEvent); } }
void MainUI::CopyFiles(QStringList list){ qDebug() << "Copy Files:" << list; if(list.isEmpty()){ return; } //nothing selected //Format the data string QList<QUrl> urilist; //Also assemble a URI list for cros-app compat (no copy/cut distinguishing) for(int i=0; i<list.length(); i++){ urilist << QUrl::fromLocalFile(list[i]); list[i] = list[i].prepend("copy::::"); } //Now save that data to the global clipboard QMimeData *dat = new QMimeData; dat->clear(); dat->setData("x-special/lumina-copied-files", list.join("\n").toLocal8Bit()); dat->setUrls(urilist); //the text/uri-list mimetype - built in Qt conversion/use QApplication::clipboard()->clear(); QApplication::clipboard()->setMimeData(dat); //Update all the buttons to account for clipboard change for(int i=0; i<DWLIST.length(); i++){ DWLIST[i]->refreshButtons(); } }
void ChartView::saveImage( bool clipboard ) { QSvgGenerator generator; QByteArray svg; QBuffer buffer( &svg ); generator.setTitle( "QtPlatz Generated SVG" ); generator.setDescription( "Copyright (C) 2013-2017 MS-Cheminformataics, All rights reserved" ); auto sz = this->size(); QRectF rc( 0, 0, sz.width(), sz.height() ); generator.setViewBox( rc ); if ( clipboard ) { generator.setOutputDevice( &buffer ); } else { auto name = QFileDialog::getSaveFileName( this, tr( "Save SVG File" ) , "chart.svg" , tr( "SVG (*.svg)" ) ); if ( ! name.isEmpty() ) generator.setFileName( name ); } QwtPlotRenderer renderer; renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasBackground, true ); renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasFrame, true ); renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, true ); QPainter painter; painter.begin( &generator ); renderer.render( this, &painter, rc ); painter.end(); if ( clipboard ) { QMimeData * mime = new QMimeData(); mime->setData( "image/svg+xml", svg ); QApplication::clipboard()->setMimeData( mime, QClipboard::Clipboard ); } }
QMimeData * djvFileBrowserModel::mimeData(const QModelIndexList & indexes) const { QMimeData * mimeData = new QMimeData(); if (indexes.count()) { const djvFileInfo fileInfo = this->fileInfo(indexes[0]); QStringList tmp; tmp << fileInfo; QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); stream << tmp; mimeData->setData("application/x-filebrowser", data); } return mimeData; }
QMimeData * PlaylistModel::mimeData (const QModelIndexList &list) const { QMimeData *ret = new QMimeData (); QByteArray ba; QDataStream stream (&ba, QIODevice::WriteOnly); QList<int> l; for (int i = 0; i < list.size (); i ++) { QModelIndex idx = list.at (i); if (idx.column () != 0) continue; l.append (idx.row ()); } stream << l; ret->setData ("application/x-xmms2poslist", ba); return ret; }
QMimeData *LayoutsTableModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); QSet<int> rows; foreach (const QModelIndex& index, indexes) { if (index.isValid()) { rows << index.row(); } } foreach (int row, rows) { stream << row; } mimeData->setData("application/keyboard-layout-item", encodedData); return mimeData; }
QMimeData *LiteEditorWidget::createMimeDataFromSelection() const { QTextCursor cursor = textCursor(); if (m_inBlockSelectionMode) { QMimeData *mimeData = new QMimeData; QString text = this->copyBlockSelection(); mimeData->setData(QLatin1String(kVerticalTextBlockMimeType), text.toUtf8()); mimeData->setText(text); // for exchangeability return mimeData; } else if (cursor.hasSelection()) { QMimeData *mimeData = new QMimeData; QString text = cursor.selectedText(); convertToPlainText(text); mimeData->setText(text); // Copy the selected text as HTML mimeData->setHtml(cursorToHtml(cursor)); return mimeData; } return 0; }
QMimeData* TransferModel::mimeData(const QModelIndexList &indexes) const { if (indexes.isEmpty()) { return 0; } QMimeData *data = new QMimeData(); QByteArray encoded; QDataStream stream(&encoded, QIODevice::WriteOnly); for (int i = 0; i < indexes.size(); i++) { const QModelIndex &index = indexes.at(i); if (index.column() == 0) { stream << index.row() << (index.parent().isValid() ? index.parent().row() : -1); } } data->setData(MIME_TYPE, encoded); return data; }
void ePageView::_onOperatorCopy() { eASSERT(scene() != eNULL); QDomDocument xml; QDomElement rootEl = xml.createElement("operators"); xml.appendChild(rootEl); for (eInt i=0; i<scene()->selectedItems().size(); i++) { const eGuiOperator *guiOp = (eGuiOperator *)scene()->selectedItems().at(i); eASSERT(guiOp != eNULL); guiOp->saveToXml(rootEl); } QMimeData *md = new QMimeData; md->setData("operator/xml", QByteArray(xml.toString().toAscii())); QApplication::clipboard()->setMimeData(md); }
MVOpenViewsControl::MVOpenViewsControl(MVAbstractContext* context, MVMainWindow* mw) : MVAbstractControl(context, mw) { d = new MVOpenViewsControlPrivate; d->q = this; d->m_viewMapper = new QSignalMapper(this); connect(d->m_viewMapper, SIGNAL(mapped(QObject*)), this, SLOT(slot_open_view(QObject*))); d->m_flow_layout = new FlowLayout; QList<QAction*> actions; QMimeData md; /// Witold, is there a better way to do this than to set a "non-empty" dummy string? md.setData("x-mv-main", "non-empty"); QStringList plugin_names = this->mainWindow()->loadedPluginNames(); foreach (QString plugin_name, plugin_names) { actions.append(this->mainWindow()->loadedPlugin(plugin_name)->actions(md)); }