connect(floatModule, SIGNAL(changed()),
this, SLOT(change_adaptor()));
- docPS->addPanel(latexModule, _("Document Class"));
- docPS->addPanel(fontModule, _("Fonts"));
- docPS->addPanel(textLayoutModule, _("Text Layout"));
- docPS->addPanel(pageLayoutModule, _("Page Layout"));
- docPS->addPanel(marginsModule, _("Page Margins"));
- docPS->addPanel(langModule, _("Language"));
- docPS->addPanel(numberingModule, _("Numbering & TOC"));
- docPS->addPanel(biblioModule, _("Bibliography"));
- docPS->addPanel(pdfSupportModule, _("PDF Properties"));
- docPS->addPanel(mathsModule, _("Math Options"));
- docPS->addPanel(floatModule, _("Float Placement"));
- docPS->addPanel(bulletsModule, _("Bullets"));
- docPS->addPanel(branchesModule, _("Branches"));
- docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
- docPS->addPanel(preambleModule, _("LaTeX Preamble"));
- docPS->setCurrentPanel(_("Document Class"));
+ docPS->addPanel(latexModule, qt_("Document Class"));
+ docPS->addPanel(fontModule, qt_("Fonts"));
+ docPS->addPanel(textLayoutModule, qt_("Text Layout"));
+ docPS->addPanel(pageLayoutModule, qt_("Page Layout"));
+ docPS->addPanel(marginsModule, qt_("Page Margins"));
+ docPS->addPanel(langModule, qt_("Language"));
+ docPS->addPanel(numberingModule, qt_("Numbering & TOC"));
+ docPS->addPanel(biblioModule, qt_("Bibliography"));
+ docPS->addPanel(pdfSupportModule, qt_("PDF Properties"));
+ docPS->addPanel(mathsModule, qt_("Math Options"));
+ docPS->addPanel(floatModule, qt_("Float Placement"));
+ docPS->addPanel(bulletsModule, qt_("Bullets"));
+ docPS->addPanel(branchesModule, qt_("Branches"));
+ docPS->addPanel(embeddedFilesModule, qt_("Embedded Files"));
+ docPS->addPanel(preambleModule, qt_("LaTeX Preamble"));
+ docPS->setCurrentPanel(qt_("Document Class"));
// FIXME: hack to work around resizing bug in Qt >= 4.2
// bug verified with Qt 4.2.{0-3} (JSpitzm)
#if QT_VERSION >= 0x040200
void GuiDocument::showPreamble()
{
- docPS->setCurrentPanel(_("LaTeX Preamble"));
+ docPS->setCurrentPanel(qt_("LaTeX Preamble"));
}
add(converters);
add(formats);
- prefsPS->setCurrentPanel(_("User interface"));
+ prefsPS->setCurrentPanel(qt_("User interface"));
// FIXME: hack to work around resizing bug in Qt >= 4.2
// bug verified with Qt 4.2.{0-3} (JSpitzm)
#if QT_VERSION >= 0x040200
void GuiPreferences::add(PrefModule * module)
{
BOOST_ASSERT(module);
- prefsPS->addPanel(module, module->title());
+ prefsPS->addPanel(module, toqstr(module->title()));
connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
modules_.push_back(module);
}
}
-void PanelStack::addCategory(docstring const & n, docstring const & parent)
+void PanelStack::addCategory(QString const & name, QString const & parent)
{
QTreeWidgetItem * item = 0;
- QString const name = toqstr(n);
- LYXERR(Debug::GUI, "addCategory n= " << to_utf8(n) << " parent= ");
+ LYXERR(Debug::GUI, "addCategory n= " << fromqstr(name) << " parent= ");
int depth = 1;
- if (parent.empty()) {
+ if (parent.isEmpty()) {
item = new QTreeWidgetItem(list_);
item->setText(0, name);
}
else {
- PanelMap::iterator it = panel_map_.find(parent);
- //BOOST_ASSERT(it != panel_map_.end());
- if (it == panel_map_.end()) {
+ if (!panel_map_.contains(parent))
addCategory(parent);
- it = panel_map_.find(parent);
- }
- BOOST_ASSERT(it != panel_map_.end());
-
- item = new QTreeWidgetItem(it->second);
+ item = new QTreeWidgetItem(panel_map_.value(parent));
item->setText(0, name);
depth = 2;
}
- panel_map_[n] = item;
+ panel_map_[name] = item;
QFontMetrics fm(list_->font());
// calculate the real size the current item needs in the listview
}
-void PanelStack::addPanel(QWidget * panel, docstring const & name, docstring const & parent)
+void PanelStack::addPanel(QWidget * panel, QString const & name, QString const & parent)
{
addCategory(name, parent);
- QTreeWidgetItem * item = panel_map_.find(name)->second;
-
+ QTreeWidgetItem * item = panel_map_.value(name);
widget_map_[item] = panel;
stack_->addWidget(panel);
stack_->setMinimumSize(panel->minimumSize());
}
-void PanelStack::setCurrentPanel(docstring const & name)
+void PanelStack::setCurrentPanel(QString const & name)
{
- PanelMap::const_iterator cit = panel_map_.find(name);
- BOOST_ASSERT(cit != panel_map_.end());
+ QTreeWidgetItem * item = panel_map_.value(name, 0);
+ BOOST_ASSERT(item);
// force on first set
- if (list_->currentItem() == cit->second)
- switchPanel(cit->second);
+ if (list_->currentItem() == item)
+ switchPanel(item);
- list_->setCurrentItem(cit->second);
+ list_->setCurrentItem(item);
}
void PanelStack::switchPanel(QTreeWidgetItem * item,
QTreeWidgetItem * /*previous*/)
{
- WidgetMap::const_iterator cit = widget_map_.find(item);
- if (cit == widget_map_.end())
- return;
-
- stack_->setCurrentWidget(cit->second);
+ if (QWidget * w = widget_map_.value(item, 0))
+ stack_->setCurrentWidget(w);
}
#ifndef PANELSTACK_H
#define PANELSTACK_H
-#include "support/docstring.h"
-
#include <QWidget>
-
-#include <map>
+#include <QHash>
class QTreeWidget;
class QTreeWidgetItem;
{
Q_OBJECT
public:
+ ///
PanelStack(QWidget * parent = 0);
/// add a category with no associated panel
- void addCategory(docstring const & name,
- docstring const & parent = docstring());
-
+ void addCategory(QString const & name, QString const & parent = QString());
/// add a widget panel with a given name, under the given parent
- void addPanel(QWidget * panel, docstring const & name,
- docstring const & parent = docstring());
-
+ void addPanel(QWidget * panel, QString const & name,
+ QString const & parent = QString());
/// set current panel by logical name
- void setCurrentPanel(docstring const &);
-
- virtual QSize sizeHint() const;
+ void setCurrentPanel(QString const &);
+ ///
+ QSize sizeHint() const;
public Q_SLOTS:
/// set current panel from an item
void switchPanel(QTreeWidgetItem * it, QTreeWidgetItem * previous = 0);
private:
- typedef std::map<docstring, QTreeWidgetItem *> PanelMap;
-
+ ///
+ typedef QHash<QString, QTreeWidgetItem *> PanelMap;
+ ///
PanelMap panel_map_;
- typedef std::map<QTreeWidgetItem *, QWidget *> WidgetMap;
+ typedef QHash<QTreeWidgetItem *, QWidget *> WidgetMap;
WidgetMap widget_map_;