diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-08 21:17:22 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-08 21:17:22 (GMT) |
commit | 0df0a2f3d453e3dad33ed75cb62a35cff16b4b64 (patch) | |
tree | cdeb3e40bafc2eea6d6e77422120ed6f4374c436 /tools | |
parent | 3b1a0c4877faa9d1d50372f2128c06530ae4b2d4 (diff) | |
parent | e49fa5d9ab3c15918fe5fe92d30d7640e23a1307 (diff) | |
download | Qt-0df0a2f3d453e3dad33ed75cb62a35cff16b4b64.zip Qt-0df0a2f3d453e3dad33ed75cb62a35cff16b4b64.tar.gz Qt-0df0a2f3d453e3dad33ed75cb62a35cff16b4b64.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/berlin-staging-1:
generate code which does not break QT_USE_FAST_CONCATENATION with old gcc
drastically improve load time of TS files
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/linguist/messagemodel.cpp | 48 | ||||
-rw-r--r-- | 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; } |