namespace lyx {
namespace frontend {
-using support::internalLineEnding;
-using support::externalLineEnding;
-
GuiSelection::GuiSelection()
- : selection_supported_(qApp->clipboard()->supportsSelection())
+ : schedule_check_(true),
+ selection_supported_(qApp->clipboard()->supportsSelection())
{
connect(qApp->clipboard(), SIGNAL(selectionChanged()),
this, SLOT(on_dataChanged()));
- // initialize clipboard status.
- on_dataChanged();
}
void GuiSelection::haveSelection(bool own)
{
- if (!qApp->clipboard()->supportsSelection())
+ if (!selection_supported_)
return;
// Tell qt that we have a selection by setting a dummy selection.
if (str.isNull())
return docstring();
- return internalLineEnding(qstring_to_ucs4(str));
+ return internalLineEnding(str);
}
{
LYXERR(Debug::SELECTION, "GuiSelection::put: " << to_utf8(str));
- qApp->clipboard()->setText(toqstr(externalLineEnding(str)),
+ qApp->clipboard()->setText(externalLineEnding(str),
QClipboard::Selection);
}
if (!selection_supported_)
return true;
- bool text_selection_empty;
+ // Cache which is to speed up selection-status read
+ // (4 calls when open Edit menu).
+ static bool text_selection_empty;
if (schedule_check_) {
text_selection_empty = qApp->clipboard()->
text(QClipboard::Selection).isEmpty();
} // namespace frontend
} // namespace lyx
-#include "GuiSelection_moc.cpp"
+#include "moc_GuiSelection.cpp"