forked from qt-creator/qt-creator
Use Core::Id for IOptionPage::category
Change-Id: I63433edd9118a7aa4ecaef28f40bfc729d90f512 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -69,9 +69,10 @@ static QPointer<SettingsDialog> m_instance = 0;
|
||||
|
||||
// ----------- Category model
|
||||
|
||||
class Category {
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
QString id;
|
||||
Id id;
|
||||
QString displayName;
|
||||
QIcon icon;
|
||||
QList<IOptionsPage *> pages;
|
||||
@@ -94,7 +95,7 @@ public:
|
||||
const QList<Category*> &categories() const { return m_categories; }
|
||||
|
||||
private:
|
||||
Category *findCategoryById(const QString &id);
|
||||
Category *findCategoryById(Id id);
|
||||
|
||||
QList<Category*> m_categories;
|
||||
QIcon m_emptyIcon;
|
||||
@@ -145,7 +146,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
|
||||
|
||||
// Put the pages in categories
|
||||
foreach (IOptionsPage *page, pages) {
|
||||
const QString &categoryId = page->category();
|
||||
const Id categoryId = page->category();
|
||||
Category *category = findCategoryById(categoryId);
|
||||
if (!category) {
|
||||
category = new Category;
|
||||
@@ -162,7 +163,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
|
||||
}
|
||||
|
||||
foreach (IOptionsPageProvider *provider, providers) {
|
||||
const QString &categoryId = provider->category();
|
||||
const Id categoryId = provider->category();
|
||||
Category *category = findCategoryById(categoryId);
|
||||
if (!category) {
|
||||
category = new Category;
|
||||
@@ -181,7 +182,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
Category *CategoryModel::findCategoryById(const QString &id)
|
||||
Category *CategoryModel::findCategoryById(Id id)
|
||||
{
|
||||
for (int i = 0; i < m_categories.size(); ++i) {
|
||||
Category *category = m_categories.at(i);
|
||||
@@ -269,7 +270,7 @@ public:
|
||||
// Helpers to sort by category. id
|
||||
bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
|
||||
{
|
||||
if (const int cc = p1->category().compare(p2->category()))
|
||||
if (const int cc = p1->category().toString().compare(p2->category().toString()))
|
||||
return cc < 0;
|
||||
return p1->id().compare(p2->id()) < 0;
|
||||
}
|
||||
@@ -329,11 +330,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
void SettingsDialog::showPage(Id categoryId, Id pageId)
|
||||
{
|
||||
// handle the case of "show last page"
|
||||
QString initialCategory = categoryId.toString();
|
||||
Id initialCategory = categoryId;
|
||||
QString initialPage = pageId.toString();
|
||||
if (initialCategory.isEmpty() && initialPage.isEmpty()) {
|
||||
if (!initialCategory.isValid() && initialPage.isEmpty()) {
|
||||
QSettings *settings = ICore::settings();
|
||||
initialCategory = settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString();
|
||||
initialCategory = Id(settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString());
|
||||
initialPage = settings->value(QLatin1String(pageKeyC), QVariant(QString())).toString();
|
||||
}
|
||||
|
||||
@@ -462,7 +463,7 @@ void SettingsDialog::updateEnabledTabs(Category *category, const QString &search
|
||||
for (int i = 0; i < category->pages.size(); ++i) {
|
||||
const IOptionsPage *page = category->pages.at(i);
|
||||
const bool enabled = searchText.isEmpty()
|
||||
|| page->category().contains(searchText, Qt::CaseInsensitive)
|
||||
|| page->category().toString().contains(searchText, Qt::CaseInsensitive)
|
||||
|| page->displayName().contains(searchText, Qt::CaseInsensitive)
|
||||
|| page->matches(searchText);
|
||||
category->tabWidget->setTabEnabled(i, enabled);
|
||||
@@ -541,7 +542,7 @@ void SettingsDialog::apply()
|
||||
void SettingsDialog::done(int val)
|
||||
{
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->setValue(QLatin1String(categoryKeyC), m_currentCategory);
|
||||
settings->setValue(QLatin1String(categoryKeyC), m_currentCategory.toString());
|
||||
settings->setValue(QLatin1String(pageKeyC), m_currentPage);
|
||||
|
||||
ICore::saveSettings(); // save all settings
|
||||
|
||||
Reference in New Issue
Block a user