From 8d9c9386be6e45fdf919a3ac5bf79f5cde315142 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Fri, 5 Feb 2010 18:21:47 +0100
Subject: drastically improve load time of TS files

it isn't such a good idea to insert rows one by one into the model.
so instead batch the "announcement" of new data.

unloading single models is still slow, but that's a corner use case, so
don't bother fixing it now, especially as it is harder to do it.
---
 tools/linguist/linguist/messagemodel.cpp | 48 +++++++++++++++++++++-----------
 tools/linguist/linguist/messagemodel.h   |  2 +-
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp
index 6572059..4e2b473 100644
--- a/tools/linguist/linguist/messagemodel.cpp
+++ b/tools/linguist/linguist/messagemodel.cpp
@@ -584,12 +584,16 @@ void MultiContextItem::putMessageItem(int pos, MessageItem *m)
     m_messageLists.last()[pos] = m;
 }
 
-void MultiContextItem::appendMessageItem(MessageItem *m)
+void MultiContextItem::appendMessageItems(const QList<MessageItem *> &m)
 {
+    QList<MessageItem *> nullItems = m; // Basically, just a reservation
+    for (int i = 0; i < nullItems.count(); ++i)
+        nullItems[i] = 0;
     for (int i = 0; i < m_messageLists.count() - 1; ++i)
-        m_messageLists[i].append(0);
-    m_messageLists.last().append(m);
-    m_multiMessageList.append(MultiMessageItem(m));
+        m_messageLists[i] += nullItems;
+    m_messageLists.last() += m;
+    foreach (MessageItem *mi, m)
+        m_multiMessageList.append(MultiMessageItem(mi));
 }
 
 void MultiContextItem::removeMultiMessageItem(int pos)
@@ -710,33 +714,43 @@ void MultiDataModel::append(DataModel *dm, bool readWrite)
         m_msgModel->endInsertColumns();
     }
     m_msgModel->endInsertColumns();
+    int appendedContexts = 0;
     for (int i = 0; i < dm->contextCount(); ++i) {
         ContextItem *c = dm->contextItem(i);
         int mcx = findContextIndex(c->context());
         if (mcx >= 0) {
             MultiContextItem *mc = multiContextItem(mcx);
             mc->assignLastModel(c, readWrite);
+            QList<MessageItem *> appendItems;
             for (int j = 0; j < c->messageCount(); ++j) {
                 MessageItem *m = c->messageItem(j);
                 int msgIdx = mc->findMessage(m->text(), m->comment());
-                if (msgIdx >= 0) {
+                if (msgIdx >= 0)
                     mc->putMessageItem(msgIdx, m);
-                } else {
-                    int msgCnt = mc->messageCount();
-                    m_msgModel->beginInsertRows(m_msgModel->createIndex(mcx, 0, 0), msgCnt, msgCnt);
-                    mc->appendMessageItem(m);
-                    m_msgModel->endInsertRows();
-                    ++m_numMessages;
-                }
+                else
+                    appendItems << m;
+            }
+            if (!appendItems.isEmpty()) {
+                int msgCnt = mc->messageCount();
+                m_msgModel->beginInsertRows(m_msgModel->createIndex(mcx, 0, 0),
+                                            msgCnt, msgCnt + appendItems.size() - 1);
+                mc->appendMessageItems(appendItems);
+                m_msgModel->endInsertRows();
+                m_numMessages += appendItems.size();
             }
         } else {
-            MultiContextItem item(modelCount() - 1, c, readWrite);
-            m_msgModel->beginInsertRows(QModelIndex(), contextCount(), contextCount());
-            m_multiContextList.append(item);
-            m_msgModel->endInsertRows();
-            m_numMessages += item.messageCount();
+            m_multiContextList << MultiContextItem(modelCount() - 1, c, readWrite);
+            m_numMessages += c->messageCount();
+            ++appendedContexts;
         }
     }
+    if (appendedContexts) {
+        // Do that en block to avoid itemview inefficiency. It doesn't hurt that we
+        // announce the availability of the data "long" after it was actually added.
+        m_msgModel->beginInsertRows(QModelIndex(),
+                                    contextCount() - appendedContexts, contextCount() - 1);
+        m_msgModel->endInsertRows();
+    }
     dm->setWritable(readWrite);
     updateCountsOnAdd(modelCount() - 1, readWrite);
     connect(dm, SIGNAL(modifiedChanged()), SLOT(onModifiedChanged()));
