Commit fa9deea6 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Core: Minor optimizations in DocumentModel



Required for followup changes

Change-Id: I6280427433bd88fedf87e4d8d25c2f7481d94210
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent fb567a22
...@@ -190,8 +190,10 @@ DocumentModel::Entry *DocumentModel::firstRestoredEntry() ...@@ -190,8 +190,10 @@ DocumentModel::Entry *DocumentModel::firstRestoredEntry()
void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
{ {
const Utils::FileName fileName = entry->fileName();
// replace a non-loaded entry (aka 'restored') if possible // replace a non-loaded entry (aka 'restored') if possible
int previousIndex = indexOfFilePath(entry->fileName()); int previousIndex = indexOfFilePath(fileName);
if (previousIndex >= 0) { if (previousIndex >= 0) {
if (entry->document && m_entries.at(previousIndex)->document == 0) { if (entry->document && m_entries.at(previousIndex)->document == 0) {
DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); DocumentModel::Entry *previousEntry = m_entries.at(previousIndex);
...@@ -265,13 +267,13 @@ void DocumentModelPrivate::removeDocument(int idx) ...@@ -265,13 +267,13 @@ void DocumentModelPrivate::removeDocument(int idx)
if (idx < 0) if (idx < 0)
return; return;
QTC_ASSERT(idx < d->m_entries.size(), return); QTC_ASSERT(idx < d->m_entries.size(), return);
IDocument *document = d->m_entries.at(idx)->document;
int row = idx + 1/*<no document>*/; int row = idx + 1/*<no document>*/;
beginRemoveRows(QModelIndex(), row, row); beginRemoveRows(QModelIndex(), row, row);
delete d->m_entries.takeAt(idx); DocumentModel::Entry *entry = d->m_entries.takeAt(idx);
endRemoveRows(); endRemoveRows();
if (document) if (IDocument *document = entry->document)
disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged())); disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged()));
delete entry;
} }
void DocumentModel::removeAllRestoredEntries() void DocumentModel::removeAllRestoredEntries()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment