forked from qt-creator/qt-creator
Fixes: OpenDocumentsFilter does not show all opened documents after
session restore
This commit is contained in:
@@ -1428,7 +1428,7 @@ void EditorManager::updateActions()
|
||||
{
|
||||
QString fName;
|
||||
IEditor *curEditor = currentEditor();
|
||||
int openedCount = openedEditors().count() + m_d->m_editorModel->restoredEditorCount();
|
||||
int openedCount = openedEditors().count() + m_d->m_editorModel->restoredEditors().count();
|
||||
if (curEditor) {
|
||||
if (!curEditor->file()->fileName().isEmpty()) {
|
||||
QFileInfo fi(curEditor->file()->fileName());
|
||||
|
||||
@@ -188,15 +188,15 @@ void OpenEditorsModel::removeAllRestoredEditors()
|
||||
}
|
||||
}
|
||||
|
||||
int OpenEditorsModel::restoredEditorCount() const
|
||||
QList<OpenEditorsModel::Entry> OpenEditorsModel::restoredEditors() const
|
||||
{
|
||||
int count = 0;
|
||||
QList<Entry> result;
|
||||
for (int i = m_editors.count()-1; i >= 0; --i) {
|
||||
if (!m_editors.at(i).editor) {
|
||||
++count;
|
||||
result.append(m_editors.at(i));
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OpenEditorsModel::isDuplicate(IEditor *editor) const
|
||||
|
||||
@@ -72,10 +72,10 @@ public:
|
||||
void removeEditor(const QModelIndex &index);
|
||||
|
||||
void removeAllRestoredEditors();
|
||||
int restoredEditorCount() const;
|
||||
void emitDataChanged(IEditor *editor);
|
||||
|
||||
QList<IEditor *> editors() const;
|
||||
QList<Entry> restoredEditors() const;
|
||||
bool isDuplicate(IEditor *editor) const;
|
||||
QList<IEditor *> duplicatesFor(IEditor *editor) const;
|
||||
IEditor *originalForDuplicate(IEditor *duplicate) const;
|
||||
|
||||
@@ -56,13 +56,13 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(const QString &entry)
|
||||
const QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
if (!regexp.isValid())
|
||||
return value;
|
||||
foreach (IEditor *editor, m_editors) {
|
||||
QString fileName = editor->file()->fileName();
|
||||
if (regexp.exactMatch(editor->displayName())) {
|
||||
QString visibleName;
|
||||
QVariant data;
|
||||
foreach (const OpenEditorsModel::Entry &entry, m_editors) {
|
||||
QString fileName = entry.fileName();
|
||||
QString displayName = entry.displayName();
|
||||
if (regexp.exactMatch(displayName)) {
|
||||
if (fileName.isEmpty()) {
|
||||
value.append(FilterEntry(this, editor->displayName(), qVariantFromValue(editor)));
|
||||
if (entry.editor)
|
||||
value.append(FilterEntry(this, displayName, qVariantFromValue(entry.editor)));
|
||||
} else {
|
||||
QFileInfo fi(fileName);
|
||||
FilterEntry entry(this, fi.fileName(), fileName);
|
||||
@@ -77,7 +77,13 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(const QString &entry)
|
||||
|
||||
void OpenDocumentsFilter::refreshInternally()
|
||||
{
|
||||
m_editors = m_editorManager->openedEditors();
|
||||
m_editors.clear();
|
||||
foreach (IEditor *editor, m_editorManager->openedEditors()) {
|
||||
OpenEditorsModel::Entry entry;
|
||||
entry.editor = editor;
|
||||
m_editors.append(entry);
|
||||
}
|
||||
m_editors += m_editorManager->openedEditorsModel()->restoredEditors();
|
||||
}
|
||||
|
||||
void OpenDocumentsFilter::refresh(QFutureInterface<void> &future)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
namespace Locator {
|
||||
@@ -63,7 +64,7 @@ public slots:
|
||||
private:
|
||||
Core::EditorManager *m_editorManager;
|
||||
|
||||
QList<Core::IEditor *> m_editors;
|
||||
QList<Core::OpenEditorsModel::Entry> m_editors;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -256,7 +256,7 @@ void DesignMode::updateActions()
|
||||
|
||||
Core::IEditor *curEditor = m_currentEditor.data();
|
||||
int openedCount = editorManager->openedEditors().count()
|
||||
+ editorManager->openedEditorsModel()->restoredEditorCount();
|
||||
+ editorManager->openedEditorsModel()->restoredEditors().count();
|
||||
|
||||
QString fName;
|
||||
if (curEditor) {
|
||||
|
||||
Reference in New Issue
Block a user