mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
* Add possibility to append active branch names to the output file name (#3105).
File format change. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30546 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9d857249b0
commit
e6f922009f
@ -1,6 +1,10 @@
|
||||
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.
|
||||
|
@ -750,6 +750,16 @@ def revert_longtable_align(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
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]
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -772,10 +782,12 @@ convert = [[346, []],
|
||||
[360, []],
|
||||
[361, []],
|
||||
[362, []],
|
||||
[363, []]
|
||||
[363, []],
|
||||
[364, []]
|
||||
]
|
||||
|
||||
revert = [[362, [revert_longtable_align]],
|
||||
revert = [[363, [revert_branch_filename]],
|
||||
[362, [revert_longtable_align]],
|
||||
[361, [revert_applemac]],
|
||||
[360, []],
|
||||
[359, [revert_nomencl_cwidth]],
|
||||
|
@ -4,6 +4,7 @@
|
||||
* 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.
|
||||
*/
|
||||
@ -15,6 +16,8 @@
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
@ -39,7 +42,8 @@ private:
|
||||
}
|
||||
|
||||
|
||||
Branch::Branch() : selected_(false)
|
||||
Branch::Branch()
|
||||
: selected_(false), filenameSuffix_(false)
|
||||
{
|
||||
// no theApp() with command line export
|
||||
if (theApp())
|
||||
@ -74,6 +78,18 @@ bool Branch::setSelected(bool b)
|
||||
}
|
||||
|
||||
|
||||
bool Branch::hasFilenameSuffix() const
|
||||
{
|
||||
return filenameSuffix_;
|
||||
}
|
||||
|
||||
|
||||
void Branch::setFilenameSuffix(bool b)
|
||||
{
|
||||
filenameSuffix_ = b;
|
||||
}
|
||||
|
||||
|
||||
RGBColor const & Branch::color() const
|
||||
{
|
||||
return color_;
|
||||
@ -132,6 +148,7 @@ bool BranchList::add(docstring const & s)
|
||||
Branch br;
|
||||
br.setBranch(name);
|
||||
br.setSelected(false);
|
||||
br.setFilenameSuffix(false);
|
||||
list.push_back(br);
|
||||
}
|
||||
if (j == docstring::npos)
|
||||
@ -171,4 +188,15 @@ bool BranchList::rename(docstring const & oldname,
|
||||
}
|
||||
|
||||
|
||||
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("_"));
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -53,6 +53,12 @@ public:
|
||||
* \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;
|
||||
///
|
||||
@ -71,6 +77,8 @@ private:
|
||||
///
|
||||
bool selected_;
|
||||
///
|
||||
bool filenameSuffix_;
|
||||
///
|
||||
RGBColor color_;
|
||||
};
|
||||
|
||||
@ -111,6 +119,8 @@ public:
|
||||
* 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;
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -127,7 +127,7 @@ namespace {
|
||||
|
||||
// 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;
|
||||
@ -440,12 +440,29 @@ Undo & Buffer::undo()
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -2958,7 +2975,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
|
||||
return true;
|
||||
}
|
||||
|
||||
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 =
|
||||
|
@ -551,6 +551,11 @@ private:
|
||||
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.
|
||||
|
@ -618,6 +618,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
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();
|
||||
@ -849,6 +854,7 @@ void BufferParams::writeFile(ostream & os) const
|
||||
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";
|
||||
|
@ -49,6 +49,7 @@ GuiBranches::GuiBranches(QWidget * parent)
|
||||
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);
|
||||
@ -101,6 +102,7 @@ void GuiBranches::updateView()
|
||||
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);
|
||||
@ -114,6 +116,7 @@ void GuiBranches::updateView()
|
||||
renamePB->setEnabled(have_sel);
|
||||
colorPB->setEnabled(have_sel);
|
||||
activatePB->setEnabled(have_sel);
|
||||
suffixPB->setEnabled(have_sel);
|
||||
// emit signal
|
||||
changed();
|
||||
}
|
||||
@ -193,12 +196,20 @@ void GuiBranches::on_activatePB_pressed()
|
||||
}
|
||||
|
||||
|
||||
void GuiBranches::on_suffixPB_pressed()
|
||||
{
|
||||
toggleSuffix(branchesTW->currentItem());
|
||||
}
|
||||
|
||||
|
||||
void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col)
|
||||
{
|
||||
if (col < 2)
|
||||
toggleBranch(item);
|
||||
else
|
||||
else if (col == 2)
|
||||
toggleColor(item);
|
||||
else if (col == 3)
|
||||
toggleSuffix(item);
|
||||
}
|
||||
|
||||
|
||||
@ -210,6 +221,7 @@ void GuiBranches::on_branchesTW_itemSelectionChanged()
|
||||
renamePB->setEnabled(have_sel);
|
||||
colorPB->setEnabled(have_sel);
|
||||
activatePB->setEnabled(have_sel);
|
||||
suffixPB->setEnabled(have_sel);
|
||||
}
|
||||
|
||||
|
||||
@ -222,9 +234,8 @@ void GuiBranches::toggleBranch(QTreeWidgetItem * item)
|
||||
if (sel_branch.isEmpty())
|
||||
return;
|
||||
|
||||
bool const selected = (item->text(1) == qt_("Yes"));
|
||||
Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
|
||||
if (branch && branch->setSelected(!selected)) {
|
||||
if (branch && branch->setSelected(!branch->isSelected())) {
|
||||
newBranchLE->clear();
|
||||
updateView();
|
||||
}
|
||||
@ -263,6 +274,24 @@ void GuiBranches::toggleColor(QTreeWidgetItem * item)
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
@ -55,6 +55,7 @@ Q_SIGNALS:
|
||||
protected:
|
||||
void toggleBranch(QTreeWidgetItem *);
|
||||
void toggleColor(QTreeWidgetItem *);
|
||||
void toggleSuffix(QTreeWidgetItem *);
|
||||
void updateView();
|
||||
|
||||
protected Q_SLOTS:
|
||||
@ -65,6 +66,7 @@ protected Q_SLOTS:
|
||||
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();
|
||||
|
@ -19,13 +19,108 @@
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="3" >
|
||||
<widget class="QPushButton" name="renamePB" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="newBranchLA" >
|
||||
<property name="text" >
|
||||
<string>&New:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>newBranchLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3" >
|
||||
<widget class="QPushButton" name="suffixPB" >
|
||||
<property name="toolTip" >
|
||||
<string>Change the name of the selected branch</string>
|
||||
<string>Append the name of this branch to the output filename, given the branch is active.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Re&name...</string>
|
||||
<string>Filename &Suffix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>83</width>
|
||||
<height>51</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="2" colspan="2" >
|
||||
<widget class="QPushButton" name="unknownPB" >
|
||||
<property name="toolTip" >
|
||||
<string>Show undefined branches used in this document.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Undefined Branches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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" >
|
||||
<property name="text" >
|
||||
<string>A&vailable Branches:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>branchesTW</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3" >
|
||||
<widget class="QPushButton" name="activatePB" >
|
||||
<property name="toolTip" >
|
||||
<string>Toggle the selected branch</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>(&De)activate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
<property name="text" >
|
||||
<string>&Add</string>
|
||||
</property>
|
||||
</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>
|
||||
@ -39,98 +134,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3" >
|
||||
<widget class="QPushButton" name="colorPB" >
|
||||
<item row="3" column="3" >
|
||||
<widget class="QPushButton" name="renamePB" >
|
||||
<property name="toolTip" >
|
||||
<string>Define or change background color</string>
|
||||
<string>Change the name of the selected branch</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Alter Co&lor...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>83</width>
|
||||
<height>61</height>
|
||||
</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" >
|
||||
<property name="toolTip" >
|
||||
<string>Add a new branch to the list</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="newBranchLA" >
|
||||
<property name="text" >
|
||||
<string>&New:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>newBranchLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item rowspan="5" row="2" column="0" colspan="3" >
|
||||
<widget class="QTreeWidget" name="branchesTW" />
|
||||
</item>
|
||||
<item row="6" column="3" >
|
||||
<widget class="QPushButton" name="activatePB" >
|
||||
<property name="toolTip" >
|
||||
<string>Toggle the selected branch</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>(&De)activate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QLabel" name="availableLB" >
|
||||
<property name="text" >
|
||||
<string>A&vailable Branches:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>branchesTW</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" 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="7" column="2" colspan="2" >
|
||||
<widget class="QPushButton" name="unknownPB" >
|
||||
<property name="toolTip" >
|
||||
<string>Show undefined branches used in this document.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Undefined Branches</string>
|
||||
<string>Re&name...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user