: QAbstractItemDelegate(parent) {}
///
- void paint(QPainter * painter, const QStyleOptionViewItem & option,
- const QModelIndex &index) const {
+ void paint(QPainter * painter, QStyleOptionViewItem const & option,
+ QModelIndex const & index) const {
QComboBox * combo = static_cast<QComboBox const *>(parent());
// Draw using the menu item style (this is how QComboBox does it).
}
///
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const {
+ QSize sizeHint(QStyleOptionViewItem const & option,
+ QModelIndex const & index) const {
QComboBox * combo = static_cast<QComboBox const *>(parent());
QStyleOptionMenuItem opt = getStyleOption(option, index);
}
///
- QStyleOptionMenuItem getStyleOption(const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+ QStyleOptionMenuItem getStyleOption(QStyleOptionViewItem const & option,
+ QModelIndex const & index) const
{
QComboBox * combo = static_cast<QComboBox const *>(parent());
public:
///
GuiFilterProxyModel(QObject * parent)
- : QSortFilterProxyModel(parent) {}
+ : QSortFilterProxyModel(parent) {}
///
void setCharFilter(QString const & f)
if (i.isValid())
setCurrentIndex(i.row());
}
+
+ // Workaround to resize to content size
+ // FIXME: There must be a better way. The QComboBox::AdjustToContents)
+ // does not help.
+ if (view()->isVisible())
+ QComboBox::showPopup();
}
}
+void GuiLayoutBox::showPopup()
+{
+ resetFilter();
+ owner_.message(_("Enter characters to filter the layout list."));
+ QComboBox::showPopup();
+}
+
+
bool GuiLayoutBox::eventFilter(QObject * o, QEvent * e)
{
if (e->type() != QEvent::KeyPress)
return;
}
- // find row to insert the item
+ // find row to insert the item, after the separator if it exists
int i = 1; // skip the Standard layout
- QString is = model_->item(i, 0)->text();
- while (is.compare(titem) < 0) {
- // e.g. --Separator--
- if (is[0].category() != QChar::Letter_Uppercase)
- break;
- ++i;
- if (i == end)
- break;
- is = model_->item(i, 0)->text();
+
+ QList<QStandardItem *> sep = model_->findItems("--", Qt::MatchStartsWith);
+ if (!sep.isEmpty())
+ i = sep.first()->index().row() + 1;
+ if (i < model_->rowCount()) {
+ // find alphabetic position
+ QString is = model_->item(i, 0)->text();
+ while (is.compare(titem) < 0) {
+ // e.g. --Separator--
+ if (is.at(0).category() != QChar::Letter_Uppercase)
+ break;
+ ++i;
+ if (i == end)
+ break;
+ is = model_->item(i, 0)->text();
+ }
}
model_->insertRow(i, row);