forked from qt-creator/qt-creator
Make document model API more consistent with entry vs document
Change-Id: Iae2fe480d9fcb564d566f1dcca142c21c99c2d5b Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -67,7 +67,7 @@ private:
|
|||||||
const QIcon m_lockedIcon;
|
const QIcon m_lockedIcon;
|
||||||
const QIcon m_unlockedIcon;
|
const QIcon m_unlockedIcon;
|
||||||
|
|
||||||
QList<DocumentModel::Entry *> m_documents;
|
QList<DocumentModel::Entry *> m_entries;
|
||||||
QMap<IDocument *, QList<IEditor *> > m_editors;
|
QMap<IDocument *, QList<IEditor *> > m_editors;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ DocumentModelPrivate::DocumentModelPrivate() :
|
|||||||
|
|
||||||
DocumentModelPrivate::~DocumentModelPrivate()
|
DocumentModelPrivate::~DocumentModelPrivate()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_documents);
|
qDeleteAll(m_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DocumentModelPrivate *d;
|
static DocumentModelPrivate *d;
|
||||||
@@ -143,7 +143,7 @@ int DocumentModelPrivate::columnCount(const QModelIndex &parent) const
|
|||||||
int DocumentModelPrivate::rowCount(const QModelIndex &parent) const
|
int DocumentModelPrivate::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
return m_documents.count() + 1/*<no document>*/;
|
return m_entries.count() + 1/*<no document>*/;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,11 +184,11 @@ void DocumentModel::addRestoredDocument(const QString &fileName, const QString &
|
|||||||
d->addEntry(entry);
|
d->addEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentModel::Entry *DocumentModel::firstRestoredDocument()
|
DocumentModel::Entry *DocumentModel::firstRestoredEntry()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d->m_documents.count(); ++i)
|
for (int i = 0; i < d->m_entries.count(); ++i)
|
||||||
if (!d->m_documents.at(i)->document)
|
if (!d->m_entries.at(i)->document)
|
||||||
return d->m_documents.at(i);
|
return d->m_entries.at(i);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,9 +199,9 @@ void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
|
|||||||
// replace a non-loaded entry (aka 'restored') if possible
|
// replace a non-loaded entry (aka 'restored') if possible
|
||||||
int previousIndex = indexOfFilePath(fileName);
|
int previousIndex = indexOfFilePath(fileName);
|
||||||
if (previousIndex >= 0) {
|
if (previousIndex >= 0) {
|
||||||
if (entry->document && m_documents.at(previousIndex)->document == 0) {
|
if (entry->document && m_entries.at(previousIndex)->document == 0) {
|
||||||
DocumentModel::Entry *previousEntry = m_documents.at(previousIndex);
|
DocumentModel::Entry *previousEntry = m_entries.at(previousIndex);
|
||||||
m_documents[previousIndex] = entry;
|
m_entries[previousIndex] = entry;
|
||||||
delete previousEntry;
|
delete previousEntry;
|
||||||
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
||||||
} else {
|
} else {
|
||||||
@@ -212,13 +212,13 @@ void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
|
|||||||
|
|
||||||
int index;
|
int index;
|
||||||
QString displayName = entry->displayName();
|
QString displayName = entry->displayName();
|
||||||
for (index = 0; index < m_documents.count(); ++index) {
|
for (index = 0; index < m_entries.count(); ++index) {
|
||||||
if (displayName < m_documents.at(index)->displayName())
|
if (displayName < m_entries.at(index)->displayName())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int row = index + 1/*<no document>*/;
|
int row = index + 1/*<no document>*/;
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
m_documents.insert(index, entry);
|
m_entries.insert(index, entry);
|
||||||
if (entry->document)
|
if (entry->document)
|
||||||
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
@@ -234,8 +234,8 @@ int DocumentModelPrivate::indexOfFilePath(const QString &filePath) const
|
|||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
const QString fixedPath = DocumentManager::fixFileName(filePath, DocumentManager::KeepLinks);
|
const QString fixedPath = DocumentManager::fixFileName(filePath, DocumentManager::KeepLinks);
|
||||||
for (int i = 0; i < d->m_documents.count(); ++i) {
|
for (int i = 0; i < d->m_entries.count(); ++i) {
|
||||||
if (DocumentManager::fixFileName(d->m_documents.at(i)->fileName(), DocumentManager::KeepLinks) == fixedPath)
|
if (DocumentManager::fixFileName(d->m_entries.at(i)->fileName(), DocumentManager::KeepLinks) == fixedPath)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -244,7 +244,7 @@ int DocumentModelPrivate::indexOfFilePath(const QString &filePath) const
|
|||||||
void DocumentModel::removeEntry(DocumentModel::Entry *entry)
|
void DocumentModel::removeEntry(DocumentModel::Entry *entry)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!entry->document, return); // we wouldn't know what to do with the associated editors
|
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);
|
d->removeDocument(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
|
|||||||
void DocumentModel::removeDocument(const QString &fileName)
|
void DocumentModel::removeDocument(const QString &fileName)
|
||||||
{
|
{
|
||||||
int index = indexOfFilePath(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);
|
d->removeDocument(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,23 +275,23 @@ void DocumentModelPrivate::removeDocument(int idx)
|
|||||||
{
|
{
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return;
|
return;
|
||||||
QTC_ASSERT(idx < d->m_documents.size(), return);
|
QTC_ASSERT(idx < d->m_entries.size(), return);
|
||||||
IDocument *document = d->m_documents.at(idx)->document;
|
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_documents.takeAt(idx);
|
delete d->m_entries.takeAt(idx);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
if (document)
|
if (document)
|
||||||
disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentModel::removeAllRestoredDocuments()
|
void DocumentModel::removeAllRestoredEntries()
|
||||||
{
|
{
|
||||||
for (int i = d->m_documents.count()-1; i >= 0; --i) {
|
for (int i = d->m_entries.count()-1; i >= 0; --i) {
|
||||||
if (!d->m_documents.at(i)->document) {
|
if (!d->m_entries.at(i)->document) {
|
||||||
int row = i + 1/*<no document>*/;
|
int row = i + 1/*<no document>*/;
|
||||||
d->beginRemoveRows(QModelIndex(), row, row);
|
d->beginRemoveRows(QModelIndex(), row, row);
|
||||||
delete d->m_documents.takeAt(i);
|
delete d->m_entries.takeAt(i);
|
||||||
d->endRemoveRows();
|
d->endRemoveRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,8 +322,8 @@ int DocumentModel::indexOfDocument(IDocument *document)
|
|||||||
|
|
||||||
int DocumentModelPrivate::indexOfDocument(IDocument *document) const
|
int DocumentModelPrivate::indexOfDocument(IDocument *document) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_documents.count(); ++i)
|
for (int i = 0; i < m_entries.count(); ++i)
|
||||||
if (m_documents.at(i)->document == document)
|
if (m_entries.at(i)->document == document)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document)
|
|||||||
int index = indexOfDocument(document);
|
int index = indexOfDocument(document);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return d->m_documents.at(index);
|
return d->m_entries.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<IDocument *> DocumentModel::openedDocuments()
|
QList<IDocument *> DocumentModel::openedDocuments()
|
||||||
@@ -346,7 +346,7 @@ IDocument *DocumentModel::documentForFilePath(const QString &filePath)
|
|||||||
int index = indexOfFilePath(filePath);
|
int index = indexOfFilePath(filePath);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return d->m_documents.at(index)->document;
|
return d->m_entries.at(index)->document;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath)
|
QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath)
|
||||||
@@ -360,22 +360,22 @@ QList<IEditor *> DocumentModel::editorsForFilePath(const QString &filePath)
|
|||||||
QModelIndex DocumentModelPrivate::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex DocumentModelPrivate::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
if (column < 0 || column > 1 || row < 0 || row >= m_documents.count() + 1/*<no document>*/)
|
if (column < 0 || column > 1 || row < 0 || row >= m_entries.count() + 1/*<no document>*/)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
return createIndex(row, column);
|
return createIndex(row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentModel::Entry *DocumentModel::documentAtRow(int row)
|
DocumentModel::Entry *DocumentModel::entryAtRow(int row)
|
||||||
{
|
{
|
||||||
int entryIndex = row - 1/*<no document>*/;
|
int entryIndex = row - 1/*<no document>*/;
|
||||||
if (entryIndex < 0)
|
if (entryIndex < 0)
|
||||||
return 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
|
QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
|
||||||
@@ -394,7 +394,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const DocumentModel::Entry *e = m_documents.at(entryIndex);
|
const DocumentModel::Entry *e = m_entries.at(entryIndex);
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return (e->document && e->document->isModified())
|
return (e->document && e->document->isModified())
|
||||||
@@ -440,9 +440,9 @@ void DocumentModelPrivate::itemChanged()
|
|||||||
emit dataChanged(mindex, mindex);
|
emit dataChanged(mindex, mindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DocumentModel::Entry *> DocumentModel::documents()
|
QList<DocumentModel::Entry *> DocumentModel::entries()
|
||||||
{
|
{
|
||||||
return d->m_documents;
|
return d->m_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -64,11 +64,11 @@ public:
|
|||||||
Id m_id;
|
Id m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Entry *documentAtRow(int row);
|
static Entry *entryAtRow(int row);
|
||||||
static int rowOfDocument(IDocument *document);
|
static int rowOfDocument(IDocument *document);
|
||||||
|
|
||||||
static int documentCount();
|
static int entryCount();
|
||||||
static QList<Entry *> documents();
|
static QList<Entry *> entries();
|
||||||
static int indexOfDocument(IDocument *document);
|
static int indexOfDocument(IDocument *document);
|
||||||
static int indexOfFilePath(const QString &filePath);
|
static int indexOfFilePath(const QString &filePath);
|
||||||
static Entry *entryForDocument(IDocument *document);
|
static Entry *entryForDocument(IDocument *document);
|
||||||
@@ -77,18 +77,18 @@ public:
|
|||||||
static IDocument *documentForFilePath(const QString &filePath);
|
static IDocument *documentForFilePath(const QString &filePath);
|
||||||
static QList<IEditor *> editorsForFilePath(const QString &filePath);
|
static QList<IEditor *> editorsForFilePath(const QString &filePath);
|
||||||
static QList<IEditor *> editorsForDocument(IDocument *document);
|
static QList<IEditor *> editorsForDocument(IDocument *document);
|
||||||
static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &documents);
|
static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &entries);
|
||||||
static QList<IEditor *> oneEditorForEachOpenedDocument();
|
static QList<IEditor *> oneEditorForEachOpenedDocument();
|
||||||
static QList<IEditor *> editorsForOpenedDocuments();
|
static QList<IEditor *> editorsForOpenedDocuments();
|
||||||
|
|
||||||
// editor manager related functions, nobody else should call it
|
// editor manager related functions, nobody else should call it
|
||||||
static void addEditor(IEditor *editor, bool *isNewDocument);
|
static void addEditor(IEditor *editor, bool *isNewDocument);
|
||||||
static void addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id);
|
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 removeEditor(IEditor *editor, bool *lastOneForDocument);
|
||||||
static void removeDocument(const QString &fileName);
|
static void removeDocument(const QString &fileName);
|
||||||
static void removeEntry(Entry *entry);
|
static void removeEntry(Entry *entry);
|
||||||
static void removeAllRestoredDocuments();
|
static void removeAllRestoredEntries();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DocumentModel();
|
DocumentModel();
|
||||||
|
@@ -721,7 +721,7 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
|||||||
|
|
||||||
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||||
{
|
{
|
||||||
DocumentModel::removeAllRestoredDocuments();
|
DocumentModel::removeAllRestoredEntries();
|
||||||
if (closeDocuments(DocumentModel::openedDocuments(), askAboutModifiedEditors))
|
if (closeDocuments(DocumentModel::openedDocuments(), askAboutModifiedEditors))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -729,7 +729,7 @@ bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
|||||||
|
|
||||||
void EditorManager::closeAllEditorsExceptVisible()
|
void EditorManager::closeAllEditorsExceptVisible()
|
||||||
{
|
{
|
||||||
DocumentModel::removeAllRestoredDocuments();
|
DocumentModel::removeAllRestoredEntries();
|
||||||
QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
|
QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
|
||||||
foreach (IEditor *editor, visibleEditors())
|
foreach (IEditor *editor, visibleEditors())
|
||||||
documentsToClose.removeAll(editor->document());
|
documentsToClose.removeAll(editor->document());
|
||||||
@@ -738,7 +738,7 @@ void EditorManager::closeAllEditorsExceptVisible()
|
|||||||
|
|
||||||
void EditorManager::closeOtherEditors(IDocument *document)
|
void EditorManager::closeOtherEditors(IDocument *document)
|
||||||
{
|
{
|
||||||
DocumentModel::removeAllRestoredDocuments();
|
DocumentModel::removeAllRestoredEntries();
|
||||||
QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
|
QList<IDocument *> documentsToClose = DocumentModel::openedDocuments();
|
||||||
documentsToClose.removeAll(document);
|
documentsToClose.removeAll(document);
|
||||||
closeDocuments(documentsToClose, true);
|
closeDocuments(documentsToClose, true);
|
||||||
@@ -800,8 +800,8 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
|
|||||||
: tr("Close Other Editors"));
|
: tr("Close Other Editors"));
|
||||||
d->m_closeCurrentEditorContextAction->setEnabled(entry != 0);
|
d->m_closeCurrentEditorContextAction->setEnabled(entry != 0);
|
||||||
d->m_closeOtherEditorsContextAction->setEnabled(entry != 0);
|
d->m_closeOtherEditorsContextAction->setEnabled(entry != 0);
|
||||||
d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::documents().isEmpty());
|
d->m_closeAllEditorsContextAction->setEnabled(!DocumentModel::entries().isEmpty());
|
||||||
d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < DocumentModel::documents().count());
|
d->m_closeAllEditorsExceptVisibleContextAction->setEnabled(visibleDocumentsCount() < DocumentModel::entries().count());
|
||||||
contextMenu->addAction(d->m_closeCurrentEditorContextAction);
|
contextMenu->addAction(d->m_closeCurrentEditorContextAction);
|
||||||
contextMenu->addAction(d->m_closeAllEditorsContextAction);
|
contextMenu->addAction(d->m_closeAllEditorsContextAction);
|
||||||
contextMenu->addAction(d->m_closeOtherEditorsContextAction);
|
contextMenu->addAction(d->m_closeOtherEditorsContextAction);
|
||||||
@@ -1139,12 +1139,12 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
|||||||
if (newCurrent) {
|
if (newCurrent) {
|
||||||
activateEditor(view, newCurrent, flags);
|
activateEditor(view, newCurrent, flags);
|
||||||
} else {
|
} else {
|
||||||
DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument();
|
DocumentModel::Entry *entry = DocumentModel::firstRestoredEntry();
|
||||||
if (entry) {
|
if (entry) {
|
||||||
activateEditorForEntry(view, entry, flags);
|
activateEditorForEntry(view, entry, flags);
|
||||||
} else {
|
} else {
|
||||||
// no "restored" ones, so any entry left should have a document
|
// no "restored" ones, so any entry left should have a document
|
||||||
const QList<DocumentModel::Entry *> documents = DocumentModel::documents();
|
const QList<DocumentModel::Entry *> documents = DocumentModel::entries();
|
||||||
if (!documents.isEmpty()) {
|
if (!documents.isEmpty()) {
|
||||||
IDocument *document = documents.last()->document;
|
IDocument *document = documents.last()->document;
|
||||||
if (document)
|
if (document)
|
||||||
@@ -1691,7 +1691,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
|||||||
if (base.contains(dollar)) {
|
if (base.contains(dollar)) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
QSet<QString> docnames;
|
QSet<QString> docnames;
|
||||||
foreach (DocumentModel::Entry *entry, DocumentModel::documents()) {
|
foreach (DocumentModel::Entry *entry, DocumentModel::entries()) {
|
||||||
QString name = entry->fileName();
|
QString name = entry->fileName();
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
name = entry->displayName();
|
name = entry->displayName();
|
||||||
@@ -2024,7 +2024,7 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q
|
|||||||
void EditorManager::updateActions()
|
void EditorManager::updateActions()
|
||||||
{
|
{
|
||||||
IDocument *curDocument = currentDocument();
|
IDocument *curDocument = currentDocument();
|
||||||
const int openedCount = DocumentModel::documentCount();
|
const int openedCount = DocumentModel::entryCount();
|
||||||
|
|
||||||
if (curDocument) {
|
if (curDocument) {
|
||||||
if (HostOsInfo::isMacHost())
|
if (HostOsInfo::isMacHost())
|
||||||
@@ -2210,7 +2210,7 @@ QByteArray EditorManager::saveState()
|
|||||||
|
|
||||||
stream << d->m_editorStates;
|
stream << d->m_editorStates;
|
||||||
|
|
||||||
QList<DocumentModel::Entry *> entries = DocumentModel::documents();
|
QList<DocumentModel::Entry *> entries = DocumentModel::entries();
|
||||||
int entriesCount = 0;
|
int entriesCount = 0;
|
||||||
foreach (DocumentModel::Entry *entry, entries) {
|
foreach (DocumentModel::Entry *entry, entries) {
|
||||||
// The editor may be 0 if it was not loaded yet: In that case it is not temporary
|
// The editor may be 0 if it was not loaded yet: In that case it is not temporary
|
||||||
|
@@ -302,7 +302,7 @@ IEditor *EditorView::currentEditor() const
|
|||||||
|
|
||||||
void EditorView::listSelectionActivated(int index)
|
void EditorView::listSelectionActivated(int index)
|
||||||
{
|
{
|
||||||
EditorManager::activateEditorForEntry(this, DocumentModel::documentAtRow(index));
|
EditorManager::activateEditorForEntry(this, DocumentModel::entryAtRow(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorView::splitHorizontally()
|
void EditorView::splitHorizontally()
|
||||||
@@ -801,7 +801,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
|||||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
DocumentModel::Entry *entry = DocumentModel::firstRestoredDocument();
|
DocumentModel::Entry *entry = DocumentModel::firstRestoredEntry();
|
||||||
if (entry)
|
if (entry)
|
||||||
EditorManager::activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory
|
EditorManager::activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory
|
||||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||||
|
@@ -189,13 +189,13 @@ void OpenEditorsWidget::activateEditor(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
EditorManager::activateEditorForEntry(
|
EditorManager::activateEditorForEntry(
|
||||||
DocumentModel::documentAtRow(m_model->mapToSource(index).row()));
|
DocumentModel::entryAtRow(m_model->mapToSource(index).row()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
|
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
EditorManager::closeEditor(
|
EditorManager::closeEditor(
|
||||||
DocumentModel::documentAtRow(m_model->mapToSource(index).row()));
|
DocumentModel::entryAtRow(m_model->mapToSource(index).row()));
|
||||||
// work around selection changes
|
// work around selection changes
|
||||||
updateCurrentItem(EditorManager::currentEditor());
|
updateCurrentItem(EditorManager::currentEditor());
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
|
|||||||
{
|
{
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
QModelIndex editorIndex = indexAt(pos);
|
QModelIndex editorIndex = indexAt(pos);
|
||||||
DocumentModel::Entry *entry = DocumentModel::documentAtRow(
|
DocumentModel::Entry *entry = DocumentModel::entryAtRow(
|
||||||
m_model->mapToSource(editorIndex).row());
|
m_model->mapToSource(editorIndex).row());
|
||||||
EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry);
|
EditorManager::addSaveAndCloseEditorActions(&contextMenu, entry);
|
||||||
contextMenu.addSeparator();
|
contextMenu.addSeparator();
|
||||||
|
@@ -236,7 +236,7 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
|
|||||||
|
|
||||||
void OpenEditorsWindow::addRestoredItems()
|
void OpenEditorsWindow::addRestoredItems()
|
||||||
{
|
{
|
||||||
foreach (DocumentModel::Entry *entry, DocumentModel::documents()) {
|
foreach (DocumentModel::Entry *entry, DocumentModel::entries()) {
|
||||||
if (entry->document)
|
if (entry->document)
|
||||||
continue;
|
continue;
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
|
@@ -308,12 +308,12 @@ void EditorToolBar::updateEditorListSelection(IEditor *newSelection)
|
|||||||
|
|
||||||
void EditorToolBar::changeActiveEditor(int row)
|
void EditorToolBar::changeActiveEditor(int row)
|
||||||
{
|
{
|
||||||
EditorManager::activateEditorForEntry(DocumentModel::documentAtRow(row));
|
EditorManager::activateEditorForEntry(DocumentModel::entryAtRow(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::listContextMenu(QPoint pos)
|
void EditorToolBar::listContextMenu(QPoint pos)
|
||||||
{
|
{
|
||||||
DocumentModel::Entry *entry = DocumentModel::documentAtRow(
|
DocumentModel::Entry *entry = DocumentModel::entryAtRow(
|
||||||
d->m_editorList->currentIndex());
|
d->m_editorList->currentIndex());
|
||||||
QString fileName = entry ? entry->fileName() : QString();
|
QString fileName = entry ? entry->fileName() : QString();
|
||||||
QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString();
|
QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString();
|
||||||
@@ -361,7 +361,7 @@ void EditorToolBar::checkDocumentStatus()
|
|||||||
{
|
{
|
||||||
IDocument *document = qobject_cast<IDocument *>(sender());
|
IDocument *document = qobject_cast<IDocument *>(sender());
|
||||||
QTC_ASSERT(document, return);
|
QTC_ASSERT(document, return);
|
||||||
DocumentModel::Entry *entry = DocumentModel::documentAtRow(
|
DocumentModel::Entry *entry = DocumentModel::entryAtRow(
|
||||||
d->m_editorList->currentIndex());
|
d->m_editorList->currentIndex());
|
||||||
|
|
||||||
if (entry && entry->document && entry->document == document)
|
if (entry && entry->document && entry->document == document)
|
||||||
|
@@ -91,7 +91,7 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Core:
|
|||||||
void OpenDocumentsFilter::refreshInternally()
|
void OpenDocumentsFilter::refreshInternally()
|
||||||
{
|
{
|
||||||
m_editors.clear();
|
m_editors.clear();
|
||||||
foreach (DocumentModel::Entry *e, DocumentModel::documents()) {
|
foreach (DocumentModel::Entry *e, DocumentModel::entries()) {
|
||||||
DocumentModel::Entry entry;
|
DocumentModel::Entry entry;
|
||||||
// create copy with only the information relevant to use
|
// create copy with only the information relevant to use
|
||||||
// to avoid model deleting entries behind our back
|
// to avoid model deleting entries behind our back
|
||||||
|
@@ -2154,12 +2154,12 @@ int FakeVimPluginPrivate::currentFile() const
|
|||||||
|
|
||||||
void FakeVimPluginPrivate::switchToFile(int n)
|
void FakeVimPluginPrivate::switchToFile(int n)
|
||||||
{
|
{
|
||||||
int size = DocumentModel::documentCount();
|
int size = DocumentModel::entryCount();
|
||||||
QTC_ASSERT(size, return);
|
QTC_ASSERT(size, return);
|
||||||
n = n % size;
|
n = n % size;
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n += size;
|
n += size;
|
||||||
EditorManager::activateEditorForEntry(DocumentModel::documents().at(n));
|
EditorManager::activateEditorForEntry(DocumentModel::entries().at(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExCommandMap &FakeVimExCommandsPage::exCommandMap()
|
ExCommandMap &FakeVimExCommandsPage::exCommandMap()
|
||||||
|
@@ -171,7 +171,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
|
|
||||||
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
|
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
|
||||||
{
|
{
|
||||||
int openedCount = Core::DocumentModel::documentCount();
|
int openedCount = Core::DocumentModel::entryCount();
|
||||||
|
|
||||||
Core::IDocument *document = 0;
|
Core::IDocument *document = 0;
|
||||||
if (currentEditor)
|
if (currentEditor)
|
||||||
|
@@ -68,7 +68,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
|
|||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
QList<QTextCodec *> codecs;
|
QList<QTextCodec *> codecs;
|
||||||
foreach (Core::DocumentModel::Entry *entry,
|
foreach (Core::DocumentModel::Entry *entry,
|
||||||
Core::DocumentModel::documents()) {
|
Core::DocumentModel::entries()) {
|
||||||
QString fileName = entry->fileName();
|
QString fileName = entry->fileName();
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
fileNames.append(fileName);
|
fileNames.append(fileName);
|
||||||
@@ -100,7 +100,7 @@ QString FindInOpenFiles::toolTip() const
|
|||||||
|
|
||||||
bool FindInOpenFiles::isEnabled() const
|
bool FindInOpenFiles::isEnabled() const
|
||||||
{
|
{
|
||||||
return Core::DocumentModel::documentCount() > 0;
|
return Core::DocumentModel::entryCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindInOpenFiles::writeSettings(QSettings *settings)
|
void FindInOpenFiles::writeSettings(QSettings *settings)
|
||||||
|
Reference in New Issue
Block a user