Am Mittwoch, 3. Januar 2007 12:33 schrieb Abdelrazak Younes: > It was easy so I've done it. It works quite well. Could you please it on > X11 and verify that I did not miss something?
What I don't like is that you used the fake selection even if on systems that have a real one. That is aginst the "simple mental model": If the selection is empty, then it is empty, and the middle mouse button does not paste anything. What I had in mind was rather something like the attached. I also like the fact that I don't need to make selection_ mutable. > In particular I think > there's nothing to do in haveSelection() but I am not sure of that. I am not sure either, but I think you are right. Georg
Index: src/frontends/qt4/GuiSelection.C =================================================================== --- src/frontends/qt4/GuiSelection.C (Revision 16478) +++ src/frontends/qt4/GuiSelection.C (Arbeitskopie) @@ -15,6 +15,8 @@ #include "GuiSelection.h" #include "qt_helpers.h" +#include "frontends/Clipboard.h" + #include "debug.h" #include <QApplication> @@ -44,6 +46,12 @@ void GuiSelection::haveSelection(bool ow docstring const GuiSelection::get() const { + if (!qApp->clipboard()->supportsSelection()) { + if (!selection_.empty()) + return selection_; + return theClipboard().get(); + } + QString const str = qApp->clipboard()->text(QClipboard::Selection); lyxerr[Debug::ACTION] << "GuiSelection::get: " << fromqstr(str) << endl; @@ -56,17 +64,18 @@ docstring const GuiSelection::get() cons void GuiSelection::put(docstring const & str) { - lyxerr[Debug::ACTION] << "GuiSelection::put: " << lyx::to_utf8(str) << endl; + lyxerr[Debug::ACTION] << "GuiSelection::put: " << to_utf8(str) << endl; + + // Store the string for further use within LyX and for platform + // that do not support the Selection concept. + if (!qApp->clipboard()->supportsSelection()) { + selection_ = str; + return; + } qApp->clipboard()->setText(toqstr(externalLineEnding(str)), QClipboard::Selection); } - -bool GuiSelection::isInternal() const -{ - return qApp->clipboard()->ownsSelection(); -} - } // namespace frontend } // namespace lyx Index: src/frontends/qt4/GuiSelection.h =================================================================== --- src/frontends/qt4/GuiSelection.h (Revision 16478) +++ src/frontends/qt4/GuiSelection.h (Arbeitskopie) @@ -33,8 +33,10 @@ public: void haveSelection(bool own); docstring const get() const; void put(docstring const & str); - bool isInternal() const; //@} +private: + /// Emulated selection for platforms that don't have a real one + docstring selection_; }; } // namespace frontend Index: src/frontends/Selection.h =================================================================== --- src/frontends/Selection.h (Revision 16478) +++ src/frontends/Selection.h (Arbeitskopie) @@ -43,10 +43,6 @@ public: * This should be called whenever some text is highlighted. */ virtual void put(docstring const &) = 0; - - /// state of clipboard. - /// \retval true if the system clipboard has been set within LyX. - virtual bool isInternal() const = 0; }; } // namespace frontend