diff --git a/tools/linguist/linguist/messagemodel.h b/tools/linguist/linguist/messagemodel.h
index 3e0107e..7d98873 100644
--- a/tools/linguist/linguist/messagemodel.h
+++ b/tools/linguist/linguist/messagemodel.h
@@ -332,7 +332,7 @@ private:
     void removeModel(int pos);
     void moveModel(int oldPos, int newPos); // newPos is *before* removing at oldPos
     void putMessageItem(int pos, MessageItem *m);
-    void appendMessageItem(MessageItem *m);
+    void appendMessageItems(const QList<MessageItem *> &m);
     void removeMultiMessageItem(int pos);
     void incrementFinishedCount() { ++m_finishedCount; }
     void decrementFinishedCount() { --m_finishedCount; }
-- 
cgit v0.12


From e49fa5d9ab3c15918fe5fe92d30d7640e23a1307 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Mon, 8 Feb 2010 12:54:35 +0100
Subject: generate code which does not break QT_USE_FAST_CONCATENATION with old
 gcc

---
 util/qlalr/cppgenerator.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/qlalr/cppgenerator.cpp b/util/qlalr/cppgenerator.cpp
index a95f5e4..f52a86f 100644
--- a/util/qlalr/cppgenerator.cpp
+++ b/util/qlalr/cppgenerator.cpp
@@ -457,7 +457,7 @@ void CppGenerator::generateDecl (QTextStream &out)
   out << "class " << grammar.table_name << endl
       << "{" << endl
       << "public:" << endl
