コード例 #1
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addFrame_withoutBorder()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *frameGroupBox = effectsScrollArea->frameGroupBox;
    frameGroupBox->setChecked(true);
    QGroupBox *borderOutsideGroupBox = effectsScrollArea->borderOutsideGroupBox;
    borderOutsideGroupBox->setChecked(false);
    QGroupBox *borderInsideGroupBox = effectsScrollArea->borderInsideGroupBox;
    borderInsideGroupBox->setChecked(false);

    effectsScrollArea->frameAroundRadioButton->setChecked(true);
    effectsScrollArea->frameWidthSpinBox->setValue(20);

    QColor color = Qt::red;
    effectsScrollArea->frameColorFrame->setColor(color);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFrameAddAround(), true);
    QCOMPARE(conf.getFrameWidth(), 20);
    QCOMPARE(conf.getFrameColor(), color);
    QCOMPARE(conf.getBorderOutsideWidth(), -1);
    QCOMPARE(conf.getBorderOutsideColor(), QColor());
    QCOMPARE(conf.getBorderInsideWidth(), -1);
    QCOMPARE(conf.getBorderInsideColor(), QColor());
}
コード例 #2
0
ファイル: window.cpp プロジェクト: Andreas665/qt
//! [4]
QGroupBox *Window::createSecondExclusiveGroup()
{
    QGroupBox *groupBox = new QGroupBox(tr("E&xclusive Radio Buttons"));
    groupBox->setCheckable(true);
    groupBox->setChecked(false);
//! [4]

//! [5]
    QRadioButton *radio1 = new QRadioButton(tr("Rad&io button 1"));
    QRadioButton *radio2 = new QRadioButton(tr("Radi&o button 2"));
    QRadioButton *radio3 = new QRadioButton(tr("Radio &button 3"));
    radio1->setChecked(true);
    QCheckBox *checkBox = new QCheckBox(tr("Ind&ependent checkbox"));
    checkBox->setChecked(true);
//! [5]

//! [6]
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(radio1);
    vbox->addWidget(radio2);
    vbox->addWidget(radio3);
    vbox->addWidget(checkBox);
    vbox->addStretch(1);
    groupBox->setLayout(vbox);

    return groupBox;
}
コード例 #3
0
	void ItemHandlerGroupbox::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGroupBox *box = new QGroupBox (XSD_->GetLabel (item));
		box->setObjectName (item.attribute ("property"));
		QGridLayout *groupLayout = new QGridLayout ();
		groupLayout->setContentsMargins (2, 2, 2, 2);
		box->setLayout (groupLayout);
		box->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
		box->setCheckable (true);

		QVariant value = XSD_->GetValue (item);

		box->setChecked (value.toBool ());
		connect (box,
				SIGNAL (toggled (bool)),
				this,
				SLOT (updatePreferences ()));
		box->setProperty ("ItemHandler",
				QVariant::fromValue<QObject*> (this));

		XSD_->ParseEntity (item, box);

		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
		lay->addWidget (box, lay->rowCount (), 0, 1, 2);
		QSpacerItem *verticalSpacer = new QSpacerItem (10, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
		lay->addItem (verticalSpacer, lay->rowCount (), 0);
	}
コード例 #4
0
NetworkProxyDialog::NetworkProxyDialog(QWidget *parent) :
    Dialog(parent),
    m_proxyTypeSelector(new ValueSelector(tr("Proxy type"), this)),
    m_hostEdit(new QLineEdit(this)),
    m_portEdit(new QLineEdit(this)),
    m_userEdit(new QLineEdit(this)),
    m_passEdit(new QLineEdit(this))
{
    setWindowTitle(tr("Network proxy"));
    
    m_proxyTypeSelector->setModel(new NetworkProxyTypeModel(this));
    m_proxyTypeSelector->setValue(Settings::instance()->networkProxyType());

    m_hostEdit->setMinimumWidth(380);
    m_hostEdit->setText(Settings::instance()->networkProxyHost());
    m_portEdit->setValidator(new QIntValidator(0, 100000, this));
    m_portEdit->setText(QString::number(Settings::instance()->networkProxyPort()));
    m_passEdit->setEchoMode(QLineEdit::Password);
    m_passEdit->setText(Settings::instance()->networkProxyPassword());
    m_userEdit->setText(Settings::instance()->networkProxyUsername());

    QGroupBox *proxyGroup = new QGroupBox(tr("Use network proxy"), this);
    proxyGroup->setCheckable(true);
    proxyGroup->setChecked(Settings::instance()->networkProxyEnabled());
    
    QGridLayout *proxyGrid = new QGridLayout(proxyGroup);
    proxyGrid->setContentsMargins(0, 0, 0, 0);
    proxyGrid->addWidget(m_proxyTypeSelector, 0, 0, 1, 2);
    proxyGrid->addWidget(new QLabel(tr("Host"), this), 1, 0, 1, 1);
    proxyGrid->addWidget(new QLabel(tr("Port"), this), 1, 1, 1, 1);
    proxyGrid->addWidget(m_hostEdit, 2, 0, 1, 1);
    proxyGrid->addWidget(m_portEdit, 2, 1, 1, 1);
    proxyGrid->addWidget(new QLabel(tr("Username"), this), 3, 0, 1, 2);
    proxyGrid->addWidget(m_userEdit, 4, 0, 1, 2);
    proxyGrid->addWidget(new QLabel(tr("Password"), this), 5, 0, 1, 2);
    proxyGrid->addWidget(m_passEdit, 6, 0, 1, 2);

    QWidget *scrollWidget = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout(scrollWidget);
    vbox->setContentsMargins(0, 0, 0, 0);
    vbox->addWidget(proxyGroup);
    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(scrollWidget);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Vertical, this);
    QHBoxLayout *hbox = new QHBoxLayout(this);
    hbox->addWidget(scrollArea);
    hbox->addWidget(buttonBox);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(proxyGroup, SIGNAL(toggled(bool)), Settings::instance(), SLOT(setNetworkProxyEnabled(bool)));
    connect(m_proxyTypeSelector, SIGNAL(valueChanged(QVariant)), this, SLOT(setNetworkProxyType(QVariant)));
    connect(m_hostEdit, SIGNAL(textEdited(QString)), Settings::instance(), SLOT(setNetworkProxyHost(QString)));
    connect(m_portEdit, SIGNAL(textEdited(QString)), this, SLOT(setNetworkProxyPort(QString)));
    connect(m_userEdit, SIGNAL(textEdited(QString)), Settings::instance(), SLOT(setNetworkProxyUsername(QString)));
    connect(m_passEdit, SIGNAL(textEdited(QString)), Settings::instance(), SLOT(setNetworkProxyPassword(QString)));
}
コード例 #5
0
ファイル: qgsdualview.cpp プロジェクト: alexbruy/QGIS
void QgsDualView::modifySort()
{
  if ( !mLayer )
    return;

  QgsAttributeTableConfig config = mConfig;

  QDialog orderByDlg;
  orderByDlg.setWindowTitle( tr( "Configure Attribute Table Sort Order" ) );
  QDialogButtonBox *dialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
  QGridLayout *layout = new QGridLayout();
  connect( dialogButtonBox, &QDialogButtonBox::accepted, &orderByDlg, &QDialog::accept );
  connect( dialogButtonBox, &QDialogButtonBox::rejected, &orderByDlg, &QDialog::reject );
  orderByDlg.setLayout( layout );

  QGroupBox *sortingGroupBox = new QGroupBox();
  sortingGroupBox->setTitle( tr( "Defined sort order in attribute table" ) );
  sortingGroupBox->setCheckable( true );
  sortingGroupBox->setChecked( !sortExpression().isEmpty() );
  layout->addWidget( sortingGroupBox );
  sortingGroupBox->setLayout( new QGridLayout() );

  QgsExpressionBuilderWidget *expressionBuilder = new QgsExpressionBuilderWidget();
  QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( mLayer ) );
  expressionBuilder->setExpressionContext( context );
  expressionBuilder->setLayer( mLayer );
  expressionBuilder->loadFieldNames();
  expressionBuilder->loadRecent( QStringLiteral( "generic" ) );
  expressionBuilder->setExpressionText( sortExpression().isEmpty() ? mLayer->displayExpression() : sortExpression() );

  sortingGroupBox->layout()->addWidget( expressionBuilder );

  QCheckBox *cbxSortAscending = new QCheckBox( tr( "Sort ascending" ) );
  cbxSortAscending->setChecked( config.sortOrder() == Qt::AscendingOrder );
  sortingGroupBox->layout()->addWidget( cbxSortAscending );

  layout->addWidget( dialogButtonBox );
  if ( orderByDlg.exec() )
  {
    Qt::SortOrder sortOrder = cbxSortAscending->isChecked() ? Qt::AscendingOrder : Qt::DescendingOrder;
    if ( sortingGroupBox->isChecked() )
    {
      setSortExpression( expressionBuilder->expressionText(), sortOrder );
      config.setSortExpression( expressionBuilder->expressionText() );
      config.setSortOrder( sortOrder );
    }
    else
    {
      setSortExpression( QString(), sortOrder );
      config.setSortExpression( QString() );
    }

    setAttributeTableConfig( config );
  }
}
コード例 #6
0
void GameBoard::configura()
{

    //Pausa o Jogo para as Configurações
    stopped();

    //Cria a nova janela de configurações
    QDialog *janelaconfig = new QDialog;


    //Textos da nova janela e de identificação dos botões
    QLabel *Titulo = new QLabel("<big><b>Configuracoes</b></big>");
    QLabel *Key_Menu = new QLabel("Menu de Atalhos: ");
    QLabel *Configur = new QLabel("Configurar Parametros: ");


    //Caixa de organização de grupos
    QGroupBox *confBox = new QGroupBox;
    confBox->setCheckable(false);
    confBox->setChecked(true);

    //Botões da janela de configuração
    QPushButton *keys = new QPushButton("Atalhos do Teclado");
    QPushButton *ajuste = new QPushButton("Ajustes de Jogo");
    QPushButton *voltar = new QPushButton("Voltar");

    connect(keys, SIGNAL(clicked()), SLOT(Menu()));
    connect(ajuste, SIGNAL(clicked()), SLOT(Settings()));
    connect(voltar, SIGNAL(clicked()), this, SLOT(continueGame()));
    connect(voltar, SIGNAL(clicked()), janelaconfig, SLOT(close()));


    //Ajuste do Layout da Página
    QGridLayout *toplay = new QGridLayout;
    toplay->addWidget(Key_Menu, 0, 0);
    toplay->addWidget(keys,0, 1);
    toplay->addWidget(Configur, 1, 0);
    toplay->addWidget(ajuste, 1, 1);
    toplay->addWidget(voltar, 2, 1);


    confBox->setLayout(toplay);

    QVBoxLayout *leftlay = new QVBoxLayout;
    leftlay->addWidget(Titulo);
    leftlay->addWidget(confBox);


    janelaconfig->setLayout(leftlay);
    janelaconfig->setMinimumSize(300, 230);

    janelaconfig->show();

}
コード例 #7
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_histogram_no()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *histogramGroupBox = effectsScrollArea->histogramGroupBox;
    histogramGroupBox->setChecked(false);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getHistogramOperation(), quint8(0));
}
コード例 #8
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_filter_no()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
    filterGroupBox->setChecked(false);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFilterType(), int(NoFilter));
    QCOMPARE(conf.getFilterBrush(), QBrush());
}
コード例 #9
0
	void ItemHandlerGroupbox::SetValue (QWidget *widget,
			const QVariant& value) const
	{
		QGroupBox *groupbox = qobject_cast<QGroupBox*> (widget);
		if (!groupbox)
		{
			qWarning () << Q_FUNC_INFO
				<< "not a QGroupBox"
				<< widget;
			return;
		}
		groupbox->setChecked (value.toBool ());
	}
