void CWizDocumentWebViewPage::on_editorCommandPaste_triggered() { QClipboard* clip = QApplication::clipboard(); Q_ASSERT(clip); const QMimeData* mime = clip->mimeData(); // QStringList formats = mime->formats(); // for(int i = 0; i < formats.size(); ++ i) { // qDebug() << "Mime Format: " << formats.at(i) << " Mime data: " << mime->data(formats.at(i)); // } if (mime->hasHtml()) { QString strHtml = mime->html(); QRegExp regHead("</?head[^>]*>", Qt::CaseInsensitive); if (strHtml.contains(regHead)) { // convert mass html to rtf, then convert rft to html QTextDocument textParase; textParase.setHtml(strHtml); strHtml = textParase.toHtml(); QRegExp regBodyContant("<body[^>]*>[\\s\\S]*</body>"); int index = regBodyContant.indexIn(strHtml); if (index > -1) { QString strBody = regBodyContant.cap(0); if (strBody.isEmpty()) return; QRegExp regBody = QRegExp("</?body[^>]*>", Qt::CaseInsensitive); strBody.replace(regBody, ""); strHtml = strBody; QMimeData* data = new QMimeData(); data->setHtml(strHtml); clip->setMimeData(data); return; } } } if (!clip->image().isNull()) { // save clipboard image to $TMPDIR QString strTempPath = Utils::PathResolve::tempPath(); CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png"; if (!clip->image().save(strFileName)) { TOLOG("ERROR: Can't save clipboard image to file"); return; } QMimeData* data = new QMimeData(); QString strHtml = getImageHtmlLabelByFile(strFileName); data->setHtml(strHtml); clip->setMimeData(data); } }
void ResultsJsInterface::pushImageToClipboard(const QByteArray &base64, const QString &html) { QMimeData *mimeData = new QMimeData(); QByteArray byteArray = QByteArray::fromBase64(base64); QImage pm; if(pm.loadFromData(byteArray)) { #ifdef __WIN32__ //needed because jpegs/clipboard doesn't support transparency in windows QImage image2(pm.size(), QImage::Format_ARGB32); image2.fill(Qt::white); QPainter painter(&image2); painter.drawImage(0, 0, pm); mimeData->setImageData(image2); #else mimeData->setImageData(pm); #endif } if ( ! html.isEmpty()) mimeData->setHtml(html); if (mimeData->hasImage() || mimeData->hasHtml()) { QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData, QClipboard::Clipboard); } }
void ClipboardItem::onButtonClicked() { QClipboard *sysClipboard = QApplication::clipboard(); QMimeData *clipMime = new QMimeData; if(mimeType != "screen") { if (mimeType == "html") { clipMime->setHtml(data); clipMime->setText(dataPlain); } else if (mimeType == "plain") { clipMime->setText(data); } else { delete clipMime; return; } sysClipboard->setMimeData(clipMime); } else { QString groupAddress; QSettings *settings = new QSettings; int pinMod = settings->value("pin").toInt() % 256; delete settings; groupAddress = "239.255.0." + QString::number(pinMod); vlc = new QProcess; vlc->start("vlc udp://" + data + "@" + groupAddress + ":12345"); } }
void NodeGraph::copySelectedNodes() { if ( _imp->_selection.empty() ) { Dialogs::warningDialog( tr("Copy").toStdString(), tr("You must select at least a node to copy first.").toStdString() ); return; } SERIALIZATION_NAMESPACE::NodeClipBoard cb; _imp->copyNodesInternal(_imp->_selection, &cb.nodes); std::ostringstream ss; try { SERIALIZATION_NAMESPACE::write(ss, cb, NATRON_CLIPBOARD_HEADER); } catch (...) { qDebug() << "Failed to copy selection to system clipboard"; } QMimeData* mimedata = new QMimeData; QByteArray data( ss.str().c_str() ); mimedata->setData(QLatin1String("text/plain"), data); QClipboard* clipboard = QApplication::clipboard(); //ownership is transferred to the clipboard clipboard->setMimeData(mimedata); }
void CWizDocumentWebViewPage::on_editorCommandPaste_triggered() { QClipboard* clip = QApplication::clipboard(); Q_ASSERT(clip); //const QMimeData* mime = clip->mimeData(); //qDebug() << mime->formats(); //qDebug() << mime->data("text/html"); //qDebug() << mime->hasImage(); if (!clip->image().isNull()) { // save clipboard image to $TMPDIR QString strTempPath = Utils::PathResolve::tempPath(); CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png"; if (!clip->image().save(strFileName)) { TOLOG("ERROR: Can't save clipboard image to file"); return; } QMimeData* data = new QMimeData(); QString strHtml = getImageHtmlLabelByFile(strFileName); data->setHtml(strHtml); clip->setMimeData(data); } }
void FxSelection::copySelection() { QClipboard *clipboard = QApplication::clipboard(); FxsData *fxsData = new FxsData(); fxsData->setFxs(m_selectedFxs, m_selectedLinks, m_selectedColIndexes, m_xshHandle->getXsheet()); clipboard->setMimeData(fxsData); }
bool DndFactory::copyIncidences( const Incidence::List &incidences ) { QClipboard *clipboard = QApplication::clipboard(); Q_ASSERT( clipboard ); MemoryCalendar::Ptr calendar( new MemoryCalendar( d->mCalendar->timeSpec() ) ); Incidence::List::ConstIterator it; for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) { if ( *it ) { calendar->addIncidence( Incidence::Ptr( ( *it )->clone() ) ); } } QMimeData *mimeData = new QMimeData; ICalDrag::populateMimeData( mimeData, calendar ); VCalDrag::populateMimeData( mimeData, calendar ); if ( calendar->incidences().isEmpty() ) { return false; } else { clipboard->setMimeData( mimeData ); return true; } }
void TCellKeyframeSelection::copyCellsKeyframes() { TCellKeyframeData *data = new TCellKeyframeData(); // Copy cells int r0, c0, r1, c1; m_cellSelection->getSelectedCells(r0, c0, r1, c1); if (!isEmpty()) { int colCount = c1 - c0 + 1; int rowCount = r1 - r0 + 1; if (colCount <= 0 || rowCount <= 0) return; TXsheet *xsh = m_xsheetHandle->getXsheet(); TCellData *cellData = new TCellData(); cellData->setCells(xsh, r0, c0, r1, c1); data->setCellData(cellData); } // Copy keyframes if (!isEmpty()) { QClipboard *clipboard = QApplication::clipboard(); TXsheet *xsh = m_xsheetHandle->getXsheet(); TKeyframeData *keyframeData = new TKeyframeData(); TKeyframeData::Position startPos(r0, c0); keyframeData->setKeyframes(m_keyframeSelection->getSelection(), xsh, startPos); data->setKeyframeData(keyframeData); } // Set the cliboard QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(data, QClipboard::Clipboard); }
// Claim the selection. void ScintillaQt::ClaimSelection() { bool isSel = !sel.Empty(); if (isSel) { QClipboard *cb = QApplication::clipboard(); // If we support X11 style selection then make it available now. if (cb->supportsSelection()) { SelectionText text; CopySelectionRange(&text); if (text.s) cb->setMimeData(mimeSelection(text), QClipboard::Selection); } primarySelection = true; } else primarySelection = false; emit qsb->QSCN_SELCHANGED(isSel); }
void matlabCopyScript(const QList<QList<double> >& data) { QString matlab=toMatlabScript(data, false); QClipboard *clipboard = QApplication::clipboard(); QMimeData* mime=new QMimeData(); mime->setText(matlab); clipboard->setMimeData(mime); }
void LineBuilderState::copy() { if (log) Logger::getLogger()->infoLog() << "LineBuilderState::copy()\n"; QClipboard *buffer = QApplication::clipboard(); RoadElementMimeData* data = new RoadElementMimeData(lineBroken); buffer->setMimeData(data); }
// copy to clipboard void KFindTreeView::copySelection() { QMimeData * mime = m_model->mimeData( m_proxyModel->mapSelectionToSource( selectionModel()->selection() ).indexes() ); if (mime) { QClipboard * cb = qApp->clipboard(); cb->setMimeData( mime ); } }
void WebView::convertClipboardHtmlImages(QClipboard::Mode mode) { QClipboard *cb = QApplication::clipboard(); QString html = TextUtil::img2title(selectedHtml()); QMimeData *data = new QMimeData; data->setHtml(html); data->setText(TextUtil::rich2plain(html, false)); cb->setMimeData(data, mode); }
void MOTableView::onCopyAsked() { QModelIndexList indexList = this->selectedIndexes(); if(model()) { QMimeData* mimeData = model()->mimeData(indexList); QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData); } }
void StdCmdCopy::activated(int iMsg) { bool done = getGuiApplication()->sendMsgToActiveView("Copy"); if (!done) { WaitCursor wc; QMimeData * mimeData = getMainWindow()->createMimeDataFromSelection(); QClipboard* cb = QApplication::clipboard(); cb->setMimeData(mimeData); } }
void Editor::copy() { if (!activeStack() || selection_->empty()) return; ObjectList ol(*selection_, model_); QClipboard *clipboard = kapp->clipboard(); clipboard->setMimeData(ol.mimeData(), QClipboard::Clipboard); }
void copyFilesToClipboard(FmPathList* files) { QClipboard* clipboard = QApplication::clipboard(); QMimeData* data = new QMimeData(); char* urilist = fm_path_list_to_uri_list(files); // Gnome, LXDE, and XFCE data->setData("x-special/gnome-copied-files", (QString("copy\n") + urilist).toUtf8()); // The KDE way data->setData("text/uri-list", urilist); // data.setData("x-kde-cut-selection", "0"); g_free(urilist); clipboard->setMimeData(data); }
void QgsComposerView::copyItems( ClipboardMode mode ) { if ( !composition() ) { return; } QList<QgsComposerItem*> composerItemList = composition()->selectedComposerItems(); QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin(); QDomDocument doc; QDomElement documentElement = doc.createElement( "ComposerItemClipboard" ); for ( ; itemIt != composerItemList.end(); ++itemIt ) { // copy each item in a group QgsComposerItemGroup* itemGroup = dynamic_cast<QgsComposerItemGroup*>( *itemIt ); if ( itemGroup && composition() ) { QSet<QgsComposerItem*> groupedItems = itemGroup->items(); QSet<QgsComposerItem*>::iterator it = groupedItems.begin(); for ( ; it != groupedItems.end(); ++it ) { ( *it )->writeXML( documentElement, doc ); } } ( *itemIt )->writeXML( documentElement, doc ); if ( mode == ClipboardModeCut ) { composition()->removeComposerItem( *itemIt ); } } doc.appendChild( documentElement ); //if it's a copy, we have to remove the UUIDs since we don't want any duplicate UUID if ( mode == ClipboardModeCopy ) { // remove all uuid attributes QDomNodeList composerItemsNodes = doc.elementsByTagName( "ComposerItem" ); for ( int i = 0; i < composerItemsNodes.count(); ++i ) { QDomNode composerItemNode = composerItemsNodes.at( i ); if ( composerItemNode.isElement() ) { composerItemNode.toElement().removeAttribute( "uuid" ); } } } QMimeData *mimeData = new QMimeData; mimeData->setData( "text/xml", doc.toByteArray() ); QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData( mimeData ); }
void ScriptModel::copyActions(const QList<int> &rows) { QModelIndexList indexes; for(int row: rows) { indexes << index(row, 0, QModelIndex()); } QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData(indexes)); }
void MainWindow::copyNodeAction () { QModelIndex index = tree->currentIndex(); QClipboard *clip = qApp->clipboard(); QByteArray xml_data = model->indexToBuffer ( index ); QString caption = model->data( index, Qt::DisplayRole ).toString(); QMimeData *md = new QMimeData; md->setData ( QString("text/plain"), caption.toUtf8() ); md->setData ( QString("text/xml"), xml_data ); clip->setMimeData ( md ); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked) { std::vector<QString> referenceList; SelectionManager::instance()->selectionAsReferences(referenceList); MimeDataWithReferences* myObject = new MimeDataWithReferences; myObject->setReferences(referenceList); QClipboard* clipboard = QApplication::clipboard(); if (clipboard) { clipboard->setMimeData(myObject); } }
void CommunObject::clearClipboard() { QClipboard* clipboard = QGuiApplication::clipboard(); clipboard->clear(); /* * Qt bug: 'Android: QClipboard::clear() not implemented' * Bug description: 'This is done by calling setMimeData() with a null pointer, * but when that happens in the Android plugin we just return * without doing anything.' */ #if defined(Q_OS_ANDROID) clipboard->setMimeData(nullptr); #endif }
void DesignDocumentView::toClipboard() const { QClipboard *clipboard = QApplication::clipboard(); auto data = new QMimeData; data->setText(toText()); QStringList imports; foreach (const Import &import, model()->imports()) imports.append(import.toImportString()); data->setData(QLatin1String("QmlDesigner::imports"), stringListToArray(imports)); clipboard->setMimeData(data); }
void Clipboard::pushDataToClipboard(const QList<NodeInfo> &nodesData, const QList<EdgeInfo> &edgesData) { QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); stream << nodesData; stream << edgesData; QMimeData *mimeData = new QMimeData(); mimeData->setData(DEFAULT_MIME_TYPE, data); QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData); }
void ResultsJsInterface::pushToClipboard(const QString &mimeType, const QString &data, const QString &html) { QMimeData *mimeData = new QMimeData(); if (mimeType == "text/plain") mimeData->setText(data); if ( ! html.isEmpty()) mimeData->setHtml(html); QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(mimeData, QClipboard::Clipboard); }
void DirTreeView::copyToClipboard(bool copy) { qDebug() << "copyToClipboard()"; QList<QUrl> urlList(selectedUrlList()); if (urlList.size() == 0) return; UrlListMimeData* mime = new UrlListMimeData(copy ? UrlListMimeData::CopyAction : UrlListMimeData::CutAction); mime->setList(urlList); QClipboard* clipboard = QApplication::clipboard(); clipboard->setMimeData(mime); }
void QXmlTreeView::copyCurrentNode() { QXmlTreeModel* treeModel = static_cast<QXmlTreeModel*>(model()); if (!treeModel) return; QString data; QTextStream stream(&data); QDomDocument document("Paste"); QXmlTreeNode* xmlNode = treeModel->rootNode(); if (currentIndex().isValid()) xmlNode = static_cast<QXmlTreeNode*>(currentIndex().internalPointer()); document.appendChild(xmlNode->xmlNode().cloneNode()); document.save(stream,4); QClipboard* clipboard = QApplication::clipboard(); QMimeData* mime = new QMimeData(); mime->setData("text/plain", data.toUtf8()); clipboard->setMimeData(mime); }
void CmdCopy::cmdRedo () { LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdRedo"; MimePoints *mimePoints; if (m_transformIsDefined) { mimePoints = new MimePoints (m_csv, m_html); } else { mimePoints = new MimePoints (m_csv); } QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData (mimePoints, QClipboard::Clipboard); document().updatePointOrdinals (mainWindow().transformation()); mainWindow().updateAfterCommand(); }
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 ezQtPropertyWidget::ExtendContextMenu(QMenu& m) { // revert { QAction* pRevert = m.addAction("Revert to Default"); pRevert->setEnabled(!m_bIsDefault); connect(pRevert, &QAction::triggered, this, [this]() { m_pObjectAccessor->StartTransaction("Revert to Default"); for (const ezPropertySelection& sel : m_Items) { ezVariant defaultValue = m_pGrid->GetDocument()->GetDefaultValue(sel.m_pObject, m_pProp->GetPropertyName()); // If the default value of a map entry is invalid, we assume the key should not exist and remove it. if (m_pProp->GetCategory() == ezPropertyCategory::Map && !defaultValue.IsValid()) { m_pObjectAccessor->RemoveValue(sel.m_pObject, m_pProp, sel.m_Index); } else { m_pObjectAccessor->SetValue(sel.m_pObject, m_pProp, defaultValue, sel.m_Index); } } m_pObjectAccessor->FinishTransaction(); }); } // copy internal name { auto lambda = [this]() { QClipboard* clipboard = QApplication::clipboard(); QMimeData* mimeData = new QMimeData(); mimeData->setText(m_pProp->GetPropertyName()); clipboard->setMimeData(mimeData); }; QAction* pAction = m.addAction("Copy Internal Property Name:"); connect(pAction, &QAction::triggered, this, lambda); QAction* pAction2 = m.addAction(m_pProp->GetPropertyName()); connect(pAction2, &QAction::triggered, this, lambda); } }