Commit c4306e70 authored by Knut Petter Svendsen's avatar Knut Petter Svendsen

Refactor open editors window

Change-Id: Idf729d85b604ad770339d8d914c5d554d2526221
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent a01151c5
......@@ -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);
......
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