]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSelection.h
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiSelection.h
index 8ffed6d32628eeb7ac52604f42ddbc20a0db0b0a..1567b3e697f5f4734e6bcae98fa30542270686d2 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef SELECTION_H
-#define SELECTION_H
+#ifndef GUISELECTION_H
+#define GUISELECTION_H
 
 #include "frontends/Selection.h"
 
+#include <QObject>
+
 namespace lyx {
 namespace frontend {
 
 /**
  * The Qt4 version of the Selection.
  */
-class GuiSelection: public Selection
+class GuiSelection : public QObject, public Selection
 {
+       Q_OBJECT
 public:
+       GuiSelection();
        virtual ~GuiSelection() {}
 
        /** Selection overloaded methods
@@ -35,9 +39,23 @@ public:
        void put(docstring const & str);
        bool empty() const;
        //@}
+
+private Q_SLOTS:
+       void on_dataChanged();
+
+private:
+       // Direct call clipboard()->text(QClipboard::Selection) inside onDataChanged causes
+       // selection to be obtained. Now imagine the some LyX instance A, when making selection -
+       // each change triggers onDataChange in all others instances for each mouse
+       // or keyboard move. This in turn causes many calls of requestSelection in A
+       // which interferes with the selecting itself. As a result middle button pasting
+       // for more instances don't work and debugging is a hell. So we just schedule
+       // obtaining of selection on the time empty() is actually called.
+       mutable bool schedule_check_;
+       bool const selection_supported_;
 };
 
 } // namespace frontend
 } // namespace lyx
 
-#endif // SELECTION_H
+#endif // GUISELECTION_H