void QMimeOnDesktop::setData(const QByteArray &data)
{
    QTemporaryFile temp(QDir::tempPath() + "/po_file_temp_XXXXXX"+(ext.isNull() ? "":"."+ext));
    temp.open();
    path = temp.fileName();
    this->data = data;
    setUrls(QList<QUrl>() << QUrl::fromLocalFile(path));
}
Exemple #2
0
void parseUrlAndGo(QString url) {
    if (url.startsWith(CONNECT_PREFIX) && url.endsWith(CONNECT_SUFFIX)) {
        url.remove(0, CONNECT_PREFIX.size());
        url.remove(-CONNECT_SUFFIX.size(), CONNECT_SUFFIX.size());
    }

    qDebug() << "Joining Steam Friend at:" << url;
    auto mimeData = new QMimeData();
    mimeData->setUrls(QList<QUrl>() << QUrl(url));
    auto event = new QDropEvent(QPointF(0, 0), Qt::MoveAction, mimeData, Qt::LeftButton, Qt::NoModifier);

    QCoreApplication::postEvent(qApp, event);
}
	QMimeData* LocalCollectionModel::mimeData (const QModelIndexList& indexes) const
	{
		QList<QUrl> urls;
		for (const auto& index : indexes)
			urls += Util::Map (CollectPaths (index, this), &QUrl::fromLocalFile);

		if (urls.isEmpty ())
			return nullptr;

		auto result = new QMimeData;
		result->setUrls (urls);
		return result;
	}
	QMimeData* LocalCollectionModel::mimeData (const QModelIndexList& indexes) const
	{
		QList<QUrl> urls;
		for (const auto& index : indexes)
		{
			const auto& paths = CollectPaths (index, this);
			std::transform (paths.begin (), paths.end (), std::back_inserter (urls),
					[] (const QString& path) { return QUrl::fromLocalFile (path); });
		}
		if (urls.isEmpty ())
			return nullptr;

		auto result = new QMimeData;
		result->setUrls (urls);
		return result;
	}
/*!
  Creates an object to drag the list of urls in \a urls.
  The \a dragSource and \a name arguments are passed on to
  QStoredDrag.
*/
QUrlDrag::QUrlDrag( QStrList urls,
	    QWidget * dragSource, const char * name ) :
    QStoredDrag( "url/url", dragSource, name )
{
    setUrls(urls);
}