#include <QString>
#include "support/lstrings.h"
+
using lyx::support::internalLineEnding;
using lyx::support::externalLineEnding;
namespace lyx {
namespace frontend {
+GuiClipboard::GuiClipboard()
+{
+ connect(qApp->clipboard(), SIGNAL(dataChanged()),
+ this, SLOT(on_dataChanged()));
+ // initialize clipboard status.
+ on_dataChanged();
+}
+
+
string const GuiClipboard::getAsLyX() const
{
- LYXERR(Debug::ACTION) << "GuiClipboard::getAsLyX(): `";
+ LYXERR(Debug::ACTION, "GuiClipboard::getAsLyX(): `");
// We don't convert encodings here since the encoding of the
// clipboard contents is specified in the data itself
QMimeData const * source =
qApp->clipboard()->mimeData(QClipboard::Clipboard);
if (!source) {
- LYXERR(Debug::ACTION) << "' (no QMimeData)" << endl;
+ LYXERR(Debug::ACTION, "' (no QMimeData)");
return string();
}
if (source->hasFormat(mime_type)) {
// data from ourself or some other LyX instance
QByteArray const ar = source->data(mime_type);
string const s(ar.data(), ar.count());
- LYXERR(Debug::ACTION) << s << "'" << endl;
+ LYXERR(Debug::ACTION, s << "'");
return s;
}
- LYXERR(Debug::ACTION) << "'" << endl;
+ LYXERR(Debug::ACTION, "'");
return string();
}
{
// text data from other applications
QString const str = qApp->clipboard()->text(QClipboard::Clipboard)
- .normalized(QString::NormalizationForm_KC);
- LYXERR(Debug::ACTION) << "GuiClipboard::getAsText(): `"
- << fromqstr(str) << "'" << endl;
+ .normalized(QString::NormalizationForm_C);
+ LYXERR(Debug::ACTION, "GuiClipboard::getAsText(): `" << fromqstr(str) << "'");
if (str.isNull())
return docstring();
void GuiClipboard::put(string const & lyx, docstring const & text)
{
- LYXERR(Debug::ACTION) << "GuiClipboard::put(`" << lyx << "' `"
- << to_utf8(text) << "')" << endl;
+ LYXERR(Debug::ACTION, "GuiClipboard::put(`" << lyx << "' `"
+ << to_utf8(text) << "')");
// We don't convert the encoding of lyx since the encoding of the
// clipboard contents is specified in the data itself
QMimeData * data = new QMimeData;
}
+void GuiClipboard::on_dataChanged()
+{
+ text_clipboard_empty_ = qApp->clipboard()->
+ text(QClipboard::Clipboard).isEmpty();
+
+ has_lyx_contents_ = hasLyXContents();
+}
+
+
bool GuiClipboard::empty() const
{
// We need to check both the plaintext and the LyX version of the
// clipboard. The plaintext version is empty if the LyX version
- // contains only one inset, and the LyX version is empry if the
+ // contains only one inset, and the LyX version is empty if the
// clipboard does not come from LyX.
- if (!qApp->clipboard()->text(QClipboard::Clipboard).isEmpty())
+ if (!text_clipboard_empty_)
return false;
- return !hasLyXContents();
+ return !has_lyx_contents_;
}
} // namespace frontend
} // namespace lyx
+
+#include "GuiClipboard_moc.cpp"