]> git.lyx.org Git - features.git/commitdiff
Introduce groups for graphics insets. That includes:
authorPavel Sanda <sanda@lyx.org>
Tue, 6 May 2008 21:13:09 +0000 (21:13 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 6 May 2008 21:13:09 +0000 (21:13 +0000)
- GuiGraphics dialog field for setup new groups.
- Graphics context menu for assigning to certain group.
- Fileformat change for groupId field in Graphics inset.
- Undo mechanism added to inset-apply, for catching changes
  in preference dialog.
- Qt designer 4.4 used now.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24644 a592a061-630c-0410-9148-cb99ea01b6c8

17 files changed:
development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
lib/ui/stdcontext.inc
src/Buffer.cpp
src/FuncCode.h
src/LyXAction.cpp
src/LyXFunc.cpp
src/Text3.cpp
src/frontends/qt4/GuiGraphics.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Menus.cpp
src/frontends/qt4/ui/GraphicsUi.ui
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetGraphicsParams.cpp
src/insets/InsetGraphicsParams.h

index 4a957b527e4160c1028152c838761744912b6894..aba24ce1905cf3e05a8ae18a27abdc2c26e267e9 100644 (file)
@@ -1,5 +1,7 @@
 LyX file-format changes
 -----------------------
+2008-05-06 Pavel Sanda <sanda@lyx.org>
+       * Format incremented to 332: Added groupId for graphics insets.
 
 2008-25-04 Helge Hafting <helge.hafting@aitel.hist.no>
        * Format incremented to 330: More horizontal fills
index c7bf9b8875ac02b5cbadec4859b57741e0031f0d..2a85e446129f6d4a202d34f424f33d8286241a3f 100644 (file)
@@ -80,7 +80,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_3",     [221], minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), minor_versions("1.4" , 5)),
                    ("1_5", range(246,277), minor_versions("1.5" , 2)),
-                   ("1_6", range(277,332), minor_versions("1.6" , 0))]
+                   ("1_6", range(277,333), minor_versions("1.6" , 0))]
 
 
 def formats_list():
index fc94c6aef5a3eed671cc41d82645dcffdbebc17c..c8bc593777ba2298b8d3c6cf5350bd03da4d1fa8 100644 (file)
@@ -2188,6 +2188,26 @@ def revert_master(document):
         del document.header[i]
 
 
+def revert_graphics_group(document):
+    ' Revert group information from graphics insets '
+    i = 0
+    while 1:
+        i = find_token(document.body, "\\begin_inset Graphics", i)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i)
+        if j == -1:
+            document.warning("Malformed lyx document: Missing '\\end_inset'.")
+            i = i + 1
+            continue
+        k = find_token(document.body, "        groupId", i, j)
+        if k == -1:
+            i = i + 1
+            continue
+        del document.body[k]
+        i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -2248,9 +2268,11 @@ convert = [[277, [fix_wrong_tables]],
            [329, []],
            [330, []],
            [331, [convert_ltcaption]],
+           [332, []],
           ]
 
-revert =  [[330, [revert_ltcaption]],
+revert =  [[331, [revert_graphics_group]],
+           [330, [revert_ltcaption]],
            [329, [revert_leftarrowfill, revert_rightarrowfill, revert_upbracefill, revert_downbracefill]],
            [328, [revert_master]],
            [327, []],
index 58bdf1008e38314a89ecf64487ec01d9ceb4abda..cf801ef70ad6d626c39b7e6e4d478dfcac635da4 100644 (file)
@@ -300,6 +300,7 @@ Menuset
                Item "Settings...|S" "next-inset-toggle"
                Separator
                Item "Edit externally...|x" "inset-edit"
+               GraphicsGroups
        End
 
 #
index 86b93ce9d5a6abcc4e1a9c58ae7702b7cad65d1e..b6e234b7520f5d75069503ae28916c204af5f520 100644 (file)
@@ -115,7 +115,7 @@ namespace os = support::os;
 
 namespace {
 
-int const LYX_FORMAT = 331;
+int const LYX_FORMAT = 332;    //ps, graphgroups
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index 4619551357fee898ec70f8d16f7938a44f2bb3ec..0b51047d759b5e1206851ef18f2ba1efabeb6509 100644 (file)
@@ -409,6 +409,8 @@ enum FuncCode
        LFUN_COMPLETION_COMPLETE,
        // 315
        LFUN_NEXT_INSET_MODIFY,         // JSpitzm 20080323
+       LFUN_GRAPHICS_GROUPS_UNIFY,
+       LFUN_SET_GRAPHICS_GROUP,
        LFUN_LASTACTION                  // end of the table
 };
 
index 2bd439c188927b34ff3a623461f5594b9e84ac9e..d584783b61f76551301c34587d7187ef9ce4966c 100644 (file)
@@ -1239,6 +1239,27 @@ void LyXAction::init()
  * \endvar
  */
                { LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_GRAPHICS_GROUPS_UNIFY
+ * \li Action: Unify all graphics insets with the one given as an parameter.
+ * \li Notion: This is internally used for synchronize certain group of graphics insets.
+ * \li Syntax: graphics-groups-unigfy <GRAPHICS_PARAMS>
+ * \li Params: <GRAPHICS_PARAMS>: Parameters for graphics inset
+                                  (syntax can be seen in .lyx files).
+ * \li Origin: sanda, 6 May 2008
+ * \endvar
+ */
+               { LFUN_GRAPHICS_GROUPS_UNIFY, "graphics-groups-unify", ReadOnly, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_SET_GRAPHICS_GROUP
+ * \li Action: Set the group for the graphics inset on the cursor position.
+ * \li Syntax: set-graphics-group [<GROUP>]
+ * \li Params: <GROUP>: Id for an existing group. In case tthe Id is an empty string,
+                        the graphics inset is removed from the current group.
+ * \li Origin: sanda, 6 May 2008
+ * \endvar
+ */
+               { LFUN_SET_GRAPHICS_GROUP, "set-graphics-group", ReadOnly, Edit },
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_FINISHED_FORWARD
index c5d376686aeaaef58a6f1fdc7f37644516dcf0cb..7bbeba7aef521276c6e4fc9aa6e244291ee83f6f 100644 (file)
@@ -621,6 +621,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_MESSAGE:
        case LFUN_INSET_EDIT:
        case LFUN_ALL_INSETS_TOGGLE:
+       case LFUN_GRAPHICS_GROUPS_UNIFY:
        case LFUN_BUFFER_LANGUAGE:
        case LFUN_TEXTCLASS_APPLY:
        case LFUN_TEXTCLASS_LOAD:
@@ -1462,6 +1463,16 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
                }
 
+               case LFUN_GRAPHICS_GROUPS_UNIFY: {
+                       LASSERT(lyx_view_, /**/);
+                       if (argument.empty() || !lyx_view_->buffer()) break;
+                       //view()->cursor().recordUndoFullDocument(); let inset-apply do that job
+                       InsetGraphics::unifyGraphicsGroups(*lyx_view_->buffer(), argument);
+                       lyx_view_->buffer()->markDirty();
+                       updateFlags = Update::Force | Update::FitCursor;
+                       break;
+               }
+
                case LFUN_BUFFER_LANGUAGE: {
                        LASSERT(lyx_view_, /**/);
                        Buffer & buffer = *lyx_view_->buffer();
index b5bdc3b4ec0816027853d61ae8722b37fcb9e7dc..3dd736b9dd698d399466b69d843bb7d5568cb530 100644 (file)
@@ -57,6 +57,8 @@
 #include "insets/InsetSpecialChar.h"
 #include "insets/InsetText.h"
 #include "insets/InsetInfo.h"
+#include "insets/InsetGraphics.h"
+#include "insets/InsetGraphicsParams.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
@@ -890,6 +892,30 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
+       case LFUN_SET_GRAPHICS_GROUP: {
+               Inset * instmp = &cur.inset();
+               if (instmp->lyxCode() != GRAPHICS_CODE) instmp = cur.nextInset();
+               if (!instmp || instmp->lyxCode() != GRAPHICS_CODE) break;
+
+               cur.recordUndoFullDocument();
+               Inset & inset = *instmp;
+               InsetGraphics & ins = static_cast<InsetGraphics &>(inset);
+
+               string id = to_utf8(cmd.argument());
+               string grp = InsetGraphics::getGroupParams(bv->buffer(), id);
+               InsetGraphicsParams tmp, inspar = ins.getParams();
+
+               if (id.empty())
+                       inspar.groupId = to_utf8(cmd.argument());
+               else {
+                       InsetGraphics::string2params(grp, bv->buffer(), tmp);
+                       tmp.filename = inspar.filename;
+                       inspar = tmp;
+               }
+
+               ins.setParams(inspar);
+       }
+
        case LFUN_SPACE_INSERT:
                if (cur.paragraph().layout().free_spacing)
                        insertChar(cur, ' ');
@@ -2251,6 +2277,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_BUFFER_BEGIN_SELECT:
        case LFUN_BUFFER_END_SELECT:
        case LFUN_UNICODE_INSERT:
+       case LFUN_SET_GRAPHICS_GROUP:
                // these are handled in our dispatch()
                enable = true;
                break;
index e2740bab3516f1b10532c7d5733d3f0dd9b4ecf8..774c0f0578e16fc416315532fc518801047d3ed8 100644 (file)
@@ -539,6 +539,8 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
        scaleCB->blockSignals(false);
        Scale->setEnabled(scaleChecked);
 
+       groupId->setText(toqstr(igp.groupId));
+
        lengthAutoToWidgets(Width, widthUnit, igp.width,
                unitDefault);
        bool const widthChecked = !Width->text().isEmpty() &&
@@ -682,6 +684,8 @@ void GuiGraphics::applyView()
 
        // more latex options
        igp.special = fromqstr(latexoptions->text());
+
+       igp.groupId = fromqstr(groupId->text());
 }
 
 
@@ -732,6 +736,9 @@ void GuiGraphics::dispatchParams()
        InsetGraphicsParams tmp_params(params_);
        string const lfun = InsetGraphics::params2string(tmp_params, buffer());
        dispatch(FuncRequest(getLfun(), lfun));
+       if (!params_.groupId.empty())
+               dispatch(FuncRequest(LFUN_GRAPHICS_GROUPS_UNIFY,
+                               InsetGraphics::params2string(params_, buffer())));
 }
 
 
index 65704847e49177e532b2be428ec1c746368a5ebc..2711b4826aaa37ef7357e24c9ca73e3d7135213c 100644 (file)
@@ -1844,6 +1844,7 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_INSET_APPLY: {
+                       view()->cursor().recordUndoFullDocument();
                        string const name = cmd.getArg(0);
                        Inset * inset = getOpenInset(name);
                        if (inset) {
index 62423d42a3b29af7438007ffaccf1c2e51420e00..51ef148db949cd3228bfd556ad923011f86caa91 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "insets/Inset.h"
 #include "insets/InsetCitation.h"
+#include "insets/InsetGraphics.h"
 
 #include "support/lassert.h"
 #include "support/convert.h"
@@ -137,7 +138,9 @@ public:
                /** Available branches in document */
                Branches,
                /** Available citation styles for a given citation */
-               CiteStyles
+               CiteStyles,
+               /** Available graphics groups */
+               GraphicsGroups
        };
 
        explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
@@ -290,6 +293,7 @@ public:
        void expandToolbars();
        void expandBranches(Buffer const * buf);
        void expandCiteStyles(BufferView const *);
+       void expandGraphicsGroups(Buffer const * buf);
        ///
        ItemList items_;
        ///
@@ -390,7 +394,8 @@ void MenuDefinition::read(Lexer & lex)
                md_floatlistinsert,
                md_floatinsert,
                md_pasterecent,
-               md_toolbars
+               md_toolbars,
+               md_graphicsgroups
        };
 
        LexerKeyword menutags[] = {
@@ -405,6 +410,7 @@ void MenuDefinition::read(Lexer & lex)
                { "exportformats", md_exportformats },
                { "floatinsert", md_floatinsert },
                { "floatlistinsert", md_floatlistinsert },
+               { "graphicsgroups", md_graphicsgroups },
                { "importformats", md_importformats },
                { "item", md_item },
                { "lastfiles", md_lastfiles },
@@ -513,6 +519,10 @@ void MenuDefinition::read(Lexer & lex)
                        add(MenuItem(MenuItem::CiteStyles));
                        break;
 
+               case md_graphicsgroups:
+                       add(MenuItem(MenuItem::GraphicsGroups));
+                       break;
+
                case md_optsubmenu:
                        optional = true;
                        // fallback to md_submenu
@@ -623,6 +633,21 @@ QString limitStringLength(docstring const & str)
 }
 
 
+void MenuDefinition::expandGraphicsGroups(Buffer const * buf)
+{
+       set<string> grp;
+       InsetGraphics::getGraphicsGroups(*buf, grp);
+       set<string>::const_iterator it = grp.begin();
+       set<string>::const_iterator end = grp.end();
+       if (grp.empty()) return;
+
+       add(MenuItem(MenuItem::Separator));
+       add(MenuItem(MenuItem::Command, qt_("Clear group"), FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
+       for (; it != end; it++) {
+               add(MenuItem(MenuItem::Command, toqstr(*it), FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
+       }
+}
+
 void MenuDefinition::expandLastfiles()
 {
        LastFilesSection::LastFiles const & lf = LyX::cref().session().lastFiles().lastFiles();
@@ -1396,6 +1421,10 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
                        tomenu.expandToc(buf);
                        break;
 
+               case MenuItem::GraphicsGroups:
+                       tomenu.expandGraphicsGroups(buf);
+                       break;
+
                case MenuItem::Submenu: {
                        MenuItem item(*cit);
                        item.setSubmenu(MenuDefinition(cit->submenuname()));
index 642681fc5326ff665eea7c6ca854b4cc32310281..2ae6fad5290020511591fa1101d8f0f51721e05f 100644 (file)
@@ -5,14 +5,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>481</width>
-    <height>354</height>
+    <width>584</width>
+    <height>373</height>
    </rect>
   </property>
   <property name="sizePolicy" >
-   <sizepolicy>
-    <hsizetype>1</hsizetype>
-    <vsizetype>1</vsizetype>
+   <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
    <property name="spacing" >
     <number>6</number>
    </property>
+   <item row="1" column="0" >
+    <layout class="QHBoxLayout" >
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QPushButton" name="restorePB" >
+       <property name="text" >
+        <string>&amp;Restore</string>
+       </property>
+       <property name="autoDefault" >
+        <bool>false</bool>
+       </property>
+       <property name="default" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType" >
+        <enum>QSizePolicy::MinimumExpanding</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>20</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="okPB" >
+       <property name="text" >
+        <string>&amp;OK</string>
+       </property>
+       <property name="autoDefault" >
+        <bool>true</bool>
+       </property>
+       <property name="default" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="applyPB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>&amp;Apply</string>
+       </property>
+       <property name="autoDefault" >
+        <bool>false</bool>
+       </property>
+       <property name="default" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="closePB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string>Close</string>
+       </property>
+       <property name="autoDefault" >
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
    <item row="0" column="0" >
-    <widget class="QTabWidget" name="TabWidget" >
+    <widget class="QTabWidget" name="tabWidget" >
      <property name="toolTip" >
       <string/>
      </property>
       <number>0</number>
      </property>
      <widget class="QWidget" name="Graphics" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>562</width>
+        <height>293</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>&amp;Graphics</string>
       </attribute>
              <bool>true</bool>
             </property>
             <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>1</hsizetype>
-              <vsizetype>0</vsizetype>
+             <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>61</width>
               <height>20</height>
              <bool>true</bool>
             </property>
             <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>1</hsizetype>
-              <vsizetype>0</vsizetype>
+             <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
           <item row="0" column="1" >
            <widget class="QLineEdit" name="angle" >
             <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>3</hsizetype>
-              <vsizetype>0</vsizetype>
+             <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
       </layout>
      </widget>
      <widget class="QWidget" name="Clipping" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>100</width>
+        <height>30</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>&amp;Clipping</string>
       </attribute>
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>20</width>
            <height>40</height>
           <bool>true</bool>
          </property>
          <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>5</hsizetype>
-           <vsizetype>1</vsizetype>
+          <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          <property name="orientation" >
           <enum>Qt::Horizontal</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>181</width>
            <height>20</height>
       </layout>
      </widget>
      <widget class="QWidget" name="ExtraOptions" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>562</width>
+        <height>293</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>LaTe&amp;X and LyX options</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
-        <number>9</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item row="4" column="0" colspan="2" >
+       <item row="0" column="0" >
+        <widget class="QLabel" name="latexoptionsLA" >
+         <property name="toolTip" >
+          <string>Additional LaTeX options</string>
+         </property>
+         <property name="text" >
+          <string>LaTeX &amp;options:</string>
+         </property>
+         <property name="buddy" >
+          <cstring>latexoptions</cstring>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1" >
+        <widget class="QLineEdit" name="latexoptions" >
+         <property name="sizePolicy" >
+          <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="toolTip" >
+          <string>Additional LaTeX options</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" colspan="2" >
+        <widget class="QCheckBox" name="draftCB" >
+         <property name="toolTip" >
+          <string>Draft mode</string>
+         </property>
+         <property name="text" >
+          <string>&amp;Draft mode</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" colspan="2" >
+        <widget class="QCheckBox" name="unzipCB" >
+         <property name="toolTip" >
+          <string>Don't uncompress image before exporting to LaTeX</string>
+         </property>
+         <property name="text" >
+          <string>Don't un&amp;zip on export</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0" colspan="2" >
         <widget class="QGroupBox" name="displayGB" >
          <property name="focusPolicy" >
           <enum>Qt::StrongFocus</enum>
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>40</width>
               <height>20</height>
              <bool>true</bool>
             </property>
             <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>1</hsizetype>
-              <vsizetype>0</vsizetype>
+             <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
              <string>Screen display</string>
             </property>
             <property name="text" >
-             <string>&amp;Display:</string>
+             <string>Scr&amp;een Display:</string>
             </property>
             <property name="buddy" >
              <cstring>showCB</cstring>
             </property>
            </widget>
           </item>
+          <item row="1" column="0" >
+           <widget class="QLabel" name="label" >
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="text" >
+             <string>Initialize Group-Id:</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1" >
+           <widget class="QLineEdit" name="groupId" >
+            <property name="minimumSize" >
+             <size>
+              <width>87</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="toolTip" >
+             <string>Group-id to be set up from the current parameters</string>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
-       <item row="5" column="1" >
+       <item row="4" column="1" >
         <spacer>
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
-           <width>20</width>
-           <height>41</height>
+           <width>354</width>
+           <height>81</height>
           </size>
          </property>
         </spacer>
        </item>
-       <item row="2" column="0" colspan="2" >
-        <widget class="QCheckBox" name="unzipCB" >
-         <property name="toolTip" >
-          <string>Don't uncompress image before exporting to LaTeX</string>
-         </property>
-         <property name="text" >
-          <string>Don't un&amp;zip on export</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="1" >
-        <widget class="QLineEdit" name="latexoptions" >
-         <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>3</hsizetype>
-           <vsizetype>0</vsizetype>
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="toolTip" >
-          <string>Additional LaTeX options</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="0" >
-        <widget class="QLabel" name="latexoptionsLA" >
-         <property name="toolTip" >
-          <string>Additional LaTeX options</string>
-         </property>
-         <property name="text" >
-          <string>LaTeX &amp;options:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>latexoptions</cstring>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0" colspan="2" >
-        <widget class="QCheckBox" name="draftCB" >
-         <property name="toolTip" >
-          <string>Draft mode</string>
-         </property>
-         <property name="text" >
-          <string>&amp;Draft mode</string>
-         </property>
-        </widget>
-       </item>
       </layout>
      </widget>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <widget class="QPushButton" name="restorePB" >
-       <property name="text" >
-        <string>&amp;Restore</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-       <property name="default" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::MinimumExpanding</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>20</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="okPB" >
-       <property name="text" >
-        <string>&amp;OK</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>true</bool>
-       </property>
-       <property name="default" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="applyPB" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>1</hsizetype>
-         <vsizetype>0</vsizetype>
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text" >
-        <string>&amp;Apply</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-       <property name="default" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="closePB" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>1</hsizetype>
-         <vsizetype>0</vsizetype>
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text" >
-        <string>Close</string>
-       </property>
-       <property name="autoDefault" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
   </layout>
  </widget>
  <customwidgets>
   </customwidget>
  </customwidgets>
  <tabstops>
-  <tabstop>TabWidget</tabstop>
+  <tabstop>tabWidget</tabstop>
   <tabstop>filename</tabstop>
   <tabstop>browsePB</tabstop>
   <tabstop>scaleCB</tabstop>
index 2f6f4ab2ea2d625d6f6381470f993121a70543e8..f280818a2479604477e19044f5f7cb1bbc989b38 100644 (file)
@@ -67,6 +67,7 @@ TODO
 #include "OutputParams.h"
 #include "sgml.h"
 #include "TocBackend.h"
+#include "InsetIterator.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -949,4 +950,61 @@ string InsetGraphics::params2string(InsetGraphicsParams const & params,
 }
 
 
+void InsetGraphics::getGraphicsGroups(Buffer const & b, std::set<string> & ids)
+{
+       Inset & inset = b.inset();
+       InsetIterator it  = inset_iterator_begin(inset);
+       InsetIterator const end = inset_iterator_end(inset);
+       for (; it != end; ++it)
+               if (it->lyxCode() == GRAPHICS_CODE) {
+                       InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+                       InsetGraphicsParams inspar = ins.getParams();
+                       if (!inspar.groupId.empty()) {
+                               ids.insert(inspar.groupId);
+                       }
+               }
+}
+
+
+string InsetGraphics::getGroupParams(Buffer const & b, std::string const & groupId)
+{
+       if (groupId.empty()) return string();
+       Inset & inset = b.inset();
+       InsetIterator it  = inset_iterator_begin(inset);
+       InsetIterator const end = inset_iterator_end(inset);
+       for (; it != end; ++it)
+               if (it->lyxCode() == GRAPHICS_CODE) {
+                       InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+                       InsetGraphicsParams inspar = ins.getParams();
+                       if (inspar.groupId == groupId) {
+                               InsetGraphicsParams tmp = inspar;
+                               tmp.filename.erase();
+                               return params2string(tmp, b);
+                       }
+               }
+       return string();
+}
+
+void InsetGraphics::unifyGraphicsGroups(Buffer const & b, std::string const & argument)
+{
+                       InsetGraphicsParams params;
+                       InsetGraphics::string2params(argument, b, params);
+
+                       Inset & inset = b.inset();
+                       InsetIterator it  = inset_iterator_begin(inset);
+                       InsetIterator const end = inset_iterator_end(inset);
+                       for (; it != end; ++it) {
+                               if (it->lyxCode() == GRAPHICS_CODE) {
+                                       InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+                                       InsetGraphicsParams inspar = ins.getParams();
+                                       if (params.groupId == inspar.groupId) {
+                                               params.filename = inspar.filename;
+                                               ins.setParams(params);
+                                       }
+                               }
+                       }
+
+}
+
+
 } // namespace lyx
index dae9a701d2a42711b8b01bae621058c9381c09de..2c601567b7ab2b594ab7cc367c0a75b1069321af 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef INSET_GRAPHICS_H
 #define INSET_GRAPHICS_H
 
+#include <set>
 #include "Inset.h"
 #include "InsetGraphicsParams.h"
 
@@ -47,11 +48,23 @@ public:
        ///
        static std::string params2string(InsetGraphicsParams const &,
                                          Buffer const &);
+       /// Saves the list of currently used groups in the document.
+       static void getGraphicsGroups(Buffer const &, std::set<std::string> &);
+       /// Returns parameters of a given graphics group (except filename).
+       static std::string getGroupParams(Buffer const &,
+                                               std::string const &);
+       /** Synchronize all Graphics insets of the group.
+           Both groupId and params are taken from argument.
+       */
+       static void unifyGraphicsGroups(Buffer const &, std::string const &);
+
        /** Set the inset parameters, used by the GUIndependent dialog.
            Return true of new params are different from what was so far.
        */
        bool setParams(InsetGraphicsParams const & params);
 
+       InsetGraphicsParams getParams() const { return params_;}
+
 private:
        ///
        InsetGraphics(InsetGraphics const &);
index 35fb9bcb516ea0c0c5bcdf1a7ba0deb6d384fbe7..b2b15f0ad3888187625553bfe6210a58cf94b791 100644 (file)
@@ -79,6 +79,7 @@ void InsetGraphicsParams::init()
        rotateAngle = "0";              // angle of rotation in degrees
        rotateOrigin.erase();           // Origin of rotation
        special.erase();                // additional userdefined stuff
+       groupId.clear();
 }
 
 
@@ -101,6 +102,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
        rotateAngle = igp.rotateAngle;
        rotateOrigin = igp.rotateOrigin;
        special = igp.special;
+       groupId = igp.groupId;
 }
 
 
@@ -123,7 +125,8 @@ bool operator==(InsetGraphicsParams const & left,
 
            left.rotateAngle == right.rotateAngle &&
            left.rotateOrigin == right.rotateOrigin &&
-           left.special == right.special;
+           left.special == right.special &&
+           left.groupId == right.groupId;
 }
 
 
@@ -174,6 +177,8 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
                os << "\trotateOrigin " << rotateOrigin << '\n';
        if (!special.empty())
                os << "\tspecial " << special << '\n';
+       if (!groupId.empty())
+               os << "\tgroupId "<< groupId << '\n';
 }
 
 
@@ -227,6 +232,9 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
        } else if (token == "special") {
                lex.eatLine();
                special = lex.getString();
+       } else if (token == "groupId") {
+               lex.eatLine();
+               groupId = lex.getString();
 
        // catch and ignore following two old-format tokens and their arguments.
        // e.g. "size_kind scale" clashes with the setting of the
index f3429afe9bab2df89c4a466064571bc19e622213..6cff5965337edca6c1a9ef414b5ff1c618b116aa 100644 (file)
@@ -83,6 +83,8 @@ public:
        // to display or not.
        graphics::Params as_grfxParams() const;
 
+       // Identification of the graphics template. No template equals empty string.
+       std::string groupId;
 private:
        /// Initialize the object to a default status.
        void init();