forked from qt-creator/qt-creator
OpenEditorsModel API: Use 'document' more where is about documents.
Rename OpenEditorsModel to DocumentModel. In the DocumentModel also make the distinction between "restored" document (i.e. just info about file name, display name, id), "opened document" (i.e. document with IEditor and IDocument), and "document" (which refers to any). Change-Id: I01ebe10ec84aab5fe81e54be6bec14f653f28771 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -33,7 +33,7 @@ SOURCES += mainwindow.cpp \
|
||||
versiondialog.cpp \
|
||||
editormanager/editormanager.cpp \
|
||||
editormanager/editorview.cpp \
|
||||
editormanager/openeditorsmodel.cpp \
|
||||
editormanager/documentmodel.cpp \
|
||||
editormanager/openeditorsview.cpp \
|
||||
editormanager/openeditorswindow.cpp \
|
||||
editormanager/ieditorfactory.cpp \
|
||||
@@ -115,7 +115,7 @@ HEADERS += mainwindow.h \
|
||||
statusbarmanager.h \
|
||||
editormanager/editormanager.h \
|
||||
editormanager/editorview.h \
|
||||
editormanager/openeditorsmodel.h \
|
||||
editormanager/documentmodel.h \
|
||||
editormanager/openeditorsview.h \
|
||||
editormanager/openeditorswindow.h \
|
||||
editormanager/ieditor.h \
|
||||
|
||||
@@ -207,8 +207,8 @@ QtcPlugin {
|
||||
"editormanager/ieditorfactory.h",
|
||||
"editormanager/iexternaleditor.cpp",
|
||||
"editormanager/iexternaleditor.h",
|
||||
"editormanager/openeditorsmodel.cpp",
|
||||
"editormanager/openeditorsmodel.h",
|
||||
"editormanager/documentmodel.cpp",
|
||||
"editormanager/documentmodel.h",
|
||||
"editormanager/openeditorsview.cpp",
|
||||
"editormanager/openeditorsview.h",
|
||||
"editormanager/openeditorswindow.cpp",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
#include "ieditor.h"
|
||||
#include "idocument.h"
|
||||
|
||||
@@ -38,75 +38,75 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
struct OpenEditorsModelPrivate
|
||||
struct DocumentModelPrivate
|
||||
{
|
||||
OpenEditorsModelPrivate();
|
||||
~OpenEditorsModelPrivate();
|
||||
DocumentModelPrivate();
|
||||
~DocumentModelPrivate();
|
||||
|
||||
const QIcon m_lockedIcon;
|
||||
const QIcon m_unlockedIcon;
|
||||
|
||||
QList<OpenEditorsModel::Entry *> m_documents;
|
||||
QList<DocumentModel::Entry *> m_documents;
|
||||
QMap<IDocument *, QList<IEditor *> > m_editors;
|
||||
};
|
||||
|
||||
OpenEditorsModelPrivate::OpenEditorsModelPrivate() :
|
||||
DocumentModelPrivate::DocumentModelPrivate() :
|
||||
m_lockedIcon(QLatin1String(":/core/images/locked.png")),
|
||||
m_unlockedIcon(QLatin1String(":/core/images/unlocked.png"))
|
||||
{
|
||||
}
|
||||
|
||||
OpenEditorsModelPrivate::~OpenEditorsModelPrivate()
|
||||
DocumentModelPrivate::~DocumentModelPrivate()
|
||||
{
|
||||
qDeleteAll(m_documents);
|
||||
}
|
||||
|
||||
OpenEditorsModel::Entry::Entry() :
|
||||
DocumentModel::Entry::Entry() :
|
||||
document(0)
|
||||
{
|
||||
}
|
||||
|
||||
OpenEditorsModel::OpenEditorsModel(QObject *parent) :
|
||||
QAbstractItemModel(parent), d(new OpenEditorsModelPrivate)
|
||||
DocumentModel::DocumentModel(QObject *parent) :
|
||||
QAbstractItemModel(parent), d(new DocumentModelPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
OpenEditorsModel::~OpenEditorsModel()
|
||||
DocumentModel::~DocumentModel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QIcon OpenEditorsModel::lockedIcon() const
|
||||
QIcon DocumentModel::lockedIcon() const
|
||||
{
|
||||
return d->m_lockedIcon;
|
||||
}
|
||||
|
||||
QIcon OpenEditorsModel::unlockedIcon() const
|
||||
QIcon DocumentModel::unlockedIcon() const
|
||||
{
|
||||
return d->m_unlockedIcon;
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::fileName() const {
|
||||
QString DocumentModel::Entry::fileName() const {
|
||||
return document ? document->filePath() : m_fileName;
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::displayName() const {
|
||||
QString DocumentModel::Entry::displayName() const {
|
||||
return document ? document->displayName() : m_displayName;
|
||||
}
|
||||
|
||||
Id OpenEditorsModel::Entry::id() const
|
||||
Id DocumentModel::Entry::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
int OpenEditorsModel::columnCount(const QModelIndex &parent) const
|
||||
int DocumentModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid())
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OpenEditorsModel::rowCount(const QModelIndex &parent) const
|
||||
int DocumentModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid())
|
||||
return d->m_documents.count() + 1/*<no document>*/;
|
||||
@@ -114,7 +114,7 @@ int OpenEditorsModel::rowCount(const QModelIndex &parent) const
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
QList<IEditor *> OpenEditorsModel::oneEditorForEachDocument() const
|
||||
QList<IEditor *> DocumentModel::oneEditorForEachOpenedDocument() const
|
||||
{
|
||||
QList<IEditor *> result;
|
||||
QMapIterator<IDocument *, QList<IEditor *> > it(d->m_editors);
|
||||
@@ -123,7 +123,7 @@ QList<IEditor *> OpenEditorsModel::oneEditorForEachDocument() const
|
||||
return result;
|
||||
}
|
||||
|
||||
void OpenEditorsModel::addEditor(IEditor *editor, bool *isNewDocument)
|
||||
void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
@@ -141,7 +141,7 @@ void OpenEditorsModel::addEditor(IEditor *editor, bool *isNewDocument)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorsModel::addRestoredEditor(const QString &fileName, const QString &displayName, const Id &id)
|
||||
void DocumentModel::addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id)
|
||||
{
|
||||
Entry *entry = new Entry;
|
||||
entry->m_fileName = fileName;
|
||||
@@ -150,7 +150,7 @@ void OpenEditorsModel::addRestoredEditor(const QString &fileName, const QString
|
||||
addEntry(entry);
|
||||
}
|
||||
|
||||
OpenEditorsModel::Entry *OpenEditorsModel::firstRestoredEditor() const
|
||||
DocumentModel::Entry *DocumentModel::firstRestoredDocument() const
|
||||
{
|
||||
for (int i = 0; i < d->m_documents.count(); ++i)
|
||||
if (!d->m_documents.at(i)->document)
|
||||
@@ -158,7 +158,7 @@ OpenEditorsModel::Entry *OpenEditorsModel::firstRestoredEditor() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OpenEditorsModel::addEntry(Entry *entry)
|
||||
void DocumentModel::addEntry(Entry *entry)
|
||||
{
|
||||
QString fileName = entry->fileName();
|
||||
|
||||
@@ -190,7 +190,7 @@ void OpenEditorsModel::addEntry(Entry *entry)
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
int OpenEditorsModel::indexofFileName(const QString &filename) const
|
||||
int DocumentModel::indexofFileName(const QString &filename) const
|
||||
{
|
||||
if (filename.isEmpty())
|
||||
return -1;
|
||||
@@ -201,14 +201,14 @@ int OpenEditorsModel::indexofFileName(const QString &filename) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void OpenEditorsModel::removeEntry(OpenEditorsModel::Entry *entry)
|
||||
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);
|
||||
removeDocument(index);
|
||||
}
|
||||
|
||||
void OpenEditorsModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
|
||||
void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
|
||||
{
|
||||
if (lastOneForDocument)
|
||||
*lastOneForDocument = false;
|
||||
@@ -224,14 +224,14 @@ void OpenEditorsModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorsModel::removeDocument(const QString &fileName)
|
||||
void DocumentModel::removeDocument(const QString &fileName)
|
||||
{
|
||||
int index = indexofFileName(fileName);
|
||||
QTC_ASSERT(!d->m_documents.at(index)->document, return); // we wouldn't know what to do with the associated editors
|
||||
removeDocument(index);
|
||||
}
|
||||
|
||||
void OpenEditorsModel::removeDocument(int idx)
|
||||
void DocumentModel::removeDocument(int idx)
|
||||
{
|
||||
if (idx < 0)
|
||||
return;
|
||||
@@ -245,7 +245,7 @@ void OpenEditorsModel::removeDocument(int idx)
|
||||
disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged()));
|
||||
}
|
||||
|
||||
void OpenEditorsModel::removeAllRestoredEditors()
|
||||
void DocumentModel::removeAllRestoredDocuments()
|
||||
{
|
||||
for (int i = d->m_documents.count()-1; i >= 0; --i) {
|
||||
if (!d->m_documents.at(i)->document) {
|
||||
@@ -257,12 +257,12 @@ void OpenEditorsModel::removeAllRestoredEditors()
|
||||
}
|
||||
}
|
||||
|
||||
QList<IEditor *> OpenEditorsModel::editorsForDocument(IDocument *document) const
|
||||
QList<IEditor *> DocumentModel::editorsForDocument(IDocument *document) const
|
||||
{
|
||||
return d->m_editors.value(document);
|
||||
}
|
||||
|
||||
QList<IEditor *> OpenEditorsModel::editorsForDocuments(const QList<IDocument *> &documents) const
|
||||
QList<IEditor *> DocumentModel::editorsForDocuments(const QList<IDocument *> &documents) const
|
||||
{
|
||||
QList<IEditor *> result;
|
||||
foreach (IDocument *document, documents)
|
||||
@@ -270,7 +270,7 @@ QList<IEditor *> OpenEditorsModel::editorsForDocuments(const QList<IDocument *>
|
||||
return result;
|
||||
}
|
||||
|
||||
int OpenEditorsModel::indexOfDocument(IDocument *document) const
|
||||
int DocumentModel::indexOfDocument(IDocument *document) const
|
||||
{
|
||||
for (int i = 0; i < d->m_documents.count(); ++i)
|
||||
if (d->m_documents.at(i)->document == document)
|
||||
@@ -278,7 +278,7 @@ int OpenEditorsModel::indexOfDocument(IDocument *document) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
QModelIndex OpenEditorsModel::index(int row, int column, const QModelIndex &parent) const
|
||||
QModelIndex DocumentModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if (column < 0 || column > 1 || row < 0 || row >= d->m_documents.count() + 1/*<no document>*/)
|
||||
@@ -286,7 +286,7 @@ QModelIndex OpenEditorsModel::index(int row, int column, const QModelIndex &pare
|
||||
return createIndex(row, column);
|
||||
}
|
||||
|
||||
OpenEditorsModel::Entry *OpenEditorsModel::entryAtRow(int row) const
|
||||
DocumentModel::Entry *DocumentModel::documentAtRow(int row) const
|
||||
{
|
||||
int entryIndex = row - 1/*<no document>*/;
|
||||
if (entryIndex < 0)
|
||||
@@ -294,12 +294,12 @@ OpenEditorsModel::Entry *OpenEditorsModel::entryAtRow(int row) const
|
||||
return d->m_documents[entryIndex];
|
||||
}
|
||||
|
||||
int OpenEditorsModel::openDocumentCount() const
|
||||
int DocumentModel::documentCount() const
|
||||
{
|
||||
return d->m_documents.count();
|
||||
}
|
||||
|
||||
QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant DocumentModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (index.column() != 0 && role < Qt::UserRole))
|
||||
return QVariant();
|
||||
@@ -343,14 +343,14 @@ QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int OpenEditorsModel::rowOfDocument(IDocument *document) const
|
||||
int DocumentModel::rowOfDocument(IDocument *document) const
|
||||
{
|
||||
if (!document)
|
||||
return 0 /*<no document>*/;
|
||||
return indexOfDocument(document) + 1/*<no document>*/;
|
||||
}
|
||||
|
||||
void OpenEditorsModel::itemChanged()
|
||||
void DocumentModel::itemChanged()
|
||||
{
|
||||
IDocument *document = qobject_cast<IDocument *>(sender());
|
||||
|
||||
@@ -361,7 +361,7 @@ void OpenEditorsModel::itemChanged()
|
||||
emit dataChanged(mindex, mindex);
|
||||
}
|
||||
|
||||
QList<OpenEditorsModel::Entry *> OpenEditorsModel::entries() const
|
||||
QList<DocumentModel::Entry *> DocumentModel::documents() const
|
||||
{
|
||||
return d->m_documents;
|
||||
}
|
||||
@@ -27,8 +27,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef OPENEDITORSMODEL_H
|
||||
#define OPENEDITORSMODEL_H
|
||||
#ifndef DOCUMENTMODEL_H
|
||||
#define DOCUMENTMODEL_H
|
||||
|
||||
#include "../core_global.h"
|
||||
#include "../id.h"
|
||||
@@ -39,17 +39,17 @@ QT_FORWARD_DECLARE_CLASS(QIcon)
|
||||
|
||||
namespace Core {
|
||||
|
||||
struct OpenEditorsModelPrivate;
|
||||
struct DocumentModelPrivate;
|
||||
class IEditor;
|
||||
class IDocument;
|
||||
|
||||
class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
|
||||
class CORE_EXPORT DocumentModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenEditorsModel(QObject *parent);
|
||||
virtual ~OpenEditorsModel();
|
||||
explicit DocumentModel(QObject *parent);
|
||||
virtual ~DocumentModel();
|
||||
|
||||
QIcon lockedIcon() const;
|
||||
QIcon unlockedIcon() const;
|
||||
@@ -71,26 +71,25 @@ public:
|
||||
Id m_id;
|
||||
};
|
||||
|
||||
Entry *entryAtRow(int row) const;
|
||||
Entry *documentAtRow(int row) const;
|
||||
int rowOfDocument(IDocument *document) const;
|
||||
|
||||
int openDocumentCount() const;
|
||||
|
||||
QList<Entry *> entries() const;
|
||||
int documentCount() const;
|
||||
QList<Entry *> documents() const;
|
||||
int indexOfDocument(IDocument *document) const;
|
||||
|
||||
QList<IEditor *> editorsForDocument(IDocument *document) const;
|
||||
QList<IEditor *> editorsForDocuments(const QList<IDocument *> &documents) const;
|
||||
QList<IEditor *> oneEditorForEachDocument() const;
|
||||
int indexOfDocument(IDocument *document) const;
|
||||
QList<IEditor *> oneEditorForEachOpenedDocument() const;
|
||||
|
||||
// editor manager related methods, nobody else should call it
|
||||
void addEditor(IEditor *editor, bool *isNewDocument);
|
||||
void addRestoredEditor(const QString &fileName, const QString &displayName, const Id &id);
|
||||
Entry *firstRestoredEditor() const;
|
||||
void removeEntry(Entry *entry);
|
||||
void addRestoredDocument(const QString &fileName, const QString &displayName, const Id &id);
|
||||
Entry *firstRestoredDocument() const;
|
||||
void removeEditor(IEditor *editor, bool *lastOneForDocument);
|
||||
void removeDocument(const QString &fileName);
|
||||
void removeAllRestoredEditors();
|
||||
void removeEntry(Entry *entry);
|
||||
void removeAllRestoredDocuments();
|
||||
|
||||
private slots:
|
||||
void itemChanged();
|
||||
@@ -100,9 +99,9 @@ private:
|
||||
int indexofFileName(const QString &filename) const;
|
||||
void removeDocument(int idx);
|
||||
|
||||
OpenEditorsModelPrivate *d;
|
||||
DocumentModelPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // OPENEDITORSMODEL_H
|
||||
#endif // DOCUMENTMODEL_H
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "findplaceholder.h"
|
||||
#include "openeditorswindow.h"
|
||||
#include "openeditorsview.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
#include "openwithdialog.h"
|
||||
#include "outputpane.h"
|
||||
#include "outputpanemanager.h"
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
QAction *m_closeOtherEditorsContextAction;
|
||||
QAction *m_openGraphicalShellAction;
|
||||
QAction *m_openTerminalAction;
|
||||
OpenEditorsModel::Entry *m_contextMenuEntry;
|
||||
DocumentModel::Entry *m_contextMenuEntry;
|
||||
|
||||
Internal::OpenEditorsWindow *m_windowPopup;
|
||||
Internal::EditorClosingCoreListener *m_coreListener;
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
QMap<QString, QVariant> m_editorStates;
|
||||
Internal::OpenEditorsViewFactory *m_openEditorsFactory;
|
||||
|
||||
OpenEditorsModel *m_editorModel;
|
||||
DocumentModel *m_documentModel;
|
||||
|
||||
IDocument::ReloadSetting m_reloadSetting;
|
||||
|
||||
@@ -258,7 +258,7 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
|
||||
m_autoSaveEnabled(true),
|
||||
m_autoSaveInterval(5)
|
||||
{
|
||||
m_editorModel = new OpenEditorsModel(parent);
|
||||
m_documentModel = new DocumentModel(parent);
|
||||
}
|
||||
|
||||
EditorManagerPrivate::~EditorManagerPrivate()
|
||||
@@ -508,7 +508,7 @@ EditorToolBar *EditorManager::createToolBar(QWidget *parent)
|
||||
void EditorManager::removeEditor(IEditor *editor)
|
||||
{
|
||||
bool lastOneForDocument = false;
|
||||
d->m_editorModel->removeEditor(editor, &lastOneForDocument);
|
||||
d->m_documentModel->removeEditor(editor, &lastOneForDocument);
|
||||
if (lastOneForDocument)
|
||||
DocumentManager::removeDocument(editor->document());
|
||||
ICore::removeContextObject(editor);
|
||||
@@ -660,7 +660,7 @@ void EditorManager::emptyView(Core::Internal::EditorView *view)
|
||||
|
||||
QList<IEditor *> editors = view->editors();
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (d->m_editorModel->editorsForDocument(editor->document()).size() == 1) {
|
||||
if (d->m_documentModel->editorsForDocument(editor->document()).size() == 1) {
|
||||
// it's the only editor for that file
|
||||
// so we need to keep it around (--> in the editor model)
|
||||
if (currentEditor() == editor) {
|
||||
@@ -741,7 +741,7 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
||||
|
||||
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||
{
|
||||
d->m_editorModel->removeAllRestoredEditors();
|
||||
d->m_documentModel->removeAllRestoredDocuments();
|
||||
if (closeEditors(openedEditors(), askAboutModifiedEditors)) {
|
||||
// d->clearNavigationHistory();
|
||||
return true;
|
||||
@@ -751,7 +751,7 @@ bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||
|
||||
void EditorManager::closeOtherEditors(IDocument *document)
|
||||
{
|
||||
d->m_editorModel->removeAllRestoredEditors();
|
||||
d->m_documentModel->removeAllRestoredDocuments();
|
||||
QList<IEditor *> editorsToClose;
|
||||
foreach (IEditor *editor, openedEditors())
|
||||
if (editor->document() != document)
|
||||
@@ -784,7 +784,7 @@ static void assignAction(QAction *self, QAction *other)
|
||||
self->setIconVisibleInMenu(other->isIconVisibleInMenu());
|
||||
}
|
||||
|
||||
void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, OpenEditorsModel::Entry *entry)
|
||||
void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentModel::Entry *entry)
|
||||
{
|
||||
QTC_ASSERT(contextMenu, return);
|
||||
d->m_contextMenuEntry = entry;
|
||||
@@ -821,7 +821,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, OpenEditors
|
||||
contextMenu->addAction(d->m_closeOtherEditorsContextAction);
|
||||
}
|
||||
|
||||
void EditorManager::addNativeDirActions(QMenu *contextMenu, OpenEditorsModel::Entry *entry)
|
||||
void EditorManager::addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry *entry)
|
||||
{
|
||||
QTC_ASSERT(contextMenu, return);
|
||||
bool enabled = entry && !entry->fileName().isEmpty();
|
||||
@@ -949,7 +949,7 @@ void EditorManager::closeEditorFromContextMenu()
|
||||
{
|
||||
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : 0;
|
||||
if (document)
|
||||
closeEditors(d->m_editorModel->editorsForDocument(document));
|
||||
closeEditors(d->m_documentModel->editorsForDocument(document));
|
||||
}
|
||||
|
||||
void EditorManager::closeOtherEditorsFromContextMenu()
|
||||
@@ -1035,14 +1035,14 @@ void EditorManager::closeEditor(Core::IEditor *editor)
|
||||
closeEditors(QList<IEditor *>() << editor);
|
||||
}
|
||||
|
||||
void EditorManager::closeEditor(OpenEditorsModel::Entry *entry)
|
||||
void EditorManager::closeEditor(DocumentModel::Entry *entry)
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
if (entry->document)
|
||||
closeEditors(d->m_editorModel->editorsForDocument(entry->document));
|
||||
closeEditors(d->m_documentModel->editorsForDocument(entry->document));
|
||||
else
|
||||
d->m_editorModel->removeEntry(entry);
|
||||
d->m_documentModel->removeEntry(entry);
|
||||
}
|
||||
|
||||
bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool askAboutModifiedEditors)
|
||||
@@ -1068,7 +1068,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
}
|
||||
}
|
||||
if (editorAccepted) {
|
||||
acceptedEditors += d->m_editorModel->editorsForDocument(editor->document()).toSet();
|
||||
acceptedEditors += d->m_documentModel->editorsForDocument(editor->document()).toSet();
|
||||
acceptedDocuments.insert(editor->document());
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1083,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
if (!list.isEmpty()) {
|
||||
closingFailed = true;
|
||||
acceptedDocuments.subtract(list.toSet());
|
||||
QSet<IEditor*> skipSet = d->m_editorModel->editorsForDocuments(list).toSet();
|
||||
QSet<IEditor*> skipSet = d->m_documentModel->editorsForDocuments(list).toSet();
|
||||
acceptedEditors = acceptedEditors.subtract(skipSet);
|
||||
}
|
||||
}
|
||||
@@ -1131,12 +1131,12 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
if (newCurrent) {
|
||||
activateEditor(view, newCurrent, flags);
|
||||
} else {
|
||||
OpenEditorsModel::Entry *entry = d->m_editorModel->firstRestoredEditor();
|
||||
DocumentModel::Entry *entry = d->m_documentModel->firstRestoredDocument();
|
||||
if (entry) {
|
||||
activateEditorForEntry(view, entry, flags);
|
||||
} else {
|
||||
// no "restored" ones, so any entry left should have a document
|
||||
const QList<OpenEditorsModel::Entry *> documents = d->m_editorModel->entries();
|
||||
const QList<DocumentModel::Entry *> documents = d->m_documentModel->documents();
|
||||
if (!documents.isEmpty()) {
|
||||
IDocument *document = documents.last()->document;
|
||||
if (document)
|
||||
@@ -1178,12 +1178,12 @@ Core::IEditor *EditorManager::pickUnusedEditor() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EditorManager::activateEditorForEntry(OpenEditorsModel::Entry *entry, OpenEditorFlags flags)
|
||||
void EditorManager::activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags)
|
||||
{
|
||||
activateEditorForEntry(currentEditorView(), entry, flags);
|
||||
}
|
||||
|
||||
void EditorManager::activateEditorForEntry(Internal::EditorView *view, OpenEditorsModel::Entry *entry, OpenEditorFlags flags)
|
||||
void EditorManager::activateEditorForEntry(Internal::EditorView *view, DocumentModel::Entry *entry, OpenEditorFlags flags)
|
||||
{
|
||||
QTC_ASSERT(view, return);
|
||||
if (!entry) { // no document
|
||||
@@ -1199,7 +1199,7 @@ void EditorManager::activateEditorForEntry(Internal::EditorView *view, OpenEdito
|
||||
}
|
||||
|
||||
if (!openEditor(view, entry->fileName(), entry->id(), flags))
|
||||
d->m_editorModel->removeEntry(entry);
|
||||
d->m_documentModel->removeEntry(entry);
|
||||
}
|
||||
|
||||
void EditorManager::activateView(EditorView *view)
|
||||
@@ -1409,7 +1409,7 @@ void EditorManager::addEditor(IEditor *editor)
|
||||
ICore::addContextObject(editor);
|
||||
|
||||
bool isNewDocument = false;
|
||||
d->m_editorModel->addEditor(editor, &isNewDocument);
|
||||
d->m_documentModel->addEditor(editor, &isNewDocument);
|
||||
if (isNewDocument) {
|
||||
const bool isTemporary = editor->isTemporary();
|
||||
const bool addWatcher = !isTemporary;
|
||||
@@ -1845,7 +1845,7 @@ void EditorManager::gotoNextDocHistory()
|
||||
dialog->selectNextEditor();
|
||||
} else {
|
||||
EditorView *view = currentEditorView();
|
||||
dialog->setEditors(d->m_globalHistory, view, d->m_editorModel);
|
||||
dialog->setEditors(d->m_globalHistory, view, d->m_documentModel);
|
||||
dialog->selectNextEditor();
|
||||
showPopupOrSelectDocument();
|
||||
}
|
||||
@@ -1858,7 +1858,7 @@ void EditorManager::gotoPreviousDocHistory()
|
||||
dialog->selectPreviousEditor();
|
||||
} else {
|
||||
EditorView *view = currentEditorView();
|
||||
dialog->setEditors(d->m_globalHistory, view, d->m_editorModel);
|
||||
dialog->setEditors(d->m_globalHistory, view, d->m_documentModel);
|
||||
dialog->selectPreviousEditor();
|
||||
showPopupOrSelectDocument();
|
||||
}
|
||||
@@ -1985,7 +1985,7 @@ void EditorManager::updateActions()
|
||||
{
|
||||
IEditor *curEditor = currentEditor();
|
||||
IDocument *curDocument = curEditor ? curEditor->document() : 0;
|
||||
int openedCount = d->m_editorModel->openDocumentCount();
|
||||
int openedCount = d->m_documentModel->documentCount();
|
||||
|
||||
if (curDocument) {
|
||||
if (HostOsInfo::isMacHost())
|
||||
@@ -2009,8 +2009,8 @@ void EditorManager::updateActions()
|
||||
d->m_closeOtherEditorsAction->setEnabled(openedCount > 1);
|
||||
d->m_closeOtherEditorsAction->setText((openedCount > 1 ? tr("Close All Except %1").arg(quotedName) : tr("Close Others")));
|
||||
|
||||
d->m_gotoNextDocHistoryAction->setEnabled(d->m_editorModel->rowCount() != 0);
|
||||
d->m_gotoPreviousDocHistoryAction->setEnabled(d->m_editorModel->rowCount() != 0);
|
||||
d->m_gotoNextDocHistoryAction->setEnabled(d->m_documentModel->rowCount() != 0);
|
||||
d->m_gotoPreviousDocHistoryAction->setEnabled(d->m_documentModel->rowCount() != 0);
|
||||
EditorView *view = currentEditorView();
|
||||
d->m_goBackAction->setEnabled(view ? view->canGoBack() : false);
|
||||
d->m_goForwardAction->setEnabled(view ? view->canGoForward() : false);
|
||||
@@ -2068,15 +2068,15 @@ QList<IEditor*> EditorManager::visibleEditors() const
|
||||
return editors;
|
||||
}
|
||||
|
||||
// TODO code using this should probably better use OpenEditorsModel
|
||||
// TODO code using this should probably better use DocumentModel
|
||||
QList<IEditor*> EditorManager::openedEditors() const
|
||||
{
|
||||
return d->m_editorModel->oneEditorForEachDocument();
|
||||
return d->m_documentModel->oneEditorForEachOpenedDocument();
|
||||
}
|
||||
|
||||
OpenEditorsModel *EditorManager::openedEditorsModel() const
|
||||
DocumentModel *EditorManager::documentModel() const
|
||||
{
|
||||
return d->m_editorModel;
|
||||
return d->m_documentModel;
|
||||
}
|
||||
|
||||
void EditorManager::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
|
||||
@@ -2159,12 +2159,12 @@ QByteArray EditorManager::saveState() const
|
||||
|
||||
stream << d->m_editorStates;
|
||||
|
||||
QList<OpenEditorsModel::Entry *> entries = d->m_editorModel->entries();
|
||||
QList<DocumentModel::Entry *> entries = d->m_documentModel->documents();
|
||||
int entriesCount = 0;
|
||||
foreach (OpenEditorsModel::Entry *entry, entries) {
|
||||
foreach (DocumentModel::Entry *entry, entries) {
|
||||
// TODO: isTemporary should move to IDocument
|
||||
IEditor *editor = entry->document
|
||||
? d->m_editorModel->editorsForDocument(entry->document).first()
|
||||
? d->m_documentModel->editorsForDocument(entry->document).first()
|
||||
: 0;
|
||||
// The editor may be 0 if it was not loaded yet: In that case it is not temporary
|
||||
if (!editor || !editor->isTemporary())
|
||||
@@ -2173,9 +2173,9 @@ QByteArray EditorManager::saveState() const
|
||||
|
||||
stream << entriesCount;
|
||||
|
||||
foreach (OpenEditorsModel::Entry *entry, entries) {
|
||||
foreach (DocumentModel::Entry *entry, entries) {
|
||||
IEditor *editor = entry->document
|
||||
? d->m_editorModel->editorsForDocument(entry->document).first()
|
||||
? d->m_documentModel->editorsForDocument(entry->document).first()
|
||||
: 0;
|
||||
if (!editor || !editor->isTemporary())
|
||||
stream << entry->fileName() << entry->displayName() << entry->id();
|
||||
@@ -2224,7 +2224,7 @@ bool EditorManager::restoreState(const QByteArray &state)
|
||||
if (rfi.exists() && fi.lastModified() < rfi.lastModified())
|
||||
openEditor(fileName, id, DoNotMakeVisible);
|
||||
else
|
||||
d->m_editorModel->addRestoredEditor(fileName, displayName, id);
|
||||
d->m_documentModel->addRestoredDocument(fileName, displayName, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "../core_global.h"
|
||||
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/idocument.h> // enumerations
|
||||
@@ -131,11 +131,11 @@ public:
|
||||
QList<IEditor*> openedEditors() const;
|
||||
|
||||
static void activateEditor(IEditor *editor, OpenEditorFlags flags = 0);
|
||||
void activateEditorForEntry(OpenEditorsModel::Entry *entry, OpenEditorFlags flags = 0);
|
||||
void activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags = 0);
|
||||
IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0);
|
||||
|
||||
OpenEditorsModel *openedEditorsModel() const;
|
||||
void closeEditor(OpenEditorsModel::Entry *entry);
|
||||
DocumentModel *documentModel() const;
|
||||
void closeEditor(DocumentModel::Entry *entry);
|
||||
void closeOtherEditors(IDocument *document);
|
||||
|
||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||
@@ -185,8 +185,8 @@ public:
|
||||
static void setWindowTitleVcsTopic(const QString &topic);
|
||||
static QString windowTitleVcsTopic();
|
||||
|
||||
void addSaveAndCloseEditorActions(QMenu *contextMenu, OpenEditorsModel::Entry *entry);
|
||||
void addNativeDirActions(QMenu *contextMenu, OpenEditorsModel::Entry *entry);
|
||||
void addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentModel::Entry *entry);
|
||||
void addNativeDirActions(QMenu *contextMenu, DocumentModel::Entry *entry);
|
||||
|
||||
signals:
|
||||
void currentEditorChanged(Core::IEditor *editor);
|
||||
@@ -259,7 +259,7 @@ private:
|
||||
IEditor *placeEditor(Internal::EditorView *view, IEditor *editor);
|
||||
IEditor *duplicateEditor(IEditor *editor);
|
||||
IEditor *activateEditor(Internal::EditorView *view, IEditor *editor, OpenEditorFlags flags = 0);
|
||||
void activateEditorForEntry(Internal::EditorView *view, OpenEditorsModel::Entry *entry, OpenEditorFlags flags = 0);
|
||||
void activateEditorForEntry(Internal::EditorView *view, DocumentModel::Entry *entry, OpenEditorFlags flags = 0);
|
||||
void activateView(Internal::EditorView *view);
|
||||
IEditor *openEditor(Internal::EditorView *view, const QString &fileName,
|
||||
const Id &id = Id(), OpenEditorFlags flags = 0, bool *newEditor = 0);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "editormanager.h"
|
||||
#include "icore.h"
|
||||
#include "minisplitter.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
|
||||
#include <coreplugin/editortoolbar.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -303,8 +303,8 @@ IEditor *EditorView::currentEditor() const
|
||||
|
||||
void EditorView::listSelectionActivated(int index)
|
||||
{
|
||||
OpenEditorsModel *model = EditorManager::instance()->openedEditorsModel();
|
||||
EditorManager::instance()->activateEditorForEntry(this, model->entryAtRow(index));
|
||||
DocumentModel *model = EditorManager::instance()->documentModel();
|
||||
EditorManager::instance()->activateEditorForEntry(this, model->documentAtRow(index));
|
||||
}
|
||||
|
||||
void EditorView::splitHorizontally()
|
||||
@@ -786,7 +786,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||
|
||||
if (!e) {
|
||||
OpenEditorsModel::Entry *entry = em->openedEditorsModel()->firstRestoredEditor();
|
||||
DocumentModel::Entry *entry = em->documentModel()->firstRestoredDocument();
|
||||
if (entry)
|
||||
em->activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory
|
||||
| Core::EditorManager::DoNotChangeCurrentEditor);
|
||||
|
||||
@@ -57,7 +57,7 @@ class IContext;
|
||||
class IDocument;
|
||||
class IEditor;
|
||||
class InfoBarDisplay;
|
||||
class OpenEditorsModel;
|
||||
class DocumentModel;
|
||||
class EditorToolBar;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "openeditorsview.h"
|
||||
#include "editormanager.h"
|
||||
#include "ieditor.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -98,7 +98,7 @@ OpenEditorsWidget::OpenEditorsWidget()
|
||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
EditorManager *em = EditorManager::instance();
|
||||
m_model = new ProxyModel(this);
|
||||
m_model->setSourceModel(em->openedEditorsModel());
|
||||
m_model->setSourceModel(em->documentModel());
|
||||
setModel(m_model);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
@@ -129,7 +129,7 @@ void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
|
||||
{
|
||||
IDocument *document = editor ? editor->document() : 0;
|
||||
EditorManager *em = EditorManager::instance();
|
||||
QModelIndex index = m_model->index(em->openedEditorsModel()->indexOfDocument(document), 0);
|
||||
QModelIndex index = m_model->index(em->documentModel()->indexOfDocument(document), 0);
|
||||
if (!index.isValid()) {
|
||||
clearSelection();
|
||||
return;
|
||||
@@ -195,13 +195,13 @@ void OpenEditorsWidget::activateEditor(const QModelIndex &index)
|
||||
{
|
||||
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
EditorManager *em = EditorManager::instance();
|
||||
em->activateEditorForEntry(em->openedEditorsModel()->entryAtRow(m_model->mapToSource(index).row()));
|
||||
em->activateEditorForEntry(em->documentModel()->documentAtRow(m_model->mapToSource(index).row()));
|
||||
}
|
||||
|
||||
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
|
||||
{
|
||||
EditorManager *em = EditorManager::instance();
|
||||
em->closeEditor(em->openedEditorsModel()->entryAtRow(m_model->mapToSource(index).row()));
|
||||
em->closeEditor(em->documentModel()->documentAtRow(m_model->mapToSource(index).row()));
|
||||
// work around selection changes
|
||||
updateCurrentItem(EditorManager::currentEditor());
|
||||
}
|
||||
@@ -210,7 +210,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
|
||||
{
|
||||
QMenu contextMenu;
|
||||
QModelIndex editorIndex = indexAt(pos);
|
||||
OpenEditorsModel::Entry *entry = EditorManager::instance()->openedEditorsModel()->entryAtRow(
|
||||
DocumentModel::Entry *entry = EditorManager::instance()->documentModel()->documentAtRow(
|
||||
m_model->mapToSource(editorIndex).row());
|
||||
EditorManager::instance()->addSaveAndCloseEditorActions(&contextMenu, entry);
|
||||
contextMenu.addSeparator();
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "openeditorswindow.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "documentmodel.h"
|
||||
#include "editormanager.h"
|
||||
#include "editorview.h"
|
||||
#include "idocument.h"
|
||||
@@ -193,7 +193,7 @@ void OpenEditorsWindow::centerOnItem(int selectedIndex)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, EditorView *view, OpenEditorsModel *model)
|
||||
void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, EditorView *view, DocumentModel *model)
|
||||
{
|
||||
m_editorList->clear();
|
||||
|
||||
@@ -203,7 +203,7 @@ void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, Edi
|
||||
addHistoryItems(globalHistory, view, model, documentsDone);
|
||||
|
||||
// add purely restored editors which are not initialised yet
|
||||
foreach (OpenEditorsModel::Entry *entry, model->entries()) {
|
||||
foreach (DocumentModel::Entry *entry, model->documents()) {
|
||||
if (entry->document)
|
||||
continue;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
@@ -229,7 +229,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
||||
} else {
|
||||
if (!EditorManager::openEditor(
|
||||
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>())) {
|
||||
EditorManager::instance()->openedEditorsModel()->removeDocument(item->toolTip(0));
|
||||
EditorManager::instance()->documentModel()->removeDocument(item->toolTip(0));
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ void OpenEditorsWindow::ensureCurrentVisible()
|
||||
|
||||
|
||||
void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
||||
OpenEditorsModel *model, QSet<IDocument *> &documentsDone)
|
||||
DocumentModel *model, QSet<IDocument *> &documentsDone)
|
||||
{
|
||||
foreach (const EditLocation &hi, history) {
|
||||
if (hi.document.isNull() || documentsDone.contains(hi.document))
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Core {
|
||||
|
||||
class IDocument;
|
||||
class IEditor;
|
||||
class OpenEditorsModel;
|
||||
class DocumentModel;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
explicit OpenEditorsWindow(QWidget *parent = 0);
|
||||
|
||||
void setEditors(const QList<EditLocation> &globalHistory, EditorView *view, OpenEditorsModel *model);
|
||||
void setEditors(const QList<EditLocation> &globalHistory, EditorView *view, DocumentModel *model);
|
||||
|
||||
bool eventFilter(QObject *src, QEvent *e);
|
||||
void focusInEvent(QFocusEvent *);
|
||||
@@ -78,7 +78,7 @@ private slots:
|
||||
private:
|
||||
static void updateItem(QTreeWidgetItem *item, IEditor *editor);
|
||||
void addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
||||
OpenEditorsModel *model, QSet<IDocument*> &documentsDone);
|
||||
DocumentModel *model, QSet<IDocument*> &documentsDone);
|
||||
void ensureCurrentVisible();
|
||||
bool isCentering();
|
||||
void centerOnItem(int selectedIndex);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -57,7 +57,7 @@ namespace Core {
|
||||
struct EditorToolBarPrivate {
|
||||
explicit EditorToolBarPrivate(QWidget *parent, EditorToolBar *q);
|
||||
|
||||
Core::OpenEditorsModel *m_editorsListModel;
|
||||
Core::DocumentModel *m_editorsListModel;
|
||||
QComboBox *m_editorList;
|
||||
QToolButton *m_closeEditorButton;
|
||||
QToolButton *m_lockButton;
|
||||
@@ -115,7 +115,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
|
||||
d->m_lockButton->setAutoRaise(true);
|
||||
d->m_lockButton->setEnabled(false);
|
||||
|
||||
d->m_editorsListModel = EditorManager::instance()->openedEditorsModel();
|
||||
d->m_editorsListModel = EditorManager::instance()->documentModel();
|
||||
connect(d->m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
|
||||
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
|
||||
|
||||
@@ -310,13 +310,13 @@ void EditorToolBar::updateEditorListSelection(IEditor *newSelection)
|
||||
void EditorToolBar::changeActiveEditor(int row)
|
||||
{
|
||||
EditorManager *em = EditorManager::instance();
|
||||
em->activateEditorForEntry(d->m_editorsListModel->entryAtRow(row));
|
||||
em->activateEditorForEntry(d->m_editorsListModel->documentAtRow(row));
|
||||
}
|
||||
|
||||
void EditorToolBar::listContextMenu(QPoint pos)
|
||||
{
|
||||
OpenEditorsModel::Entry *entry = EditorManager::instance()
|
||||
->openedEditorsModel()->entryAtRow(d->m_editorList->currentIndex());
|
||||
DocumentModel::Entry *entry = EditorManager::instance()
|
||||
->documentModel()->documentAtRow(d->m_editorList->currentIndex());
|
||||
QString fileName = entry ? entry->fileName() : QString();
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
@@ -1997,7 +1997,7 @@ void FakeVimPluginPrivate::highlightMatches(const QString &needle)
|
||||
|
||||
int FakeVimPluginPrivate::currentFile() const
|
||||
{
|
||||
OpenEditorsModel *model = EditorManager::instance()->openedEditorsModel();
|
||||
DocumentModel *model = EditorManager::instance()->documentModel();
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
if (!editor)
|
||||
return -1;
|
||||
@@ -2007,13 +2007,13 @@ int FakeVimPluginPrivate::currentFile() const
|
||||
void FakeVimPluginPrivate::switchToFile(int n)
|
||||
{
|
||||
EditorManager *editorManager = ICore::editorManager();
|
||||
OpenEditorsModel *model = editorManager->openedEditorsModel();
|
||||
int size = model->openDocumentCount();
|
||||
DocumentModel *model = editorManager->documentModel();
|
||||
int size = model->documentCount();
|
||||
QTC_ASSERT(size, return);
|
||||
n = n % size;
|
||||
if (n < 0)
|
||||
n += size;
|
||||
editorManager->activateEditorForEntry(model->entries().at(n));
|
||||
editorManager->activateEditorForEntry(model->documents().at(n));
|
||||
}
|
||||
|
||||
ExCommandMap &FakeVimExCommandsPage::exCommandMap()
|
||||
|
||||
@@ -66,7 +66,7 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::Fil
|
||||
QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
if (!regexp.isValid())
|
||||
return value;
|
||||
foreach (const OpenEditorsModel::Entry &editorEntry, m_editors) {
|
||||
foreach (const DocumentModel::Entry &editorEntry, m_editors) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
QString fileName = editorEntry.fileName();
|
||||
@@ -87,8 +87,8 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::Fil
|
||||
void OpenDocumentsFilter::refreshInternally()
|
||||
{
|
||||
m_editors.clear();
|
||||
foreach (OpenEditorsModel::Entry *e, EditorManager::instance()->openedEditorsModel()->entries()) {
|
||||
OpenEditorsModel::Entry entry;
|
||||
foreach (DocumentModel::Entry *e, EditorManager::instance()->documentModel()->documents()) {
|
||||
DocumentModel::Entry entry;
|
||||
// create copy with only the information relevant to use
|
||||
// to avoid model deleting entries behind our back
|
||||
entry.m_displayName = e->displayName();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
@@ -61,7 +61,7 @@ public slots:
|
||||
private:
|
||||
Core::EditorManager *m_editorManager;
|
||||
|
||||
QList<Core::OpenEditorsModel::Entry> m_editors;
|
||||
QList<Core::DocumentModel::Entry> m_editors;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
@@ -172,7 +172,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
||||
|
||||
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
|
||||
{
|
||||
int openedCount = Core::ICore::editorManager()->openedEditorsModel()->openDocumentCount();
|
||||
int openedCount = Core::ICore::editorManager()->documentModel()->documentCount();
|
||||
|
||||
m_saveAction.setEnabled(currentEditor != 0 && currentEditor->document()->isModified());
|
||||
m_saveAsAction.setEnabled(currentEditor != 0 && currentEditor->document()->isSaveAsAllowed());
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <utils/filesearch.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@@ -67,8 +67,8 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
|
||||
QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextEditorsEncodings();
|
||||
QStringList fileNames;
|
||||
QList<QTextCodec *> codecs;
|
||||
foreach (Core::OpenEditorsModel::Entry *entry,
|
||||
Core::EditorManager::instance()->openedEditorsModel()->entries()) {
|
||||
foreach (Core::DocumentModel::Entry *entry,
|
||||
Core::EditorManager::instance()->documentModel()->documents()) {
|
||||
QString fileName = entry->fileName();
|
||||
if (!fileName.isEmpty()) {
|
||||
fileNames.append(fileName);
|
||||
|
||||
Reference in New Issue
Block a user