]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiToolbar.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiToolbar.cpp
index 680d45d19d0eb79fc2f78cdae34bd2b3f503fcda..ed6277df583dca60083a741d130b6381a8bde518 100644 (file)
@@ -248,8 +248,8 @@ public:
        : 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).
@@ -284,8 +284,8 @@ public:
        }
        
        ///
-       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);
@@ -325,8 +325,8 @@ private:
        }
 
        ///
-       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());
 
@@ -360,7 +360,7 @@ class GuiFilterProxyModel : public QSortFilterProxyModel
 public:
        ///
        GuiFilterProxyModel(QObject * parent)
-       : QSortFilterProxyModel(parent) {}
+               : QSortFilterProxyModel(parent) {}
 
        ///
        void setCharFilter(QString const & f)
@@ -426,6 +426,12 @@ void GuiLayoutBox::setFilter(QString const & s)
                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();
 }
 
 
@@ -435,6 +441,14 @@ void GuiLayoutBox::resetFilter()
 }
 
 
+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)
@@ -533,7 +547,7 @@ void GuiLayoutBox::addItemSort(docstring const & item, bool sorted)
                QString is = model_->item(i, 0)->text();
                while (is.compare(titem) < 0) {
                        // e.g. --Separator--
-                       if (is[0].category() != QChar::Letter_Uppercase)
+                       if (is.at(0).category() != QChar::Letter_Uppercase)
                                break;
                        ++i;
                        if (i == end)