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:
Abdelrazak Younes 2008-06-05 16:03:08 +00:00
parent 6e4494b9b7
commit ccea2a5cd9
4 changed files with 23 additions and 17 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -39,10 +39,6 @@ public:
private Q_SLOTS:
void on_closePB_clicked();
private:
///
InsetInfo * inset() const;
};
} // namespace frontend