namespace lyx {
namespace frontend {
+GuiSelection::GuiSelection()
+ : selection_supported_(qApp->clipboard()->supportsSelection())
+{
+ connect(qApp->clipboard(), SIGNAL(dataChanged()),
+ this, SLOT(on_dataChanged()));
+ // initialize clipboard status.
+ on_dataChanged();
+}
+
+
void GuiSelection::haveSelection(bool own)
{
if (!qApp->clipboard()->supportsSelection())
}
+void GuiSelection::on_dataChanged()
+{
+ text_selection_empty_ = qApp->clipboard()->
+ text(QClipboard::Selection).isEmpty();
+}
+
+
bool GuiSelection::empty() const
{
- if (!qApp->clipboard()->supportsSelection())
+ if (!selection_supported_)
return true;
- return qApp->clipboard()->text(QClipboard::Selection).isEmpty();
+ return text_selection_empty_;
}
} // namespace frontend
} // namespace lyx
+
+#include "GuiSelection_moc.cpp"
#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
void put(docstring const & str);
bool empty() const;
//@}
+
+private Q_SLOTS:
+ void on_dataChanged();
+
+private:
+ bool text_selection_empty_;
+ bool const selection_supported_;
};
} // namespace frontend