mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Move inset lookup to Dialog class as this is generic enough to be reused by other dialogs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25147 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6e4494b9b7
commit
ccea2a5cd9
@ -16,10 +16,14 @@
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "Cursor.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "LyXFunc.h"
|
||||
|
||||
#include "insets/Inset.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
@ -204,6 +208,17 @@ bool Dialog::isVisibleView() const
|
||||
}
|
||||
|
||||
|
||||
Inset * Dialog::inset(InsetCode code) const
|
||||
{
|
||||
Inset * ins = bufferview()->cursor().innerInsetOfType(code);
|
||||
if (!ins)
|
||||
ins = bufferview()->cursor().nextInset();
|
||||
if (!ins || ins->lyxCode() != code)
|
||||
return 0;
|
||||
return ins;
|
||||
}
|
||||
|
||||
|
||||
void Dialog::checkStatus()
|
||||
{
|
||||
// buffer independant dialogs are always active.
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "FuncCode.h"
|
||||
|
||||
#include "insets/InsetCode.h"
|
||||
|
||||
#include "support/strfwd.h"
|
||||
|
||||
#include <QString>
|
||||
@ -25,6 +27,7 @@ namespace lyx {
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
class FuncRequest;
|
||||
class Inset;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -89,6 +92,9 @@ public:
|
||||
virtual void showData(std::string const & data);
|
||||
//@}
|
||||
|
||||
/// \return inset at current cursor location.
|
||||
Inset * inset(InsetCode code) const;
|
||||
|
||||
/** Check whether we may apply our data.
|
||||
*
|
||||
* The buttons are disabled if not and (re-)enabled if yes.
|
||||
|
@ -50,20 +50,9 @@ void GuiInfo::on_closePB_clicked()
|
||||
}
|
||||
|
||||
|
||||
InsetInfo * GuiInfo::inset() const
|
||||
{
|
||||
Inset * ins = bufferview()->cursor().innerInsetOfType(INFO_CODE);
|
||||
if (!ins)
|
||||
ins = bufferview()->cursor().nextInset();
|
||||
if (ins->lyxCode() != INFO_CODE)
|
||||
return 0;
|
||||
return static_cast<InsetInfo *>(ins);
|
||||
}
|
||||
|
||||
|
||||
void GuiInfo::applyView()
|
||||
{
|
||||
InsetInfo * ii = inset();
|
||||
InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
|
||||
if (!ii)
|
||||
return;
|
||||
|
||||
@ -77,7 +66,7 @@ void GuiInfo::applyView()
|
||||
|
||||
void GuiInfo::updateView()
|
||||
{
|
||||
InsetInfo * ii = inset();
|
||||
InsetInfo * ii = static_cast<InsetInfo *>(inset(INFO_CODE));
|
||||
if (!ii) {
|
||||
// FIXME: A New button to create an InsetInfo at the cursor location
|
||||
// would be nice.
|
||||
|
@ -39,10 +39,6 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_closePB_clicked();
|
||||
|
||||
private:
|
||||
///
|
||||
InsetInfo * inset() const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user