1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-24 23:23:54 +00:00
openmw/apps/opencs/view/prefs/page.cpp

45 lines
1 KiB
C++
Raw Normal View History

2015-12-08 16:21:58 +00:00
#include "page.hpp"
2022-10-19 17:02:00 +00:00
#include <utility>
#include <vector>
#include <apps/opencs/view/prefs/pagebase.hpp>
2015-12-08 16:21:58 +00:00
#include <QGridLayout>
#include "../../model/prefs/category.hpp"
2022-09-22 18:26:05 +00:00
#include "../../model/prefs/setting.hpp"
2015-12-08 16:21:58 +00:00
2022-09-22 18:26:05 +00:00
CSVPrefs::Page::Page(CSMPrefs::Category& category, QWidget* parent)
: PageBase(category, parent)
2015-12-08 16:21:58 +00:00
{
2022-09-22 18:26:05 +00:00
QWidget* widget = new QWidget(parent);
mGrid = new QGridLayout(widget);
2017-05-08 05:24:28 +00:00
2022-09-22 18:26:05 +00:00
for (CSMPrefs::Category::Iterator iter = category.begin(); iter != category.end(); ++iter)
addSetting(*iter);
2017-05-08 05:24:28 +00:00
2022-09-22 18:26:05 +00:00
setWidget(widget);
2015-12-08 16:21:58 +00:00
}
2022-09-22 18:26:05 +00:00
void CSVPrefs::Page::addSetting(CSMPrefs::Setting* setting)
2015-12-08 16:21:58 +00:00
{
2022-09-22 18:26:05 +00:00
std::pair<QWidget*, QWidget*> widgets = setting->makeWidgets(this);
2015-12-08 16:21:58 +00:00
int next = mGrid->rowCount();
if (widgets.first)
{
2022-09-22 18:26:05 +00:00
mGrid->addWidget(widgets.first, next, 0);
mGrid->addWidget(widgets.second, next, 1);
2015-12-08 16:21:58 +00:00
}
else if (widgets.second)
{
2022-09-22 18:26:05 +00:00
mGrid->addWidget(widgets.second, next, 0, 1, 2);
2015-12-08 16:21:58 +00:00
}
else
{
2022-09-22 18:26:05 +00:00
mGrid->addWidget(new QWidget(this), next, 0);
2015-12-08 16:21:58 +00:00
}
}