summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9d85724)
File format change.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30546
a592a061-630c-0410-9148-
cb99ea01b6c8
LyX file-format changes
-----------------------
LyX file-format changes
-----------------------
+2009-07-13 Jürgen Spitzmüller <spitz@lyx.org>
+ * Format incremented to 364: add \filename_suffix parameter
+ to branches.
+
2009-07-11 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 363: support for horizontal longtable
alignment.
2009-07-11 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 363: support for horizontal longtable
alignment.
+def revert_branch_filename(document):
+ " Remove \\filename_suffix parameter from branches "
+ i = 0
+ while True:
+ i = find_token(document.header, "\\filename_suffix", i)
+ if i == -1:
+ return
+ del document.header[i]
+
+
[360, []],
[361, []],
[362, []],
[360, []],
[361, []],
[362, []],
-revert = [[362, [revert_longtable_align]],
+revert = [[363, [revert_branch_filename]],
+ [362, [revert_longtable_align]],
[361, [revert_applemac]],
[360, []],
[359, [revert_nomencl_cwidth]],
[361, [revert_applemac]],
[360, []],
[359, [revert_nomencl_cwidth]],
* Licence details can be found in the file COPYING.
*
* \author Martin Vermeer
* Licence details can be found in the file COPYING.
*
* \author Martin Vermeer
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
*
* Full author contact details are available in file CREDITS.
*/
#include "frontends/Application.h"
#include "frontends/Application.h"
+#include "support/lstrings.h"
+
#include <algorithm>
using namespace std;
#include <algorithm>
using namespace std;
-Branch::Branch() : selected_(false)
+Branch::Branch()
+ : selected_(false), filenameSuffix_(false)
{
// no theApp() with command line export
if (theApp())
{
// no theApp() with command line export
if (theApp())
+bool Branch::hasFilenameSuffix() const
+{
+ return filenameSuffix_;
+}
+
+
+void Branch::setFilenameSuffix(bool b)
+{
+ filenameSuffix_ = b;
+}
+
+
RGBColor const & Branch::color() const
{
return color_;
RGBColor const & Branch::color() const
{
return color_;
Branch br;
br.setBranch(name);
br.setSelected(false);
Branch br;
br.setBranch(name);
br.setSelected(false);
+ br.setFilenameSuffix(false);
list.push_back(br);
}
if (j == docstring::npos)
list.push_back(br);
}
if (j == docstring::npos)
+docstring BranchList::getFilenameSuffix() const
+{
+ docstring result;
+ List::const_iterator it = list.begin();
+ for (; it != list.end(); ++it) {
+ if (it->isSelected() && it->hasFilenameSuffix())
+ result += "-" + it->branch();
+ }
+ return support::subst(result, from_ascii("/"), from_ascii("_"));
+}
+
* \return true if the selection status changes.
*/
bool setSelected(bool);
* \return true if the selection status changes.
*/
bool setSelected(bool);
+ /** If true, the branch name will be appended
+ * to the output file name.
+ */
+ bool hasFilenameSuffix() const;
+ /// Select/deselect filename suffix property.
+ void setFilenameSuffix(bool);
///
RGBColor const & color() const;
///
///
RGBColor const & color() const;
///
+ bool filenameSuffix_;
+ ///
* if a branch with the newname already exists.
*/
bool rename(docstring const &, docstring const &, bool const merge = false);
* if a branch with the newname already exists.
*/
bool rename(docstring const &, docstring const &, bool const merge = false);
+ /// get the complete filename suffix
+ docstring getFilenameSuffix() const;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 363; // uwestoehr: support for longtable alignment
+int const LYX_FORMAT = 364; // spitz: branch suffixes for filenames
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
string Buffer::latexName(bool const no_path) const
{
string Buffer::latexName(bool const no_path) const
{
- FileName latex_name = makeLatexName(d->filename);
+ FileName latex_name =
+ makeLatexName(exportFileName());
return no_path ? latex_name.onlyFileName()
: latex_name.absFilename();
}
return no_path ? latex_name.onlyFileName()
: latex_name.absFilename();
}
+FileName Buffer::exportFileName() const
+{
+ docstring const branch_suffix =
+ params().branchlist().getFilenameSuffix();
+ if (branch_suffix.empty())
+ return fileName();
+
+ string const name = fileName().onlyFileNameWithoutExt()
+ + to_utf8(branch_suffix);
+ FileName res(fileName().onlyPath().absFilename() + "/" + name);
+ res.changeExtension(fileName().extension());
+
+ return res;
+}
+
+
string Buffer::logName(LogType * type) const
{
string const filename = latexName(false);
string Buffer::logName(LogType * type) const
{
string const filename = latexName(false);
- result_file = changeExtension(absFileName(), ext);
+ result_file = changeExtension(exportFileName().absFilename(), ext);
// We need to copy referenced files (e. g. included graphics
// if format == "dvi") to the result dir.
vector<ExportedFile> const files =
// We need to copy referenced files (e. g. included graphics
// if format == "dvi") to the result dir.
vector<ExportedFile> const files =
ReadStatus readFile(Lexer &, support::FileName const & filename,
bool fromString = false);
ReadStatus readFile(Lexer &, support::FileName const & filename,
bool fromString = false);
+ /** If we have branches that use the file suffix
+ feature, return the file name with suffix appended.
+ */
+ support::FileName exportFileName() const;
+
/// Use the Pimpl idiom to hide the internals.
class Impl;
/// The pointer never changes although *pimpl_'s contents may.
/// Use the Pimpl idiom to hide the internals.
class Impl;
/// The pointer never changes although *pimpl_'s contents may.
if (branch_ptr)
branch_ptr->setSelected(lex.getInteger());
}
if (branch_ptr)
branch_ptr->setSelected(lex.getInteger());
}
+ if (tok == "\\filename_suffix") {
+ lex.next();
+ if (branch_ptr)
+ branch_ptr->setFilenameSuffix(lex.getInteger());
+ }
// not yet operational
if (tok == "\\color") {
lex.eatLine();
// not yet operational
if (tok == "\\color") {
lex.eatLine();
for (; it != end; ++it) {
os << "\\branch " << to_utf8(it->branch())
<< "\n\\selected " << it->isSelected()
for (; it != end; ++it) {
os << "\\branch " << to_utf8(it->branch())
<< "\n\\selected " << it->isSelected()
+ << "\n\\filename_suffix " << it->hasFilenameSuffix()
<< "\n\\color " << lyx::X11hexname(it->color())
<< "\n\\end_branch"
<< "\n";
<< "\n\\color " << lyx::X11hexname(it->color())
<< "\n\\end_branch"
<< "\n";
branchesTW->headerItem()->setText(0, qt_("Branch"));
branchesTW->headerItem()->setText(1, qt_("Activated"));
branchesTW->headerItem()->setText(2, qt_("Color"));
branchesTW->headerItem()->setText(0, qt_("Branch"));
branchesTW->headerItem()->setText(1, qt_("Activated"));
branchesTW->headerItem()->setText(2, qt_("Color"));
+ branchesTW->headerItem()->setText(3, qt_("Filename Suffix"));
branchesTW->setSortingEnabled(true);
undef_ = new BranchesUnknownDialog(this);
branchesTW->setSortingEnabled(true);
undef_ = new BranchesUnknownDialog(this);
coloritem.fill(itemcolor);
newItem->setIcon(2, QIcon(coloritem));
}
coloritem.fill(itemcolor);
newItem->setIcon(2, QIcon(coloritem));
}
+ newItem->setText(3, it->hasFilenameSuffix() ? qt_("Yes") : qt_("No"));
// restore selected branch
if (bname == sel_branch) {
branchesTW->setCurrentItem(newItem);
// restore selected branch
if (bname == sel_branch) {
branchesTW->setCurrentItem(newItem);
renamePB->setEnabled(have_sel);
colorPB->setEnabled(have_sel);
activatePB->setEnabled(have_sel);
renamePB->setEnabled(have_sel);
colorPB->setEnabled(have_sel);
activatePB->setEnabled(have_sel);
+ suffixPB->setEnabled(have_sel);
// emit signal
changed();
}
// emit signal
changed();
}
+void GuiBranches::on_suffixPB_pressed()
+{
+ toggleSuffix(branchesTW->currentItem());
+}
+
+
void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col)
{
if (col < 2)
toggleBranch(item);
void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col)
{
if (col < 2)
toggleBranch(item);
+ else if (col == 3)
+ toggleSuffix(item);
renamePB->setEnabled(have_sel);
colorPB->setEnabled(have_sel);
activatePB->setEnabled(have_sel);
renamePB->setEnabled(have_sel);
colorPB->setEnabled(have_sel);
activatePB->setEnabled(have_sel);
+ suffixPB->setEnabled(have_sel);
if (sel_branch.isEmpty())
return;
if (sel_branch.isEmpty())
return;
- bool const selected = (item->text(1) == qt_("Yes"));
Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
- if (branch && branch->setSelected(!selected)) {
+ if (branch && branch->setSelected(!branch->isSelected())) {
newBranchLE->clear();
updateView();
}
newBranchLE->clear();
updateView();
}
+void GuiBranches::toggleSuffix(QTreeWidgetItem * item)
+{
+ if (item == 0)
+ return;
+
+ QString sel_branch = item->text(0);
+ if (sel_branch.isEmpty())
+ return;
+
+ Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
+ if (branch) {
+ branch->setFilenameSuffix(!branch->hasFilenameSuffix());
+ newBranchLE->clear();
+ updateView();
+ }
+}
+
+
void GuiBranches::on_unknownPB_pressed()
{
undef_->branchesLW->clear();
void GuiBranches::on_unknownPB_pressed()
{
undef_->branchesLW->clear();
protected:
void toggleBranch(QTreeWidgetItem *);
void toggleColor(QTreeWidgetItem *);
protected:
void toggleBranch(QTreeWidgetItem *);
void toggleColor(QTreeWidgetItem *);
+ void toggleSuffix(QTreeWidgetItem *);
void updateView();
protected Q_SLOTS:
void updateView();
protected Q_SLOTS:
void on_branchesTW_itemDoubleClicked(QTreeWidgetItem *, int);
void on_branchesTW_itemSelectionChanged();
void on_colorPB_clicked();
void on_branchesTW_itemDoubleClicked(QTreeWidgetItem *, int);
void on_branchesTW_itemSelectionChanged();
void on_colorPB_clicked();
+ void on_suffixPB_pressed();
void on_unknownPB_pressed();
void addUnknown();
void addAllUnknown();
void on_unknownPB_pressed();
void addUnknown();
void addAllUnknown();
<property name="spacing" >
<number>6</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
- <item row="3" column="3" >
- <widget class="QPushButton" name="renamePB" >
- <property name="toolTip" >
- <string>Change the name of the selected branch</string>
- </property>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="newBranchLA" >
- <string>Re&name...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="3" >
- <widget class="QPushButton" name="removePB" >
- <property name="toolTip" >
- <string>Remove the selected branch</string>
+ <string>&New:</string>
- <property name="text" >
- <string>&Remove</string>
+ <property name="buddy" >
+ <cstring>newBranchLE</cstring>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="4" column="3" >
- <widget class="QPushButton" name="colorPB" >
+ <item row="5" column="3" >
+ <widget class="QPushButton" name="suffixPB" >
<property name="toolTip" >
<property name="toolTip" >
- <string>Define or change background color</string>
+ <string>Append the name of this branch to the output filename, given the branch is active.</string>
</property>
<property name="text" >
</property>
<property name="text" >
- <string>Alter Co&lor...</string>
+ <string>Filename &Suffix</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="5" column="3" >
+ <item row="6" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<property name="sizeHint" >
<size>
<width>83</width>
<property name="sizeHint" >
<size>
<width>83</width>
</size>
</property>
</spacer>
</item>
</size>
</property>
</spacer>
</item>
- <item row="0" column="1" colspan="2" >
- <widget class="QLineEdit" name="newBranchLE" />
- </item>
- <item row="0" column="3" >
- <widget class="QPushButton" name="addBranchPB" >
+ <item row="8" column="2" colspan="2" >
+ <widget class="QPushButton" name="unknownPB" >
<property name="toolTip" >
<property name="toolTip" >
- <string>Add a new branch to the list</string>
+ <string>Show undefined branches used in this document.</string>
</property>
<property name="text" >
</property>
<property name="text" >
- <string>&Add</string>
+ <string>&Undefined Branches</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="0" column="0" >
- <widget class="QLabel" name="newBranchLA" >
+ <item row="8" column="0" colspan="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>251</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="3" >
+ <widget class="QLabel" name="availableLB" >
- <string>&New:</string>
+ <string>A&vailable Branches:</string>
</property>
<property name="buddy" >
</property>
<property name="buddy" >
- <cstring>newBranchLE</cstring>
+ <cstring>branchesTW</cstring>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item rowspan="5" row="2" column="0" colspan="3" >
- <widget class="QTreeWidget" name="branchesTW" />
- </item>
- <item row="6" column="3" >
+ <item row="7" column="3" >
<widget class="QPushButton" name="activatePB" >
<property name="toolTip" >
<string>Toggle the selected branch</string>
<widget class="QPushButton" name="activatePB" >
<property name="toolTip" >
<string>Toggle the selected branch</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="1" column="0" colspan="3" >
- <widget class="QLabel" name="availableLB" >
+ <item rowspan="6" row="2" column="0" colspan="3" >
+ <widget class="QTreeWidget" name="branchesTW" />
+ </item>
+ <item row="0" column="3" >
+ <widget class="QPushButton" name="addBranchPB" >
+ <property name="toolTip" >
+ <string>Add a new branch to the list</string>
+ </property>
- <string>A&vailable Branches:</string>
+ <string>&Add</string>
- <property name="buddy" >
- <cstring>branchesTW</cstring>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QLineEdit" name="newBranchLE" />
+ </item>
+ <item row="4" column="3" >
+ <widget class="QPushButton" name="colorPB" >
+ <property name="toolTip" >
+ <string>Define or change background color</string>
+ </property>
+ <property name="text" >
+ <string>Alter Co&lor...</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
+ <item row="2" column="3" >
+ <widget class="QPushButton" name="removePB" >
+ <property name="toolTip" >
+ <string>Remove the selected branch</string>
- <property name="sizeHint" >
- <size>
- <width>251</width>
- <height>20</height>
- </size>
+ <property name="text" >
+ <string>&Remove</string>
- <item row="7" column="2" colspan="2" >
- <widget class="QPushButton" name="unknownPB" >
+ <item row="3" column="3" >
+ <widget class="QPushButton" name="renamePB" >
<property name="toolTip" >
<property name="toolTip" >
- <string>Show undefined branches used in this document.</string>
+ <string>Change the name of the selected branch</string>
</property>
<property name="text" >
</property>
<property name="text" >
- <string>&Undefined Branches</string>
+ <string>Re&name...</string>
</property>
</widget>
</item>
</property>
</widget>
</item>