X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FPanelStack.cpp;h=343b36ecb087f180340312dbfed15cfb8c348b19;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=596096715bbb66bff329d2a4e687eecf6db98a97;hpb=5861442f6f20b6df88b66aa8805c20deb63b2353;p=lyx.git diff --git a/src/frontends/qt4/PanelStack.cpp b/src/frontends/qt4/PanelStack.cpp index 596096715b..343b36ecb0 100644 --- a/src/frontends/qt4/PanelStack.cpp +++ b/src/frontends/qt4/PanelStack.cpp @@ -17,15 +17,13 @@ #include "support/debug.h" #include -#include -#include #include #include +#include +#include #include "support/lassert.h" -#include - using namespace std; namespace lyx { @@ -40,13 +38,9 @@ PanelStack::PanelStack(QWidget * parent) list_->setRootIsDecorated(false); list_->setColumnCount(1); - // Hide the pointless list header list_->header()->hide(); -// QStringList HeaderLabels; -// HeaderLabels << QString("Category"); -// list_->setHeaderLabels(HeaderLabels); - connect(list_, SIGNAL(currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)), + connect(list_, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(switchPanel(QTreeWidgetItem *, QTreeWidgetItem*))); connect(list_, SIGNAL(itemClicked (QTreeWidgetItem*, int)), this, SLOT(itemSelected(QTreeWidgetItem *, int))); @@ -83,8 +77,7 @@ void PanelStack::addCategory(QString const & name, QString const & parent) QFontMetrics fm(list_->font()); // calculate the real size the current item needs in the listview - int itemsize = fm.width(name) + 10 - + list_->indentation() * depth; + int itemsize = fm.width(name) + 10 + list_->indentation() * depth; // adjust the listview width to the max. itemsize if (itemsize > list_->minimumWidth()) list_->setMinimumWidth(itemsize); @@ -101,10 +94,19 @@ void PanelStack::addPanel(QWidget * panel, QString const & name, QString const & } +void PanelStack::showPanel(QString const & name, bool show) +{ + QTreeWidgetItem * item = panel_map_.value(name, 0); + LASSERT(item, return); + + item->setHidden(!show); +} + + void PanelStack::setCurrentPanel(QString const & name) { QTreeWidgetItem * item = panel_map_.value(name, 0); - LASSERT(item, /**/); + LASSERT(item, return); // force on first set if (list_->currentItem() == item) @@ -114,6 +116,15 @@ void PanelStack::setCurrentPanel(QString const & name) } +bool PanelStack::isCurrentPanel(QString const & name) const +{ + QTreeWidgetItem * item = panel_map_.value(name, 0); + LASSERT(item, return false); + + return (list_->currentItem() == item); +} + + void PanelStack::switchPanel(QTreeWidgetItem * item, QTreeWidgetItem * previous) { @@ -128,9 +139,9 @@ void PanelStack::switchPanel(QTreeWidgetItem * item, if (previous && previous->parent() != item) switchPanel( item->child(0), previous ); } - else - if (QWidget * w = widget_map_.value(item, 0)) - stack_->setCurrentWidget(w); + else if (QWidget * w = widget_map_.value(item, 0)) { + stack_->setCurrentWidget(w); + } } @@ -151,4 +162,4 @@ QSize PanelStack::sizeHint() const } // namespace frontend } // namespace lyx -#include "PanelStack_moc.cpp" +#include "moc_PanelStack.cpp"