From 2ab77c16f64b5e966c351f4d7a544e4892825127 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 10 Mar 2008 15:30:32 +0000 Subject: [PATCH] Introduce Inset::isLabeled() in order to avoid reimplementing Inset::initView() everywhere we need a labels update. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23637 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/Inset.cpp | 8 ++++++++ src/insets/Inset.h | 9 +++++++-- src/insets/InsetBibitem.h | 2 ++ src/insets/InsetCitation.cpp | 8 -------- src/insets/InsetCitation.h | 2 +- src/insets/InsetLabel.h | 3 +++ src/insets/InsetListings.h | 2 ++ src/insets/InsetRef.cpp | 9 --------- src/insets/InsetRef.h | 7 ++----- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 7cc726876a..9c4b014bee 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -16,6 +16,7 @@ #include "Inset.h" +#include "buffer_funcs.h" #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" @@ -150,6 +151,13 @@ docstring Inset::name() const } +void Inset::initView() +{ + if (isLabeled()) + lyx::updateLabels(buffer()); +} + + docstring Inset::toolTip(BufferView const &, int, int) const { return docstring(); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 1f3e911497..f6a427ddb5 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -101,9 +101,14 @@ public: /** * This is typically used after this inset is created interactively. * Intented purpose is to sanitize internal state with regard to current - * Buffer. + * Buffer. The default implementation calls updateLabels(buffer()) is + * the inset is labeled. + * + * \sa isLabeled() **/ - virtual void initView() {} + virtual void initView(); + /// \return true if this inset is labeled. + virtual bool isLabeled() const { return false; } /// identification as math inset virtual InsetMath * asInsetMath() { return 0; } diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index c48bc17b68..44adc6b1ef 100644 --- a/src/insets/InsetBibitem.h +++ b/src/insets/InsetBibitem.h @@ -34,6 +34,8 @@ public: **/ void initView(); /// + bool isLabeled() const { return true; } + /// void read(Lexer & lex); /// docstring screenLabel() const; diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index bd149a61cf..c4effad34e 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -386,14 +386,6 @@ InsetCitation::InsetCitation(InsetCommandParams const & p) {} -void InsetCitation::initView() -{ - // We need an update of the Buffer reference cache. This is achieved by - // updateLabel(). - lyx::updateLabels(buffer()); -} - - ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */) { // standard cite does only take one argument if jurabib is diff --git a/src/insets/InsetCitation.h b/src/insets/InsetCitation.h index 440e3a185a..85f3f0ae22 100644 --- a/src/insets/InsetCitation.h +++ b/src/insets/InsetCitation.h @@ -30,7 +30,7 @@ public: /// InsetCitation(InsetCommandParams const &); /// - void initView(); + bool isLabeled() const { return true; } /// docstring screenLabel() const; /// diff --git a/src/insets/InsetLabel.h b/src/insets/InsetLabel.h index 3ab79b6f28..d7daae3461 100644 --- a/src/insets/InsetLabel.h +++ b/src/insets/InsetLabel.h @@ -28,6 +28,9 @@ public: **/ void initView(); + /// + bool isLabeled() const { return true; } + /// docstring screenLabel() const; /// diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 736d1822fb..13efb881d1 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -31,6 +31,8 @@ public: /// ~InsetListings(); /// + bool isLabeled() const { return true; } + /// InsetCode lyxCode() const { return LISTINGS_CODE; } /// lstinline is inlined, normal listing is displayed DisplayType display() const; diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 82821a61b1..b62839c162 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -12,7 +12,6 @@ #include "InsetRef.h" #include "Buffer.h" -#include "buffer_funcs.h" #include "Cursor.h" #include "DispatchResult.h" #include "FuncRequest.h" @@ -43,14 +42,6 @@ InsetRef::InsetRef(InsetRef const & ir) {} -void InsetRef::initView() -{ - // We need an update of the Buffer reference cache. This is achieved by - // updateLabel(). - lyx::updateLabels(buffer()); -} - - bool InsetRef::isCompatibleCommand(string const & s) { //FIXME This is likely not the best way to handle this. //But this stuff is hardcoded elsewhere already. diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index da4a176dbc..1af31fa3f8 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -38,11 +38,8 @@ public: InsetRef(Buffer const & buffer, InsetCommandParams const &); - /// verify label and reference. - /** - * Overloaded from Inset::initView. - **/ - void initView(); + /// + bool isLabeled() const { return true; } /// docstring screenLabel() const; /// -- 2.39.2