X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FPanelStack.cpp;h=0c65cfea1280d0ea7c987ade3075dba0d7a3e11a;hb=e029b216b7e56ce3a41ef0b853045c37c7d155d8;hp=b4e24554d59361e55144f815041c0ac9c6f7a428;hpb=7f461f4392a19cf488dec005d2f12cfea83655d9;p=lyx.git diff --git a/src/frontends/qt4/PanelStack.cpp b/src/frontends/qt4/PanelStack.cpp index b4e24554d5..0c65cfea12 100644 --- a/src/frontends/qt4/PanelStack.cpp +++ b/src/frontends/qt4/PanelStack.cpp @@ -17,14 +17,12 @@ #include "support/debug.h" #include -#include -#include #include #include +#include +#include -#include "support/assert.h" - -#include +#include "support/lassert.h" using namespace std; @@ -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))); @@ -61,7 +55,7 @@ void PanelStack::addCategory(QString const & name, QString const & parent) { QTreeWidgetItem * item = 0; - LYXERR(Debug::GUI, "addCategory n= " << fromqstr(name) << " parent= "); + LYXERR(Debug::GUI, "addCategory n= " << name << " parent= "); int depth = 1; @@ -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); @@ -104,7 +97,7 @@ void PanelStack::addPanel(QWidget * panel, QString const & name, QString const & 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) @@ -117,15 +110,20 @@ void PanelStack::setCurrentPanel(QString const & name) void PanelStack::switchPanel(QTreeWidgetItem * item, QTreeWidgetItem * previous) { + // do nothing when clicked on whitespace (item=NULL) + if( !item ) + return; + // if we have a category, expand the tree and go to the // first item if (item->childCount() > 0) { item->setExpanded(true); - if (previous != item->child(0)) - list_->setCurrentItem(item->child(0)); + if (previous && previous->parent() != item) + switchPanel( item->child(0), previous ); } - if (QWidget * w = widget_map_.value(item, 0)) + else if (QWidget * w = widget_map_.value(item, 0)) { stack_->setCurrentWidget(w); + } } @@ -146,4 +144,4 @@ QSize PanelStack::sizeHint() const } // namespace frontend } // namespace lyx -#include "PanelStack_moc.cpp" +#include "moc_PanelStack.cpp"