-----------------------
+2019-03-26 Jürgen Spitzmüller <spitz@lyx.org>
+ * format incremented to 569: New buffer param \tablestyle
+ Determines the standard table template to be used.
+
2019-03-22 Jürgen Spitzmüller <spitz@lyx.org>
* format incremented to 568: Support for the soul module:
\so, \hl, \st, \ul, \caps
revert_flex_inset(document.body, "Capitalize", "\\caps")
+def revert_tablestyle(document):
+ " Remove tablestyle params "
+
+ i = 0
+ i = find_token(document.header, "\\tablestyle", 0)
+ if i != -1:
+ del document.header[i]
+
+
##
# Conversion hub
[565, [convert_AdobeFonts]], # Handle adobe fonts in GUI
[566, [convert_hebrew_parentheses]],
[567, []],
- [568, []]
+ [568, []],
+ [569, []]
]
revert = [
+ [568, [revert_tablestyle]],
[567, [revert_soul]],
[566, [revert_malayalam]],
[565, [revert_hebrew_parentheses]],
columns = 1;
listings_params = string();
pagestyle = "default";
+ tablestyle = "default";
suppress_date = false;
justification = true;
// no color is the default (white)
sides = sidestranslator().find(psides);
} else if (token == "\\paperpagestyle") {
lex >> pagestyle;
+ } else if (token == "\\tablestyle") {
+ lex >> tablestyle;
} else if (token == "\\bullet") {
readBullets(lex);
} else if (token == "\\bulletLaTeX") {
<< "\n\\dynamic_quotes " << dynamic_quotes
<< "\n\\papercolumns " << columns
<< "\n\\papersides " << sides
- << "\n\\paperpagestyle " << pagestyle << '\n';
+ << "\n\\paperpagestyle " << pagestyle
+ << "\n\\tablestyle " << tablestyle << '\n';
if (!listings_params.empty())
os << "\\listings_params \"" <<
InsetListingsParams(listings_params).encodedString() << "\"\n";
///
std::string pagestyle;
///
+ std::string tablestyle;
+ ///
RGBColor backgroundcolor;
///
bool isbackgroundcolor;
break;
}
- case LFUN_TABULAR_INSERT:
+ case LFUN_TABULAR_INSERT: {
+ if (cur.buffer()->masterParams().tablestyle != "default") {
+ FuncRequest fr(LFUN_TABULAR_STYLE_INSERT,
+ cur.buffer()->masterParams().tablestyle + " "
+ + to_ascii(cmd.argument()));
+ lyx::dispatch(fr);
+ break;
+ }
// if there were no arguments, just open the dialog
if (doInsertInset(cur, this, cmd, false, true))
cur.posForward();
bv->showDialog("tabularcreate");
break;
+ }
case LFUN_TABULAR_STYLE_INSERT: {
string const style = cmd.getArg(0);
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/Package.h"
#include "support/TempFile.h"
#include "frontends/alert.h"
#include <QColor>
#include <QColorDialog>
#include <QCloseEvent>
+#include <QDirIterator>
#include <QFontDatabase>
#include <QHeaderView>
#include <QScrollBar>
connect(textLayoutModule->justCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(textLayoutModule->tableStyleCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+
textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
textLayoutModule->lspacingLE));
textLayoutModule->indentLE->setValidator(new LengthValidator(
// initialize the length validator
bc().addCheckedLineEdit(textLayoutModule->indentLE);
bc().addCheckedLineEdit(textLayoutModule->skipLE);
+
+ textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default"));
+ getTableStyles();
// master/child handling
}
+void GuiDocument::getTableStyles()
+{
+ // We look for lyx files in the subdirectory dir of
+ // 1) user_lyxdir
+ // 2) build_lyxdir (if not empty)
+ // 3) system_lyxdir
+ // in this order. Files with a given sub-hierarchy will
+ // only be listed once.
+ // We also consider i18n subdirectories and store them separately.
+ QStringList dirs;
+
+ // The three locations to look at.
+ string const user = addPath(package().user_support().absFileName(), "tabletemplates");
+ string const build = addPath(package().build_support().absFileName(), "tabletemplates");
+ string const system = addPath(package().system_support().absFileName(), "tabletemplates");
+
+ dirs << toqstr(user)
+ << toqstr(build)
+ << toqstr(system);
+
+ for (int i = 0; i < dirs.size(); ++i) {
+ QString const dir = dirs.at(i);
+ QDirIterator it(dir, QDir::Files, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ QString fn = QFileInfo(it.next()).fileName();
+ if (!fn.endsWith(".lyx") || fn.contains("_1x"))
+ continue;
+ QString data = fn.left(fn.lastIndexOf(".lyx"));
+ QString guiname = data;
+ guiname = toqstr(translateIfPossible(qstring_to_ucs4(guiname.replace('_', ' '))));
+ QString relpath = toqstr(makeRelPath(qstring_to_ucs4(fn),
+ qstring_to_ucs4(dir)));
+ if (textLayoutModule->tableStyleCO->findData(data) == -1)
+ textLayoutModule->tableStyleCO->addItem(guiname, data);
+ }
+ }
+}
+
+
void GuiDocument::updateDefaultFormat()
{
if (!bufferview())
break;
}
}
+ bp_.tablestyle = fromqstr(textLayoutModule->tableStyleCO->itemData(
+ textLayoutModule->tableStyleCO->currentIndex()).toString());
bp_.options =
fromqstr(latexModule->optionsLE->text());
bp_.spacing().getValueAsString());
}
setLSpacing(nitem);
+ int ts = textLayoutModule->tableStyleCO->findData(toqstr(bp_.tablestyle));
+ if (ts != -1)
+ textLayoutModule->tableStyleCO->setCurrentIndex(ts);
if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
textLayoutModule->indentRB->setChecked(true);
void setLayoutComboByIDString(std::string const & idString);
/// Update quotes styles combo, indicating the current language's default
void updateQuoteStyles(bool const set = false);
+ ///
+ void getTableStyles();
/// available modules
GuiIdListModel modules_av_model_;
<x>0</x>
<y>0</y>
<width>470</width>
- <height>380</height>
+ <height>468</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0" colspan="3">
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="spacingGB">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Spacing</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lspacingL">
+ <property name="minimumSize">
+ <size>
+ <width>91</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&Line spacing:</string>
+ </property>
+ <property name="buddy">
+ <cstring>lspacingCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="lspacingCO">
+ <property name="toolTip">
+ <string>Spacing type</string>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="lspacingLE">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Number of lines</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>69</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QGroupBox" name="tableStyleGB">
+ <property name="title">
+ <string>Table Style</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="tableStyleLA">
+ <property name="text">
+ <string>Default St&yle:</string>
+ </property>
+ <property name="buddy">
+ <cstring>tableStyleCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="tableStyleCO">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>403</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="0">
<widget class="QGroupBox" name="separateGB">
<property name="title">
<string>Paragraph Separation</string>
</layout>
</widget>
</item>
- <item row="1" column="0" colspan="3">
- <widget class="QGroupBox" name="spacingGB">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="title">
- <string>Spacing</string>
- </property>
- <property name="flat">
- <bool>true</bool>
+ <item row="6" column="0">
+ <widget class="QCheckBox" name="justCB">
+ <property name="toolTip">
+ <string>Justify text in the LyX editor (this does not affect whether the text is justified in the output)</string>
</property>
- <property name="checkable">
- <bool>false</bool>
+ <property name="text">
+ <string>Use &justification in LyX work area</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="lspacingL">
- <property name="minimumSize">
- <size>
- <width>91</width>
- <height>18</height>
- </size>
- </property>
- <property name="text">
- <string>&Line spacing:</string>
- </property>
- <property name="buddy">
- <cstring>lspacingCO</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="lspacingCO">
- <property name="toolTip">
- <string>Spacing type</string>
- </property>
- <property name="duplicatesEnabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLineEdit" name="lspacingLE">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Number of lines</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>69</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="5" column="0">
<widget class="QCheckBox" name="twoColumnCB">
<property name="toolTip">
<string>Format text into two columns</string>
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="justCB">
- <property name="toolTip">
- <string>Justify text in the LyX editor (this does not affect whether the text is justified in the output)</string>
- </property>
- <property name="text">
- <string>Use &justification in LyX work area</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="3">
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>403</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<customwidgets>
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 568 // spitz :soul.module
-#define LYX_FORMAT_TEX2LYX 568
+#define LYX_FORMAT_LYX 569 // spitz: tablestyle buffer param
+#define LYX_FORMAT_TEX2LYX 569
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER