ConfirmAddressConfigureTabWidget::ConfirmAddressConfigureTabWidget(QWidget *parent) : QWidget(parent), mIdentity(0) { QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setMargin(0); QGroupBox *groupBoxDomainName = new QGroupBox(this); groupBoxDomainName->setObjectName(QStringLiteral("groupboxdomainname")); mainLayout->addWidget(groupBoxDomainName); QVBoxLayout *layoutDomainName = new QVBoxLayout(groupBoxDomainName); layoutDomainName->setObjectName(QStringLiteral("layoutdomainname")); QHBoxLayout *radioButtonLayout = new QHBoxLayout; layoutDomainName->addLayout(radioButtonLayout); radioButtonLayout->setAlignment(Qt::AlignHCenter); mAcceptedDomain = new QRadioButton(i18n("Accepted Domain Name"), this); mAcceptedDomain->setObjectName(QStringLiteral("acceptdomainname")); radioButtonLayout->addWidget(mAcceptedDomain); mAcceptedDomain->setChecked(true); mRejectedDomain = new QRadioButton(i18n("Rejected Domain Name"), this); mRejectedDomain->setObjectName(QStringLiteral("rejectdomainname")); radioButtonLayout->addWidget(mRejectedDomain); PimCommon::SimpleStringListEditor::ButtonCode buttonCode = static_cast<PimCommon::SimpleStringListEditor::ButtonCode>(PimCommon::SimpleStringListEditor::Add | PimCommon::SimpleStringListEditor::Remove | PimCommon::SimpleStringListEditor::Modify); mDomainNameListEditor = new PimCommon::SimpleStringListEditor(groupBoxDomainName, buttonCode, i18n("A&dd..."), i18n("Re&move"), i18n("Mod&ify..."), i18n("Enter new domain name:")); mDomainNameListEditor->setObjectName(QStringLiteral("domainnamelisteditor")); connect(mDomainNameListEditor, &PimCommon::SimpleStringListEditor::changed, this, &ConfirmAddressConfigureTabWidget::configureChanged); layoutDomainName->addWidget(mDomainNameListEditor); QGroupBox *groupBoxWhiteList = new QGroupBox(i18n("Whitelist of Addresses"), this); groupBoxWhiteList->setObjectName(QStringLiteral("groupboxwhitelist")); mainLayout->addWidget(groupBoxWhiteList); QVBoxLayout *layoutWhiteList = new QVBoxLayout(groupBoxWhiteList); layoutWhiteList->setObjectName(QStringLiteral("layoutwhitelist")); buttonCode = static_cast<PimCommon::SimpleStringListEditor::ButtonCode>(PimCommon::SimpleStringListEditor::Add | PimCommon::SimpleStringListEditor::Remove | PimCommon::SimpleStringListEditor::Modify); mWhiteListEditor = new PimCommon::SimpleStringListEditor(groupBoxWhiteList, buttonCode, i18n("A&dd..."), i18n("Re&move"), i18n("Mod&ify..."), i18n("Enter new email address:")); mWhiteListEditor->setObjectName(QStringLiteral("whitelisteditor")); layoutWhiteList->addWidget(mWhiteListEditor); connect(mWhiteListEditor, &PimCommon::SimpleStringListEditor::changed, this, &ConfirmAddressConfigureTabWidget::configureChanged); }
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); }
QGroupBox *Combat::createPlayerBox(QList<Thing*> tempThings, int PlayerID) { QString temp = "Player " + QString::number(PlayerID) + " Things"; QGroupBox *groupBox = new QGroupBox(temp); QGridLayout *vbox = new QGridLayout(); QList<QPushButton*> tempButton; for(int i = 0; i < tempThings.size(); i++) { QPushButton *button = new QPushButton; button->setObjectName(QString::number(tempThings.at(i)->getID())); QString temp = "border-image: url(" + tempThings.at(i)->getUrl(); button->setStyleSheet(temp + ")"); button->setFixedSize(80,80); connect(button,SIGNAL(clicked()),this,SLOT(buttonClickedSlot())); tempButton.push_back(button); } for(int i = 0; i < tempButton.size(); i++) { if(i < 5) { vbox->addWidget(tempButton.at(i),0,i); } else { vbox->addWidget(tempButton.at(i),1,i%5); } } groupBox->setObjectName(QString::number(PlayerID)); groupBox->setLayout(vbox); return groupBox; }
void MainWindow::createStartAppDialog() { startAppDialog = new QDialog( this ); startAppDialog->setObjectName( "main startapp" ); startAppDialog->setWindowTitle( "Start new application" ); // main layout QVBoxLayout *layout = new QVBoxLayout( startAppDialog ); layout->setObjectName("main find"); // group box with title QGroupBox *groupBox = new QGroupBox(); groupBox->setObjectName("main start app group"); groupBox->setTitle( "Start Application:" ); // groupBox layout QGridLayout *groupBoxLayout = new QGridLayout( groupBox ); groupBoxLayout->setObjectName("main start app group"); // widgets startAppDialogTextLineEdit = new QLineEdit(this); startAppDialogWithTestability = new QCheckBox( "With -&testability argument" ); startAppDialogWithTestability->setObjectName("main startapp withtestability"); startAppDialogWithTestability->setCheckState( Qt::Checked ); startAppDialogStartButton = new QPushButton( "&Start", this ); startAppDialogStartButton->setObjectName("main startapp start"); startAppDialogStartButton->setDisabled(true); startAppDialogStartButton->setDefault( false ); startAppDialogStartButton->setAutoDefault( false ); startAppDialogCloseButton = new QPushButton( "&Close", this ); startAppDialogCloseButton->setObjectName("main startapp close"); startAppDialogCloseButton->setDefault( false ); startAppDialogCloseButton->setAutoDefault( false ); // layout placement groupBoxLayout->addWidget( startAppDialogTextLineEdit, 0, 0, 1, 3); groupBoxLayout->addWidget( startAppDialogWithTestability, 1, 0); groupBoxLayout->addWidget( startAppDialogStartButton, 1, 1); groupBoxLayout->addWidget( startAppDialogCloseButton, 1, 2 ); layout->addWidget( groupBox ); // signals to slots connect( startAppDialogTextLineEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( startAppDialogEnableStartButton(const QString &) ) ); connect( startAppDialogTextLineEdit, SIGNAL( returnPressed() ), this, SLOT( startAppDialogReturnPress() ) ); connect( startAppDialogStartButton, SIGNAL( clicked() ), this, SLOT( startApp() ) ); connect( startAppDialogCloseButton, SIGNAL( clicked() ), this, SLOT( closeStartAppDialog() ) ); }
void ScrollableTextDisplay1::setupUI(){ ui->allRoutesScrollArea->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); ui->allRoutesscrollAreaWidgetContents->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); QGroupBox *wrapper = new QGroupBox(); wrapper->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); wrapper->setObjectName("wrapperGroupBox"); QVBoxLayout *wrapperVerticalLayout = new QVBoxLayout; wrapperVerticalLayout->setObjectName("wrapperVerticalLayout"); QString widgetName = "displayGLText1RouteWidget_"; QSpacerItem *verticalSpacer = new QSpacerItem(0,50); int totalNumberOfRows = 0; Route tempRoute; SubRoute tempSubRoute; //generate as many GL widgets as there are number of routes for(int i = 0 ; i < allRoutes->getRoutes().size(); i++){ totalNumberOfRows = 0; //calculate size here tempRoute = allRoutes->getRoutes().at(i); for(int j = 0 ; j < tempRoute.getSubRoutes().size(); j++){ tempSubRoute = tempRoute.getSubRoutes().at(j); totalNumberOfRows += tempSubRoute.getLegs().size(); } QSize glWindowSize; glWindowSize.setHeight((totalNumberOfRows + 2)*heightPerRow); // +2 is for the top and bottom margins which will have same height as the rows glWindowSize.setWidth(0); // This is dummy, the actual value is set in the widget itself DisplayGLText1RouteWidget *displayGLText1RouteWidget = new DisplayGLText1RouteWidget((allRoutes->getRoutes().at(i)),glWindowSize, heightPerRow); displayGLText1RouteWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); displayGLText1RouteWidget->setObjectName(widgetName + QString::number(i)); wrapperVerticalLayout->addWidget(displayGLText1RouteWidget); wrapperVerticalLayout->addSpacerItem(verticalSpacer); } wrapper->setLayout(wrapperVerticalLayout); ui->allRoutesScrollArea->setWidget(wrapper); }
//selectedFeaturesPage::selectedFeaturesPage(QButtonGroup *fGroup, QWidget *parent) // : QWizardPage(parent) //{ // setTitle(tr("Selected Features")); // // QVBoxLayout *layout = new QVBoxLayout; // layout->addWidget( initFeatureBox(fGroup) ); // setLayout(layout); //} QGroupBox * FeaturesPage::initFeatureBox(QButtonGroup *fGroup) { featureGroup = fGroup; QGroupBox *groupBox = new QGroupBox(tr("Features")); groupBox->setObjectName("Features"); QVBoxLayout *featureLayout = new QVBoxLayout; QHBoxLayout *selLayout = new QHBoxLayout; QLabel *selLabel = new QLabel(tr("Select:")); QPushButton *allButton = new QPushButton(tr("All")); allButton->setObjectName("allButton"); QPushButton *nonButton = new QPushButton(tr("None")); nonButton->setObjectName("nonButton"); connect(allButton, SIGNAL(clicked()), this, SLOT(selectAll())); connect(nonButton, SIGNAL(clicked()), this, SLOT(selectNone())); selLayout->addWidget(selLabel); selLayout->addWidget(allButton); selLayout->addWidget(nonButton); selLayout->addStretch(10); featureLayout->addLayout(selLayout); QWidget *groupWidget = new QWidget; groupWidget->setObjectName("groupWidget"); QVBoxLayout *vLayout = new QVBoxLayout; QList<QAbstractButton *> buttons = featureGroup->buttons(); for(int b = 0; b<buttons.size(); ++b) { vLayout->addWidget( buttons.at(b) ); } groupWidget->setLayout(vLayout); QScrollArea *scrollArea = new QScrollArea; scrollArea->setObjectName("scrollArea"); scrollArea->setWidget(groupWidget); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); featureLayout->addWidget(scrollArea); groupBox->setLayout(featureLayout); return groupBox; }
void RecipeWidget::updateIngredients(float servings) { if (servings <= 0) { servings = recipe->getServings(); } for (QGroupBox* box : ingredientBoxes) { box->setVisible(false); box->deleteLater(); } ingredientBoxes.clear(); //Ingredients for (DataTypes::IngredientList group : recipe->getIngredientGroups().groups) { QGroupBox *ingredientBox = new QGroupBox(group.header); ingredientBoxes.append(ingredientBox); ingredientBox->setObjectName("ingredientTopic"); QGridLayout *layout = new QGridLayout; ingredientBox->setLayout(layout); int i = 0; for (DataTypes::Ingredient ingredient : group.ingredients) { QString a = QString::number(servings * ingredient.amount / recipe->getServings()); QString u(ingredient.unit); if (a.toFloat() == 0) a = ""; QLabel *amount = new QLabel(a + " " + u); amount->setObjectName("text"); QLabel *name = new QLabel(ingredient.name + ingredient.usageInfo); name->setObjectName("text"); layout->addWidget(amount, i, 0, 1, 1, Qt::AlignRight); layout->addWidget(name, i, 1, 1, 1, Qt::AlignLeft); //cout << amount.toStdString() << " " << name.toStdString() << endl; i++; } ui->ingredientsLayout->addWidget(ingredientBox); } }
void CQGnuPlotCreateDialog:: createWidgets(QWidget *) { typeCombo_ = new CQEnumCombo(this, enum_, "objectType"); typeCombo_->setItemText(int(CQGnuPlotEnum::ObjectTypeNone ), "None"); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypeArrow ), "Arrow" , CQPixmapCacheInst->getIcon("ARROW_OBJ")); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypeCircle ), "Circle" , CQPixmapCacheInst->getIcon("CIRCLE_OBJ")); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypeEllipse ), "Ellipse" , CQPixmapCacheInst->getIcon("ELLIPSE_OBJ")); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypeLabel ), "Label" , CQPixmapCacheInst->getIcon("LABEL_OBJ")); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypePolygon ), "Polygon" , CQPixmapCacheInst->getIcon("POLYGON_OBJ")); typeCombo_->setItemData(int(CQGnuPlotEnum::ObjectTypeRectangle), "Rectangle", CQPixmapCacheInst->getIcon("RECTANGLE_OBJ")); connect(typeCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(typeSlot(int))); addField("Type", typeCombo_, true); dimensionGroup_ = addRadioButtons("Dimension", {"2D", "3D"}, this, SLOT(dimensionSlot())); //--- QGroupBox *strokeGroup = new QGroupBox("Stroke"); strokeGroup->setObjectName("strokeGroup"); addField("", strokeGroup); QVBoxLayout *strokeLayout = new QVBoxLayout(strokeGroup); strokeLayout->setMargin(0); strokeLayout->setSpacing(0); CQDialogForm *strokeFrame = new CQDialogForm; strokeFrame->setObjectName("strokeForm"); strokeLayout->addWidget(strokeFrame); strokeFrame->addField("Color", (strokeColor_ = new CQColorChooser)); strokeFrame->addField("Width", (strokeWidth_ = new CQIntegerSpin)); strokeFrame->addField("Dash" , (strokeDash_ = new CQLineDash)); strokeColor_->setColor(QColor(0,0,0)); strokeWidth_->setValue(1); strokeColor_->setStyles(CQColorChooser::Text | CQColorChooser::ColorButton); //--- QGroupBox *fillGroup = new QGroupBox("Fill"); fillGroup->setObjectName("fillGroup"); addField("", fillGroup); QVBoxLayout *fillLayout = new QVBoxLayout(fillGroup); fillLayout->setMargin(0); fillLayout->setSpacing(0); CQDialogForm *fillFrame = new CQDialogForm; fillFrame->setObjectName("fillForm"); fillLayout->addWidget(fillFrame); fillFrame->addField("Color", (fillColor_ = new CQColorChooser)); fillColor_->setStyles(CQColorChooser::Text | CQColorChooser::ColorButton); //--- stack_ = new QStackedWidget; stack_->setObjectName("stack"); addField("", stack_); arrowFrame_ = new CQDialogForm; arrowFrame_ ->setObjectName("arrowForm"); circleFrame_ = new CQDialogForm; circleFrame_ ->setObjectName("circleForm"); ellipseFrame_ = new CQDialogForm; ellipseFrame_->setObjectName("ellipseForm"); labelFrame_ = new CQDialogForm; labelFrame_ ->setObjectName("labelForm"); polyFrame_ = new CQDialogForm; polyFrame_ ->setObjectName("polyForm"); rectFrame_ = new CQDialogForm; rectFrame_ ->setObjectName("rectForm"); stack_->addWidget(arrowFrame_ ); stack_->addWidget(circleFrame_ ); stack_->addWidget(ellipseFrame_); stack_->addWidget(labelFrame_ ); stack_->addWidget(polyFrame_ ); stack_->addWidget(rectFrame_ ); arrowFrame_->addField("From", (arrowFrom_ = new CQGnuPlotPositionEdit), true); arrowFrame_->addField("To" , (arrowTo_ = new CQGnuPlotPositionEdit), true); arrowFrame_->addStretch(); circleFrame_->addField("Center" , (circleCenter_ = new CQGnuPlotPositionEdit)); circleFrame_->addField("Radius" , (circleRadius_ = new CQRealSpin)); circleFrame_->addField("Start Angle", (circleStart_ = new CQAngleSpinBox)); circleFrame_->addField("End Angle" , (circleEnd_ = new CQAngleSpinBox)); circleFrame_->addStretch(); circleRadius_->setValue(1); circleStart_ ->setAngle(CAngle( 0)); circleEnd_ ->setAngle(CAngle(360)); ellipseFrame_->addField("Center", (ellipseCenter_ = new CQGnuPlotPositionEdit)); ellipseFrame_->addField("Angle" , (ellipseAngle_ = new CQAngleSpinBox)); ellipseFrame_->addStretch(); labelFrame_->addField("Origin", (labelOrigin_ = new CQGnuPlotPositionEdit)); labelFrame_->addField("Text" , (labelText_ = new QLineEdit)); labelFrame_->addField("Angle" , (labelAngle_ = new CQAngleSpinBox)); labelFrame_->addStretch(); polyFrame_->addCheckBox("Polygon"); rectFrame_->addField("From", (rectFrom_ = new CQGnuPlotPositionEdit)); rectFrame_->addField("To" , (rectTo_ = new CQGnuPlotPositionEdit)); rectFrame_->addStretch(); addStretch(); }
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()); }
QWidget* WidgetStyle::createWidget(const QString& name) { if(name == "CheckBox") { QCheckBox* box = new QCheckBox("CheckBox"); box->setObjectName("CheckBox"); return setLayoutWidget({ box }, { 100, 30 }); } else if(name == "ComboBox") { QComboBox* box = new QComboBox; box->addItem("Item1"); box->addItem("Item3"); box->addItem("Item3"); box->setObjectName("ComboBox"); return setLayoutWidget({ box }, { 70, 30 }); } else if(name == "DateEdit") { QDateEdit* date = new QDateEdit; date->setObjectName("DateEdit"); return setLayoutWidget({ date }, { 110, 40 }); } else if(name == "DateTimeEdit") { QDateTimeEdit* date = new QDateTimeEdit; date->setObjectName("DateTimeEdit"); return setLayoutWidget({ date }, { 160, 30 }); } else if(name == "Dialog") { QDialog* dialog = new QDialog; dialog->setObjectName("Dialog"); return setLayoutWidget({ dialog }, { 160, 110 }); } else if(name == "DockWidget") //? { QDockWidget* widget = new QDockWidget; widget->setObjectName("DockWidget"); widget->resize(61, 22); return widget; } else if(name == "DoubleSpinBox") { QDoubleSpinBox* box = new QDoubleSpinBox; box->setObjectName("DoubleSpinBox"); return setLayoutWidget({ box }, { 90, 40 }); } else if(name == "Frame") //?? { QFrame* frame = new QFrame; frame->setObjectName("Frame"); frame->resize(150, 100); return frame; } else if(name == "GroupBox") { QGroupBox* box = new QGroupBox("GroupBox"); box->setObjectName("GroupBox"); return setLayoutWidget({ box }, { 160, 110 }); } else if(name == "Label") { QLabel* label = new QLabel("Label"); label->setObjectName("Label"); return setLayoutWidget({ label }, { 40, 20}); } else if(name == "LineEdit") { QLineEdit* line = new QLineEdit; line->setObjectName("LineEdit"); return setLayoutWidget({ line }, { 30, 30 }); } else if(name == "ListView") //?? { QListView* view = new QListView; view->setObjectName("ListView"); view->resize(71, 71); return view; } else if(name == "ListWidget") { QListWidget* list = new QListWidget; list->setObjectName("ListWidget"); for(int i = 0; i < 20; i++) list->addItem(QString("Item %1").arg(i)); return setLayoutWidget({ list }, { 80, 80 }); } else if(name == "MainWindow") { QMainWindow* window = new QMainWindow; window->setObjectName("MainWindow"); return setLayoutWidget({ window }, { 160, 110 }); } else if(name == "Menu") { QMenu* parentMenu = new QMenu; parentMenu->setObjectName("Menu"); parentMenu->addMenu("Menu1"); QMenu* menu1 = parentMenu->addMenu("Menu2"); menu1->addMenu("Menu1"); menu1->addMenu("Menu2"); parentMenu->addSeparator(); parentMenu->addMenu("Menu3"); return setLayoutWidget({ parentMenu }, { 160, 110 }); } else if(name == "MenuBar") { QMenuBar* bar = new QMenuBar; bar->setObjectName("QMenuBar"); QMenu* menu1 = bar->addMenu("MenuBar1"); menu1->addMenu("Menu1"); menu1->addSeparator(); menu1->addMenu("Menu2"); QMenu* menu2 = bar->addMenu("MenuBar2"); menu2->addMenu("Menu1"); menu2->addSeparator(); menu2->addMenu("Menu2"); QMenu* menu3 = bar->addMenu("MenuBar3"); menu3->addMenu("Menu1"); menu3->addSeparator(); menu3->addMenu("Menu2"); return setLayoutWidget({ bar }, { 280, 60 }); } else if(name == "ProgressBar") { QProgressBar* bar = new QProgressBar; bar->setObjectName("ProgressBar"); bar->setRange(0, 100); bar->setValue(0); QTimer* timer = new QTimer(bar); this->connect(timer, &QTimer::timeout, this, [bar]() { if(bar->value() == 100) bar->setValue(0); else bar->setValue(bar->value() + 1); }); timer->start(100); return setLayoutWidget({ bar }, { 110, 30 }); } else if(name == "PushButton") { QPushButton* button = new QPushButton("PushButton"); button->setObjectName("PushButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "RadioButton") { QRadioButton* button = new QRadioButton("RadioButton"); button->setObjectName("RadioButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "ScrollBar") { QScrollBar* barH = new QScrollBar(Qt::Horizontal); QScrollBar* barV = new QScrollBar(Qt::Vertical); barH->setObjectName("ScrollBarH"); barV->setObjectName("ScrollBarV"); return setLayoutWidget({ barH, barV }, { 200, 100 }); } else if(name == "Slider") { QSlider* sliderH = new QSlider(Qt::Horizontal); QSlider* sliderV = new QSlider(Qt::Vertical); sliderH->setObjectName("SliderH"); sliderV->setObjectName("SliderV"); return setLayoutWidget({ sliderH, sliderV }, { 200, 100 }); } else if(name == "SpinBox") { QSpinBox* spinBox = new QSpinBox; spinBox->setObjectName("SpinBox"); return setLayoutWidget({ spinBox }, { 60, 35 }); } else if(name == "Splitter") { QSplitter* splitterV = new QSplitter(Qt::Vertical); QSplitter* splitterH = new QSplitter(Qt::Horizontal); splitterV->setObjectName("SplitterV"); splitterH->setObjectName("SplitterH"); splitterV->addWidget(new QPushButton("PushButton1")); splitterV->addWidget(new QPushButton("PushButton2")); splitterH->addWidget(splitterV); splitterH->addWidget(new QPushButton("PushButton3")); return setLayoutWidget({ splitterH }, { 250, 110 }); } else if(name == "TabWidget") { QTabWidget* tab = new QTabWidget; tab->addTab(new QWidget, "Widget1"); tab->addTab(new QWidget, "Widget2"); tab->addTab(new QWidget, "Widget3"); tab->setObjectName("TabWidget"); return setLayoutWidget({ tab }, { 210, 110 }); } else if(name == "TableView") //? { QTableView* view = new QTableView; view->setObjectName("TableView"); view->resize(200, 100); return view; } else if(name == "TableWidget") { const int n = 100; QStringList list = { "one", "two", "three" }; QTableWidget* table = new QTableWidget(n, n); table->setObjectName("TableWidget"); table->setHorizontalHeaderLabels(list); table->setVerticalHeaderLabels(list); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j))); return setLayoutWidget({ table }, { 210, 110 }); } else if(name == "TextEdit") { QTextEdit* text = new QTextEdit; text->setObjectName("TextEdit"); return setLayoutWidget({ text }, { 80, 80 }); } else if(name == "TimeEdit") { QTimeEdit* time = new QTimeEdit; time->setObjectName("TimeEdit"); return setLayoutWidget({ time }, { 80, 80 }); } else if(name == "ToolButton") { QToolButton* button = new QToolButton; button->setText("ToolButton"); button->setObjectName("ToolButton"); return setLayoutWidget({ button }, { 95, 25 }); } else if(name == "ToolBox") { QToolBox* box = new QToolBox; box->addItem(new QWidget, "Widget1"); box->addItem(new QWidget, "Widget2"); box->addItem(new QWidget, "Widget3"); box->setObjectName("ToolBox"); return setLayoutWidget({ box }, { 110, 180 }); } else if(name == "TreeView") //? { QTreeView* tree = new QTreeView; tree->setObjectName("TreeView"); tree->resize(200, 100); return tree; } else if(name == "TreeWidget") { QTreeWidget* tree = new QTreeWidget; tree->setObjectName("TreeWidget"); tree->setHeaderLabels({ "Folders", "Used Space" }); QTreeWidgetItem* item = new QTreeWidgetItem(tree); item->setText(0, "Local Disk"); for(int i = 1; i < 20; i++) { QTreeWidgetItem* dir = new QTreeWidgetItem(item); dir->setText(0, "Directory" + QString::number(i)); dir->setText(1, QString::number(i) + "MB"); } tree->setItemExpanded(item, true); return setLayoutWidget({ tree }, { 210, 110 }); } else if(name == "Widget") { QWidget* widget = new QWidget; widget->setObjectName("Widget"); return setLayoutWidget({ widget }, { 210, 110 }); } return nullptr; }
SamplesWidget::SamplesWidget(Problem *problem, QWidget *parent, Qt::WindowFlags f):QWidget(parent, f) { sampleSet = problem->getSampleSet(); sampler = problem->getSampler(); prob = problem; collection = CURRENT; QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setObjectName(QString::fromUtf8("mainLayout")); setLayout(mainLayout); QHBoxLayout *hBoxLayout = new QHBoxLayout(); hBoxLayout->setObjectName(QString::fromUtf8("sampleLayout")); mainLayout->addLayout(hBoxLayout); QLabel *label = new QLabel("Sample"); label->setObjectName(QString::fromUtf8("sampleLabel")); label->setToolTip("Current sample"); hBoxLayout->addWidget(label); sampleList = new QComboBox(); sampleList->setObjectName(QString::fromUtf8("sampleList")); sampleList->setEditable(false); sampleList->setToolTip("Current list of samples"); connect(sampleList,SIGNAL(currentIndexChanged(int)),this,SLOT(changeSample(int))); hBoxLayout->addWidget(sampleList); QPushButton *button = new QPushButton("Test collision"); button->setObjectName(QString::fromUtf8("collisionButton")); connect(button,SIGNAL(clicked()),this,SLOT(testCollision())); mainLayout->addWidget(button); button = new QPushButton("Test distance"); button->setObjectName(QString::fromUtf8("distanceButton")); connect(button,SIGNAL(clicked()),this,SLOT(testDistance())); mainLayout->addWidget(button); QGridLayout *gridLayout = new QGridLayout(); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); mainLayout->addLayout(gridLayout); QIcon addIcon; addIcon.addFile(":/icons/add_16x16.png"); addIcon.addFile(":/icons/add_22x22.png"); button = new QPushButton(addIcon,"Add"); button->setObjectName(QString::fromUtf8("addButton")); button->setToolTip("Add current configuration as a sample"); connect(button,SIGNAL(clicked()),this,SLOT(addSample())); gridLayout->addWidget(button,0,0); QIcon removeIcon; removeIcon.addFile(":/icons/remove_16x16.png"); removeIcon.addFile(":/icons/remove_22x22.png"); button = new QPushButton(removeIcon,"Remove"); button->setObjectName(QString::fromUtf8("removeButton")); button->setToolTip("Remove current sample from collection"); connect(button,SIGNAL(clicked()),this,SLOT(removeSample())); gridLayout->addWidget(button,0,1); QIcon getIcon; getIcon.addFile(":/icons/right_16x16.png"); getIcon.addFile(":/icons/right_22x22.png"); button = new QPushButton(getIcon,"Get"); button->setObjectName(QString::fromUtf8("getButton")); button->setToolTip("Get samples"); connect(button,SIGNAL(clicked()),this,SLOT(getSamples())); gridLayout->addWidget(button,1,0); QIcon updateIcon; updateIcon.addFile(":/icons/reload_16x16.png"); updateIcon.addFile(":/icons/reload_22x22.png"); button = new QPushButton(updateIcon,"Update"); button->setObjectName(QString::fromUtf8("updateButton")); button->setToolTip("Update the samples in collection"); connect(button,SIGNAL(clicked()),this,SLOT(updateSampleList())); gridLayout->addWidget(button,1,1); QIcon copyIcon; copyIcon.addFile(":/icons/copy_16x16.png"); copyIcon.addFile(":/icons/copy_22x22.png"); button = new QPushButton(copyIcon,"Copy"); button->setObjectName(QString::fromUtf8("copyButton")); button->setToolTip("Copy the two first samples in a new collection"); connect(button,SIGNAL(clicked()),this,SLOT(copySampleList())); gridLayout->addWidget(button,2,0); QIcon clearIcon; clearIcon.addFile(":/icons/trashcan_16x16.png"); clearIcon.addFile(":/icons/trashcan_22x22.png"); button = new QPushButton(clearIcon,"Clear"); button->setObjectName(QString::fromUtf8("clearButton")); button->setToolTip("Remove all samples in collection"); connect(button,SIGNAL(clicked()),this,SLOT(clearSampleList())); gridLayout->addWidget(button,2,1); QGroupBox *groupBox = new QGroupBox("Add to collection"); groupBox->setObjectName(QString::fromUtf8("addGroupBox")); mainLayout->addWidget(groupBox); QVBoxLayout *vBoxLayout = new QVBoxLayout(); vBoxLayout->setObjectName(QString::fromUtf8("addLayout")); vBoxLayout->setContentsMargins(0,9,0,0); groupBox->setLayout(vBoxLayout); QComboBox *comboBox = new QComboBox(); comboBox->setObjectName(QString::fromUtf8("addComboBox")); comboBox->setEditable(false); comboBox->insertItem(CURRENT,"Current"); comboBox->insertItem(NEW,"New"); comboBox->setCurrentIndex(CURRENT); connect(comboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(changeCollection(int))); vBoxLayout->addWidget(comboBox); groupBox = new QGroupBox("Engine"); groupBox->setObjectName(QString::fromUtf8("engineGroupBox")); mainLayout->addWidget(groupBox); vBoxLayout = new QVBoxLayout(); vBoxLayout->setObjectName(QString::fromUtf8("engineLayout")); vBoxLayout->setContentsMargins(0,9,0,0); groupBox->setLayout(vBoxLayout); comboBox = new QComboBox(); comboBox->setObjectName(QString::fromUtf8("engineComboBox")); comboBox->setEditable(false); comboBox->insertItem(SDK,"SDK"); comboBox->insertItem(HALTON,"Halton"); comboBox->insertItem(RANDOM,"Random"); comboBox->insertItem(GAUSSIAN,"Gaussian"); if (typeid(*sampler) == typeid(SDKSampler)) { comboBox->setCurrentIndex(SDK); } else if (typeid(*sampler) == typeid(HaltonSampler)) { comboBox->setCurrentIndex(HALTON); } else if (typeid(*sampler) == typeid(RandomSampler)) { comboBox->setCurrentIndex(RANDOM); } else if (typeid(*sampler) == typeid(GaussianSampler)) { comboBox->setCurrentIndex(GAUSSIAN); } connect(comboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(changeEngine(int))); vBoxLayout->addWidget(comboBox); hBoxLayout = new QHBoxLayout(); hBoxLayout->setObjectName(QString::fromUtf8("amountLayout")); mainLayout->addLayout(hBoxLayout); label = new QLabel("Amount"); label->setObjectName(QString::fromUtf8("amountLabel")); label->setToolTip("Number of samples to calculate"); hBoxLayout->addWidget(label); sampleAmount = new QLineEdit(); sampleAmount->setObjectName(QString::fromUtf8("amountLineEdit")); sampleAmount->setToolTip("Number of samples to calculate"); hBoxLayout->addWidget(sampleAmount); updateSampleList(); }
EResumen::EResumen( QWidget *parent, tipo que ) : EVentana( parent ) { setObjectName( "selectorResumen" ); setWindowTitle( "Seleccione el Resumen" ); setAttribute( Qt::WA_DeleteOnClose ); generar = que; QVBoxLayout *layoutPrincipal = new QVBoxLayout( this ); layoutPrincipal->setMargin( 3 ); layoutPrincipal->setSpacing( 3 ); switch( que ) { case diario: { QGroupBox *g = new QGroupBox( this ); g->setTitle( "Elija la fecha del resumen" ); g->setAlignment( Qt::AlignHCenter ); g->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); QVBoxLayout *v = new QVBoxLayout( g ); CWfecha = new QCalendarWidget( g ); CWfecha->setGridVisible( false ); CWfecha->setMaximumDate( QDate::currentDate() ); CWfecha->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); v->addWidget( CWfecha ); g->adjustSize(); layoutPrincipal->addWidget( g ); break; } case mensual: { QGroupBox *groupBox = new QGroupBox( this ); groupBox->setObjectName(QString::fromUtf8("groupBox")); groupBox->setTitle( "Elija el mes para el resumen" ); groupBox->setAlignment( Qt::AlignCenter ); groupBox->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); QVBoxLayout *v = new QVBoxLayout(groupBox); v->setObjectName( "vLayout" ); QHBoxLayout *h1 = new QHBoxLayout(); h1->setObjectName("hLayout1"); QLabel *Lmes = new QLabel(groupBox); Lmes->setObjectName(QString::fromUtf8("labelMes")); Lmes->setText( tr( "Mes:" ) ); h1->addWidget(Lmes); CBMes = new QComboBox(groupBox); CBMes->setObjectName(QString::fromUtf8("CBMes")); // Inserto los meses QLocale locale; for( int i = 1; i<=12; i++ ) { CBMes->insertItem( i, locale.monthName( i ) ); } CBMes->setCurrentIndex( QDate::currentDate().month() ); h1->addWidget(CBMes); v->addLayout(h1); QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); QLabel *Lano = new QLabel(groupBox); Lano->setObjectName(QString::fromUtf8("lano")); Lano->setText( tr( "Año:" ) ); horizontalLayout_2->addWidget(Lano); SBAno = new QSpinBox(groupBox); SBAno->setObjectName(QString::fromUtf8("SBAno")); SBAno->setMaximum( QDate::currentDate().year() ); SBAno->setSingleStep( 1 ); SBAno->setValue( QDate::currentDate().year() ); horizontalLayout_2->addWidget(SBAno); v->addLayout(horizontalLayout_2); layoutPrincipal->addWidget( groupBox ); break; } case anual: { QHBoxLayout *layout = new QHBoxLayout( this ); QLabel *etiqueta = new QLabel( this ); etiqueta->setText( QString( "Año:" ) ); seleccion = new QSpinBox( this ); seleccion->setRange( 0, QDate::currentDate().year() ); seleccion->setSingleStep( 1 ); seleccion->setValue( QDate::currentDate().year() ); layout->addWidget( etiqueta ); layout->addWidget( seleccion ); layoutPrincipal->addLayout( layout ); break; } case semanal: { QGroupBox *g = new QGroupBox( this ); g->setTitle( "Elija un dia de la semana para el resumen" ); g->setAlignment( Qt::AlignHCenter ); g->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); QVBoxLayout *v = new QVBoxLayout( g ); CWfecha = new QCalendarWidget( g ); CWfecha->setGridVisible( true ); CWfecha->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); v->addWidget( CWfecha ); g->adjustSize(); layoutPrincipal->addWidget( g ); break; } case entrefechas: { QHBoxLayout *horizontalLayout = new QHBoxLayout(); horizontalLayout->setObjectName( "horizontalLayout" ); horizontalLayout->setContentsMargins(0, 0, 0, 0); QLabel *LInicio = new QLabel(this); LInicio->setObjectName( "LInicio" ); LInicio->setText( "Fecha de inicio:" ); horizontalLayout->addWidget(LInicio); DEInicio = new QDateEdit(this); DEInicio->setObjectName( "DEInicio" ); DEInicio->setCalendarPopup(true); horizontalLayout->addWidget(DEInicio); QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName( "horizontalLayout_2" ); horizontalLayout_2->setContentsMargins(0, 0, 0, 0); QLabel *LFin = new QLabel(this); LFin->setObjectName( "LFin" ); LFin->setText( "Fecha de Fin:" ); horizontalLayout_2->addWidget(LFin); DEFin = new QDateEdit(this); DEFin->setObjectName( "DEFin" ); DEFin->setCalendarPopup(true); DEFin->setMaximumDate( QDate::currentDate() ); horizontalLayout_2->addWidget(DEFin); layoutPrincipal->addItem( horizontalLayout ); layoutPrincipal->addItem( horizontalLayout_2 ); } } QAction *ActGenerar = new QAction( "Generar Reporte", this ); ActGenerar->setIcon( QIcon( ":/imagenes/reporte.png" ) ); connect( ActGenerar, SIGNAL( triggered() ), this, SLOT( generarResumen() ) ); addAction( ActGenerar ); EActCerrar *ActCerrar = new EActCerrar( this ); connect( ActCerrar, SIGNAL( triggered() ), this, SLOT( close() ) ); addAction( ActCerrar ); this->adjustSize(); }