2011-05-12 14:49:42 +02:00
|
|
|
#include "optionsdialog.h"
|
2011-05-31 22:24:53 +02:00
|
|
|
#include "optionsmodel.h"
|
2011-05-12 14:49:42 +02:00
|
|
|
#include "mainoptionspage.h"
|
2011-05-12 14:44:52 +02:00
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
2011-05-13 22:00:27 +02:00
|
|
|
#include <QListWidget>
|
|
|
|
#include <QStackedWidget>
|
2011-05-31 22:24:53 +02:00
|
|
|
#include <QDataWidgetMapper>
|
2011-05-12 14:44:52 +02:00
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
OptionsDialog::OptionsDialog(QWidget *parent):
|
|
|
|
QDialog(parent), contents_widget(0), pages_widget(0),
|
|
|
|
main_options_page(0), model(0)
|
2011-05-12 14:44:52 +02:00
|
|
|
{
|
|
|
|
contents_widget = new QListWidget();
|
|
|
|
contents_widget->setMaximumWidth(128);
|
|
|
|
|
|
|
|
pages_widget = new QStackedWidget();
|
|
|
|
pages_widget->setMinimumWidth(300);
|
|
|
|
|
|
|
|
QListWidgetItem *item_main = new QListWidgetItem(tr("Main"));
|
|
|
|
contents_widget->addItem(item_main);
|
2011-05-31 22:24:53 +02:00
|
|
|
main_options_page = new MainOptionsPage(this);
|
|
|
|
pages_widget->addWidget(main_options_page);
|
2011-05-12 14:44:52 +02:00
|
|
|
|
|
|
|
contents_widget->setCurrentRow(0);
|
|
|
|
|
|
|
|
QHBoxLayout *main_layout = new QHBoxLayout();
|
|
|
|
main_layout->addWidget(contents_widget);
|
|
|
|
main_layout->addWidget(pages_widget, 1);
|
|
|
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout();
|
|
|
|
layout->addLayout(main_layout);
|
|
|
|
|
|
|
|
QHBoxLayout *buttons = new QHBoxLayout();
|
|
|
|
buttons->addStretch(1);
|
|
|
|
QPushButton *ok_button = new QPushButton(tr("OK"));
|
|
|
|
buttons->addWidget(ok_button);
|
|
|
|
QPushButton *cancel_button = new QPushButton(tr("Cancel"));
|
|
|
|
buttons->addWidget(cancel_button);
|
|
|
|
QPushButton *apply_button = new QPushButton(tr("Apply"));
|
|
|
|
buttons->addWidget(apply_button);
|
|
|
|
|
|
|
|
layout->addLayout(buttons);
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
setWindowTitle(tr("Options"));
|
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
mapper = new QDataWidgetMapper();
|
|
|
|
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
|
|
|
|
mapper->setOrientation(Qt::Vertical);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::setModel(OptionsModel *model)
|
|
|
|
{
|
|
|
|
this->model = model;
|
|
|
|
|
|
|
|
mapper->setModel(model);
|
|
|
|
main_options_page->setMapper(mapper);
|
2011-05-12 14:44:52 +02:00
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
mapper->toFirst();
|
2011-05-12 14:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|
|
|
{
|
|
|
|
Q_UNUSED(previous);
|
|
|
|
if(current)
|
|
|
|
{
|
|
|
|
pages_widget->setCurrentIndex(contents_widget->row(current));
|
|
|
|
}
|
|
|
|
}
|