#include <QHBoxLayout>
#include <QHeaderView>
-#include <boost/assert.hpp>
+#include "support/lassert.h"
#include <iostream>
connect(list_, SIGNAL(currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT(switchPanel(QTreeWidgetItem *, QTreeWidgetItem*)));
+ connect(list_, SIGNAL(itemClicked (QTreeWidgetItem*, int)),
+ this, SLOT(itemSelected(QTreeWidgetItem *, int)));
QHBoxLayout * layout = new QHBoxLayout(this);
layout->addWidget(list_, 0);
{
QTreeWidgetItem * item = 0;
- LYXERR(Debug::GUI, "addCategory n= " << fromqstr(name) << " parent= ");
+ LYXERR(Debug::GUI, "addCategory n= " << name << " parent= ");
int depth = 1;
void PanelStack::setCurrentPanel(QString const & name)
{
QTreeWidgetItem * item = panel_map_.value(name, 0);
- BOOST_ASSERT(item);
+ LASSERT(item, /**/);
// force on first set
if (list_->currentItem() == item)
void PanelStack::switchPanel(QTreeWidgetItem * item,
- QTreeWidgetItem * /*previous*/)
+ QTreeWidgetItem * previous)
{
// if we have a category, expand the tree and go to the
// first item
if (item->childCount() > 0) {
item->setExpanded(true);
- list_->setCurrentItem(item->child(0));
+ if (previous != item->child(0))
+ list_->setCurrentItem(item->child(0));
}
if (QWidget * w = widget_map_.value(item, 0))
stack_->setCurrentWidget(w);
}
+void PanelStack::itemSelected(QTreeWidgetItem * item, int)
+{
+ // de-select the category if a child is selected
+ if (item->childCount() > 0 && item->child(0)->isSelected())
+ item->setSelected(false);
+}
+
+
QSize PanelStack::sizeHint() const
{
return QSize(list_->width() + stack_->width(),