/* ** Copyright (C) 2013 Jiří Procházka (Hobrasoft) ** Contact: http://www.hobrasoft.cz/ ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file is under the terms of the GNU Lesser General Public License ** version 2.1 as published by the Free Software Foundation and appearing ** in the file LICENSE.LGPL included in the packaging of this file. ** Please review the following information to ensure the ** GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ */ // clazy:excludeall=qstring-arg #include "PreCompiled.h" #ifndef _PreComp_ # include # include # include # include # include #endif #include "mtextedit.h" MTextEdit::MTextEdit(QWidget *parent) : QTextEdit(parent) { } bool MTextEdit::canInsertFromMimeData(const QMimeData *source) const { return source->hasImage() || QTextEdit::canInsertFromMimeData(source); } void MTextEdit::insertFromMimeData(const QMimeData *source) { if (source->hasImage()) { QStringList formats = source->formats(); QString format; for (int i=0; i(source->imageData()), format); dropImage(qvariant_cast(source->imageData()), QString::fromLatin1("JPG")); // Sorry, ale cokoli jiného dlouho trvá return; } } QTextEdit::insertFromMimeData(source); } QMimeData *MTextEdit::createMimeDataFromSelection() const { return QTextEdit::createMimeDataFromSelection(); } void MTextEdit::dropImage(const QImage& image, const QString& format) { QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); image.save(&buffer, format.toLocal8Bit().data()); buffer.close(); QByteArray base64 = bytes.toBase64(); QByteArray base64l; for (int i=0; i