forked from qt-creator/qt-creator
Add EditorModel::openDocumentCount and use it.
As is, EditorModel::rowCount() could also be used, but this will most probably change later. So we simply add a method that is independent from all the "model" methods. Change-Id: I39a2338d765ed6a269bf8977b816a5eda371afdf Reviewed-by: Marco Bubke <marco.bubke@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -2053,7 +2053,7 @@ void EditorManager::updateActions()
|
|||||||
{
|
{
|
||||||
IEditor *curEditor = currentEditor();
|
IEditor *curEditor = currentEditor();
|
||||||
const QString fileName = fileNameForEditor(curEditor);
|
const QString fileName = fileNameForEditor(curEditor);
|
||||||
int openedCount = openedEditors().count() + d->m_editorModel->restoredEditors().count();
|
int openedCount = d->m_editorModel->openDocumentCount();
|
||||||
|
|
||||||
if (curEditor) {
|
if (curEditor) {
|
||||||
if (HostOsInfo::isMacHost())
|
if (HostOsInfo::isMacHost())
|
||||||
|
|||||||
@@ -295,6 +295,11 @@ QModelIndex OpenEditorsModel::index(int row, int column, const QModelIndex &pare
|
|||||||
return createIndex(row, column);
|
return createIndex(row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OpenEditorsModel::openDocumentCount() const
|
||||||
|
{
|
||||||
|
return d->m_editors.count();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
|
QVariant OpenEditorsModel::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))
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public:
|
|||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
|
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
int openDocumentCount() const;
|
||||||
|
|
||||||
void addEditor(IEditor *editor, bool isDuplicate = false);
|
void addEditor(IEditor *editor, bool isDuplicate = false);
|
||||||
void addRestoredEditor(const QString &fileName, const QString &displayName, const Id &id);
|
void addRestoredEditor(const QString &fileName, const QString &displayName, const Id &id);
|
||||||
QModelIndex firstRestoredEditor() const;
|
QModelIndex firstRestoredEditor() const;
|
||||||
|
|||||||
@@ -172,8 +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()->openedEditors().count()
|
int openedCount = Core::ICore::editorManager()->openedEditorsModel()->openDocumentCount();
|
||||||
+ Core::ICore::editorManager()->openedEditorsModel()->restoredEditors().count();
|
|
||||||
|
|
||||||
QString fileName;
|
QString fileName;
|
||||||
if (currentEditor) {
|
if (currentEditor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user