]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSymbols.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiSymbols.cpp
index 041a1d33d54af8232b19628859eeaa9d7639a545..1e7e7891bf2f73ac49ece06350475d533669cb5f 100644 (file)
@@ -31,6 +31,8 @@
 #include <QListWidgetItem>
 #include <QString>
 
+#include <cstdio>
+
 using namespace std;
 
 namespace lyx {
@@ -151,6 +153,7 @@ const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
 QString getBlock(char_type c)
 {
        // store an educated guess for the next search
+       // FIXME THREAD
        static int lastBlock = 0;
 
        // "clever reset"
@@ -196,7 +199,7 @@ class GuiSymbols::Model : public QAbstractItemModel
 {
 public:
        Model(GuiSymbols * parent)
-               : QAbstractItemModel(parent), parent_(parent)
+               : QAbstractItemModel(parent)
        {}
 
        QModelIndex index(int row, int column, QModelIndex const &) const
@@ -224,6 +227,7 @@ public:
                static QString const strCharacter = qt_("Character: ");
                static QString const strCodePoint = qt_("Code Point: ");
 
+               // FIXME THREAD
                static char codeName[10];
 
                char_type c = symbols_.at(index.row()); 
@@ -246,14 +250,14 @@ public:
 
        void setSymbols(QList<char_type> const & symbols)
        {
+               QAbstractItemModel::beginResetModel();
                symbols_ = symbols;
-               QAbstractItemModel::reset();
+               QAbstractItemModel::endResetModel();
        }
 
 private:
        friend class GuiSymbols;
-       GuiSymbols * parent_;
-       
+
        QList<char_type> symbols_;
 };
 
@@ -273,12 +277,17 @@ 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;
+       QFont font = symbolsLW->font();
+       const int size = font.pointSize() + 3;
        font.setPointSize(size);
        symbolsLW->setFont(font);
+       QFontMetrics fm(font);
+       const int cellHeight = fm.height() + 2;
+       // FIXME: using at least cellHeight because of
+       // QFontMetrics::maxWidth() is returning 0 with Qt/Cocoa on Mac OS
+       const int cellWidth = max(cellHeight, fm.maxWidth() + 2);
+       symbolsLW->setGridSize(QSize(cellWidth, cellHeight));
        symbolsLW->setModel(model_);
 }
 
@@ -423,11 +432,7 @@ 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::Category const cat = QChar(uint(c)).category();
-#endif
                // we do not want control or space characters
                if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
                        continue;