]> git.lyx.org Git - lyx.git/commitdiff
extend the idea of the previous patch a bit...
authorAndré Pönitz <poenitz@gmx.net>
Wed, 5 Mar 2008 20:48:19 +0000 (20:48 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 5 Mar 2008 20:48:19 +0000 (20:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23490 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/PanelStack.cpp
src/frontends/qt4/PanelStack.h

index ab66d2685b8c5bafeabc7dfc33e5cc3890eb591c..310673740782f9c21f221341d48fd4f345a91d8c 100644 (file)
@@ -983,22 +983,22 @@ GuiDocument::GuiDocument(GuiView & lv)
        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
@@ -1009,7 +1009,7 @@ GuiDocument::GuiDocument(GuiView & lv)
 
 void GuiDocument::showPreamble()
 {
-       docPS->setCurrentPanel(_("LaTeX Preamble"));
+       docPS->setCurrentPanel(qt_("LaTeX Preamble"));
 }
 
 
index 66614a61dde0a69c6397021f977e258750888e17..e35e8cc7a1b29e2e8b8b97c7e5bdc67a38196f89 100644 (file)
@@ -2240,7 +2240,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
        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
@@ -2258,7 +2258,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 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);
 }
index feb80b78be8225c684f0a8cd9f679cd575d95ed4..eae495878aed1c8d23214a74874c0b612fc5373b 100644 (file)
@@ -55,34 +55,27 @@ PanelStack::PanelStack(QWidget * parent)
 }
 
 
-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
@@ -94,38 +87,34 @@ void PanelStack::addCategory(docstring const & n, docstring const & parent)
 }
 
 
-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);
 }
 
 
index 1e38043b9548a594e480495b5155029b315e9558..45ca24bb25719d28723d943787c9ff381a9cb54a 100644 (file)
 #ifndef PANELSTACK_H
 #define PANELSTACK_H
 
-#include "support/docstring.h"
-
 #include <QWidget>
-
-#include <map>
+#include <QHash>
 
 class QTreeWidget;
 class QTreeWidgetItem;
@@ -30,31 +27,30 @@ class PanelStack : public QWidget
 {
        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_;