mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix slowness issue with Clipboard. Cache the Clipboard status when the data is changed.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20617 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dba88f4ae6
commit
e3e83d1c65
@ -36,6 +36,15 @@ static char const * const mime_type = "application/x-lyx";
|
||||
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
|
||||
{
|
||||
LYXERR(Debug::ACTION) << "GuiClipboard::getAsLyX(): `";
|
||||
@ -110,16 +119,27 @@ bool GuiClipboard::isInternal() const
|
||||
}
|
||||
|
||||
|
||||
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"
|
||||
|
@ -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 @@ public:
|
||||
bool isInternal() const;
|
||||
bool empty() const;
|
||||
//@}
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_dataChanged();
|
||||
|
||||
private:
|
||||
bool text_clipboard_empty_;
|
||||
bool has_lyx_contents_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -117,7 +117,6 @@ SOURCEFILES = \
|
||||
|
||||
NOMOCHEADER = \
|
||||
ButtonController.h \
|
||||
GuiClipboard.h \
|
||||
GuiFontLoader.h \
|
||||
GuiFontMetrics.h \
|
||||
GuiSelection.h \
|
||||
@ -143,6 +142,7 @@ MOCHEADER = \
|
||||
GuiChanges.h \
|
||||
GuiCharacter.h \
|
||||
GuiCitation.h \
|
||||
GuiClipboard.h \
|
||||
GuiCommandBuffer.h \
|
||||
GuiCommandEdit.h \
|
||||
GuiDelimiter.h \
|
||||
|
Loading…
Reference in New Issue
Block a user