コード例 #10
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_histogram_equalize()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *histogramGroupBox = effectsScrollArea->histogramGroupBox;
    histogramGroupBox->setChecked(true);
    effectsScrollArea->equalizeHistogramRadioButton->setChecked(true);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getHistogramOperation(), quint8(2));
}
コード例 #11
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addText_fontPx()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *textGroupBox = effectsScrollArea->textGroupBox;
    textGroupBox->setChecked(true);
    QLineEdit *textLineEdit = effectsScrollArea->textLineEdit;
    QString testText = "Test Text";
    textLineEdit->setText(testText);
    QComboBox *fontSizeComboBox = effectsScrollArea->textFontSizeComboBox;
    int px = 1;
    fontSizeComboBox->setCurrentIndex(px);

    QFont font = effectsScrollArea->textFontComboBox->currentFont();
    int fontSize = 20;
    font.setPixelSize(fontSize);
    font.setBold(true);
    font.setItalic(true);
    font.setUnderline(true);
    font.setStrikeOut(true);

    effectsScrollArea->textFontSizeSpinBox->setValue(fontSize);
    effectsScrollArea->textBoldPushButton->setChecked(font.bold());
    effectsScrollArea->textItalicPushButton->setChecked(font.italic());
    effectsScrollArea->textUnderlinePushButton->setChecked(font.underline());
    effectsScrollArea->textStrikeOutPushButton->setChecked(font.strikeOut());

    QColor color = Qt::green;
    effectsScrollArea->textColorFrame->setColor(color);

    effectsScrollArea->textOpacitySpinBox->setValue(0.5);
    effectsScrollArea->textPositionComboBox->setCurrentIndex(TopRightCorner);

    QPoint position = QPoint(4, 3);
    effectsScrollArea->textXSpinBox->setValue(position.x());
    effectsScrollArea->textYSpinBox->setValue(position.y());

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getTextString(), testText);
    QCOMPARE(conf.getTextFont(), font);
    QCOMPARE(conf.getTextColor(), color);
    QCOMPARE(conf.getTextOpacity(), 0.5);
    QCOMPARE(conf.getTextPosModifier(), TopRightCorner);
    QCOMPARE(conf.getTextPos(), position);
    QCOMPARE(conf.getTextUnitPair(), PosUnitPair(Pixel, Pixel));
    QCOMPARE(conf.getTextFrame(), false);
    QCOMPARE(conf.getTextRotation(), 0);
}
コード例 #12
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget *window = new QWidget;

    QVBoxLayout *windowLayout = new QVBoxLayout(window);

    QGroupBox *language = new QGroupBox("Language");
    language->setAlignment(Qt::AlignHCenter);
    QVBoxLayout *languageLayout = new QVBoxLayout(language);
    QCheckBox *check1 = new QCheckBox;
    check1->setChecked(true);
    check1->setText("Java is good!");
    QCheckBox *check2 = new QCheckBox("C++ is good!");
    QCheckBox *check3 = new QCheckBox("Nothing is good!");
    check3->setTristate(true);

    languageLayout->addWidget(check1);
    languageLayout->addWidget(check2);
    languageLayout->addWidget(check3);
    windowLayout->addWidget(language);

    QGroupBox *os = new QGroupBox("Mobile OS");
    os->setAlignment(Qt::AlignRight);
    QVBoxLayout *osLayout = new QVBoxLayout;
    osLayout->addWidget(new QRadioButton("Android"));
    osLayout->addWidget(new QRadioButton("Windows Phone"));
    osLayout->addWidget(new QRadioButton("iOS"));
    osLayout->addStretch();
    os->setLayout(osLayout);
    windowLayout->addWidget(os);

    QGroupBox *phone = new QGroupBox("Smart Phone");
    phone->setCheckable(true);
    phone->setChecked(false);
    QHBoxLayout *phoneLayout = new QHBoxLayout(phone);
    phoneLayout->addWidget(new QCheckBox("Sumsung"));
    phoneLayout->addWidget(new QCheckBox("Xiao Mi"));
    phoneLayout->addWidget(new QCheckBox("HTC"));
    windowLayout->addWidget(phone);

    windowLayout->addStretch(1);

    window->show();

    return a.exec();
}
コード例 #13
0
void Form_PlatformConfiguration::LoadConfig(const QObjectList &q)
{
    for(int i=0;i<q.length();i++)
    {

        if(!q.at(i)->children().empty())
        {
            LoadConfig(q.at(i)->children());
        }

        QObject* obj = q.at(i);

        if (obj->inherits("QLineEdit"))
        {
            QLineEdit *b = qobject_cast<QLineEdit*>(obj);
            QString Name = obj->objectName();
            QDomNode node = STT_Global::FindXml(doc_config,Name);
            if(!node.isNull() ) b->setText(node.attributes().namedItem("Value").nodeValue() );

        }
        else if (obj->inherits("QGroupBox"))
        {
            QGroupBox* b = qobject_cast<QGroupBox*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if(!node.isNull() ) b->setChecked( node.attributes().namedItem("Value").nodeValue() == "1" ? true:false);
        }
        else if (obj->inherits("QTableWidget"))
        {
            QTableWidget* b = qobject_cast<QTableWidget*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if( !node.isNull() )
            {
              int Value_R =  node.attributes().namedItem("Value_R").nodeValue().toInt();
              int Value_C =  node.attributes().namedItem("Value_C").nodeValue().toInt();
              b->setRowCount(Value_R);

              for(int i =0 ; i<Value_R ;i++)
              {
                  QDomNode item= node.childNodes().at(i);
                  for(int j=0 ;j < Value_C ; j++)
                  {
                      b->setItem(i, j, new QTableWidgetItem(item.attributes().namedItem("C"+QString::number(j)).nodeValue()));
                  }
              }
            }
        }
    }
}
コード例 #14
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addImage_no()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *imageGroupBox = effectsScrollArea->imageGroupBox;
    imageGroupBox->setChecked(false);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getImage(), QImage());
    QCOMPARE(conf.getImageLoadError(), false);
    QCOMPARE(conf.getImagePosModifier(), UndefinedPosModifier);
    QCOMPARE(conf.getImagePos(), QPoint());
    QCOMPARE(conf.getImageUnitPair(), PosUnitPair(UndefinedUnit, UndefinedUnit));
    QCOMPARE(conf.getImageRotation(), 0);
}
コード例 #15
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addFrame_no()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *frameGroupBox = effectsScrollArea->frameGroupBox;
    frameGroupBox->setChecked(false);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFrameAddAround(), false);
    QCOMPARE(conf.getFrameWidth(), -1);
    QCOMPARE(conf.getFrameColor(), QColor());
    QCOMPARE(conf.getBorderOutsideWidth(), -1);
    QCOMPARE(conf.getBorderOutsideColor(), QColor());
    QCOMPARE(conf.getBorderInsideWidth(), -1);
    QCOMPARE(conf.getBorderInsideColor(), QColor());
}
コード例 #16
0
void MainWindow::createViewPort()
{
    QString vpTitle = QString("ViewPort %1").arg(++d_numViewPorts);
    QDockWidget *dock = new QDockWidget(vpTitle, this);

    // The main layout for the dock
    QVBoxLayout *mainLayout = new QVBoxLayout;

    GLViewPort *glView = new GLViewPort(this);
    glView->setCloth(d_cloth);

    // Add the viewport on top
    mainLayout->addWidget(glView);

    // Set up the render options box
    QGroupBox *renderGroupBox = new QGroupBox(tr("Render Options"));
    renderGroupBox->setChecked(false);
    QCheckBox *checkBox1 = new QCheckBox(tr("Cloth"));
    QCheckBox *checkBox2 = new QCheckBox(tr("Springs"));
    QCheckBox *checkBox3 = new QCheckBox(tr("Particles"));
    connect(checkBox1, SIGNAL(toggled(bool)), glView, SLOT(setDrawCloth(bool)));
    connect(checkBox2, SIGNAL(toggled(bool)), glView, SLOT(setDrawSprings(bool)));
    connect(checkBox3, SIGNAL(toggled(bool)), glView, SLOT(setDrawParticles(bool)));

    QHBoxLayout *hbox = new QHBoxLayout;
    hbox->addWidget(checkBox1);
    hbox->addWidget(checkBox2);
    hbox->addWidget(checkBox3);
    checkBox1->setChecked(true);
    hbox->addStretch(1);
    renderGroupBox->setLayout(hbox);
    mainLayout->addWidget(renderGroupBox);

    QWidget *wi = new QWidget;
    wi->setLayout(mainLayout);
    dock->setWidget(wi);

    if(d_numViewPorts -1 == 0)
        setCentralWidget(dock);
    else
        addDockWidget(Qt::RightDockWidgetArea, dock);

    connect(this, SIGNAL(updateViewPorts()), glView, SLOT(updateGL()));
}
コード例 #17
0
ファイル: window.cpp プロジェクト: Andreas665/qt
//! [10]
QGroupBox *Window::createPushButtonGroup()
{
    QGroupBox *groupBox = new QGroupBox(tr("&Push Buttons"));
    groupBox->setCheckable(true);
    groupBox->setChecked(true);
//! [10]

//! [11]
    QPushButton *pushButton = new QPushButton(tr("&Normal Button"));
    QPushButton *toggleButton = new QPushButton(tr("&Toggle Button"));
    toggleButton->setCheckable(true);
    toggleButton->setChecked(true);
    QPushButton *flatButton = new QPushButton(tr("&Flat Button"));
    flatButton->setFlat(true);
//! [11]

//! [12]
    QPushButton *popupButton = new QPushButton(tr("Pop&up Button"));
    QMenu *menu = new QMenu(this);
    menu->addAction(tr("&First Item"));
    menu->addAction(tr("&Second Item"));
    menu->addAction(tr("&Third Item"));
    menu->addAction(tr("F&ourth Item"));
    popupButton->setMenu(menu);
//! [12]

    QAction *newAction = menu->addAction(tr("Submenu"));
    QMenu *subMenu = new QMenu(tr("Popup Submenu"));
    subMenu->addAction(tr("Item 1"));
    subMenu->addAction(tr("Item 2"));
    subMenu->addAction(tr("Item 3"));
    newAction->setMenu(subMenu);

//! [13]
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(pushButton);
    vbox->addWidget(toggleButton);
    vbox->addWidget(flatButton);
    vbox->addWidget(popupButton);
    vbox->addStretch(1);
    groupBox->setLayout(vbox);

    return groupBox;
}
コード例 #18
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addText_no()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *textGroupBox = effectsScrollArea->textGroupBox;
    textGroupBox->setChecked(false);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getTextString(), QString());
    QCOMPARE(conf.getTextFont(), QFont());
    QCOMPARE(conf.getTextColor(), QColor());
    QCOMPARE(conf.getTextPosModifier(), UndefinedPosModifier);
    QCOMPARE(conf.getTextPos(), QPoint());
    QCOMPARE(conf.getTextUnitPair(), PosUnitPair(UndefinedUnit, UndefinedUnit));
    QCOMPARE(conf.getTextFrame(), false);
    QCOMPARE(conf.getTextRotation(), 0);
}
コード例 #19
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_filter_colorSepia()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
    filterGroupBox->setChecked(true);

    QRadioButton *filterColorRadioButton = effectsScrollArea->filterColorRadioButton;
    filterColorRadioButton->setChecked(true);

    int sepia = 1;
    QComboBox *filterTypeComboBox = effectsScrollArea->filterTypeComboBox;
    filterTypeComboBox->setCurrentIndex(sepia);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFilterType(), int(Sepia));
    QCOMPARE(conf.getFilterBrush(), QBrush());
}
コード例 #20
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_filter_gradient()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
    filterGroupBox->setChecked(true);

    QRadioButton *filterGradientRadioButton = effectsScrollArea->filterGradientRadioButton;
    filterGradientRadioButton->setChecked(true);

    QRadialGradient gradient = QRadialGradient(QPoint(1, 2), 2.5);
    gradient.setColorAt(0.0, Qt::green);
    gradient.setColorAt(1.0, Qt::red);
    BrushFrame *filterBrushFrame = effectsScrollArea->filterBrushFrame;
    filterBrushFrame->setBrush(gradient);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFilterType(), int(Gradient));
    QCOMPARE(conf.getFilterBrush(), QBrush(gradient));
}
コード例 #21
0
void QgsDataDefinedButton::checkCheckedWidgets( bool check )
{
  // don't uncheck, only set to checked
  if ( !check )
  {
    return;
  }
  for ( int i = 0; i < mCheckedWidgets.size(); ++i )
  {
    QAbstractButton *btn = qobject_cast< QAbstractButton * >( mCheckedWidgets.at( i ) );
    if ( btn && btn->isCheckable() )
    {
      btn->setChecked( true );
      continue;
    }
    QGroupBox *grpbx = qobject_cast< QGroupBox * >( mCheckedWidgets.at( i ) );
    if ( grpbx && grpbx->isCheckable() )
    {
      grpbx->setChecked( true );
    }
  }
}
コード例 #22
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_addImage_imageNotNull()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *imageGroupBox = effectsScrollArea->imageGroupBox;
    imageGroupBox->setChecked(true);

    QString filePath = QDir::tempPath() + QDir::separator()
            + "sir_test_convert_addImage_imageNotNull.bmp";
    effectsScrollArea->imagePathLineEdit->setText(filePath);
    effectsScrollArea->imagePositionComboBox->setCurrentIndex(MiddleTopEdge);
    QPoint imagePoint(1, 2);
    effectsScrollArea->imageXSpinBox->setValue(imagePoint.x());
    effectsScrollArea->imageYSpinBox->setValue(imagePoint.y());
    effectsScrollArea->imageXComboBox->setCurrentIndex(Percent);
    effectsScrollArea->imageYComboBox->setCurrentIndex(Percent);
    effectsScrollArea->imageOpacitySpinBox->setValue(0.5);
    effectsScrollArea->imageRotationSpinBox->setValue(40);

    QImage image(2, 3, QImage::Format_RGB32);
    image.fill(Qt::green);
    QVERIFY(image.save(filePath));

    convertDialog->convert();

    QFile file(filePath);
    QVERIFY(file.remove());

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getImage(), image);
    QCOMPARE(conf.getImageLoadError(), false);
    QCOMPARE(conf.getImagePosModifier(), MiddleTopEdge);
    QCOMPARE(conf.getImagePos(), imagePoint);
    QCOMPARE(conf.getImageUnitPair(), PosUnitPair(Percent, Percent));
    QCOMPARE(conf.getImageOpacity(), 0.5);
    QCOMPARE(conf.getImageRotation(), 40);
}
コード例 #23
0
ファイル: ConvertDialogTest.cpp プロジェクト: marek629/SIR
void ConvertDialogTest::convert_filter_colorCustom()
{
    EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea;
    QGroupBox *filterGroupBox = effectsScrollArea->filterGroupBox;
    filterGroupBox->setChecked(true);

    QRadioButton *filterColorRadioButton = effectsScrollArea->filterColorRadioButton;
    filterColorRadioButton->setChecked(true);

    int custom = 2;
    QComboBox *filterTypeComboBox = effectsScrollArea->filterTypeComboBox;
    filterTypeComboBox->setCurrentIndex(custom);

    QColor color = Qt::red;
    BrushFrame *filterBrushFrame = effectsScrollArea->filterBrushFrame;
    filterBrushFrame->setColor(color);

    convertDialog->convert();

    SharedInformation *sharedInfo = convertDialog->sharedInfo;
    EffectsConfiguration conf = sharedInfo->effectsConfiguration();
    QCOMPARE(conf.getFilterType(), int(CustomColor));
    QCOMPARE(conf.getFilterBrush(), QBrush(color));
}
コード例 #24
0
ファイル: mesytecMadc32ui.cpp プロジェクト: mojca/gecko
void MesytecMadc32UI::applySettings()
{
    applyingSettings = true;

    QList<QGroupBox*> gbs = findChildren<QGroupBox*>();
    if(!gbs.empty())
    {
        QList<QGroupBox*>::const_iterator it = gbs.begin();
        while(it != gbs.end())
        {
            QGroupBox* w = (*it);
            for(int ch=0; ch < MADC32V2_NUM_CHANNELS; ch++) {
                if(w->objectName() == tr("enable_channel%1").arg(ch)) w->setChecked(module->conf_.enable_channel[ch]);
            }
            it++;
        }
    }
    QList<QCheckBox*> cbs = findChildren<QCheckBox*>();
    if(!cbs.empty())
    {
        QList<QCheckBox*>::const_iterator it = cbs.begin();
        while(it != cbs.end())
        {
            QCheckBox* w = (*it);

            if(w->objectName() == "enable_multi_event_send_different_eob_marker") w->setChecked(module->conf_.enable_multi_event_send_different_eob_marker);
            if(w->objectName() == "enable_multi_event_compare_with_max_transfer_data") w->setChecked(module->conf_.enable_multi_event_compare_with_max_transfer_data);
            if(w->objectName() == "enable_adc_override") w->setChecked(module->conf_.enable_adc_override);
            if(w->objectName() == "enable_switch_off_sliding_scale") w->setChecked(module->conf_.enable_switch_off_sliding_scale);
            if(w->objectName() == "enable_skip_out_of_range") w->setChecked(module->conf_.enable_skip_out_of_range);
            if(w->objectName() == "enable_ignore_thresholds") w->setChecked(module->conf_.enable_ignore_thresholds);
            if(w->objectName() == "enable_termination_input_gate0") w->setChecked(module->conf_.enable_termination_input_gate0);
            if(w->objectName() == "enable_termination_input_fast_clear") w->setChecked(module->conf_.enable_termination_input_fast_clear);
            if(w->objectName() == "enable_external_time_stamp_reset") w->setChecked(module->conf_.enable_external_time_stamp_reset);

            it++;
        }
    }
    QList<QComboBox*> cbbs = findChildren<QComboBox*>();
    if(!cbbs.empty())
    {
        QList<QComboBox*>::const_iterator it = cbbs.begin();
        while(it != cbbs.end())
        {
            QComboBox* w = (*it);
            //printf("Found combobox with the name %s\n",w->objectName().toStdString().c_str());
            if(w->objectName() == "addr_source") w->setCurrentIndex(module->conf_.addr_source);
            if(w->objectName() == "multi_event_mode") w->setCurrentIndex(module->conf_.multi_event_mode);
            if(w->objectName() == "vme_mode") w->setCurrentIndex(module->conf_.vme_mode);
            if(w->objectName() == "data_length_format") w->setCurrentIndex(module->conf_.data_length_format);
            if(w->objectName() == "time_stamp_source") w->setCurrentIndex(module->conf_.time_stamp_source);
            if(w->objectName() == "adc_resolution") w->setCurrentIndex(module->conf_.adc_resolution);
            if(w->objectName() == "output_format") w->setCurrentIndex(module->conf_.output_format);
            if(w->objectName() == "gate_generator_mode") w->setCurrentIndex(module->conf_.gate_generator_mode);
            if(w->objectName() == "ecl_gate1_mode") w->setCurrentIndex(module->conf_.ecl_gate1_mode);
            if(w->objectName() == "ecl_fclear_mode") w->setCurrentIndex(module->conf_.ecl_fclear_mode);
            if(w->objectName() == "ecl_busy_mode") w->setCurrentIndex(module->conf_.ecl_busy_mode);
            if(w->objectName() == "nim_gate1_mode") w->setCurrentIndex(module->conf_.nim_gate1_mode);
            if(w->objectName() == "nim_fclear_mode") w->setCurrentIndex(module->conf_.nim_fclear_mode);
            if(w->objectName() == "input_range") {
                switch (module->conf_.input_range){
                case MesytecMadc32ModuleConfig::ir4V: w->setCurrentIndex(0); break;
                case MesytecMadc32ModuleConfig::ir8V: w->setCurrentIndex(1); break;
                case MesytecMadc32ModuleConfig::ir10V: w->setCurrentIndex(2); break;
                default: w->setCurrentIndex(2); break;
                }
            }
            if(w->objectName() == "marking_type") w->setCurrentIndex(module->conf_.marking_type);
            if(w->objectName() == "bank_operation") w->setCurrentIndex(module->conf_.bank_operation);
            if(w->objectName() == "test_pulser_mode") w->setCurrentIndex(module->conf_.test_pulser_mode);
            it++;
        }
    }
    QList<QSpinBox*> csb = findChildren<QSpinBox*>();
    if(!csb.empty())
    {
        QList<QSpinBox*>::const_iterator it = csb.begin();
        while(it != csb.end())
        {
            QSpinBox* w = (*it);
            //printf("Found spinbox with the name %s\n",w->objectName().toStdString().c_str());
            if(w->objectName() == "irq_level") w->setValue(module->conf_.irq_level);
            if(w->objectName() == "irq_vector") w->setValue(module->conf_.irq_vector);
            if(w->objectName() == "irq_threshold") w->setValue(module->conf_.irq_threshold);
            if(w->objectName() == "base_addr_register") w->setValue(module->conf_.base_addr_register);
            if(w->objectName() == "time_stamp_divisor") w->setValue(module->conf_.time_stamp_divisor);
            if(w->objectName() == "max_transfer_data") w->setValue(module->conf_.max_transfer_data);
            if(w->objectName() == "rc_module_id_read") w->setValue(module->conf_.rc_module_id_read);
            if(w->objectName() == "rc_module_id_write") w->setValue(module->conf_.rc_module_id_write);

            for(int ch=0; ch<2; ch++)
            {
                if(w->objectName() == tr("hold_delay_%1").arg(ch)) w->setValue(module->conf_.hold_delay[ch]);
                if(w->objectName() == tr("hold_width_%1").arg(ch)) w->setValue(module->conf_.hold_width[ch]);
            }
            for(int ch=0; ch<MADC32V2_NUM_CHANNELS; ch++)
            {
                if(w->objectName() == tr("thresholds%1").arg(ch)) w->setValue(module->conf_.thresholds[ch]);
            }
            it++;
        }
    }
    QList<QRadioButton*> crb = findChildren<QRadioButton*>();
    if(!crb.empty())
    {
        QList<QRadioButton*>::const_iterator it = crb.begin();
        while(it != crb.end())
        {
            QRadioButton* w = (*it);
            if(w->objectName() == "mcst_cblt_none") w->setChecked(module->conf_.mcst_cblt_none);
            if(w->objectName() == "enable_cblt_mode") w->setChecked(module->conf_.enable_cblt_mode);
            if(w->objectName() == "enable_mcst_mode") w->setChecked(module->conf_.enable_mcst_mode);
            if(w->objectName() == "enable_cblt_first") w->setChecked(module->conf_.enable_cblt_first);
            if(w->objectName() == "enable_cblt_last") w->setChecked(module->conf_.enable_cblt_last);
            if(w->objectName() == "enable_cblt_middle") w->setChecked(module->conf_.enable_cblt_middle);
            it++;
        }
    }
\
    QLabel* b_addr = (QLabel*) uif.getWidgets()->find("base_addr").value();
    b_addr->setText(tr("0x%1").arg(module->conf_.base_addr,2,16,QChar('0')));

    applyingSettings = false;
}
コード例 #25
0
MouseSettingsPage::MouseSettingsPage(AntiMicroSettings *settings, QWidget *parent) :
    QWizardPage(parent)
{
    this->settings = settings;

    setTitle(tr("Mouse Settings"));
    setSubTitle(tr("Customize settings used for mouse emulation"));
    QVBoxLayout *tempMainLayout = new QVBoxLayout;
    setLayout(tempMainLayout);

#ifdef Q_OS_WIN
    QCheckBox *disablePrecision = new QCheckBox(tr("Disable Enhance Pointer Precision"));
    disablePrecision->setToolTip(tr("Disable the \"Enhanced Pointer Precision\" Windows setting\n"
                                    "while antimicro is running. Disabling \"Enhanced Pointer Precision\"\n"
                                    "will allow mouse movement within antimicro to be more\n"
                                    "precise."));
    tempMainLayout->addWidget(disablePrecision);
    tempMainLayout->addSpacerItem(new QSpacerItem(10, 10));
    registerField("disableEnhancePrecision", disablePrecision);
#endif

    QGroupBox *smoothingGroupBox = new QGroupBox(tr("Smoothing"));
    smoothingGroupBox->setCheckable(true);
    smoothingGroupBox->setChecked(false);
    registerField("mouseSmoothing", smoothingGroupBox, "checked", SIGNAL(toggled(bool)));

    layout()->addWidget(smoothingGroupBox);

    QVBoxLayout *tempVLayout = new QVBoxLayout;

    QHBoxLayout *tempHLayout = new QHBoxLayout;
    QLabel *tempLabel = new QLabel(tr("History Buffer:"));
    QSpinBox *tempSpinBox = new QSpinBox;
    tempSpinBox->setMinimum(1);
    tempSpinBox->setMaximum(30);
    tempSpinBox->setValue(10);
    tempLabel->setBuddy(tempSpinBox);
    registerField("historyBuffer", tempSpinBox);

    tempHLayout->addWidget(tempLabel);
    tempHLayout->addWidget(tempSpinBox);
    tempVLayout->addLayout(tempHLayout);

    tempHLayout = new QHBoxLayout;
    tempLabel = new QLabel(tr("Weight Modifier:"));
    QDoubleSpinBox *tempDoubleSpinBox = new QDoubleSpinBox;
    tempDoubleSpinBox->setMinimum(0.0);
    tempDoubleSpinBox->setMaximum(1.0);
    tempDoubleSpinBox->setValue(0.20);
    tempDoubleSpinBox->setSingleStep(0.10);
    tempLabel->setBuddy(tempDoubleSpinBox);
    registerField("weightModifier", tempDoubleSpinBox);

    tempHLayout->addWidget(tempLabel);
    tempHLayout->addWidget(tempDoubleSpinBox);
    tempVLayout->addLayout(tempHLayout);

    smoothingGroupBox->setLayout(tempVLayout);

    tempHLayout = new QHBoxLayout;
    tempLabel = new QLabel(tr("Refresh Rate:"));
    QComboBox *tempComboBox = new QComboBox;

    for (int i = 1; i <= JoyButton::MAXIMUMMOUSEREFRESHRATE; i++)
    {
        tempComboBox->addItem(QString("%1 ms").arg(i), i);
    }

    int refreshIndex = tempComboBox->findData(JoyButton::getMouseRefreshRate());
    if (refreshIndex >= 0)
    {
        tempComboBox->setCurrentIndex(refreshIndex);
    }

    tempComboBox->setToolTip(tr("The refresh rate is the amount of time that will elapse\n"
                                "in between mouse events. Please be cautious when\n"
                                "editing this setting as it will cause the program to use\n"
                                "more CPU power. Setting this value too low can cause\n"
                                "system instability. Please test the setting before using\n"
                                "it unattended."));
    tempLabel->setBuddy(tempComboBox);
    registerField("mouseRefreshRate", tempComboBox);

    tempHLayout->addWidget(tempLabel);
    tempHLayout->addWidget(tempComboBox);
    tempMainLayout->addSpacerItem(new QSpacerItem(10, 10));
    tempMainLayout->addLayout(tempHLayout);
}
コード例 #26
0
bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
{
    if ( !editor )
        return false;

    QgsVectorLayer::EditType editType = vl->editType( idx );
    const QgsField &field = vl->pendingFields()[idx];
    QVariant::Type myFieldType = field.type();

    QSettings settings;
    QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();

    switch ( editType )
    {
    case QgsVectorLayer::Classification:
    case QgsVectorLayer::UniqueValues:
    case QgsVectorLayer::Enumeration:
    case QgsVectorLayer::ValueMap:
    case QgsVectorLayer::ValueRelation:
    {
        QVariant v = value;
        QComboBox *cb = qobject_cast<QComboBox *>( editor );
        if ( !cb )
            return false;

        if ( v.isNull() )
        {
            v = nullValue;
        }

        int idx = cb->findData( v );
        if ( idx < 0 )
            return false;

        cb->setCurrentIndex( idx );
    }
    break;

    case QgsVectorLayer::DialRange:
    case QgsVectorLayer::SliderRange:
    case QgsVectorLayer::EditRange:
    {
        if ( myFieldType == QVariant::Int )
        {
            if ( editType == QgsVectorLayer::EditRange )
            {
                QSpinBox *sb = qobject_cast<QSpinBox *>( editor );
                if ( !sb )
                    return false;
                sb->setValue( value.toInt() );
            }
            else
            {
                QAbstractSlider *sl = qobject_cast<QAbstractSlider *>( editor );
                if ( !sl )
                    return false;
                sl->setValue( value.toInt() );
            }
            break;
        }
        else if ( myFieldType == QVariant::Double )
        {
            QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor );
            if ( !dsb )
                return false;
            dsb->setValue( value.toDouble() );
        }
    }

    case QgsVectorLayer::CheckBox:
    {
        QGroupBox *gb = qobject_cast<QGroupBox *>( editor );
        if ( gb )
        {
            QPair<QString, QString> states = vl->checkedState( idx );
            gb->setChecked( value == states.first );
            break;
        }

        QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
        if ( cb )
        {
            QPair<QString, QString> states = vl->checkedState( idx );
            cb->setChecked( value == states.first );
            break;
        }
    }

    // fall-through

    case QgsVectorLayer::LineEdit:
    case QgsVectorLayer::UniqueValuesEditable:
    case QgsVectorLayer::Immutable:
    case QgsVectorLayer::UuidGenerator:
    default:
    {
        QLineEdit *le = qobject_cast<QLineEdit *>( editor );
        QComboBox *cb = qobject_cast<QComboBox *>( editor );
        QTextEdit *te = qobject_cast<QTextEdit *>( editor );
        QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
        if ( !le && ! cb && !te && !pte )
            return false;

        QString text;
        if ( value.isNull() )
        {
            if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong )
                text = "";
            else if ( editType == QgsVectorLayer::UuidGenerator )
                text = QUuid::createUuid().toString();
            else
                text = nullValue;
        }
        else
        {
            text = value.toString();
        }

        if ( le )
            le->setText( text );
        if ( cb && cb->isEditable() )
            cb->setEditText( text );
        if ( te )
            te->setHtml( text );
        if ( pte )
            pte->setPlainText( text );
    }
    break;

    case QgsVectorLayer::FileName:
    case QgsVectorLayer::Calendar:
    {
        QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
        if ( cw )
        {
            cw->setSelectedDate( value.toDate() );
            break;
        }

        QLineEdit* le = qobject_cast<QLineEdit*>( editor );
        if ( !le )
        {
            le = editor->findChild<QLineEdit *>();
        }
        if ( !le )
        {
            return false;
        }
        le->setText( value.toString() );
    }
    break;
    }

    return true;
}
コード例 #27
0
//Reading ad writing parameters from/to selected widget to/from parameters container
void SynchronizeInterfaceWindow(QWidget *window, cParameterContainer *par,
		enumReadWrite mode)
{
	WriteLog("cInterface::SynchronizeInterface: QLineEdit", 3);
	//----------- QLineEdit -------------------
	{
		QList<QLineEdit *> widgetListLineEdit = window->findChildren<QLineEdit *>();
		QList<QLineEdit *>::iterator it;

		for (it = widgetListLineEdit.begin(); it != widgetListLineEdit.end(); ++it)
		{
			//qDebug() << "QLineEdit:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;

			QString name = (*it)->objectName();
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QLineEdit") || className == QString("MyLineEdit")))
			{
				QLineEdit *lineEdit = *it;
				// QString text = lineEdit->text();
				//qDebug() << name << " - text: " << text << endl;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);
				//qDebug() << name << " - type: " << type << endl;

				if (className == QString("MyLineEdit"))
				{
					MyLineEdit *mylineedit = (MyLineEdit*) *it;
					mylineedit->AssignParameterContainer(par);
					mylineedit->AssingParameterName(parameterName);
				}

				//----- get vectors ------------
				if (type == QString("vect3") || type == QString("logvect3"))
				{
					char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1();
					QString nameVect = parameterName.left(parameterName.length() - 2);

					if (mode == read)
					{
						double value = systemData.locale.toDouble(lineEdit->text());
						//qDebug() << nameVect << " - " << lastChar << " axis = " << value << endl;
						CVector3 vect = par->Get<CVector3>(nameVect);

						switch (lastChar)
						{
							case 'x':
								vect.x = value;
								break;

							case 'y':
								vect.y = value;
								break;

							case 'z':
								vect.z = value;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect
										<< " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						par->Set(nameVect, vect);
					}
					else if (mode == write)
					{
						CVector3 vect = par->Get<CVector3>(nameVect);
						QString qtext;

						switch (lastChar)
						{
							case 'x':
								qtext = QString("%L1").arg(vect.x, 0, 'g', 16);
								break;

							case 'y':
								qtext = QString("%L1").arg(vect.y, 0, 'g', 16);
								break;

							case 'z':
								qtext = QString("%L1").arg(vect.z, 0, 'g', 16);
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect
										<< " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						lineEdit->setText(qtext);
						lineEdit->setCursorPosition(0);
					}
				}

				//----- get vectors 4D  ------------
				if (type == QString("vect4"))
				{
					char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1();
					QString nameVect = parameterName.left(parameterName.length() - 2);

					if (mode == read)
					{
						double value = systemData.locale.toDouble(lineEdit->text());
						//qDebug() << nameVect << " - " << lastChar << " axis = " << value << endl;
						CVector4 vect = par->Get<CVector4>(nameVect);

						switch (lastChar)
						{
							case 'x':
								vect.x = value;
								break;

							case 'y':
								vect.y = value;
								break;

							case 'z':
								vect.z = value;
								break;

							case 'w':
								vect.w = value;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect
										<< " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						par->Set(nameVect, vect);
					}
					else if (mode == write)
					{
						CVector4 vect = par->Get<CVector4>(nameVect);
						QString qtext;

						switch (lastChar)
						{
							case 'x':
								qtext = QString("%L1").arg(vect.x, 0, 'g', 16);
								break;

							case 'y':
								qtext = QString("%L1").arg(vect.y, 0, 'g', 16);
								break;

							case 'z':
								qtext = QString("%L1").arg(vect.z, 0, 'g', 16);
								break;

							case 'w':
								qtext = QString("%L1").arg(vect.w, 0, 'g', 16);
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect
										<< " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						lineEdit->setText(qtext);
						lineEdit->setCursorPosition(0);
					}
				}

				//---------- get double scalars --------
				else if (type == QString("edit") || type == QString("logedit"))
				{
					if (mode == read)
					{
						double value = systemData.locale.toDouble(lineEdit->text());
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						double value = par->Get<double>(parameterName);
						lineEdit->setText(QString("%L1").arg(value, 0, 'g', 16));
						lineEdit->setCursorPosition(0);
					}
				}

				//----------- get texts ------------
				else if (type == QString("text"))
				{
					if (mode == read)
					{
						QString value = lineEdit->text();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						QString value = par->Get<QString>(parameterName);
						lineEdit->setText(value);
					}
				}
			}
		} //end foreach
	}

	WriteLog("cInterface::SynchronizeInterface: QDoubleSpinBox", 3);
	//------------ Double spin-box --------------
	{
		QList<QDoubleSpinBox *> widgetListDoubleSpinBox = window->findChildren<QDoubleSpinBox*>();
		QList<QDoubleSpinBox *>::iterator it;
		for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "QDoubleSpinBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QDoubleSpinBox") || className == QString("MyDoubleSpinBox")))
			{
				QDoubleSpinBox *spinbox = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (className == QString("MyDoubleSpinBox"))
				{
					MyDoubleSpinBox *mydoublespinbox = (MyDoubleSpinBox*) *it;
					mydoublespinbox->AssignParameterContainer(par);
					mydoublespinbox->AssingParameterName(parameterName);
				}

				if (type == QString("spinbox") || type == QString("spinboxd"))
				{
					if (mode == read)
					{
						double value = spinbox->value();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						double value = par->Get<double>(parameterName);
						spinbox->setValue(value);
					}
				}
				else if (type == QString("spinbox3") || type == QString("spinboxd3"))
				{
					char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1();
					QString nameVect = parameterName.left(parameterName.length() - 2);
					if (mode == read)
					{
						double value = spinbox->value();
						CVector3 vect = par->Get<CVector3>(nameVect);

						switch (lastChar)
						{
							case 'x':
								vect.x = value;
								break;

							case 'y':
								vect.y = value;
								break;

							case 'z':
								vect.z = value;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " "
										<< nameVect << " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						par->Set(nameVect, vect);
					}
					else if (mode == write)
					{
						CVector3 vect = par->Get<CVector3>(nameVect);
						double value = 0;

						switch (lastChar)
						{
							case 'x':
								value = vect.x;
								break;

							case 'y':
								value = vect.y;
								break;

							case 'z':
								value = vect.z;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " "
										<< nameVect << " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						spinbox->setValue(value);
					}
				}
				else if (type == QString("spinbox4") || type == QString("spinboxd4"))
				{
					char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1();
					QString nameVect = parameterName.left(parameterName.length() - 2);
					if (mode == read)
					{
						double value = spinbox->value();
						CVector4 vect = par->Get<CVector4>(nameVect);

						switch (lastChar)
						{
							case 'x':
								vect.x = value;
								break;

							case 'y':
								vect.y = value;
								break;

							case 'z':
								vect.z = value;
								break;

							case 'w':
								vect.w = value;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " "
										<< nameVect << " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						par->Set(nameVect, vect);
					}
					else if (mode == write)
					{
						CVector4 vect = par->Get<CVector4>(nameVect);
						double value = 0;

						switch (lastChar)
						{
							case 'x':
								value = vect.x;
								break;

							case 'y':
								value = vect.y;
								break;

							case 'z':
								value = vect.z;
								break;

							case 'w':
								value = vect.w;
								break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " "
										<< nameVect << " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						spinbox->setValue(value);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: QSpinBox", 3);
	//------------ integer spin-box --------------
	{
		QList<QSpinBox *> widgetListDoubleSpinBox = window->findChildren<QSpinBox*>();
		QList<QSpinBox *>::iterator it;
		for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "QDoubleSpinBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QSpinBox") || className == QString("MySpinBox")))
			{
				QSpinBox *spinbox = *it;
				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (className == QString("MySpinBox"))
				{
					MySpinBox *myspinbox = (MySpinBox*) *it;
					myspinbox->AssignParameterContainer(par);
					myspinbox->AssingParameterName(parameterName);
				}

				if (type == QString("spinboxInt"))
				{
					if (mode == read)
					{
						int value = spinbox->value();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						int value = par->Get<int>(parameterName);
						spinbox->setValue(value);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: QCheckBox", 3);
	//checkboxes
	{
		QList<QCheckBox *> widgetListDoubleSpinBox = window->findChildren<QCheckBox*>();
		QList<QCheckBox *>::iterator it;
		for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "QCheckBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QCheckBox") || className == QString("MyCheckBox")))
			{
				QCheckBox *checkbox = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (className == QString("MyCheckBox"))
				{
					MyCheckBox *mycheckbox = (MyCheckBox*) *it;
					mycheckbox->AssignParameterContainer(par);
					mycheckbox->AssingParameterName(parameterName);
				}

				if (type == QString("checkBox"))
				{
					if (mode == read)
					{
						bool value = checkbox->isChecked();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						bool value = par->Get<bool>(parameterName);
						checkbox->setChecked(value);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: QGroupBox", 3);
	//groupsBox with checkbox
	{
		QList<QGroupBox *> widgetListDoubleSpinBox = window->findChildren<QGroupBox*>();
		QList<QGroupBox *>::iterator it;
		for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "QGroupBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QGroupBox") || className == QString("MyGroupBox")))
			{
				QGroupBox *groupbox = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (className == QString("MyGroupBox"))
				{
					MyGroupBox *mygroupbox = (MyGroupBox*) *it;
					mygroupbox->AssignParameterContainer(par);
					mygroupbox->AssingParameterName(parameterName);
				}

				if (type == QString("groupCheck"))
				{
					if (mode == read)
					{
						bool value = groupbox->isChecked();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						bool value = par->Get<bool>(parameterName);
						groupbox->setChecked(value);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: FileSelectWidget", 3);
	//---------- file select widgets -----------
	{
		QList<FileSelectWidget *> widgetListPushButton = window->findChildren<FileSelectWidget*>();
		QList<FileSelectWidget *>::iterator it;
		for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it)
		{
			QString name = (*it)->objectName();
			// QString className = (*it)->metaObject()->className();
			if (name.length() > 1 && (*it)->metaObject()->className() == QString("FileSelectWidget"))
			{
				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				FileSelectWidget *fileSelectWidget = *it;
				fileSelectWidget->AssignParameterContainer(par);
				fileSelectWidget->AssingParameterName(parameterName);

				if (mode == read)
				{
					par->Set(parameterName, fileSelectWidget->GetPath());
				}
				else if (mode == write)
				{
					fileSelectWidget->SetPath(par->Get<QString>(parameterName));
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: MyColorButton", 3);
	//---------- color buttons -----------
	{
		QList<MyColorButton *> widgetListPushButton = window->findChildren<MyColorButton*>();
		QList<MyColorButton *>::iterator it;
		for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it)
		{
			QString name = (*it)->objectName();
			// QString className = (*it)->metaObject()->className();
			if (name.length() > 1 && (*it)->metaObject()->className() == QString("MyColorButton"))
			{
				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				MyColorButton *colorButton = *it;
				colorButton->AssignParameterContainer(par);
				colorButton->AssingParameterName(parameterName);

				if (mode == read)
				{
					par->Set(parameterName, colorButton->GetColor());
				}
				else if (mode == write)
				{
					colorButton->setText("");
					colorButton->SetColor(par->Get<sRGB>(parameterName));
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: ColorPaletteWidget", 3);
	//---------- colorpalette -----------
	{
		QList<ColorPaletteWidget *> widgetListColorPalette =
				window->findChildren<ColorPaletteWidget*>();
		QList<ColorPaletteWidget *>::iterator it;
		for (it = widgetListColorPalette.begin(); it != widgetListColorPalette.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "ColorPalette:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			if (name.length() > 1 && (*it)->metaObject()->className() == QString("ColorPaletteWidget"))
			{
				ColorPaletteWidget *colorPaletteWidget = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				colorPaletteWidget->AssignParameterContainer(par);
				colorPaletteWidget->AssingParameterName(parameterName);

				if (type == QString("colorpalette"))
				{
					if (mode == read)
					{
						cColorPalette palette = colorPaletteWidget->GetPalette();
						par->Set(parameterName, palette);
					}
					else if (mode == write)
					{
						cColorPalette palette = par->Get<cColorPalette>(parameterName);
						colorPaletteWidget->SetPalette(palette);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: QComboBox", 3);
	//combo boxes
	{
		QList<QComboBox *> widgetListPushButton = window->findChildren<QComboBox*>();
		QList<QComboBox *>::iterator it;
		for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it)
		{
			QString name = (*it)->objectName();
			//qDebug() << "QComboBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl;
			if (name.length() > 1 && (*it)->metaObject()->className() == QString("QComboBox"))
			{
				QComboBox *comboBox = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (type == QString("comboBox"))
				{
					if (mode == read)
					{
						int selection = comboBox->currentIndex();
						if (parameterName.left(7) == QString("formula"))
						{
							selection = fractalList[comboBox->itemData(selection).toInt()].internalID;
						}
						par->Set(parameterName, selection);
					}
					else if (mode == write)
					{
						int selection = par->Get<int>(parameterName);
						if (parameterName.left(7) == QString("formula"))
						{
							for (int i = 0; i < fractalList.size(); i++)
							{
								if (fractalList[i].internalID == selection)
								{
									selection = comboBox->findData(i);
									break;
								}
							}
						}
						comboBox->setCurrentIndex(selection);
					}
				}
			}
		}
	}

	WriteLog("cInterface::SynchronizeInterface: cMaterialSelector", 3);
	//---------- material selector -----------
	{
		QList<cMaterialSelector *> widgetListMaterialSelector =
				window->findChildren<cMaterialSelector*>();
		QList<cMaterialSelector *>::iterator it;
		for (it = widgetListMaterialSelector.begin(); it != widgetListMaterialSelector.end(); ++it)
		{
			QString name = (*it)->objectName();
			// QString className = (*it)->metaObject()->className();
			if (name.length() > 1 && (*it)->metaObject()->className() == QString("cMaterialSelector"))
			{
				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				cMaterialSelector *materialSelector = *it;
				materialSelector->AssignParameterContainer(par);
				materialSelector->AssingParameterName(parameterName);

				if (type == QString("materialselector"))
				{
					if (mode == read)
					{
						par->Set(parameterName, materialSelector->GetMaterialIndex());
					}
					else if (mode == write)
					{
						materialSelector->SetMaterialIndex(par->Get<int>(parameterName));
					}
				}
			}
		}
	}
	WriteLog("cInterface::SynchronizeInterface: Done", 3);
}
コード例 #28
0
void LDViewExportOption::populate(void)
{
	QWidget *parent;
	parent = m_box;
    LDExporterSettingList &settings = m_exporter->getSettings();
    LDExporterSettingList::iterator it;

	if (m_box != NULL)
	{
//		scrollArea->removeChild(m_box);
		scrollArea->adjustSize();
		delete m_box;
	}
	m_box = new QWidget(scrollArea);
	m_box->setObjectName("m_box");
	m_lay = new QVBoxLayout();
	m_lay->setObjectName("m_lay");
	m_lay->setMargin(11);
	m_lay->setSpacing(4);
	m_box->setLayout(m_lay);
	QVBoxLayout *vbl= NULL;
    std::stack<int> groupSizes;
	std::stack<QWidget *> parents;
    int groupSize = 0;
    for (it = settings.begin(); it != settings.end(); it++)
    {
        bool inGroup = groupSize > 0;

        if (groupSize > 0)
        {
            groupSize--;
            if (groupSize == 0)
            {
                // We just got to the end of a group, so pop the previous
                // groupSize value off the groupSizes stack.
                groupSize = groupSizes.top();
                groupSizes.pop();
				parent = parents.top();
				parents.pop();
//				vbl = new QVBoxLayout(parent->layout());
				//vbl = NULL;
            }
        }
        if (it->getGroupSize() > 0)
        {
            // This item is the start of a group.
            if (inGroup)
            {
                // At the beginning of this iteration we were in a group, so
                // use a bool setting instead of a group setting.
				QString qstmp;
				ucstringtoqstring(qstmp,it->getName());

				QCheckBox *check;
				check = new QCheckBox(qstmp,parent);
				check->setObjectName(qstmp);
				check->setChecked(it->getBoolValue());
				m_settings[&*it] = check;
				if (vbl)
				{
					vbl->addWidget(check);
					m_groups[vbl][&*it] = check;
				}
            }
            else
            {
                // Top level group; use a group setting.
				if (vbl)
				{
                	QSpacerItem *sp = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
                	QHBoxLayout *hbox;
                	QPushButton *rg;
                	hbox = new QHBoxLayout();
                	rg = new QPushButton("Reset Group");
                	hbox->addItem(sp);
                	hbox->addWidget(rg);
					rg->setObjectName("Reset Group");
                	vbl->addLayout(hbox);
					connect( rg, SIGNAL( clicked() ), this, SLOT( doResetGroup() ) );
				}
				QString qstmp;
				ucstringtoqstring(qstmp,it->getName());
				QGroupBox *gb;
				gb = new QGroupBox (qstmp, m_box);
				gb->setObjectName(qstmp);
				m_lay->addWidget(gb);
				vbl = new QVBoxLayout(gb);
				gb->setLayout(vbl);
				parent=gb;
				if (it->getType() == LDExporterSetting::TBool)
				{
					gb->setCheckable(true);
					gb->setChecked(it->getBoolValue());
					m_settings[&*it] = gb;
					m_groups[vbl][&*it] = gb;
				}
            }
			parents.push(parent);
            // We're now in a new group, so push the current groupSize onto
            // the groupSizes stack.
            groupSizes.push(groupSize);
            // Update groupSize based on the new group's size.
            groupSize = it->getGroupSize();
        }
        else
        {
            // This setting isn't the start of a group; add the appropriate type
            // of option UI to the canvas.
			QString qstmp;
			ucstringtoqstring(qstmp,it->getName());
			QHBoxLayout *hbox;
			QVBoxLayout *vbox;
			QLineEdit *li;
			QLabel *label;
			QHBoxLayout *hbox2;
			QCheckBox *check;
			hbox = new QHBoxLayout();
			hbox->setSpacing(4);
            switch (it->getType())
            {
            case LDExporterSetting::TBool:
				check = new QCheckBox(qstmp);
				check->setChecked(it->getBoolValue());
				check->setObjectName(qstmp);
				hbox->addWidget(check);
				m_settings[&*it] = check;
				if (vbl != NULL)
				{
					m_groups[vbl][&*it] = check;
				}
                break;
            case LDExporterSetting::TFloat:
            case LDExporterSetting::TLong:
				// Long and float are intentionally handeled the same.
				label = new QLabel(qstmp);
				label->setObjectName(qstmp);
				hbox->addWidget(label);
				li = new QLineEdit(qstmp);
				li->setObjectName(qstmp);
				hbox->addWidget(li);
				ucstringtoqstring(qstmp,it->getStringValue());
				li->setText(qstmp);
				m_settings[&*it] = li;
				if (vbl != NULL)
				{
					m_groups[vbl][&*it] = li;
				}
                break;
            case LDExporterSetting::TString:
				vbox = new QVBoxLayout();
				vbox->setSpacing(4);
				hbox->addLayout(vbox);
				label = new QLabel(qstmp);
				vbox->addWidget(label);
				hbox2 = new QHBoxLayout();
				hbox2->setSpacing(4);
				vbox->addLayout(hbox2);
				li = new QLineEdit(qstmp);
				hbox2->addWidget(li);
				ucstringtoqstring(qstmp,it->getStringValue());
				li->setText(qstmp);
				m_settings[&*it] = li;
				if (vbl != NULL)
				{
					m_groups[vbl][&*it] = li;
				}
				if (it->isPath())
				{
					QPushButton *but = new QPushButton();
					but->setText(TCObject::ls("LDXBrowse..."));
					hbox2->addWidget(but);
					connect( but, SIGNAL( clicked() ), this, SLOT( doBrowse()));
					m_button[but]=li;
				}
                break;
            case LDExporterSetting::TEnum:
				vbox = new QVBoxLayout();
				vbox->setSpacing(4);
				hbox->addLayout(vbox);
                label = new QLabel(qstmp);
		vbox->addWidget(label);
				QComboBox *combo;
				combo = new QComboBox();
				vbox->addWidget(combo);
				for (size_t i = 0; i < it->getOptions().size(); i++)
				{
					ucstringtoqstring(qstmp,it->getOptions()[i]);
					combo->addItem(qstmp);
				}
				combo->setCurrentIndex(it->getSelectedOption());
				m_settings[&*it] = combo;
				if (vbl != NULL)
				{
					m_groups[vbl][&*it] = combo;
				}
                break;
            default:
                throw "not implemented";
            }
			if (it->getTooltip().size() > 0)
			{
				ucstringtoqstring(qstmp, it->getTooltip());
				//QToolTip::add(hbox, qstmp);
			}
			if (vbl) vbl->addLayout(hbox);
        }
	}
    if (vbl)
    {
        QSpacerItem *sp = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
        QHBoxLayout *hbox;
        QPushButton *rg;
        hbox = new QHBoxLayout();
        rg = new QPushButton("Reset Group");
		rg->setObjectName("Reset Group");
        hbox->addItem(sp);
        hbox->addWidget(rg);
        vbl->addLayout(hbox);
		connect( rg, SIGNAL( clicked() ), this, SLOT( doResetGroup() ) );
    }

	m_lay->addStretch();
	scrollArea->setWidget(m_box);
	m_box->adjustSize();
	scrollArea->adjustSize();
//	resize(width() + m_box->width() - scrollArea->visibleWidth(), height());
	setFixedWidth(width());
}
コード例 #29
0
void UIPropertySetters::DefaultSetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType propertyType, QVariant propertyValue)
{
	switch (editorType)
	{
		case SettingsPropertyMapper::CHECKBOX:
		{
			QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(editor);
			if (pCheckBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::BOOL)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pCheckBox->setChecked(propertyValue.toBool());
			break;
		}
		case SettingsPropertyMapper::RADIOBUTTON:
		{
			QRadioButton* pRadioButton = qobject_cast<QRadioButton*>(editor);
			if (pRadioButton == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::BOOL)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pRadioButton->setChecked(propertyValue.toBool());
			break;
		}
		case SettingsPropertyMapper::CHECKABLE_GROUPBOX:
		{
			QGroupBox* pGroupBox = qobject_cast<QGroupBox*>(editor);
			if (pGroupBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (!pGroupBox->isCheckable())
			{
				qCritical() << "Given QGroupBox is not checkable";
			}
			if (propertyType != SettingsPropertyMapper::BOOL)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pGroupBox->setChecked(propertyValue.toBool());
			break;
		}
		case SettingsPropertyMapper::LINE_EDIT:
		{
			QLineEdit* pLineEdit = qobject_cast<QLineEdit*>(editor);
			if (pLineEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType == SettingsPropertyMapper::STRING || propertyType == SettingsPropertyMapper::INT)
			{
				pLineEdit->setText(propertyValue.toString());
			}
			else
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
			}
			break;
		}
		case SettingsPropertyMapper::TEXT_EDIT:
		{
			QTextEdit* pTextEdit = qobject_cast<QTextEdit*>(editor);
			if (pTextEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::STRING)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pTextEdit->setText(propertyValue.toString());
			break;
		}
		case SettingsPropertyMapper::COMBOBOX:
		{
			QComboBox* pComboBox = qobject_cast<QComboBox*>(editor);
			if (pComboBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::INT)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pComboBox->setCurrentIndex(propertyValue.toInt());
			break;
		}
		case SettingsPropertyMapper::SPINBOX:
		{
			QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor);
			if (pSpinBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::INT)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pSpinBox->setValue(propertyValue.toInt());
			break;
		}
		case SettingsPropertyMapper::DOUBLE_SPINBOX:
		{
			QDoubleSpinBox* pDoubleSpinBox = qobject_cast<QDoubleSpinBox*>(editor);
			if (pDoubleSpinBox == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::DOUBLE)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pDoubleSpinBox->setValue(propertyValue.toDouble());
			break;
		}
		case SettingsPropertyMapper::TIME_EDIT:
		{
			QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor);
			if (pTimeEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::TIME)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pTimeEdit->setTime(propertyValue.toTime());
			break;
		}
		case SettingsPropertyMapper::DATETIME_EDIT:
		{
			QDateTimeEdit* pDateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
			if (pDateTimeEdit == NULL)
			{
				qCritical() << "Invalid editor given";
				return;
			}
			if (propertyType != SettingsPropertyMapper::DATETIME)
			{
				qCritical() << "Unable to set value with default setter for property using value" << propertyValue;
				return;
			}
			pDateTimeEdit->setDateTime(propertyValue.toDateTime());
			break;
		}
		default: break;
	}
}
コード例 #30
0
void QgsPropertyOverrideButton::updateSiblingWidgets( bool state )
{

  Q_FOREACH ( const SiblingWidget &sw, mSiblingWidgets )
  {
    switch ( sw.mSiblingType )
    {

      case SiblingCheckState:
      {
        // don't uncheck, only set to checked
        if ( state )
        {
          QAbstractButton *btn = qobject_cast< QAbstractButton * >( sw.mWidgetPointer.data() );
          if ( btn && btn->isCheckable() )
          {
            btn->setChecked( sw.mNatural ? state : !state );
          }
          else
          {
            QGroupBox *grpbx = qobject_cast< QGroupBox * >( sw.mWidgetPointer.data() );
            if ( grpbx && grpbx->isCheckable() )
            {
              grpbx->setChecked( sw.mNatural ? state : !state );
            }
          }
        }
        break;
      }

      case SiblingEnableState:
      {
        QLineEdit *le = qobject_cast< QLineEdit * >( sw.mWidgetPointer.data() );
        if ( le )
          le->setReadOnly( sw.mNatural ? !state : state );
        else
          sw.mWidgetPointer.data()->setEnabled( sw.mNatural ? state : !state );
        break;
      }

      case SiblingVisibility:
      {
        sw.mWidgetPointer.data()->setVisible( sw.mNatural ? state : !state );
        break;
      }

      case SiblingExpressionText:
      {
        QLineEdit *le = qobject_cast<QLineEdit *>( sw.mWidgetPointer.data() );
        if ( le )
        {
          le->setText( mProperty.asExpression() );
        }
        else
        {
          QTextEdit *te = qobject_cast<QTextEdit *>( sw.mWidgetPointer.data() );
          if ( te )
          {
            te->setText( mProperty.asExpression() );
          }
        }
        break;
      }

      default:
        break;
    }


  }
}