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;
|
QSet<IDocument*> documentsDone;
|
||||||
addHistoryItems(view->editorHistory(), view, model, documentsDone);
|
addHistoryItems(view->editorHistory(), view, model, documentsDone);
|
||||||
|
|
||||||
// add missing editors from the global history
|
// add missing editors from the global history
|
||||||
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 (DocumentModel::Entry *entry, model->documents()) {
|
addRestoredItems(model);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -274,3 +263,20 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
|
|||||||
m_editorList->setCurrentItem(item);
|
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);
|
static void updateItem(QTreeWidgetItem *item, IEditor *editor);
|
||||||
void addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
void addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
||||||
DocumentModel *model, QSet<IDocument*> &documentsDone);
|
DocumentModel *model, QSet<IDocument*> &documentsDone);
|
||||||
|
void addRestoredItems(DocumentModel *model);
|
||||||
void ensureCurrentVisible();
|
void ensureCurrentVisible();
|
||||||
bool isCentering();
|
bool isCentering();
|
||||||
void centerOnItem(int selectedIndex);
|
void centerOnItem(int selectedIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user