Fix enabling of LFUN_PRIMARY_SELECTION_PASTE: It was always disabled, because

we don't set the selection with qApp->clipboard()->put().
Therefore we get the status of the internal selection from the cursor, and
the empty flag for fake selections is not needed anymore.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16610 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2007-01-08 18:37:40 +00:00
parent ba57568a72
commit a683072ea0
4 changed files with 5 additions and 16 deletions

View File

@ -59,8 +59,8 @@ public:
virtual void put(docstring const &) = 0;
/**
* Is the X selection empty?
* This reports only the state of the internal selection on systems
* that don't have a real selection.
* This does always return true on systems that don't have a real
* selection.
*/
virtual bool empty() const = 0;
};

View File

@ -32,10 +32,8 @@ namespace frontend {
void GuiSelection::haveSelection(bool own)
{
if (!qApp->clipboard()->supportsSelection()) {
empty_ = !own;
if (!qApp->clipboard()->supportsSelection())
return;
}
// Tell qt that we have a selection by setting a dummy selection.
// We don't use the interface provided by Qt for setting the
@ -82,7 +80,7 @@ void GuiSelection::put(docstring const & str)
bool GuiSelection::empty() const
{
if (!qApp->clipboard()->supportsSelection())
return empty_;
return true;
return qApp->clipboard()->text(QClipboard::Selection).isEmpty();
}

View File

@ -25,7 +25,6 @@ namespace frontend {
class GuiSelection: public Selection
{
public:
GuiSelection() : empty_(true) {}
virtual ~GuiSelection() {}
/** Selection overloaded methods
@ -36,14 +35,6 @@ public:
void put(docstring const & str);
bool empty() const;
//@}
private:
/**
* Is the selection empty?
* Only used on systems that don't support a real selection to
* reflect the status of the internal selection of LyX.
* This is needed to emulate the X selection as far as possible.
*/
bool empty_;
};
} // namespace frontend

View File

@ -1757,7 +1757,7 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
break;
case LFUN_PRIMARY_SELECTION_PASTE:
enable = !theSelection().empty();
enable = cur.selection() || !theSelection().empty();
break;
case LFUN_PARAGRAPH_MOVE_UP: