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