-      << "  enum {" << endl;
+      << "  enum VariousConstants {" << endl;
 
   foreach (Name t, grammar.terminals)
     {
-- 
cgit v0.12


From a3d3d2b746f515e197a40a9f87e767d68e25cb1a Mon Sep 17 00:00:00 2001
From: Dominik Holland <dominik.holland@nokia.com>
Date: Tue, 9 Feb 2010 10:58:48 +0100
Subject: Fix Float Conversion in xmlpatterns

On Maemo5 devices there is an automatic conversion to Float.
So qtToXDMType() needs a special case.

Reviewed By: Peter Hartmann
---
 src/xmlpatterns/data/qatomicvalue.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/xmlpatterns/data/qatomicvalue.cpp b/src/xmlpatterns/data/qatomicvalue.cpp
index 6858e27..c4f3578 100644
--- a/src/xmlpatterns/data/qatomicvalue.cpp
+++ b/src/xmlpatterns/data/qatomicvalue.cpp
@@ -226,6 +226,8 @@ ItemType::Ptr AtomicValue::qtToXDMType(const QXmlItem &item)
         /* Fallthrough. */
         case QVariant::Time:
             return BuiltinTypes::xsDateTime;
+        case QMetaType::Float:
+	    return BuiltinTypes::xsFloat;
         case QVariant::Double:
             return BuiltinTypes::xsDouble;
         default:
-- 
cgit v0.12


From 16f89107f9c8019b05d5ccee1b6deccfdff6f98e Mon Sep 17 00:00:00 2001
From: Frederik Schwarzer <schwarzerf@gmail.com>
Date: Tue, 9 Feb 2010 11:57:58 +0100
Subject: fix a few mistakes in German translation

Merge-request: 2302
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
---
 translations/qt_de.ts | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/translations/qt_de.ts b/translations/qt_de.ts
index 8cbf402..6447451 100644
--- a/translations/qt_de.ts
+++ b/translations/qt_de.ts
@@ -7572,7 +7572,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
         <location line="+2"/>
         <source>Play movie in full-screen mode</source>
         <comment>Media controller element</comment>
-        <translation>FIlm im Vollbildmodus abspielen</translation>
+        <translation>Film im Vollbildmodus abspielen</translation>
     </message>
     <message>
         <location line="+2"/>
@@ -8245,7 +8245,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
     <message>
         <location filename="../src/xmlpatterns/api/qcoloringmessagehandler.cpp" line="+87"/>
         <source>Warning in %1, at line %2, column %3: %4</source>
-        <translation>Fehler in %1, bei Zeile %2, Spalte %3: %4</translation>
+        <translation>Warnung in %1, bei Zeile %2, Spalte %3: %4</translation>
     </message>
     <message>
         <location line="+7"/>
@@ -9466,7 +9466,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
         <location line="-470"/>
         <location line="+451"/>
         <source>%1 is not allowed to derive from %2 by list as the latter defines it as final.</source>
-        <translation>%1 darf nicht durch Listen von %2 abgeleitet werden, da sie letzterer sie als final deklariert.</translation>
+        <translation>%1 darf nicht durch Listen von %2 abgeleitet werden, da letzterer sie als final deklariert.</translation>
     </message>
     <message>
         <location line="-431"/>
@@ -9917,7 +9917,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
     <message>
         <location line="+6"/>
         <source>Complex type %1 cannot be derived by extension from %2 as the latter contains %3 element in its content model.</source>
-        <translation>Der komplexe Typ % kann nicht durch Erweiterung von %2 abgeleitet werden, da letzterer ein &apos;%3&apos;-Element in seinem Inhaltsmodell hat.</translation>
+        <translation>Der komplexe Typ %1 kann nicht durch Erweiterung von %2 abgeleitet werden, da letzterer ein &apos;%3&apos;-Element in seinem Inhaltsmodell hat.</translation>
     </message>
     <message>
         <location line="+101"/>
-- 
cgit v0.12


From f38f61df31b708e1f4e50c5fdcc30099f9a1fe8f Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Tue, 9 Feb 2010 12:46:41 +0100
Subject: =?UTF-8?q?Fix=20warnings=20~QX11PixmapData():=20QPixmap=20objects?=
 =?UTF-8?q?=20must=20be=20destroyed..=20Reviewed-by:=20Trond=20Kjern=C3=A5?=
 =?UTF-8?q?sen=20<trond@trolltech.com>=20Task-number:=20QTBUG-8046?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 tools/designer/src/lib/shared/actionrepository.cpp | 21 ++++++++++-----------
 tools/designer/src/lib/shared/actionrepository_p.h |  9 +++++++--
 tools/designer/src/lib/shared/iconloader.cpp       |  3 +--
 tools/designer/src/lib/shared/qdesigner_menu.cpp   | 11 +++++------
 tools/designer/src/lib/shared/qdesigner_menu_p.h   |  2 ++
 5 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index e3ff2c1..1076ff4 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -77,18 +77,12 @@ static inline QAction *actionOfItem(const QStandardItem* item)
     return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole));
 }
 
-static QIcon fixActionIcon(const QIcon &icon)
-{
-    if (icon.isNull())
-        return qdesigner_internal::emptyIcon();
-    return icon;
-}
-
 namespace qdesigner_internal {
 
 // ----------- ActionModel
 ActionModel::ActionModel(QWidget *parent ) :
     QStandardItemModel(parent),
+    m_emptyIcon(emptyIcon()),
     m_core(0)
 {
     QStringList headers;
@@ -127,7 +121,7 @@ void ActionModel::update(int row)
     for (int i = 0; i < NumColumns; i++)
        list += item(row, i);
 
-    setItems(m_core, actionOfItem(list.front()), list);
+    setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list);
 }
 
 void ActionModel::remove(int row)
@@ -150,7 +144,7 @@ QModelIndex ActionModel::addAction(QAction *action)
         item->setFlags(flags);
         items.push_back(item);
     }
-    setItems(m_core, action, items);
+    setItems(m_core, action, m_emptyIcon, items);
     appendRow(items);
     return indexFromItem(items.front());
 }
@@ -185,7 +179,9 @@ PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropert
     return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index));
 }
 
