diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index 1ea36e1ebb1..932a1d72b6e 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -67,7 +67,7 @@ private: const QIcon m_lockedIcon; const QIcon m_unlockedIcon; - QList m_documents; + QList m_entries; QMap > m_editors; }; @@ -79,7 +79,7 @@ DocumentModelPrivate::DocumentModelPrivate() : DocumentModelPrivate::~DocumentModelPrivate() { - qDeleteAll(m_documents); + qDeleteAll(m_entries); } static DocumentModelPrivate *d; @@ -143,7 +143,7 @@ int DocumentModelPrivate::columnCount(const QModelIndex &parent) const int DocumentModelPrivate::rowCount(const QModelIndex &parent) const { if (!parent.isValid()) - return m_documents.count() + 1/**/; + return m_entries.count() + 1/**/; return 0; } @@ -184,11 +184,11 @@ void DocumentModel::addRestoredDocument(const QString &fileName, const QString & d->addEntry(entry); } -DocumentModel::Entry *DocumentModel::firstRestoredDocument() +DocumentModel::Entry *DocumentModel::firstRestoredEntry() { - for (int i = 0; i < d->m_documents.count(); ++i) - if (!d->m_documents.at(i)->document) - return d->m_documents.at(i); + for (int i = 0; i < d->m_entries.count(); ++i) + if (!d->m_entries.at(i)->document) + return d->m_entries.at(i); return 0; } @@ -199,9 +199,9 @@ void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) // replace a non-loaded entry (aka 'restored') if possible int previousIndex = indexOfFilePath(fileName); if (previousIndex >= 0) { - if (entry->document && m_documents.at(previousIndex)->document == 0) { - DocumentModel::Entry *previousEntry = m_documents.at(previousIndex); - m_documents[previousIndex] = entry; + if (entry->document && m_entries.at(previousIndex)->document == 0) { + DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); + m_entries[previousIndex] = entry; delete previousEntry; connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); } else { @@ -212,13 +212,13 @@ void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) int index; QString displayName = entry->displayName(); - for (index = 0; index < m_documents.count(); ++index) { - if (displayName < m_documents.at(index)->displayName()) + for (index = 0; index < m_entries.count(); ++index) { + if (displayName < m_entries.at(index)->displayName()) break; } int row = index + 1/**/; beginInsertRows(QModelIndex(), row, row); - m_documents.insert(index, entry); + m_entries.insert(index, entry); if (entry->document) connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); endInsertRows(); @@ -234,8 +234,8 @@ int DocumentModelPrivate::indexOfFilePath(const QString &filePath) const if (filePath.isEmpty()) return -1; const QString fixedPath = DocumentManager::fixFileName(filePath, DocumentManager::KeepLinks); - for (int i = 0; i < d->m_documents.count(); ++i) { - if (DocumentManager::fixFileName(d->m_documents.at(i)->fileName(), DocumentManager::KeepLinks) == fixedPath) + for (int i = 0; i < d->m_entries.count(); ++i) { + if (DocumentManager::fixFileName(d->m_entries.at(i)->fileName(), DocumentManager::KeepLinks) == fixedPath) return i; } return -1; @@ -244,7 +244,7 @@ int DocumentModelPrivate::indexOfFilePath(const QString &filePath) const void DocumentModel::removeEntry(DocumentModel::Entry *entry) { QTC_ASSERT(!entry->document, return); // we wouldn't know what to do with the associated editors - int index = d->m_documents.indexOf(entry); + int index = d->m_entries.indexOf(entry); d->removeDocument(index); } @@ -267,7 +267,7 @@ void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument) void DocumentModel::removeDocument(const QString &fileName) { int index = indexOfFilePath(fileName); - QTC_ASSERT(!d->m_documents.at(index)->document, return); // we wouldn't know what to do with the associated editors + QTC_ASSERT(!d->m_entries.at(index)->document, return); // we wouldn't know what to do with the associated editors d->removeDocument(index); } @@ -275,23 +275,23 @@ void DocumentModelPrivate::removeDocument(int idx) { if (idx < 0) return; - QTC_ASSERT(idx < d->m_documents.size(), return); - IDocument *document = d->m_documents.at(idx)->document; + QTC_ASSERT(idx < d->m_entries.size(), return); + IDocument *document = d->m_entries.at(idx)->document; int row = idx + 1/**/; beginRemoveRows(QModelIndex(), row, row); - delete d->m_documents.takeAt(idx); + delete d->m_entries.takeAt(idx); endRemoveRows(); if (document) disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged())); } -void DocumentModel::removeAllRestoredDocuments() +void DocumentModel::removeAllRestoredEntries() { - for (int i = d->m_documents.count()-1; i >= 0; --i) { - if (!d->m_documents.at(i)->document) { + for (int i = d->m_entries.count()-1; i >= 0; --i) { + if (!d->m_entries.at(i)->document) { int row = i + 1/**/; d->beginRemoveRows(QModelIndex(), row, row); - delete d->m_documents.takeAt(i); + delete d->m_entries.takeAt(i); d->endRemoveRows(); } } @@ -322,8 +322,8 @@ int DocumentModel::indexOfDocument(IDocument *document) int DocumentModelPrivate::indexOfDocument(IDocument *document) const { - for (int i = 0; i < m_documents.count(); ++i) - if (m_documents.at(i)->document == document) + for (int i = 0; i < m_entries.count(); ++i) + if (m_entries.at(i)->document == document) return i; return -1; } @@ -333,7 +333,7 @@ DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) int index = indexOfDocument(document); if (index < 0) return 0; - return d->m_documents.at(index); + return d->m_entries.at(index); } QList DocumentModel::openedDocuments() @@ -346,7 +346,7 @@ IDocument *DocumentModel::documentForFilePath(const QString &filePath) int index = indexOfFilePath(filePath); if (index < 0) return 0; - return d->m_documents.at(index)->document; + return d->m_entries.at(index)->document; } QList DocumentModel::editorsForFilePath(const QString &filePath) @@ -360,22 +360,22 @@ QList DocumentModel::editorsForFilePath(const QString &filePath) QModelIndex DocumentModelPrivate::index(int row, int column, const QModelIndex &parent) const { Q_UNUSED(parent) - if (column < 0 || column > 1 || row < 0 || row >= m_documents.count() + 1/**/) + if (column < 0 || column > 1 || row < 0 || row >= m_entries.count() + 1/**/) return QModelIndex(); return createIndex(row, column); } -DocumentModel::Entry *DocumentModel::documentAtRow(int row) +DocumentModel::Entry *DocumentModel::entryAtRow(int row) { int entryIndex = row - 1/**/; if (entryIndex < 0) return 0; - return d->m_documents[entryIndex]; + return d->m_entries[entryIndex]; } -int DocumentModel::documentCount() +int DocumentModel::entryCount() { - return d->m_documents.count(); + return d->m_entries.count(); } QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const @@ -394,7 +394,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const return QVariant(); } } - const DocumentModel::Entry *e = m_documents.at(entryIndex); + const DocumentModel::Entry *e = m_entries.at(entryIndex); switch (role) { case Qt::DisplayRole: return (e->document && e->document->isModified()) @@ -440,9 +440,9 @@ void DocumentModelPrivate::itemChanged() emit dataChanged(mindex, mindex); } -QList DocumentModel::documents() +QList DocumentModel::entries() { - return d->m_documents; + return d->m_entries; } } // namespace Core diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h index 09e8c8969cd..c956890bf22 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.h +++ b/src/plugins/coreplugin/editormanager/documentmodel.h @@ -64,11 +64,11 @@ public: Id m_id; }; - static Entry *documentAtRow(int row); + static Entry *entryAtRow(int row); static int rowOfDocument(IDocument *document); - static int documentCount(); - static QList documents(); + static int entryCount(); + static QList entries(); static int indexOfDocument(IDocument *document); static int indexOfFilePath(const QString &filePath); static Entry *entryForDocument(IDocument *document); @@ -77,18 +77,18 @@ public: static IDocument *documentForFilePath(const QString &filePath); static QList editorsForFilePath(const QString &filePath); static QList editorsForDocument(IDocument *document); - static QList editorsForDocuments(const QList &documents); + static QList editorsForDocuments(const QList &entries); static QList oneEditorForEachOpenedDocument(); static QList editorsForOpenedDocuments(); // editor manager related functions, nobody else should call it static void addEditor(IEditor *editor, bool *isNewDocument); static void addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id); - static Entry *firstRestoredDocument(); + static Entry *firstRestoredEntry(); static void removeEditor(IEditor *editor, bool *lastOneForDocument); static void removeDocument(const QString &fileName); static void removeEntry(Entry *entry); - static void removeAllRestoredDocuments(); + static void removeAllRestoredEntries(); private: DocumentModel(); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 8a25d5d683b..cb27e5daf86 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -721,7 +721,7 @@ void EditorManager::closeView(Core::Internal::EditorView *view) bool EditorManager::closeAllEditors(bool askAboutModifiedEditors) { - DocumentModel::removeAllRestoredDocuments(); + DocumentModel::removeAllRestoredEntries(); if (closeDocuments(DocumentModel::openedDocuments(), askAboutModifiedEditors)) return true; return false; @@ -729,7 +729,7 @@ bool EditorManager::closeAllEditors(bool askAboutModifiedEditors) void EditorManager::closeAllEditorsExceptVisible() { - DocumentModel::removeAllRestoredDocuments(); + DocumentModel::removeAllRestoredEntries(); QList documentsToClose = DocumentModel::openedDocuments(); foreach (IEditor *editor, visibleEditors()) documentsToClose.removeAll(editor->document()); @@ -738,7 +738,7 @@ void EditorManager::closeAllEditorsExceptVisible() void EditorManager::closeOtherEditors(IDocument *document) { - DocumentModel::removeAllRestoredDocuments(); + DocumentModel::removeAllRestoredEntries(); QList documentsToClose = DocumentModel::openedDocuments(); documentsToClose.removeAll(document); closeDocuments(documentsToClose, true); @@ -800,8 +800,8 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod : tr("Close Other Editors")); d->m_closeCurrentEditorContextAction->setEnabled(entry != 0); d->m_closeOtherEditorsContextAction->setEnabled(entry != 0); - d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::documents().isEmpty()); - d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < DocumentModel::documents().count()); + d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::entries().isEmpty()); + d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < DocumentModel::entries().count()); contextMenu->addAction(d->m_closeCurrentEditorContextAction); contextMenu->addAction(d->m_closeAllEditorsContextAction); contextMenu->addAction(d->m_closeOtherEditorsContextAction); @@ -1139,12 +1139,12 @@ bool EditorManager::closeEditors(const QList &editorsToClose, bool ask if (newCurrent) { activateEditor(view, newCurrent, flags); } else { - DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument(); + DocumentModel::Entry *entry = DocumentModel::firstRestoredEntry(); if (entry) { activateEditorForEntry(view, entry, flags); } else { // no "restored" ones, so any entry left should have a document - const QList documents = DocumentModel::documents(); + const QList documents = DocumentModel::entries(); if (!documents.isEmpty()) { IDocument *document = documents.last()->document; if (document) @@ -1691,7 +1691,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId, if (base.contains(dollar)) { int i = 1; QSet docnames; - foreach (DocumentModel::Entry *entry, DocumentModel::documents()) { + foreach (DocumentModel::Entry *entry, DocumentModel::entries()) { QString name = entry->fileName(); if (name.isEmpty()) name = entry->displayName(); @@ -2024,7 +2024,7 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q void EditorManager::updateActions() { IDocument *curDocument = currentDocument(); - const int openedCount = DocumentModel::documentCount(); + const int openedCount = DocumentModel::entryCount(); if (curDocument) { if (HostOsInfo::isMacHost()) @@ -2210,7 +2210,7 @@ QByteArray EditorManager::saveState() stream << d->m_editorStates; - QList entries = DocumentModel::documents(); + QList entries = DocumentModel::entries(); int entriesCount = 0; foreach (DocumentModel::Entry *entry, entries) { // The editor may be 0 if it was not loaded yet: In that case it is not temporary diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 833dcd02ca2..cfe715b7e24 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -302,7 +302,7 @@ IEditor *EditorView::currentEditor() const void EditorView::listSelectionActivated(int index) { - EditorManager::activateEditorForEntry(this, DocumentModel::documentAtRow(index)); + EditorManager::activateEditorForEntry(this, DocumentModel::entryAtRow(index)); } void EditorView::splitHorizontally() @@ -801,7 +801,7 @@ void SplitterOrView::restoreState(const QByteArray &state) | Core::EditorManager::DoNotChangeCurrentEditor); if (!e) { - DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument(); + DocumentModel::Entry *entry = DocumentModel::firstRestoredEntry(); if (entry) EditorManager::activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory | Core::EditorManager::DoNotChangeCurrentEditor); diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 23c74590222..91de92aa5d2 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -189,13 +189,13 @@ void OpenEditorsWidget::activateEditor(const QModelIndex &index) { selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); EditorManager::activateEditorForEntry( - DocumentModel::documentAtRow(m_model->mapToSource(index).row())); + DocumentModel::entryAtRow(m_model->mapToSource(index).row())); } void OpenEditorsWidget::closeEditor(const QModelIndex &index) { EditorManager::closeEditor( - DocumentModel::documentAtRow(m_model->mapToSource(index).row())); + DocumentModel::entryAtRow(m_model->mapToSource(index).row())); // work around selection changes updateCurrentItem(EditorManager::currentEditor()); } @@ -204,7 +204,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos) { QMenu contextMenu; QModelIndex editorIndex = indexAt(pos); - DocumentModel::Entry *entry = DocumentModel::documentAtRow( + DocumentModel::Entry *entry = DocumentModel::entryAtRow( m_model->mapToSource(editorIndex).row()); EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry); contextMenu.addSeparator(); diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 21965bbed4b..7d0af0b8a26 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -236,7 +236,7 @@ void OpenEditorsWindow::addHistoryItems(const QList &history, Edit void OpenEditorsWindow::addRestoredItems() { - foreach (DocumentModel::Entry *entry, DocumentModel::documents()) { + foreach (DocumentModel::Entry *entry, DocumentModel::entries()) { if (entry->document) continue; QTreeWidgetItem *item = new QTreeWidgetItem(); diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index fabdbfa5e53..2fabf7111c1 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -308,12 +308,12 @@ void EditorToolBar::updateEditorListSelection(IEditor *newSelection) void EditorToolBar::changeActiveEditor(int row) { - EditorManager::activateEditorForEntry(DocumentModel::documentAtRow(row)); + EditorManager::activateEditorForEntry(DocumentModel::entryAtRow(row)); } void EditorToolBar::listContextMenu(QPoint pos) { - DocumentModel::Entry *entry = DocumentModel::documentAtRow( + DocumentModel::Entry *entry = DocumentModel::entryAtRow( d->m_editorList->currentIndex()); QString fileName = entry ? entry->fileName() : QString(); QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString(); @@ -361,7 +361,7 @@ void EditorToolBar::checkDocumentStatus() { IDocument *document = qobject_cast(sender()); QTC_ASSERT(document, return); - DocumentModel::Entry *entry = DocumentModel::documentAtRow( + DocumentModel::Entry *entry = DocumentModel::entryAtRow( d->m_editorList->currentIndex()); if (entry && entry->document && entry->document == document) diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index fe1c5ca003d..422b9afa202 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -91,7 +91,7 @@ QList OpenDocumentsFilter::matchesFor(QFutureInterface codecs; foreach (Core::DocumentModel::Entry *entry, - Core::DocumentModel::documents()) { + Core::DocumentModel::entries()) { QString fileName = entry->fileName(); if (!fileName.isEmpty()) { fileNames.append(fileName); @@ -100,7 +100,7 @@ QString FindInOpenFiles::toolTip() const bool FindInOpenFiles::isEnabled() const { - return Core::DocumentModel::documentCount() > 0; + return Core::DocumentModel::entryCount() > 0; } void FindInOpenFiles::writeSettings(QSettings *settings)