mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 18:19:42 +00:00
Fix bug #6096.
We used to need a hack to set the size of the layout combo, but the code was changed in Qt 4.5 or so. Hence the appearance of this bug in 2009. We can now just remove this hack, and all seems to work correctly.
This commit is contained in:
parent
938ef60258
commit
d7f4346a19
@ -118,7 +118,7 @@ public:
|
|||||||
filterModel_(new GuiLayoutFilterModel(p)),
|
filterModel_(new GuiLayoutFilterModel(p)),
|
||||||
lastSel_(-1),
|
lastSel_(-1),
|
||||||
layoutItemDelegate_(new LayoutItemDelegate(parent)),
|
layoutItemDelegate_(new LayoutItemDelegate(parent)),
|
||||||
visibleCategories_(0), inShowPopup_(false)
|
visibleCategories_(0)
|
||||||
{
|
{
|
||||||
filterModel_->setSourceModel(model_);
|
filterModel_->setSourceModel(model_);
|
||||||
}
|
}
|
||||||
@ -149,8 +149,6 @@ public:
|
|||||||
LayoutItemDelegate * layoutItemDelegate_;
|
LayoutItemDelegate * layoutItemDelegate_;
|
||||||
///
|
///
|
||||||
unsigned visibleCategories_;
|
unsigned visibleCategories_;
|
||||||
///
|
|
||||||
bool inShowPopup_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -243,25 +241,6 @@ QSize LayoutItemDelegate::sizeHint(QStyleOptionViewItem const & opt,
|
|||||||
static_cast<QSortFilterProxyModel const *>(index.model());
|
static_cast<QSortFilterProxyModel const *>(index.model());
|
||||||
QSize size = QItemDelegate::sizeHint(opt, index);
|
QSize size = QItemDelegate::sizeHint(opt, index);
|
||||||
|
|
||||||
/// QComboBox uses the first row height to estimate the
|
|
||||||
/// complete popup height during QComboBox::showPopup().
|
|
||||||
/// To avoid scrolling we have to sneak in space for the headers.
|
|
||||||
/// So we tweak this value accordingly. It's not nice, but the
|
|
||||||
/// only possible way it seems.
|
|
||||||
if (lyxrc.group_layouts && index.row() == 0 && layout_->d->inShowPopup_) {
|
|
||||||
int itemHeight = size.height();
|
|
||||||
|
|
||||||
// we have to show \c cats many headers:
|
|
||||||
unsigned cats = layout_->d->visibleCategories_;
|
|
||||||
|
|
||||||
// and we have \c n items to distribute the needed space over
|
|
||||||
unsigned n = layout_->model()->rowCount();
|
|
||||||
|
|
||||||
// so the needed average height (rounded upwards) is:
|
|
||||||
size.setHeight((headerHeight(opt) * cats + itemHeight * n + n - 1) / n);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add space for the category headers here?
|
// Add space for the category headers here?
|
||||||
// Not for the standard layout though.
|
// Not for the standard layout though.
|
||||||
QString stdCat = category(*model->sourceModel(), 0);
|
QString stdCat = category(*model->sourceModel(), 0);
|
||||||
@ -378,23 +357,8 @@ void LayoutBox::Private::setFilter(QString const & s)
|
|||||||
p->setCurrentIndex(i.row());
|
p->setCurrentIndex(i.row());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround to resize to content size
|
|
||||||
// FIXME: There must be a better way. The QComboBox::AdjustToContents)
|
|
||||||
// does not help.
|
|
||||||
if (p->view()->isVisible()) {
|
if (p->view()->isVisible()) {
|
||||||
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
|
|
||||||
// the hack in the item delegate to make space for the headers.
|
|
||||||
// We do not call our implementation of showPopup because that
|
|
||||||
// would reset the filter again. This is only needed if the user clicks
|
|
||||||
// on the QComboBox.
|
|
||||||
LATTEST(!inShowPopup_);
|
|
||||||
inShowPopup_ = true;
|
|
||||||
p->QComboBox::showPopup();
|
p->QComboBox::showPopup();
|
||||||
inShowPopup_ = false;
|
|
||||||
|
|
||||||
// The item delegate hack is off again. So trigger a relayout of the popup.
|
|
||||||
filterModel_->triggerLayoutChange();
|
|
||||||
|
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
owner_.message(bformat(_("Filtering layouts with \"%1$s\". "
|
owner_.message(bformat(_("Filtering layouts with \"%1$s\". "
|
||||||
"Press ESC to remove filter."),
|
"Press ESC to remove filter."),
|
||||||
@ -462,15 +426,7 @@ void LayoutBox::showPopup()
|
|||||||
|
|
||||||
d->resetFilter();
|
d->resetFilter();
|
||||||
|
|
||||||
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
|
|
||||||
// the hack in the item delegate to make space for the headers.
|
|
||||||
LATTEST(!d->inShowPopup_);
|
|
||||||
d->inShowPopup_ = true;
|
|
||||||
QComboBox::showPopup();
|
QComboBox::showPopup();
|
||||||
d->inShowPopup_ = false;
|
|
||||||
|
|
||||||
// The item delegate hack is off again. So trigger a relayout of the popup.
|
|
||||||
d->filterModel_->triggerLayoutChange();
|
|
||||||
|
|
||||||
view()->setUpdatesEnabled(enabled);
|
view()->setUpdatesEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user