]> git.lyx.org Git - features.git/commitdiff
Introduce Inset::isLabeled() in order to avoid reimplementing Inset::initView() every...
authorAbdelrazak Younes <younes@lyx.org>
Mon, 10 Mar 2008 15:30:32 +0000 (15:30 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 10 Mar 2008 15:30:32 +0000 (15:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23637 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetBibitem.h
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetLabel.h
src/insets/InsetListings.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h

index 7cc726876a6695ad7253f9c695155fa211ef7f88..9c4b014bee12dcd148c8497aed9e66048fb105d0 100644 (file)
@@ -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();
index 1f3e9114979a56224cd2093c881eb4c1bbae4a91..f6a427ddb5a67759b83c8984f57927a036abeaaf 100644 (file)
@@ -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; }
index c48bc17b688c950ed1d88a750e2f0243db5826c9..44adc6b1ef6cc4c5758215f101fcad16faad11a6 100644 (file)
@@ -34,6 +34,8 @@ public:
          **/
        void initView();
        ///
+       bool isLabeled() const { return true; }
+       ///
        void read(Lexer & lex);
        ///
        docstring screenLabel() const;
index bd149a61cf3d396fe1e4f11ad5185ae383f0e7c5..c4effad34ef604e4e7aae084655a06f75c5ccc1b 100644 (file)
@@ -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
index 440e3a185abfaf4fd52d5668b9798f91fe550998..85f3f0ae22167621daa8fe90af23c43ca02d3600 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        InsetCitation(InsetCommandParams const &);
        ///
-       void initView();
+       bool isLabeled() const { return true; }
        ///
        docstring screenLabel() const;
        ///
index 3ab79b6f2825c7194d573d6573738325c7d0079d..d7daae3461973d6c91172236ff4d13fcefdc75f1 100644 (file)
@@ -28,6 +28,9 @@ public:
          **/
        void initView();
 
+       ///
+       bool isLabeled() const { return true; }
+
        ///
        docstring screenLabel() const;
        ///
index 736d1822fb4bac6c8ce5883313df0224c5df26b8..13efb881d15ef15c05816fb578d720601a583615 100644 (file)
@@ -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;
index 82821a61b1ee4ec827b0b721b4a6be3db03d88b8..b62839c162b1da7b67da76f37554d0b6500fd29d 100644 (file)
@@ -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.
index da4a176dbc051df568d83b74b62641efe440844c..1af31fa3f808d904b3fe7e8d55349bc436cbcf0f 100644 (file)
@@ -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;
        ///