[LyX/master] Improve \includeonly support
Juergen Spitzmueller <[email protected]> Sun, 28 Jun 2026 14:31:30 +0000
| Newsgroups | gmane.editors.lyx.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit b2a896f2f8a363f8928986b5940464b8fd515f50 Author: Juergen Spitzmueller <[email protected]> Date: Sun Jun 28 16:30:28 2026 +0200 Improve \includeonly support It _is_ possible to exclude all (empty \includeonly) as well as to include all. So let us allow this. --- src/BufferParams.cpp | 2 ++ src/frontends/qt/GuiDocument.cpp | 37 ++++++++++++------------------------- src/frontends/qt/GuiDocument.h | 2 +- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 88c37e26a4..6e8abdf2ac 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2432,6 +2432,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, // we do not use "auto const &" here, because incfile is modified later // coverity[auto_causes_copy] for (auto incfile : included_children_) { + if (incfile == "@none@") + continue; FileName inc = makeAbsPath(incfile, filepath.absFileName()); string mangled = DocFileName(changeExtension(inc.absFileName(), ".tex")). mangledFileName(); diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 3c8b62050c..f25fa5e572 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -2169,15 +2169,12 @@ void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int) if (isChildIncluded(child)) includeonlys_.remove(child); - else + else { + includeonlys_.remove("@none@"); includeonlys_.push_back(child); + } - if (int(includeonlys_.size()) == masterChildModule->childrenTW->topLevelItemCount()) - Alert::warning(_("All children selected!"), - _("If not at least one child is excluded, " - "this will be reset to 'Include all children' " - "after application.")); - updateIncludeonlys(false); + updateIncludeonlys(); change_adaptor(); } @@ -3994,9 +3991,13 @@ void GuiDocument::applyView() bp_.clearIncludedChildren(); updateIncludeonlys(); if (masterChildModule->includeonlyRB->isChecked()) { - list<string>::const_iterator it = includeonlys_.begin(); - for (; it != includeonlys_.end() ; ++it) { - bp_.addIncludedChildren(*it); + if (includeonlys_.empty()) + bp_.addIncludedChildren("@none@"); + else { + list<string>::const_iterator it = includeonlys_.begin(); + for (; it != includeonlys_.end() ; ++it) { + bp_.addIncludedChildren(*it); + } } } if (masterChildModule->maintainCRNoneRB->isChecked()) @@ -4963,10 +4964,6 @@ void GuiDocument::updateIncludeonlyDisplay() { if (includeonlys_.empty()) { masterChildModule->includeallRB->setChecked(true); - // Disable "Include selected only" if there is - // only one to select from - masterChildModule->includeonlyRB->setEnabled( - masterChildModule->childrenTW->topLevelItemCount() > 1); masterChildModule->childrenTW->setEnabled(false); masterChildModule->maintainGB->setEnabled(false); } else { @@ -4977,7 +4974,7 @@ void GuiDocument::updateIncludeonlyDisplay() } -void GuiDocument::updateIncludeonlys(bool const cleanup) +void GuiDocument::updateIncludeonlys() { masterChildModule->childrenTW->clear(); QString const no = qt_("No"); @@ -4986,8 +4983,6 @@ void GuiDocument::updateIncludeonlys(bool const cleanup) ListOfBuffers children = buffer().getChildren(); ListOfBuffers::const_iterator it = children.begin(); ListOfBuffers::const_iterator end = children.end(); - bool has_unincluded = false; - bool all_unincluded = true; for (; it != end; ++it) { QTreeWidgetItem * item = new QTreeWidgetItem(masterChildModule->childrenTW); // FIXME Unicode @@ -4996,15 +4991,7 @@ void GuiDocument::updateIncludeonlys(bool const cleanup) from_utf8(buffer().filePath()))); item->setText(0, toqstr(name)); item->setText(1, isChildIncluded(name) ? yes : no); - if (!isChildIncluded(name)) - has_unincluded = true; - else - all_unincluded = false; } - // Both if all children are included and if none is included - // is equal to "include all" (i.e., omit \includeonly). - if (cleanup && (!has_unincluded || all_unincluded)) - includeonlys_.clear(); } diff --git a/src/frontends/qt/GuiDocument.h b/src/frontends/qt/GuiDocument.h index 686ab5a1ed..d7eae7b632 100644 --- a/src/frontends/qt/GuiDocument.h +++ b/src/frontends/qt/GuiDocument.h @@ -232,7 +232,7 @@ private: /// void updateIncludeonlyDisplay(); /// - void updateIncludeonlys(bool const cleanup = true); + void updateIncludeonlys(); /// void updateDefaultBiblio(std::string const & style, std::string const & which = std::string()); -- lyx-cvs mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-cvs