summaryrefslogtreecommitdiffstats
path: root/tests/manual/dialogs
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2014-03-23 17:07:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-25 00:00:23 +0100
commitdbb6b58abede12cf9f2fad3086dd59a9d46b7ee7 (patch)
treee28701cc3a06b7aba9e58ee1c9e3eee89b441027 /tests/manual/dialogs
parent225a5b4787b3a04fd32958dba3e479761efc0623 (diff)
QPrintDialog - Convert manual test to .ui file
Convert the manual print dialogs test to use a ui file as subsequent changes will add a lot more widgets. Change-Id: I06ac54b67532f0eea1e91a2d9aca4f587d2fa332 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/manual/dialogs')
-rw-r--r--tests/manual/dialogs/dialogs.pro1
-rw-r--r--tests/manual/dialogs/printdialogpanel.cpp157
-rw-r--r--tests/manual/dialogs/printdialogpanel.h18
-rw-r--r--tests/manual/dialogs/printdialogpanel.ui270
-rw-r--r--tests/manual/dialogs/utils.cpp21
-rw-r--r--tests/manual/dialogs/utils.h4
6 files changed, 357 insertions, 114 deletions
diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro
index 71c41119fe..21ebf9b622 100644
--- a/tests/manual/dialogs/dialogs.pro
+++ b/tests/manual/dialogs/dialogs.pro
@@ -8,3 +8,4 @@ SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp
wizardpanel.cpp messageboxpanel.cpp printdialogpanel.cpp utils.cpp
HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \
wizardpanel.h messageboxpanel.h printdialogpanel.h utils.h
+FORMS += printdialogpanel.ui
diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp
index 5c89055e22..b012d34db0 100644
--- a/tests/manual/dialogs/printdialogpanel.cpp
+++ b/tests/manual/dialogs/printdialogpanel.cpp
@@ -65,7 +65,7 @@
#include <QDebug>
#include <QTextStream>
-const FlagData modeComboData[] =
+const FlagData printerModeComboData[] =
{
{"ScreenResolution", QPrinter::ScreenResolution},
{"PrinterResolution", QPrinter::PrinterResolution},
@@ -260,91 +260,30 @@ public slots:
void slotPaintRequested(QPrinter *p) { print(p); }
};
-class PageSizeControl : public QWidget {
-public:
- explicit PageSizeControl(QWidget *parent = 0);
- QSizeF pageSize() const { return QSizeF(m_width->value(), m_height->value()); }
- void setPageSize(const QSizeF &s) { m_width->setValue(s.width()); m_height->setValue(s.height()); }
-
-private:
- QDoubleSpinBox *m_width;
- QDoubleSpinBox *m_height;
-};
-
-PageSizeControl::PageSizeControl(QWidget *parent)
- : QWidget(parent)
- , m_width(new QDoubleSpinBox(this))
- , m_height(new QDoubleSpinBox(this))
-{
- m_width->setRange(1, 1000);
- m_width->setSingleStep(10);
- m_height->setRange(1, 1000);
- m_height->setSingleStep(10);
- QHBoxLayout *hBoxLayout = new QHBoxLayout(this);
- hBoxLayout->addWidget(m_width);
- hBoxLayout->addWidget(new QLabel("x", this));
- hBoxLayout->addWidget(m_height);
- hBoxLayout->addWidget(new QLabel("mm", this));
-}
-
PrintDialogPanel::PrintDialogPanel(QWidget *parent)
: QWidget(parent)
- , m_creationGroupBox(new QGroupBox(tr("Create"), this))
- , m_settingsGroupBox(new QGroupBox(tr("Settings"), this))
- , m_dialogsGroupBox(new QGroupBox(tr("Dialogs"), this))
- , m_pageSizeCombo(new QComboBox)
{
- // Create with resolution
- QHBoxLayout *hBoxLayout = new QHBoxLayout(m_creationGroupBox);
- m_modeCombo = createCombo(m_creationGroupBox, modeComboData, sizeof(modeComboData)/sizeof(FlagData));
- hBoxLayout->addWidget(m_modeCombo);
- m_createButton = new QPushButton(tr("Create"), m_creationGroupBox);
- connect(m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter()));
- hBoxLayout->addWidget(m_createButton);
- m_deleteButton = new QPushButton(tr("Delete"), m_creationGroupBox);
- connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter()));
- hBoxLayout->addWidget(m_deleteButton);
- hBoxLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
-
- QFormLayout *formLayout = new QFormLayout(m_settingsGroupBox);
- m_pageSizeCombo = createCombo(m_settingsGroupBox, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData));
- connect(m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl()));
- formLayout->addRow(tr("Paper #:"), m_pageSizeCombo);
- m_customPageSizeControl = new PageSizeControl;
- formLayout->addRow(tr("Custom size:"), m_customPageSizeControl);
- m_orientationCombo = createCombo(m_settingsGroupBox, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData));
- formLayout->addRow("Orientation:", m_orientationCombo);
- m_fullPageCheckBox = new QCheckBox(tr("Full page"), m_settingsGroupBox);
- formLayout->addRow(m_fullPageCheckBox);
-
- QVBoxLayout *vBoxLayout = new QVBoxLayout(m_dialogsGroupBox);
-
- m_printDialogOptionsControl = new OptionsControl(tr("Options"), printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData), m_dialogsGroupBox);
- vBoxLayout->addWidget(m_printDialogOptionsControl);
- m_printDialogRangeCombo = createCombo(m_dialogsGroupBox, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData));
- vBoxLayout->addWidget(m_printDialogRangeCombo);
-
- {
- QPrintDialog dialog;
- m_printDialogOptionsControl->setValue(dialog.options());
- m_printDialogRangeCombo->setCurrentIndex(dialog.printRange());
- }
-
- QPushButton *button = new QPushButton(tr("Print..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPrintDialog()));
- vBoxLayout->addWidget(button);
- button = new QPushButton(tr("Preview..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPreviewDialog()));
- vBoxLayout->addWidget(button);
- button = new QPushButton(tr("Page Setup..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPageSetupDialog()));
- vBoxLayout->addWidget(button);
-
- QGridLayout *gridLayout = new QGridLayout(this);
- gridLayout->addWidget(m_creationGroupBox, 0, 0);
- gridLayout->addWidget(m_settingsGroupBox, 1, 0);
- gridLayout->addWidget(m_dialogsGroupBox, 0, 1, 2, 1);
- gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 2, 0, 1, 2);
+ m_panel.setupUi(this);
+
+ // Setup the Create box
+ populateCombo(m_panel.m_printerModeCombo, printerModeComboData, sizeof(printerModeComboData)/sizeof(FlagData));
+ connect(m_panel.m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter()));
+ connect(m_panel.m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter()));
+
+ // Setup the Settings box
+ populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData));
+ connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl()));
+ populateCombo(m_panel.m_orientationCombo, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData));
+
+ // Setup the Dialogs box
+ m_panel.m_dialogOptionsGroupBox->populateOptions(printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData));
+ populateCombo(m_panel.m_printDialogRangeCombo, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData));
+ QPrintDialog dialog;
+ m_panel.m_dialogOptionsGroupBox->setValue(dialog.options());
+ m_panel.m_printDialogRangeCombo->setCurrentIndex(dialog.printRange());
+ connect(m_panel.m_printButton, SIGNAL(clicked()), this, SLOT(showPrintDialog()));
+ connect(m_panel.m_printPreviewButton, SIGNAL(clicked()), this, SLOT(showPreviewDialog()));
+ connect(m_panel.m_pageSetupButton, SIGNAL(clicked()), this, SLOT(showPageSetupDialog()));
enablePanels();
}
@@ -356,16 +295,16 @@ PrintDialogPanel::~PrintDialogPanel()
void PrintDialogPanel::enablePanels()
{
const bool exists = !m_printer.isNull();
- m_createButton->setEnabled(!exists);
- m_modeCombo->setEnabled(!exists);
- m_deleteButton->setEnabled(exists);
- m_settingsGroupBox->setEnabled(exists);
- m_dialogsGroupBox->setEnabled(exists);
+ m_panel.m_createButton->setEnabled(!exists);
+ m_panel.m_printerModeCombo->setEnabled(!exists);
+ m_panel.m_deleteButton->setEnabled(exists);
+ m_panel.m_settingsGroupBox->setEnabled(exists);
+ m_panel.m_dialogsGroupBox->setEnabled(exists);
}
void PrintDialogPanel::createPrinter()
{
- const QPrinter::PrinterMode mode = comboBoxValue<QPrinter::PrinterMode>(m_modeCombo);
+ const QPrinter::PrinterMode mode = comboBoxValue<QPrinter::PrinterMode>(m_panel.m_printerModeCombo);
m_printer.reset(new QPrinter(mode)); // Can set only once.
retrieveSettings(m_printer.data());
enablePanels();
@@ -378,36 +317,49 @@ void PrintDialogPanel::deletePrinter()
enablePanels();
}
+QSizeF PrintDialogPanel::pageSize() const
+{
+ return QSizeF(m_panel.m_pageWidth->value(), m_panel.m_pageHeight->value());
+}
+
+void PrintDialogPanel::setPageSize(const QSizeF &sizef)
+{
+ m_panel.m_pageWidth->setValue(sizef.width());
+ m_panel.m_pageHeight->setValue(sizef.height());
+}
+
void PrintDialogPanel::applySettings(QPrinter *printer) const
{
- const QPrinter::PageSize pageSize = comboBoxValue<QPrinter::PageSize>(m_pageSizeCombo);
- if (pageSize == QPrinter::Custom)
- printer->setPaperSize(m_customPageSizeControl->pageSize(), QPrinter::Millimeter);
+ const QPrinter::PageSize pageSizeId = comboBoxValue<QPrinter::PageSize>(m_panel.m_pageSizeCombo);
+ if (pageSizeId == QPrinter::Custom)
+ printer->setPaperSize(pageSize(), QPrinter::Millimeter);
else
- printer->setPageSize(pageSize);
- printer->setOrientation(comboBoxValue<QPrinter::Orientation>(m_orientationCombo));
- printer->setFullPage(m_fullPageCheckBox->isChecked());
+ printer->setPageSize(pageSizeId);
+ printer->setOrientation(comboBoxValue<QPrinter::Orientation>(m_panel.m_orientationCombo));
+ printer->setFullPage(m_panel.m_fullPageCheckBox->isChecked());
}
void PrintDialogPanel::retrieveSettings(const QPrinter *printer)
{
- setComboBoxValue(m_pageSizeCombo, printer->pageSize());
- setComboBoxValue(m_orientationCombo, printer->orientation());
- m_fullPageCheckBox->setChecked(printer->fullPage());
- m_customPageSizeControl->setPageSize(m_printer->paperSize(QPrinter::Millimeter));
+ setComboBoxValue(m_panel.m_pageSizeCombo, printer->pageSize());
+ setComboBoxValue(m_panel.m_orientationCombo, printer->orientation());
+ m_panel.m_fullPageCheckBox->setChecked(printer->fullPage());
+ setPageSize(m_printer->paperSize(QPrinter::Millimeter));
}
void PrintDialogPanel::enableCustomSizeControl()
{
- m_customPageSizeControl->setEnabled(m_pageSizeCombo->currentIndex() == QPrinter::Custom);
+ bool custom = (m_panel.m_pageSizeCombo->currentIndex() == QPrinter::Custom);
+ m_panel.m_pageWidth->setEnabled(custom);
+ m_panel.m_pageHeight->setEnabled(custom);
}
void PrintDialogPanel::showPrintDialog()
{
applySettings(m_printer.data());
QPrintDialog dialog(m_printer.data(), this);
- dialog.setOptions(m_printDialogOptionsControl->value<QPrintDialog::PrintDialogOptions>());
- dialog.setPrintRange(comboBoxValue<QPrintDialog::PrintRange>(m_printDialogRangeCombo));
+ dialog.setOptions(m_panel.m_dialogOptionsGroupBox->value<QPrintDialog::PrintDialogOptions>());
+ dialog.setPrintRange(comboBoxValue<QPrintDialog::PrintRange>(m_panel.m_printDialogRangeCombo));
if (dialog.exec() == QDialog::Accepted) {
retrieveSettings(m_printer.data());
print(m_printer.data());
@@ -431,6 +383,7 @@ void PrintDialogPanel::showPageSetupDialog()
retrieveSettings(m_printer.data());
}
+#include "moc_printdialogpanel.cpp"
#include "printdialogpanel.moc"
#endif // !QT_NO_PRINTER
diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h
index c869782769..a7ae257cf8 100644
--- a/tests/manual/dialogs/printdialogpanel.h
+++ b/tests/manual/dialogs/printdialogpanel.h
@@ -44,6 +44,8 @@
#ifndef QT_NO_PRINTER
+#include "ui_printdialogpanel.h"
+
#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -73,22 +75,14 @@ private slots:
void enableCustomSizeControl();
private:
+ QSizeF pageSize() const;
+ void setPageSize(const QSizeF &sizef);
void applySettings(QPrinter *printer) const;
void retrieveSettings(const QPrinter *printer);
void enablePanels();
- QGroupBox *m_creationGroupBox;
- QPushButton *m_createButton;
- QPushButton *m_deleteButton;
- QGroupBox *m_settingsGroupBox;
- QCheckBox *m_fullPageCheckBox;
- QGroupBox *m_dialogsGroupBox;
- OptionsControl *m_printDialogOptionsControl;
- QComboBox *m_printDialogRangeCombo;
- QComboBox *m_modeCombo;
- QComboBox *m_orientationCombo;
- QComboBox *m_pageSizeCombo;
- PageSizeControl *m_customPageSizeControl;
+ Ui::PrintDialogPanel m_panel;
+
QScopedPointer<QPrinter> m_printer;
};
diff --git a/tests/manual/dialogs/printdialogpanel.ui b/tests/manual/dialogs/printdialogpanel.ui
new file mode 100644
index 0000000000..a185629fc1
--- /dev/null
+++ b/tests/manual/dialogs/printdialogpanel.ui
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PrintDialogPanel</class>
+ <widget class="QWidget" name="PrintDialogPanel">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>507</width>
+ <height>291</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="m_createGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Create</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Printer Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_printerModeCombo"/>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="m_createButton">
+ <property name="text">
+ <string>Create</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_deleteButton">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="m_settingsGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Settings</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Page Size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_pageSizeCombo"/>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QDoubleSpinBox" name="m_pageWidth">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_pageHeight">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Orientation:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="m_orientationCombo"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Full Page Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="m_fullPageCheckBox">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>22</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="m_dialogsGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Dialogs</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="OptionsControl" name="m_dialogOptionsGroupBox">
+ <property name="title">
+ <string>Options</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="m_printDialogRangeCombo"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_printButton">
+ <property name="text">
+ <string>Print...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_printPreviewButton">
+ <property name="text">
+ <string>Preview...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_pageSetupButton">
+ <property name="text">
+ <string>Page Setup...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>OptionsControl</class>
+ <extends>QGroupBox</extends>
+ <header>utils.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/manual/dialogs/utils.cpp b/tests/manual/dialogs/utils.cpp
index 7e0067c7f3..2dc01359b1 100644
--- a/tests/manual/dialogs/utils.cpp
+++ b/tests/manual/dialogs/utils.cpp
@@ -52,11 +52,23 @@ QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size)
return c;
}
+void populateCombo(QComboBox *combo, const FlagData *d, size_t size)
+{
+ for (size_t i = 0; i < size; ++i)
+ combo->addItem(QLatin1String(d[i].description), QVariant(d[i].value));
+}
+
void setComboBoxValue(QComboBox *c, int v)
{
c->setCurrentIndex(c->findData(QVariant(v)));
}
+OptionsControl::OptionsControl(QWidget *parent)
+ : QGroupBox(parent)
+{
+ setLayout(new QVBoxLayout(this));
+}
+
OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent)
: QGroupBox(title, parent)
{
@@ -68,6 +80,15 @@ OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_
}
}
+void OptionsControl::populateOptions(const FlagData *data, size_t count)
+{
+ for (size_t i = 0; i < count; ++i) {
+ QCheckBox *box = new QCheckBox(QString::fromLatin1(data[i].description));
+ m_checkBoxes.push_back(CheckBoxFlagPair(box, data[i].value));
+ layout()->addWidget(box);
+ }
+}
+
void OptionsControl::setValue(int flags)
{
foreach (const CheckBoxFlagPair &cf, m_checkBoxes)
diff --git a/tests/manual/dialogs/utils.h b/tests/manual/dialogs/utils.h
index 634795627f..ac91754139 100644
--- a/tests/manual/dialogs/utils.h
+++ b/tests/manual/dialogs/utils.h
@@ -59,6 +59,7 @@ struct FlagData
// Helpers for creating combo boxes representing enumeration values from flag data.
QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size);
+void populateCombo(QComboBox *combo, const FlagData *d, size_t size);
template <class Enum>
Enum comboBoxValue(const QComboBox *c)
@@ -71,8 +72,11 @@ void setComboBoxValue(QComboBox *c, int v);
// A group box with check boxes for option flags.
class OptionsControl : public QGroupBox {
public:
+ OptionsControl(QWidget *parent);
explicit OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent);
+ void populateOptions(const FlagData *data, size_t count);
+
void setValue(int flags);
template <class Enum>
Enum value() const { return static_cast<Enum>(intValue()); }