if (cit->first == "tableofcontents")
continue;
- string const & floatName = floatlist.getType(cit->first).listName();
- QString label;
- bool in_other_list = true;
- if (!floatName.empty()) {
- label = qt_(floatName);
- in_other_list = false;
- }
- else if (cit->first == "child") {
- label = qt_("Child Documents");
- in_other_list = false;
- } else if (cit->first == "graphics")
- label = qt_("List of Graphics");
- else if (cit->first == "equation")
- label = qt_("List of Equations");
- else if (cit->first == "index")
- label = qt_("List of Indexes");
- else if (cit->first == "listing") {
+ if (cit->first == "listing") {
// FIXME: the listing navigate menu causes a crash for unknown
// reason. See http://bugzilla.lyx.org/show_bug.cgi?id=4613
- // This is a temporary fix:
- //label = qt_("List of Listings");
continue;
}
- else if (cit->first == "marginalnote")
- label = qt_("List of Marginal notes");
- else if (cit->first == "note")
- label = qt_("List of Notes");
- else if (cit->first == "footnote")
- label = qt_("List of Footnotes");
- else if (cit->first == "label")
- label = qt_("Labels and References");
- else if (cit->first == "citation")
- label = qt_("List of Citations");
- else
- // This should not happen unless the entry is missing above.
- label = qt_("Other floats: ") + toqstr(cit->first);
MenuDefinition submenu;
-
if (cit->second.size() >= 30) {
FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
TocIterator ccit = cit->second.begin();
TocIterator eend = cit->second.end();
for (; ccit != eend; ++ccit) {
- QString const label = limitStringLength(ccit->str());
- submenu.add(MenuItem(MenuItem::Command, label,
+ submenu.add(MenuItem(MenuItem::Command,
+ limitStringLength(ccit->str()),
FuncRequest(ccit->action())));
}
}
- MenuItem item(MenuItem::Submenu, label);
+ MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
item.setSubmenu(submenu);
- if (in_other_list)
- other_lists.add(item);
- else {
+ if (floatlist.typeExist(cit->first) || cit->first == "child") {
+ // Those two types deserve to be in the main menu.
item.setSubmenu(submenu);
add(item);
- }
+ } else
+ other_lists.add(item);
}
if (!other_lists.empty()) {
MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
add(item);
}
-
// Handle normal TOC
cit = toc_list.find("tableofcontents");
if (cit == end) {
addWithStatusCheck(MenuItem(MenuItem::Command,
qt_("No Table of contents"),
FuncRequest()));
- } else {
+ } else
expandToc2(cit->second, 0, cit->second.size(), 0);
- }
}
#include "TocModel.h"
#include "Buffer.h"
-#include "BufferParams.h"
#include "BufferView.h"
-#include "DocIterator.h"
#include "Cursor.h"
-#include "FloatList.h"
+#include "DocIterator.h"
#include "FuncRequest.h"
#include "LyXFunc.h"
-#include "TextClass.h"
#include "support/convert.h"
#include "support/debug.h"
}
-QString TocModels::guiName(string const & type) const
-{
- if (type == "tableofcontents")
- return qt_("Table of Contents");
- if (type == "child")
- return qt_("Child Documents");
- if (type == "graphics")
- return qt_("List of Graphics");
- if (type == "equation")
- return qt_("List of Equations");
- if (type == "footnote")
- return qt_("List of Footnotes");
- if (type == "listing")
- return qt_("List of Listings");
- if (type == "index")
- return qt_("List of Indexes");
- if (type == "marginalnote")
- return qt_("List of Marginal notes");
- if (type == "note")
- return qt_("List of Notes");
- if (type == "citation")
- return qt_("List of Citations");
- if (type == "label")
- return qt_("Labels and References");
-
- FloatList const & floats = bv_->buffer().params().documentClass().floats();
- if (floats.typeExist(type))
- return qt_(floats.getType(type).listName());
-
- return qt_(type);
-}
-
-
void TocModels::reset(BufferView const * bv)
{
bv_ = bv;
TocList::const_iterator end = tocs.end();
for (; it != end; ++it) {
types_.push_back(toqstr(it->first));
- type_names_.push_back(guiName(it->first));
+ type_names_.push_back(guiName(it->first, bv->buffer().params()));
models_.push_back(new TocModel(it->second));
}
}
private:
///
void clear();
- /// Return the guiname from a given cmdName of the TOC param
- QString guiName(std::string const & type) const;
///
BufferView const * bv_;
///
#include "frontends/alert.h"
+#include "BufferParams.h"
+#include "FloatList.h"
#include "Language.h"
#include "Length.h"
+#include "TextClass.h"
#include "support/debug.h"
#include "support/filetools.h"
return list;
}
+
+QString guiName(string const & type, BufferParams const & bp)
+{
+ if (type == "tableofcontents")
+ return qt_("Table of Contents");
+ if (type == "child")
+ return qt_("Child Documents");
+ if (type == "graphics")
+ return qt_("List of Graphics");
+ if (type == "equation")
+ return qt_("List of Equations");
+ if (type == "footnote")
+ return qt_("List of Footnotes");
+ if (type == "listing")
+ return qt_("List of Listings");
+ if (type == "index")
+ return qt_("List of Indexes");
+ if (type == "marginalnote")
+ return qt_("List of Marginal notes");
+ if (type == "note")
+ return qt_("List of Notes");
+ if (type == "citation")
+ return qt_("List of Citations");
+ if (type == "label")
+ return qt_("Labels and References");
+
+ FloatList const & floats = bp.documentClass().floats();
+ if (floats.typeExist(type))
+ return qt_(floats.getType(type).listName());
+
+ return qt_(type);
+}
+
+
} // namespace lyx
namespace support { class FileName; }
+class BufferParams;
class LyXErr;
LyXErr & operator<<(LyXErr &, QString const &);
QString makeAbsPath(QString const & relpath, QString const & base);
QString changeExtension(QString const & oldname, QString const & ext);
+/// \return the display string associated with given type and buffer
+/// parameter.
+QString guiName(std::string const & type, BufferParams const & bp);
+
} // namespace lyx
#endif // QTHELPERS_H