#include <config.h>
+#include "GuiApplication.h"
#include "GuiClipboard.h"
#include "Buffer.h"
#include "frontends/alert.h"
+#include "support/checksum.h"
+
#include <QApplication>
#include <QBuffer>
#include <QClipboard>
#include <QTextDocument>
#include <QTimer>
-#include <boost/crc.hpp>
-
#include <memory>
#include <map>
#include <iostream>
{
connect(qApp->clipboard(), SIGNAL(dataChanged()),
this, SLOT(on_dataChanged()));
+ if(qApp->clipboard()->supportsFindBuffer()) {
+ connect(qApp->clipboard(), SIGNAL(findBufferChanged()),
+ this, SLOT(on_findChanged()));
+ on_findChanged();
+ }
// initialize clipboard status.
update();
}
if (cache_.hasFormat(lyxMimeType())) {
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(lyxMimeType());
- string const s(ar.data(), ar.count());
+ string const s(ar.data(), ar.size());
LYXERR(Debug::CLIPBOARD, s << "'");
return s;
}
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(mime);
LYXERR(Debug::CLIPBOARD, "Getting from clipboard: mime = " << mime.constData()
- << "length = " << ar.count());
+ << "length = " << ar.size());
QFile f(toqstr(filename.absFileName()));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
* Since we are going to write a HTML file for external converters we need
* to ensure that it is a well formed HTML file, including all the mentioned tags.
*/
-QString tidyHtml(QString input)
+QString tidyHtml(QString const & input)
{
// Misuse QTextDocument to cleanup the HTML.
// As a side effect, all visual markup like <tt> is converted to CSS,
// clutter.
QTextDocument converter;
converter.setHtml(input);
+#if QT_VERSION < 0x060000
return converter.toHtml("utf-8");
+#else
+ return converter.toHtml();
+#endif
}
} // namespace
data->setData(lyxMimeType(), qlyx);
// If the OS has not the concept of clipboard ownership,
// we recognize internal data through its checksum.
- if (!hasInternal()) {
- boost::crc_32_type crc32;
- crc32.process_bytes(lyx.c_str(), lyx.size());
- checksum = crc32.checksum();
- }
+ if (!hasInternal())
+ checksum = support::checksum(lyx);
}
// Don't test for text.empty() since we want to be able to clear the
// clipboard.
// We are running on OS X: Check whether clipboard data is from
// ourself by comparing its checksum with the stored one.
QByteArray const ar = cache_.data(lyxMimeType());
- string const data(ar.data(), ar.count());
- boost::crc_32_type crc32;
- crc32.process_bytes(data.c_str(), data.size());
- return checksum == crc32.checksum();
+ string const data(ar.data(), ar.size());
+ return checksum == static_cast<std::uint32_t>(support::checksum(data));
}
}
+void GuiClipboard::setFindBuffer(docstring const & text)
+{
+ LYXERR(Debug::CLIPBOARD, "new findbuffer: " << text);
+ Clipboard::setFindBuffer(text);
+ if(qApp->clipboard()->supportsFindBuffer()) {
+ qApp->clipboard()->setText(toqstr(text), QClipboard::FindBuffer);
+ }
+}
+
+
+void GuiClipboard::on_findChanged()
+{
+ Clipboard::setFindBuffer(from_utf8(fromqstr(
+ qApp->clipboard()->text(QClipboard::FindBuffer))));
+}
+
+
void GuiClipboard::on_dataChanged()
{
update();