Commit c531970b authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarMarco Bubke <marco.bubke@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 3e117b12
...@@ -2053,7 +2053,7 @@ void EditorManager::updateActions() ...@@ -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 ...@@ -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: ...@@ -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 ...@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment