forked from qt-creator/qt-creator
SettingsDialog: Add warnings when category or page to show is invalid
Change-Id: Ide7ef2eb1a9be9a363e5e062214a20da76d2064b Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
@@ -353,6 +354,9 @@ void SettingsDialog::showPage(Id categoryId, Id pageId)
|
|||||||
initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC)));
|
initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initialCategory.isValid()) // no category given and no old setting
|
||||||
|
return;
|
||||||
|
|
||||||
int initialCategoryIndex = -1;
|
int initialCategoryIndex = -1;
|
||||||
int initialPageIndex = -1;
|
int initialPageIndex = -1;
|
||||||
const QList<Category*> &categories = m_model->categories();
|
const QList<Category*> &categories = m_model->categories();
|
||||||
@@ -360,13 +364,22 @@ void SettingsDialog::showPage(Id categoryId, Id pageId)
|
|||||||
Category *category = categories.at(i);
|
Category *category = categories.at(i);
|
||||||
if (category->id == initialCategory) {
|
if (category->id == initialCategory) {
|
||||||
initialCategoryIndex = i;
|
initialCategoryIndex = i;
|
||||||
for (int j = 0; j < category->pages.size(); ++j) {
|
if (initialPage.isValid()) {
|
||||||
IOptionsPage *page = category->pages.at(j);
|
for (int j = 0; j < category->pages.size(); ++j) {
|
||||||
if (page->id() == initialPage)
|
IOptionsPage *page = category->pages.at(j);
|
||||||
initialPageIndex = 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) {
|
if (initialCategoryIndex != -1) {
|
||||||
const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex));
|
const QModelIndex modelIndex = m_proxyModel->mapFromSource(m_model->index(initialCategoryIndex));
|
||||||
m_categoryList->setCurrentIndex(modelIndex);
|
m_categoryList->setCurrentIndex(modelIndex);
|
||||||
|
Reference in New Issue
Block a user