]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSymbols.cpp
On Mac, moving down a paragraph should place the cursor at the end of the current...
[lyx.git] / src / frontends / qt4 / GuiSymbols.cpp
index d8e713e100407b26354641d57776ec92f1685398..874f27587495f0af142ad555d88cf6d1451167ea 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -19,6 +19,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "Cursor.h"
 #include "Encoding.h"
 #include "FuncRequest.h"
 
@@ -30,6 +31,8 @@
 #include <QListWidgetItem>
 #include <QString>
 
+#include <cstdio>
+
 using namespace std;
 
 namespace lyx {
@@ -245,8 +248,9 @@ public:
 
        void setSymbols(QList<char_type> const & symbols)
        {
+               QAbstractItemModel::beginResetModel();
                symbols_ = symbols;
-               QAbstractItemModel::reset();
+               QAbstractItemModel::endResetModel();
        }
 
 private:
@@ -272,12 +276,13 @@ GuiSymbols::GuiSymbols(GuiView & lv)
        setFocusProxy(symbolsLW);
 
        symbolsLW->setViewMode(QListView::IconMode);
-       symbolsLW->setUniformItemSizes(true);
        // increase the display size of the symbols a bit
        QFont font= symbolsLW->font();
        int size = font.pointSize() + 3;
        font.setPointSize(size);
        symbolsLW->setFont(font);
+       QFontMetrics fm(font);
+       symbolsLW->setGridSize(QSize(fm.maxWidth() + 2, fm.height() + 2));
        symbolsLW->setModel(model_);
 }
 
@@ -383,13 +388,14 @@ void GuiSymbols::on_categoryFilterCB_toggled(bool on)
 
 void GuiSymbols::scrollToItem(QString const & category)
 {
-       if (used_blocks.find(category) != used_blocks.end()) {
-               int row = used_blocks[category];
-               QModelIndex index = symbolsLW->model()->index(row, 0, QModelIndex());
-               symbolsLW->scrollTo(index, QAbstractItemView::PositionAtTop);
-       }
+       if (used_blocks.find(category) == used_blocks.end())
+               return;
+       int row = used_blocks[category];
+       QModelIndex index = symbolsLW->model()->index(row, 0, QModelIndex());
+       symbolsLW->scrollTo(index, QAbstractItemView::PositionAtTop);
 }
 
+
 void GuiSymbols::updateSymbolList(bool update_combo)
 {
        QString category = categoryCO->currentText();
@@ -421,17 +427,12 @@ void GuiSymbols::updateSymbolList(bool update_combo)
                char_type c = *it;
                if (!update_combo && !show_all && (c <= range_start || c >= range_end))
                        continue;
-#if QT_VERSION >= 0x040300
                QChar::Category const cat = QChar::category(uint(c));
-#else
-               QChar const qc = uint(c);
-               QChar::Category const cat = qc.category();
-#endif
                // we do not want control or space characters
                if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
                        continue;
                ++numItem;
-               if (show_all || c >= range_start && c <= range_end)
+               if (show_all || (c >= range_start && c <= range_end))
                        s.append(c);
                if (update_combo) {
                        QString block = getBlock(c);
@@ -476,4 +477,4 @@ Dialog * createGuiSymbols(GuiView & lv)
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiSymbols_moc.cpp"
+#include "moc_GuiSymbols.cpp"