forked from qt-creator/qt-creator
Refactor open editors window
Change-Id: Idf729d85b604ad770339d8d914c5d554d2526221 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -199,23 +199,12 @@ void OpenEditorsWindow::setEditors(const QList<EditLocation> &globalHistory, Edi
|
||||
|
||||
QSet<IDocument*> documentsDone;
|
||||
addHistoryItems(view->editorHistory(), view, model, documentsDone);
|
||||
|
||||
// add missing editors from the global history
|
||||
addHistoryItems(globalHistory, view, model, documentsDone);
|
||||
|
||||
// add purely restored editors which are not initialised yet
|
||||
foreach (DocumentModel::Entry *entry, model->documents()) {
|
||||
if (entry->document)
|
||||
continue;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
QString title = entry->displayName();
|
||||
item->setIcon(0, m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, entry->fileName());
|
||||
item->setData(0, Qt::UserRole+2, QVariant::fromValue(entry->id()));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
|
||||
m_editorList->addTopLevelItem(item);
|
||||
}
|
||||
addRestoredItems(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,3 +263,20 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
|
||||
m_editorList->setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorsWindow::addRestoredItems(DocumentModel *model)
|
||||
{
|
||||
foreach (DocumentModel::Entry *entry, model->documents()) {
|
||||
if (entry->document)
|
||||
continue;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
QString title = entry->displayName();
|
||||
item->setIcon(0, m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, entry->fileName());
|
||||
item->setData(0, Qt::UserRole+2, QVariant::fromValue(entry->id()));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
|
||||
m_editorList->addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ private:
|
||||
static void updateItem(QTreeWidgetItem *item, IEditor *editor);
|
||||
void addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
||||
DocumentModel *model, QSet<IDocument*> &documentsDone);
|
||||
void addRestoredItems(DocumentModel *model);
|
||||
void ensureCurrentVisible();
|
||||
bool isCentering();
|
||||
void centerOnItem(int selectedIndex);
|
||||
|
||||
Reference in New Issue
Block a user