-void  ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItemList &sl)
+void  ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
+                            const QIcon &defaultIcon,
+                            QStandardItemList &sl)
 {
 
     // Tooltip, mostly for icon view mode
@@ -200,7 +196,10 @@ void  ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
 
     QStandardItem *item =  sl[NameColumn];
     item->setText(action->objectName());
-    item->setIcon(fixActionIcon(action->icon()));
+    QIcon icon = action->icon();
+    if (icon.isNull())
+        icon = defaultIcon;
+    item->setIcon(icon);
     item->setToolTip(firstTooltip);
     item->setWhatsThis(firstTooltip);
     // Used
diff --git a/tools/designer/src/lib/shared/actionrepository_p.h b/tools/designer/src/lib/shared/actionrepository_p.h
index 65adc5d..6e17e7b 100644
--- a/tools/designer/src/lib/shared/actionrepository_p.h
+++ b/tools/designer/src/lib/shared/actionrepository_p.h
@@ -59,6 +59,7 @@
 #include <QtGui/QTreeView>
 #include <QtGui/QListView>
 #include <QtGui/QStackedWidget>
+#include <QtGui/QIcon>
 
 QT_BEGIN_NAMESPACE
 
@@ -110,10 +111,14 @@ signals:
     void resourceImageDropped(const QString &path, QAction *action);
 
 private:
+    typedef QList<QStandardItem *> QStandardItemList;
+
     void initializeHeaders();
+    static void setItems(QDesignerFormEditorInterface *core, QAction *a,
+                         const QIcon &defaultIcon,
+                         QStandardItemList &sl);
 
-    typedef QList<QStandardItem *> QStandardItemList;
-    static void setItems(QDesignerFormEditorInterface *core, QAction *a, QStandardItemList &sl);
+    const QIcon m_emptyIcon;
 
     QDesignerFormEditorInterface *m_core;
 };
diff --git a/tools/designer/src/lib/shared/iconloader.cpp b/tools/designer/src/lib/shared/iconloader.cpp
index df0bb7e..ed312b8 100644
--- a/tools/designer/src/lib/shared/iconloader.cpp
+++ b/tools/designer/src/lib/shared/iconloader.cpp
@@ -70,8 +70,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name)
 
 QDESIGNER_SHARED_EXPORT QIcon emptyIcon()
 {
-    static const QIcon empty_icon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png"));
-    return  empty_icon;
+    return QIcon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png"));
 }
 
 } // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index c83abad..ba512e4 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -88,6 +88,7 @@ static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection d
 
 QDesignerMenu::QDesignerMenu(QWidget *parent) :
     QMenu(parent),
+    m_subMenuPixmap(QPixmap(QLatin1String(":/trolltech/formeditor/images/submenu.png"))),
     m_currentIndex(0),
     m_addItem(new SpecialMenuAction(this)),
     m_addSeparator(new SpecialMenuAction(this)),
@@ -550,11 +551,10 @@ void QDesignerMenu::deleteAction(QAction *a)
 
 QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
 {
-    static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
     const QRect g = actionGeometry(action);
-    const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2;
-    const int y = g.top() + (g.height() - pm.height())/2 + 1;
-    return QRect(x, y, pm.width(), pm.height());
+    const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - m_subMenuPixmap.width() - 2) : 2;
+    const int y = g.top() + (g.height() - m_subMenuPixmap.height())/2 + 1;
+    return QRect(x, y, m_subMenuPixmap.width(), m_subMenuPixmap.height());
 }
 
 bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const
@@ -591,8 +591,7 @@ void QDesignerMenu::paintEvent(QPaintEvent *event)
 
             p.fillRect(g, lg);
         } else if (hasSubMenuPixmap(a)) {
-            static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
-            p.drawPixmap(subMenuPixmapRect(a).topLeft(), pm);
+            p.drawPixmap(subMenuPixmapRect(a).topLeft(), m_subMenuPixmap);
         }
     }
 
diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h
index 9c9a311..ae1e0e7 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h
@@ -57,6 +57,7 @@
 
 #include <QtGui/QAction>
 #include <QtGui/QMenu>
+#include <QtGui/QPixmap>
 #include <QtCore/QHash>
 
 QT_BEGIN_NAMESPACE
@@ -183,6 +184,7 @@ protected:
 private:
     bool hideSubMenuOnCursorKey();
     bool showSubMenuOnCursorKey();
+    const QPixmap m_subMenuPixmap;
 
     QPoint m_startPosition;
     int m_currentIndex;
-- 
cgit v0.12