Thanks, Abdel, for doing this. It'll make a big difference for a lot of people. Including me.

rh

[EMAIL PROTECTED] wrote:
Author: younes
Date: Sun Sep 30 22:28:15 2007
New Revision: 20617

URL: http://www.lyx.org/trac/changeset/20617
Log:
Fix slowness issue with Clipboard. Cache the Clipboard status when the data is 
changed.

Modified:
    lyx-devel/trunk/src/frontends/qt4/GuiClipboard.cpp
    lyx-devel/trunk/src/frontends/qt4/GuiClipboard.h
    lyx-devel/trunk/src/frontends/qt4/Makefile.am

Modified: lyx-devel/trunk/src/frontends/qt4/GuiClipboard.cpp
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiClipboard.cpp?rev=20617
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiClipboard.cpp (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiClipboard.cpp Sun Sep 30 22:28:15 2007
@@ -35,6 +35,15 @@
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
 {
@@ -110,16 +119,27 @@
 }
+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"

Modified: lyx-devel/trunk/src/frontends/qt4/GuiClipboard.h
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiClipboard.h?rev=20617
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiClipboard.h (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiClipboard.h Sun Sep 30 22:28:15 2007
@@ -16,15 +16,19 @@
#include "frontends/Clipboard.h" +#include <QObject>
+
 namespace lyx {
 namespace frontend {
/**
  * The Qt4 version of the Clipboard.
  */
-class GuiClipboard : public Clipboard
+class GuiClipboard: public QObject, public Clipboard
 {
+       Q_OBJECT
 public:
+       GuiClipboard();
        virtual ~GuiClipboard() {}
/** Clipboard overloaded methods
@@ -37,6 +41,13 @@
        bool isInternal() const;
        bool empty() const;
        //@}
+
+private Q_SLOTS:
+       void on_dataChanged();
+
+private:
+       bool text_clipboard_empty_;
+       bool has_lyx_contents_;
 };
} // namespace frontend

Modified: lyx-devel/trunk/src/frontends/qt4/Makefile.am
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/Makefile.am?rev=20617
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/Makefile.am (original)
+++ lyx-devel/trunk/src/frontends/qt4/Makefile.am Sun Sep 30 22:28:15 2007
@@ -117,7 +117,6 @@
NOMOCHEADER = \
        ButtonController.h \
-       GuiClipboard.h \
        GuiFontLoader.h \
        GuiFontMetrics.h \
        GuiSelection.h \
@@ -143,6 +142,7 @@
        GuiChanges.h \
        GuiCharacter.h \
        GuiCitation.h \
+       GuiClipboard.h \
        GuiCommandBuffer.h \
        GuiCommandEdit.h \
        GuiDelimiter.h \


_______________________________________________
Cvslog mailing list
[EMAIL PROTECTED]
http://www.lyx.org/mailman/listinfo/cvslog

Reply via email to