Example #1
0
static inline QString displayNameOfEditor(const QString &fileName)
{
    Core::IDocument *document = Core::EditorManager::documentModel()->documentForFilePath(fileName);
    if (document)
        return document->displayName();
    return QString();
}
void TabBar::addEditorTab(Core::IEditor *editor)
{
    Core::IDocument *document = editor->document();

    const int index = addTab(document->displayName());
    setTabIcon(index, Core::FileIconProvider::icon(QFileInfo(document->filePath())));
    setTabToolTip(index, document->filePath());

    m_editors.append(editor);

    connect(document, &Core::IDocument::changed, [this, editor, document]() {
        const int index = m_editors.indexOf(editor);
        if (index == -1)
            return;
        QString tabText = document->displayName();
        if (document->isModified())
            tabText += QLatin1Char('*');
        setTabText(index, tabText);
    });
}