BOOST_ASSERT(sub.size() == 4);
// now, create a TextClass with description containing path information
string className(sub.str(2) == "" ? textclass : sub.str(2));
- string description(sub.str(3) + " <" + path + ">");
LayoutFile * tmpl =
- new LayoutFile(textclass, className, description, true);
+ new LayoutFile(textclass, className, localIndex, true);
// This textclass is added on request so it will definitely be
// used. Load it now because other load() calls may fail if they
// are called in a context without buffer path information.
this, SLOT(classChanged()));
connect(latexModule->classCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(latexModule->layoutPB, SIGNAL(clicked()),
+ this, SLOT(browseLayout()));
selectionManager =
new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
}
+void GuiDocument::browseLayout()
+{
+ QString const label1 = qt_("Layouts|#o#O");
+ QString const dir1 = toqstr(lyxrc.document_path);
+ FileFilterList const filter(_("LyX Layout (*.layout)"));
+ QString file = browseRelFile(QString(), bufferFilepath(),
+ qt_("Local layout file"), filter, false,
+ label1, dir1);
+
+ if (!suffixIs(fromqstr(file), ".layout"))
+ return;
+
+ FileName layoutFile = makeAbsPath(fromqstr(file),
+ fromqstr(bufferFilepath()));
+
+ // load the layout file
+ LayoutFileList & bcl = LayoutFileList::get();
+ string classname = layoutFile.onlyFileName();
+ LayoutFileIndex name = bcl.addLayoutFile(
+ classname.substr(0, classname.size() - 7),
+ layoutFile.onlyPath().absFilename());
+
+ if (name.empty()) {
+ Alert::error(_("Error"),
+ _("Unable to read local layout file."));
+ return;
+ }
+
+ // do not trigger classChanged if there is no change.
+ if (latexModule->classCO->currentText() == toqstr(name))
+ return;
+
+ // add to combo box
+ int idx = latexModule->classCO->findText(toqstr(name));
+ if (idx == -1) {
+ classes_model_.insertRow(0, toqstr(name), name);
+ latexModule->classCO->setCurrentIndex(0);
+ } else
+ latexModule->classCO->setCurrentIndex(idx);
+ classChanged();
+}
+
+
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
<property name="spacing" >
<number>6</number>
</property>
- <item row="3" column="0" colspan="3" >
+ <item row="3" column="0" colspan="4" >
<widget class="QGroupBox" name="modulesGB" >
<property name="title" >
<string>Modules</string>
</property>
</widget>
</item>
- <item row="2" column="2" >
+ <item row="2" column="2" colspan="2">
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="classCO" />
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </item>
+ <item row="0" column="3" >
+ <widget class="QPushButton" name="layoutPB" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>B&rowse...</string>
+ </property>
+ </widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="optionsL" >
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2" >
+ <item row="1" column="1" colspan="3" >
<widget class="QLineEdit" name="optionsLE" />
</item>
</layout>