[LyX/2.5.x] Allow to set multipage-table and caption on tabular insertion
Juergen Spitzmueller <[email protected]> Thu, 30 Apr 2026 15:20:56 +0000
| Newsgroups | gmane.editors.lyx.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 8e43afbc2c257b2150342e650a41cef3b57faa51 Author: Juergen Spitzmueller <[email protected]> Date: Thu Apr 30 14:45:39 2026 +0200 Allow to set multipage-table and caption on tabular insertion Both can be set now in the tabular create dialog (for all styles) or with the lfuns (cherry picked from commit b00e7f7c7ff5eb4699da0cedd8076b4bd2613719) --- src/LyXAction.cpp | 6 ++++-- src/Text.cpp | 18 ++++++++++++++++-- src/frontends/qt/GuiTabularCreate.cpp | 17 ++++++++++++++++- src/frontends/qt/GuiTabularCreate.h | 1 + src/frontends/qt/ui/TabularCreateUi.ui | 23 ++++++++++++++++++++++- status.25x | 3 +++ 6 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index ecc7b4f327..fcf554e4d2 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -4046,8 +4046,9 @@ void LyXAction::init() * \li Action: Inserts table into the document. * \li Notion: See #LFUN_TABULAR_FEATURE for some more details about tabular modifications. - * \li Syntax: tabular-insert [<ROWS> <COLUMNS>] + * \li Syntax: tabular-insert [<ROWS> <COLUMNS> <EXTRAS>] * \li Params: In case no arguments are given show insert dialog. + * EXTRAS can be "longtable" or "longtable-caption" currently. * \li Origin: Jug, 12 Apr 2000 * \endvar */ @@ -4058,9 +4059,10 @@ void LyXAction::init() * \li Action: Inserts table of a given style into the document. * \li Notion: See #LFUN_TABULAR_FEATURE for some more details about tabular modifications. - * \li Syntax: tabular-style-insert <style> <ROWS> <COLUMNS> + * \li Syntax: tabular-style-insert <style> <ROWS> <COLUMNS> <EXTRAS> * \li Params: Valid styles are the names of the files in lib/tabletemplates, * minus _1x<n> and .lyx suffix. + * EXTRAS can be "longtable" or "longtable-caption" currently. * \li Origin: spitz, 25 Mar 2019 * \endvar */ diff --git a/src/Text.cpp b/src/Text.cpp index 58e92b1ad3..6b109e85ba 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -5570,11 +5570,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (cmd.argument().empty()) { bv->showDialog("tabularcreate"); break; - } else if (cur.buffer()->masterParams().tablestyle != "default" - || bv->buffer().params().documentClass().tablestyle() != "default") { + } + string const extras = cmd.getArg(2); + if (!extras.empty() || cur.buffer()->masterParams().tablestyle != "default" + || bv->buffer().params().documentClass().tablestyle() != "default") { string tabstyle = cur.buffer()->masterParams().tablestyle; if (tabstyle == "default") tabstyle = bv->buffer().params().documentClass().tablestyle(); + if (tabstyle == "default") + tabstyle = "Grid_with_Head"; if (!libFileSearch("tabletemplates", tabstyle + ".lyx").empty()) { FuncRequest fr(LFUN_TABULAR_STYLE_INSERT, tabstyle + " " + to_ascii(cmd.argument())); @@ -5597,6 +5601,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) string const style = cmd.getArg(0); string const rows = cmd.getArg(1); string const cols = cmd.getArg(2); + string const extras = cmd.getArg(3); if (cols.empty() || !isStrInt(cols) || rows.empty() || !isStrInt(rows)) break; @@ -5638,6 +5643,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (r > 1) // go to first cell cur.up(); + if (extras == "longtable") { + FuncRequest fr(LFUN_TABULAR_FEATURE, "set-longtabular"); + lyx::dispatch(fr); + } else if (extras == "longtable-caption") { + FuncRequest fr(LFUN_COMMAND_SEQUENCE, "tabular-feature set-longtabular;" + "tabular-feature append-row;" + "tabular-feature set-ltcaption"); + lyx::dispatch(fr); + } break; } diff --git a/src/frontends/qt/GuiTabularCreate.cpp b/src/frontends/qt/GuiTabularCreate.cpp index 483d53a1b1..447134f237 100644 --- a/src/frontends/qt/GuiTabularCreate.cpp +++ b/src/frontends/qt/GuiTabularCreate.cpp @@ -92,6 +92,9 @@ GuiTabularCreate::GuiTabularCreate(GuiView & lv) connect(columnsSB, SIGNAL(valueChanged(int)), this, SLOT(columnsChanged(int))); + connect(longtableCB, SIGNAL(clicked()), + this, SLOT(longtableChanged())); + bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy); bc().setOK(buttonBox->button(QDialogButtonBox::Ok)); bc().setApply(buttonBox->button(QDialogButtonBox::Apply)); @@ -123,6 +126,12 @@ void GuiTabularCreate::rowsChanged(int) } +void GuiTabularCreate::longtableChanged() +{ + captionCB->setEnabled(longtableCB->isChecked()); +} + + void GuiTabularCreate::applyView() { params_.first = ulong(rowsSB->value()); @@ -135,6 +144,7 @@ bool GuiTabularCreate::initialiseParams(string const &) params_.first = 5; params_.second = 5; style_ = styleCO->itemData(styleCO->currentIndex()).toString(); + longtableChanged(); changed(); return true; } @@ -153,6 +163,11 @@ void GuiTabularCreate::dispatchParams() if (style_ != "default") sdata = fromqstr(style_) + ' '; sdata += convert<string>(params().first) + ' ' + convert<string>(params().second); + if (longtableCB->isChecked()) { + sdata += " longtable"; + if (captionCB->isChecked()) + sdata += "-caption"; + } dispatch(FuncRequest(getLfun(), sdata)); } @@ -160,7 +175,7 @@ void GuiTabularCreate::dispatchParams() FuncCode GuiTabularCreate::getLfun() const { if (style_.isEmpty() || style_ == "default") - return LFUN_TABULAR_INSERT; + return LFUN_TABULAR_INSERT; return LFUN_TABULAR_STYLE_INSERT; } diff --git a/src/frontends/qt/GuiTabularCreate.h b/src/frontends/qt/GuiTabularCreate.h index 7495bc73b2..df860dac8f 100644 --- a/src/frontends/qt/GuiTabularCreate.h +++ b/src/frontends/qt/GuiTabularCreate.h @@ -32,6 +32,7 @@ private Q_SLOTS: void columnsChanged(int); void rowsChanged(int); void on_styleCO_activated(int); + void longtableChanged(); private: /// Apply changes diff --git a/src/frontends/qt/ui/TabularCreateUi.ui b/src/frontends/qt/ui/TabularCreateUi.ui index 23e3665aa0..4a476e357a 100644 --- a/src/frontends/qt/ui/TabularCreateUi.ui +++ b/src/frontends/qt/ui/TabularCreateUi.ui @@ -114,6 +114,27 @@ </widget> </item> <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QCheckBox" name="longtableCB"> + <property name="toolTip"> + <string>Insert a table that can spread across multiple pages</string> + </property> + <property name="text"> + <string>&Multi-page table</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="captionCB"> + <property name="text"> + <string>With ca&ption</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0"> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <widget class="QLabel" name="styleLA"> @@ -137,7 +158,7 @@ </item> </layout> </item> - <item row="3" column="0"> + <item row="4" column="0"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="standardButtons"> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> diff --git a/status.25x b/status.25x index 9c9d3630a0..cce09e600e 100644 --- a/status.25x +++ b/status.25x @@ -30,6 +30,9 @@ What's new - Implement LFUN_REFERENCE_TO_PARAGRAPH for mathed (bug 13206). +- It is now possible in the tabular creation dialog (Inset > Table) to + insert a multi-page table (optionally with caption) directly. + * DOCUMENTATION AND LOCALIZATION -- lyx-cvs mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-cvs