Well, I don't know. Please try yourself and let me know. Attached is two patches: First patch (toc.diff) prevents over-demoting and second one (TocBackend.diff), puts everything in TOC. (Abdel, This was what you had asked, isn't it?)
In my opinion, numbered TOC entries are structural elemens of a document. Non-numbered ones are used mostly for categorization elements. Therefore I vote for the first patch. I don't think putting another slider in dialog area is a good idea in terms of simpllicity of dialog. Similar settings are made in Document/Settings/Numbering & TOC, which is correct place for this IMHO. regards, Ugras On 5/15/07, Helge Hafting <[EMAIL PROTECTED]> wrote:
Ozgur Ugras BARAN wrote: > It is strictly dialog related problem, therefore I should have put > some function in controller. The place for a flag like demotionEnabled > maybe in TocBackend, but this doesn't remove the necessity of a > controller function. IMHO, the code is cleaner as it is now. > > My question was different, actually. What I am doing now is to prevent > demotion from the dialog. Another option would be not to filter TOC > entries in TOC dialog, therefore, demotion will never be a problem. > The downside of this method is over-crowded TOC dialog. Will that "crowding" be a problem? Only seeing the numbered entries looks like a somewhat arbitrary limitation. Of course, users then have configurability - they can see everything by temporarily making everything numbered. Another idea: Put in a slider so the user can decide how many levels to see. Default to all, or perhaps to the numbered levels. The user can then change to whatever he likes. Helge Hafting
Index: frontends/qt4/TocWidget.cpp =================================================================== --- frontends/qt4/TocWidget.cpp (revision 18311) +++ frontends/qt4/TocWidget.cpp (working copy) @@ -211,6 +211,8 @@ tocTV->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); tocTV->selectionModel()->blockSignals(false); + moveInTB->setEnabled(moveOutTB->isEnabled() && + form_->allowDemoteCurrentItem(typeCO->currentIndex())); } @@ -223,7 +225,8 @@ moveUpTB->setEnabled(enable); moveDownTB->setEnabled(enable); - moveInTB->setEnabled(enable); + moveInTB->setEnabled(enable && + form_->allowDemoteCurrentItem(typeCO->currentIndex())); moveOutTB->setEnabled(enable); depthSL->setEnabled(enable); Index: frontends/controllers/ControlToc.cpp =================================================================== --- frontends/controllers/ControlToc.cpp (revision 18311) +++ frontends/controllers/ControlToc.cpp (working copy) @@ -142,5 +142,11 @@ return _(type); } +bool ControlToc::allowDemoteCurrentItem(size_t type) const +{ + return (kernel().buffer().params().tocdepth + - getCurrentTocItem(type)->depth() + 1) > 0; +} + } // namespace frontend } // namespace lyx Index: frontends/controllers/ControlToc.h =================================================================== --- frontends/controllers/ControlToc.h (revision 18311) +++ frontends/controllers/ControlToc.h (working copy) @@ -62,6 +62,8 @@ bool canOutline(size_t type) const; /// void updateBackend(); + /// Is current item depth is equal the max allowed toc depth + bool allowDemoteCurrentItem(size_t type_) const; private: /// Return the guiname from a given cmdName of the TOC param
Index: TocBackend.cpp =================================================================== --- TocBackend.cpp (revision 18311) +++ TocBackend.cpp (working copy) @@ -156,7 +156,6 @@ int const toclevel = toc_item->par_it_->layout()->toclevel; if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel - && toclevel <= bufparams.tocdepth && tocstring.empty()) tocstring = toc_item->par_it_->asString(*buffer_, true); @@ -205,8 +204,7 @@ /// now the toc entry for the paragraph int const toclevel = pit->layout()->toclevel; if (toclevel != Layout::NOT_IN_TOC - && toclevel >= min_toclevel - && toclevel <= bufparams.tocdepth) { + && toclevel >= min_toclevel) { // insert this into the table of contents if (tocstring.empty()) tocstring = pit->asString(*buffer_, true);