コード例 #1
0
ファイル: settingsdialog.cpp プロジェクト: 55171514/qtcreator
void SettingsDialog::showPage(const Id pageId)
{
    // handle the case of "show last page"
    Id initialPageId = pageId;
    if (!initialPageId.isValid()) {
        QSettings *settings = ICore::settings();
        initialPageId = Id::fromSetting(settings->value(QLatin1String(pageKeyC)));
    }

    int initialCategoryIndex = -1;
    int initialPageIndex = -1;

    const QList<Category*> &categories = m_model->categories();
    if (initialPageId.isValid()) {
        // First try categories without lazy items.
        for (int i = 0; i < categories.size(); ++i) {
            Category *category = categories.at(i);
            if (category->providers.isEmpty()) {  // no providers
                ensureCategoryWidget(category);
                if (category->findPageById(initialPageId, &initialPageIndex)) {
                    initialCategoryIndex = i;
                    break;
                }
            }
        }

        if (initialPageIndex == -1) {
            // On failure, expand the remaining items.
            for (int i = 0; i < categories.size(); ++i) {
                Category *category = categories.at(i);
                if (!category->providers.isEmpty()) { // has providers
                    ensureCategoryWidget(category);
                    if (category->findPageById(initialPageId, &initialPageIndex)) {
                        initialCategoryIndex = i;
                        break;
                    }
                }
            }
        }
    }

    if (initialPageId.isValid() && initialPageIndex == -1)
        return; // Unknown settings page, probably due to missing plugin.

    if (initialCategoryIndex != -1) {
        const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex));
        m_categoryList->setCurrentIndex(modelIndex);
        if (initialPageIndex != -1)
            categories.at(initialCategoryIndex)->tabWidget->setCurrentIndex(initialPageIndex);
    }
}
コード例 #2
0
ファイル: settingsdialog.cpp プロジェクト: Gardenya/qtcreator
void SettingsDialog::showPage(Id categoryId, Id pageId)
{
    // handle the case of "show last page"
    Id initialCategory = categoryId;
    Id initialPage = pageId;
    if (!initialCategory.isValid() && !initialPage.isValid()) {
        QSettings *settings = ICore::settings();
        initialCategory = Id::fromSetting(settings->value(QLatin1String(categoryKeyC)));
        initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC)));
    }

    if (!initialCategory.isValid()) // no category given and no old setting
        return;

    int initialCategoryIndex = -1;
    int initialPageIndex = -1;
    const QList<Category*> &categories = m_model->categories();
    for (int i = 0; i < categories.size(); ++i) {
        Category *category = categories.at(i);
        if (category->id == initialCategory) {
            initialCategoryIndex = i;
            if (initialPage.isValid()) {
                ensureCategoryWidget(category);
                for (int j = 0; j < category->pages.size(); ++j) {
                    IOptionsPage *page = category->pages.at(j);
                    if (page->id() == initialPage)
                        initialPageIndex = j;
                }
            }
            break;
        }
    }

    QTC_ASSERT(initialCategoryIndex != -1,
               qDebug("Unknown category: %s", initialCategory.name().constData()); return);
    QTC_ASSERT(!initialPage.isValid() || initialPageIndex != -1,
               qDebug("Unknown page: %s", initialPage.name().constData()));

    if (initialCategoryIndex != -1) {
        const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex));
        m_categoryList->setCurrentIndex(modelIndex);
        if (initialPageIndex != -1)
            categories.at(initialCategoryIndex)->tabWidget->setCurrentIndex(initialPageIndex);
    }
}
コード例 #3
0
ファイル: settingsdialog.cpp プロジェクト: 55171514/qtcreator
void SettingsDialog::showCategory(int index)
{
    Category *category = m_model->categories().at(index);
    ensureCategoryWidget(category);
    // Update current category and page
    m_currentCategory = category->id;
    const int currentTabIndex = category->tabWidget->currentIndex();
    if (currentTabIndex != -1) {
        IOptionsPage *page = category->pages.at(currentTabIndex);
        m_currentPage = page->id();
        m_visitedPages.insert(page);
    }

    m_stackedLayout->setCurrentIndex(category->index);
    m_headerLabel->setText(category->displayName);

    updateEnabledTabs(category, m_filterLineEdit->text());
}
コード例 #4
0
ファイル: settingsdialog.cpp プロジェクト: CNOT/julia-studio
void SettingsDialog::ensureAllCategoryWidgets()
{
    foreach (Category *category, m_model->categories())
        ensureCategoryWidget(category);
}