Example #1
0
  WContainerWidget *WForm::addControl(WWidget *w, const string &labelKey, bool isFormControl) {
    string controlSize = (boost::format("col-sm-%d") % (12-d->labelColumns)).str();
    string labelSize = (boost::format("col-sm-%d") % (d->labelColumns)).str();
    string controlOffset = (boost::format("col-sm-offset-%d") % (d->labelColumns)).str();
    if(d->type == Inline) {
      controlSize = "";
      labelSize = "";
      controlOffset = "";
    }
    WContainerWidget *container = WW<WContainerWidget>().addCss("form-group");
    if(isFormControl)
      w->addStyleClass("form-control");

    if(!labelKey.empty()) {
      WLabel *label = WW<WLabel>(WString::tr(labelKey), container).addCss("control-label").addCss(labelSize);
      if(dynamic_cast<WFormWidget*>(w))
        label->setBuddy(dynamic_cast<WFormWidget*>(w));
    }
    if(d->type == Inline)
      container->addWidget(w);
    else
      container->addWidget(WW<WContainerWidget>().addCss(controlSize).addCss(labelKey.empty() ? controlOffset : "").add(w));
    addWidget(container);
    return container;
  }
Example #2
0
WWidget *FormWidgets::wPopupMenu()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WPopupMenu", "WPopupMenuItem", result);
  addText(tr("formwidgets-WPopupMenu"), result);

  WPopupMenu *popup = new WPopupMenu();
  popup->setAutoHide(true, 1000);
  popup->addItem("icons/house.png", "Build a house");
  popup->addItem("Roof included")->setCheckable(true);
  popup->addItem("Add a door")->setDisabled(true);
  popup->addSeparator();
  popup->addItem("Add a window");
  WPopupMenu *subMenu = new WPopupMenu();
  subMenu->addItem("Add a chair");
  subMenu->addItem("Add a table");
  popup->addMenu("Add furniture", subMenu);

  popup->aboutToHide().connect(boost::bind(&FormWidgets::popupAction,
					   this, popup));
  
  WLabel* clickMe = new WLabel("Clicking here will show a popup menu.",
			       result);
  clickMe->setStyleClass("popupmenuLabel");
  clickMe->clicked().connect(popup, &WPopupMenu::popup);
  
  return result;
}
WAbstractToggleButton::WAbstractToggleButton(WContainerWidget *parent)
  : WFormWidget(parent),
    checked_(false),
    checkedChanged_(false)
{ 
  WLabel *label = new WLabel(parent);
  label->setBuddy(this);
}
Example #4
0
void Reports::createUi()
{

    WContainerWidget *dateSelectForm = new WContainerWidget(this);
    dateSelectForm ->setStyleClass("form-inline");
    dateSelectForm ->setId("dateselectform");

    WLabel *label;

    label = new WLabel(tr("reports.begindate"), dateSelectForm );
    m_pBeginDateEdit = new WDateEdit(dateSelectForm );
    //label->setBuddy(m_pBeginDateEdit->lineEdit());
    label->setBuddy(m_pBeginDateEdit);


    //m_pBeginDateEdit->setBottom(WDate(WDate::currentDate().year(), WDate::currentDate().month(), 1));
    m_pBeginDateEdit->setFormat("dd.MM.yyyy");
    m_pBeginDateEdit->setDate(WDate(WDate::currentDate().year(), WDate::currentDate().month(), 1));
    m_pBeginDateEdit->setTop(WDate::currentDate());
    //m_pBeginDateEdit->lineEdit()->validator()->setMandatory(true);
    m_pBeginDateEdit->validator()->setMandatory(true);
    m_pBeginDateEdit->setStyleClass("input-medium");
    //m_pBeginDateEdit->setWidth(120);


    label = new WLabel(tr("reports.enddate"), dateSelectForm );
    m_pEndDateEdit = new WDateEdit(dateSelectForm );
    //label->setBuddy(m_pEndDateEdit->lineEdit());
    label->setBuddy(m_pEndDateEdit);
    //m_pEndDateEdit->setBottom(WDate::currentDate());
    m_pEndDateEdit->setFormat("dd.MM.yyyy");
    m_pEndDateEdit->setDate(WDate::currentDate());
    m_pEndDateEdit->setTop(WDate::currentDate());
    //m_pEndDateEdit->lineEdit()->validator()->setMandatory(true);
    m_pEndDateEdit->validator()->setMandatory(true);
    m_pEndDateEdit->setStyleClass("input-medium");

    /*
    WContainerWidget *corner_kick = new WContainerWidget(dateSelectForm );
    corner_kick->setStyleClass("corner_kick get_filter");
    WTemplate *button = new WTemplate("<ins class=\"i1\"></ins><ins class=\"i2\"></ins><ins class=\"i3\"></ins><ins class=\"i4\"></ins>${anchor}",corner_kick);
    LineEdit *submitBtn = new LineEdit(0,LineEdit::Submit);
    submitBtn->setValueText(tr("reports.filtered"));
    submitBtn->clicked().connect(boost::bind(&Reports::changed, this, submitBtn));
    button->bindWidget("anchor",submitBtn);
    */

    //WTemplate *button = new WTemplate("<ins class=\"i1\"></ins><ins class=\"i2\"></ins><ins class=\"i3\"></ins><ins class=\"i4\"></ins>${anchor}",dateSelectForm);
    WPushButton *anchor = new WPushButton(tr("reports.filtered"),dateSelectForm);
    anchor->clicked().connect(boost::bind(&Reports::changed, this, dateSelectForm));
    //button->bindWidget("anchor",anchor);
    //button->setStyleClass("corner_kick get_filter");


    //(new WLabel(tr("reports.filtered"), corner_kick))->setBuddy(new LineEdit(corner_kick,LineEdit::Submit));

}
Example #5
0
void WFormWidget::setLabel(WLabel *label)
{
  if (label_) {
    WLabel *l = label_;
    label_ = 0;
    l->setBuddy((WFormWidget *)0);
  }
  label_ = label;

  if (label_)
    label_->setHidden(isHidden());
}
Example #6
0
void SettingsPage::addSetting(const string& settingName, WFormWidget* widget)
{
  WString label = wtr(settingName + ".label");
  WString helpText = wtr(settingName + ".description");
  
  WLabel *labelWidget = WW<WLabel>(label).css("control-label");
  labelWidget->setBuddy(widget);
  WContainerWidget *control = WW<WContainerWidget>().css("controls").add(widget);
  if(!helpText.empty()) {
    control->addWidget(WW<WText>(helpText).css("help-block") );
  }
  addWidget(WW<WContainerWidget>().css("control-group")
    .add(labelWidget)
    .add( control ));
}
Example #7
0
Login::Login(WContainerWidget* parent) : WContainerWidget(parent), loggedIn_(this)
{
    setStyleClass("login");

    WLabel* userNameL = new WLabel(tr("login.userName"), this);
    userNameEdit_ = new WLineEdit(this);
    userNameEdit_->setFocus();
    userNameL->setBuddy(userNameEdit_);

    loginButton_ = new WPushButton(tr("login.loginButton"), this);
    loginButton_->setEnabled(false);
    userNameEdit_->textInput().connect(std::bind([=] () {
        if(userNameEdit_->text() == "")
            loginButton_->setEnabled(false);
        else
            loginButton_->setEnabled(true);
    }));
    loginButton_->clicked().connect(this, &Login::login);
}
VanetNodeForm::VanetNodeForm()
{
    WTable* t = new WTable(this);
    int row = 0;
    
    WLabel* l = new WLabel(tr("vanet.property.form.node.id"), t->elementAt(row, 0));
    id_ = new WLineEdit(t->elementAt(row, 1));
    WLengthValidator* lv = new WLengthValidator(1, 15);
    id_->setValidator(lv);
    l->setBuddy(id_);
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    l = new WLabel(tr("vanet.property.form.nodes.mobility"), t->elementAt(row, 0));
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    form_ = new VanetMobilityModelForm;
    t->elementAt(row, 0)->addWidget(form_);
}
Example #9
0
LoginWidget::LoginWidget(WContainerWidget *parent)
: WContainerWidget(parent)
{
  this->setId("login_widget");
  this->setStyleClass("login_widget_style");
  WText *intro = new WText("Hello! Please, login into Geo2tag "
    "or view marks from public channels",
    this);
  intro->setId("intro");
  //    WBreak *break1 = new WBreak(this);
  WLabel *usernameLabel = new WLabel("Username:"******"Password:"******"Login", this);
  //    WBreak *break2 = new WBreak(this);
  map = new WGoogleMap(this);
  map->setMinimumSize(WLength(300), WLength(400));
  map->setMaximumSize(WLength(500), WLength(400));
  map->setCenter(Wt::WGoogleMap::Coordinate(60, 30));
  map->enableScrollWheelZoom();
  //    WBreak *break3 = new WBreak(this);
  //    WOpenStreetMap *map2 = new WOpenStreetMap(this);
  //    map2->setMinimumSize(WLength(300), WLength(400));
  //    //map2->setMaximumSize(WLength(500), WLength(400));
  //
  //    WBreak *break4 = new WBreak(this);
  //    WYandexMap *map3 = new WYandexMap(this);
  //    map3->setMinimumSize(WLength(300), WLength(400));

  //  loginButton->clicked().connect(this, &LoginWidget::loginClicked);
  fillMap();
  initCons();
  //    m_con=new Connector<LoginWidget>(&m_loginQuery,LoginQueryConnected,&LoginWidget::userRecieved,this);

  this->setStyleClass("login_wigdet");
}
Example #10
0
void LoginView::createLayout()
{
  WLabel* userNameL = new WLabel(tr("login.userName"), contents());
  userNameL->setMargin(10, Left | Right);
  _user_name = new WLineEdit(contents());
  _user_name->setValidator(new WLengthValidator(5, 20, contents()));
  userNameL->setBuddy(_user_name);
  _user_name->setFocus();

  new WBreak(contents());

  WLabel* passwdL = new WLabel(tr("login.userPasswd"), contents());
  passwdL->setMargin(10, Left | Right);
  _user_passwd =  new WLineEdit(contents());
  passwdL->setBuddy(_user_passwd);
  _user_passwd->setValidator(new WLengthValidator(5, 20, contents()));
  _user_passwd->setEchoMode(WLineEdit::Password);
  _user_passwd->enterPressed().connect(this, &LoginView::loginCheck);

  new WBreak(contents());

  _login_button = new WPushButton(tr("login.loginButton"),
				  contents());
  //_login_button->clicked().connect(_user_passwd->jsRef() + ".value = " + "hex_md5(" + _user_passwd->jsRef() + ");");
  _login_button->clicked().connect(this, &LoginView::loginCheck2);
  //_user_passwd->enterPressed().connect(_user_passwd->jsRef() + ".value = " + "hex_md5(" + _user_passwd->jsRef() + ");");

}
VanetRoutingProtocolPropertyForm::VanetRoutingProtocolPropertyForm(WContainerWidget* parent)
{
    WTable* mainTable = new WTable(this);
    int row = 0;

    WLabel* l = new WLabel(tr("vanet.property.form.routing.combo"), mainTable->elementAt(row, 0));
    routingCombo_ = new WComboBox(mainTable->elementAt(row, 1));
    routingCombo_->addItem(tr("vanet.property.form.routing.combo.aodv"));
    routingCombo_->addItem(tr("vanet.property.form.routing.combo.bf"));
    routingCombo_->addItem(tr("vanet.property.form.routing.combo.dsr"));
    routingCombo_->addItem(tr("vanet.property.form.routing.combo.lar"));
    routingCombo_->addItem(tr("vanet.property.form.routing.combo.wrp"));
    l->setBuddy(routingCombo_);
    routingCombo_->setCurrentIndex(0);

//     ++row;
//     l = new WLabel(tr("vanet.property.form.routing.nodescount"), mainTable->elementAt(row, 0));
//     nodesCount_ = new WSpinBox(mainTable->elementAt(row, 1));
//     nodesCount_->setMaximum(225);
//     nodesCount_->setMinimum(2);
//     nodesCount_->setValue(30);
//     l->setBuddy(nodesCount_);
}
VanetAreaPropertyForm::VanetAreaPropertyForm(WContainerWidget* parent)
{
    WTable *formTable = new WTable(this);
    int row = 0;

    WLabel *xLabel = new WLabel(formTable->elementAt(row, 0));
    xLabel->setText(WString::fromUTF8(tr("mappropertyeditor.group.general.dimx").toUTF8()));
    dimx_ = new WSpinBox(formTable->elementAt(row, 1));
    dimx_->setMinimum(0);
    dimx_->setMaximum(90000);
    xLabel->setBuddy(dimx_);

    ++row;
    WLabel *yLabel = new WLabel(formTable->elementAt(row, 0));
    yLabel->setText(WString::fromUTF8(tr("mappropertyeditor.group.general.dimy").toUTF8()));
    dimy_ = new WSpinBox(formTable->elementAt(row, 1));
    dimy_->setMinimum(0);
    dimy_->setMaximum(90000);
    yLabel->setBuddy(dimy_);
}
Example #13
0
void IndexView::render() {
	clear();
	WTable *queryTable = new WTable(this);

	WLabel *label;
	int row = 0;

	// Title
	queryTable->elementAt(row, 0)->setColumnSpan(3);
	queryTable->elementAt(row, 0)->setContentAlignment(AlignTop | AlignCenter);
	queryTable->elementAt(row, 0)->setPadding(10);
	WText *title = new WText(("Leaked Password Query Kit"), queryTable->elementAt(row, 0));
	title->decorationStyle().font().setSize(WFont::XLarge);

	// error messages
	++row;
	queryTable->elementAt(row, 0)->setColumnSpan(3);
	feedbackMessages_ = queryTable->elementAt(row, 0);
	feedbackMessages_->setPadding(5);

	WCssDecorationStyle& errorStyle = feedbackMessages_->decorationStyle();
	errorStyle.setForegroundColor(Wt::red);
	errorStyle.font().setSize(WFont::Smaller);
	errorStyle.font().setWeight(WFont::Bold);
	errorStyle.font().setStyle(WFont::Italic);

	// User
	++row;
	keywordEdit_ = new WLineEdit(queryTable->elementAt(row, 2));
	label = new WLabel("Keyword:", queryTable->elementAt(row, 0));
	label->setBuddy(keywordEdit_);
	keywordEdit_->setValidator(new WValidator(true));
	keywordEdit_->enterPressed().connect(this, &IndexView::query);

	// Search Area
	++row;
	areaOption_ = new WSelectionBox(queryTable->elementAt(row, 2));
	areaOption_->addItem("Username");
	areaOption_->addItem("Password");
	areaOption_->setCurrentIndex(0);
	label = new WLabel("Keyword Type:", queryTable->elementAt(row,0));
	label->setBuddy(areaOption_);

	// DB to Search
	++row;
	dbOption_ = new WSelectionBox(queryTable->elementAt(row, 2));
	dbOption_->addItem("CSDN (6M)");
	dbOption_->addItem("RenRen (5M)");
	dbOption_->addItem("178 (10M)");
	dbOption_->addItem("7k7k (20M)");
	dbOption_->addItem("duduniu (10M)");
	dbOption_->addItem("duowan (10M)");
	dbOption_->addItem("MOP (10M)");
	dbOption_->addItem("Tianya (40M)");
	dbOption_->setCurrentIndex(0);
	label = new WLabel("Database:", queryTable->elementAt(row,0));
	label->setBuddy(dbOption_);

	// Search Method
	++row;
	methodOption_ = new WSelectionBox(queryTable->elementAt(row, 2));
	methodOption_->addItem("Header Match");
	methodOption_->addItem("Full-Text (1 Quota Per Minute Per IP)");
	methodOption_->setCurrentIndex(0);
	label = new WLabel("Search Method:", queryTable->elementAt(row,0));
	label->setBuddy(methodOption_);

	// Query
	++row;
	WPushButton *query = new WPushButton("Query",
		queryTable->elementAt(row, 0));
	query->clicked().connect(this, &IndexView::query);
	query->setMargin(15, Top);
	queryTable->elementAt(row, 0)->setColumnSpan(3);
	queryTable->elementAt(row, 0)->setContentAlignment(AlignTop | AlignCenter);

	// Set column widths for label and validation icon
	queryTable->elementAt(2, 0)->resize(WLength(30, WLength::FontEx), WLength::Auto);
	queryTable->elementAt(2, 1)->resize(20, WLength::Auto);

	// Result
	result_ = new WTable(this);
	result_->clear();
}
Example #14
0
  FileEditDialog(WAbstractItemModel *model, const WModelIndex& item)
    : WDialog("Edit..."),
      model_(model),
      item_(item)
  {
    int modelRow = item_.row();

    resize(300, WLength::Auto);

    /*
     * Create the form widgets, and load them with data from the model.
     */

    // name
    nameEdit_ = new WLineEdit(asString(model_->data(modelRow, 1)));

    // type
    typeEdit_ = new WComboBox();
    typeEdit_->addItem("Document");
    typeEdit_->addItem("Spreadsheet");
    typeEdit_->addItem("Presentation");
    typeEdit_->setCurrentIndex
      (typeEdit_->findText(asString(model_->data(modelRow, 2))));

    // size
    sizeEdit_ = new WLineEdit(asString(model_->data(modelRow, 3)));
    sizeEdit_->setValidator
      (new WIntValidator(0, std::numeric_limits<int>::max(), this));

    // created
    createdPicker_ = new WDatePicker();
    createdPicker_->lineEdit()->validator()->setMandatory(true);
    createdPicker_->setFormat(FileModel::dateEditFormat);
    createdPicker_->setDate(boost::any_cast<WDate>(model_->data(modelRow, 4)));

    // modified
    modifiedPicker_ = new WDatePicker();
    modifiedPicker_->lineEdit()->validator()->setMandatory(true);
    modifiedPicker_->setFormat(FileModel::dateEditFormat);
    modifiedPicker_->setDate(boost::any_cast<WDate>(model_->data(modelRow, 5)));

    /*
     * Use a grid layout for the labels and fields
     */
    WGridLayout *layout = new WGridLayout();

    WLabel *l;
    int row = 0;

    layout->addWidget(l = new WLabel("Name:"), row, 0);
    layout->addWidget(nameEdit_, row, 1);
    l->setBuddy(nameEdit_);
    ++row;

    layout->addWidget(l = new WLabel("Type:"), row, 0);
    layout->addWidget(typeEdit_, row, 1);
    l->setBuddy(typeEdit_);
    ++row;

    layout->addWidget(l = new WLabel("Size:"), row, 0);
    layout->addWidget(sizeEdit_, row, 1);
    l->setBuddy(sizeEdit_);
    ++row;

    layout->addWidget(l = new WLabel("Created:"), row, 0);
    layout->addWidget(createdPicker_->lineEdit(), row, 1);
    layout->addWidget(createdPicker_, row, 2);
    l->setBuddy(createdPicker_->lineEdit());
    ++row;

    layout->addWidget(l = new WLabel("Modified:"), row, 0);
    layout->addWidget(modifiedPicker_->lineEdit(), row, 1);
    layout->addWidget(modifiedPicker_, row, 2);
    l->setBuddy(modifiedPicker_->lineEdit());
    ++row;

    WPushButton *b;
    WContainerWidget *buttons = new WContainerWidget();
    buttons->addWidget(b = new WPushButton("Save"));
    b->clicked().connect(this, &WDialog::accept);
    contents()->enterPressed().connect(this, &WDialog::accept);
    buttons->addWidget(b = new WPushButton("Cancel"));
    b->clicked().connect(this, &WDialog::reject);

    /*
     * Focus the form widget that corresonds to the selected item.
     */
    switch (item.column()) {
    case 2:
      typeEdit_->setFocus(); break;
    case 3:
      sizeEdit_->setFocus(); break;
    case 4:
      createdPicker_->lineEdit()->setFocus(); break;
    case 5:
      modifiedPicker_->lineEdit()->setFocus(); break;
    default:
      nameEdit_->setFocus(); break;
    }

    layout->addWidget(buttons, row, 0, 0, 3, AlignCenter);
    layout->setColumnStretch(1, 1);

    contents()->setLayout(layout);

    finished().connect(this, &FileEditDialog::handleFinish);

    show();
  }
Example #15
0
///
//  Constructor
//
LoginPage::LoginPage(WContainerWidget *parent) :
    WContainerWidget(parent),
    mLoggedIn(false),
    mLogoutRequested(false)
{
    setStyleClass("maindiv");

    WLabel* loginText = new WLabel("Enter username and password:"******"");
    WText *userNameText = new WText("User Name:");

    mPasswordLineEdit = new WLineEdit("");
    mPasswordLineEdit->setEchoMode(WLineEdit::Password);

    WText *passwordText = new WText("Password:"******"Login");

    WGridLayout *loginLayout = new WGridLayout();
    loginLayout->addWidget(userNameText, 0, 0, AlignRight);
    loginLayout->addWidget(mUserNameLineEdit, 0, 1, AlignLeft);
    loginLayout->addWidget(passwordText, 1, 0, AlignRight);
    loginLayout->addWidget(mPasswordLineEdit, 1, 1, AlignLeft);

    WGridLayout *textLayout = new WGridLayout();
    textLayout->addWidget(loginText, 0, 0, AlignCenter);

    WGridLayout *buttonLayout = new WGridLayout();
    buttonLayout->addWidget(loginButton, 0, 0, AlignCenter | AlignMiddle);

    WImage *chbLogo = new WImage(tr("logo-image").toUTF8());
    WGridLayout *chbLogoLayout = new WGridLayout();
    chbLogoLayout->addWidget(chbLogo, 0, 0, AlignCenter);

    WLabel *titleLabel = new WLabel(tr("page-top-text"));
    titleLabel->setStyleClass("logintitlediv");
    WGridLayout *titleLayout = new WGridLayout();
    titleLayout->addWidget(titleLabel, 0, 0, AlignCenter);

    WContainerWidget *loginContainer = new WContainerWidget();
    loginContainer->setStyleClass("logindiv");

    mFailureLabel = new WLabel("Invalid username and/or password.  Try again.");
    mFailureLabel->setStyleClass("redtext");

    WVBoxLayout *layout = new WVBoxLayout();
    layout->addLayout(chbLogoLayout, AlignCenter);
    layout->addLayout(titleLayout, AlignCenter);
    layout->addLayout(textLayout, AlignCenter);
    layout->addLayout(loginLayout);
    layout->addWidget(mFailureLabel);
    layout->addLayout(buttonLayout, AlignCenter | AlignMiddle);

    mFailureLabel->hide();

    loginContainer->setLayout(layout, AlignTop);

    WVBoxLayout *pageLayout = new WVBoxLayout();
    pageLayout->addWidget(loginContainer);
    pageLayout->addWidget(new WText(tr("login-page-text")));

    setLayout(pageLayout, AlignMiddle | AlignCenter);

    loginButton->clicked().connect(SLOT(this, LoginPage::login));
    mPasswordLineEdit->enterPressed().connect(SLOT(this, LoginPage::login));

    resetAll();
}
VanetMobilityModelForm::VanetMobilityModelForm(WContainerWidget* parent)
{
    WTable* t = new WTable(this);
    int row = 0;

    WLabel* l = new WLabel(tr("vanet.property.form.mobility.combo"), t->elementAt(row, 0));
    mobilityCombo_ = new WComboBox(t->elementAt(row, 1));
    mobilityCombo_->addItem(tr("vanet.property.form.mobility.combo.im"));
    mobilityCombo_->addItem(tr("vanet.property.form.mobility.combo.lc"));
    mobilityCombo_->activated().connect(this, &VanetMobilityModelForm::mobilityChanged);
    l->setBuddy(mobilityCombo_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.minspeed"), t->elementAt(row, 0));
    minSpeed_ = new WDoubleSpinBox(t->elementAt(row, 1));
    minSpeed_->setDecimals(1);
    minSpeed_->setMaximum(100.0);
    minSpeed_->setMinimum(0.0);
    minSpeed_->setValue(0.0);
    l->setBuddy(minSpeed_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.maxspeed"), t->elementAt(row, 0));
    maxSpeed_ = new WDoubleSpinBox(t->elementAt(row, 1));
    maxSpeed_->setDecimals(1);
    maxSpeed_->setMaximum(300.0);
    maxSpeed_->setMinimum(0.0);
    maxSpeed_->setValue(0.0);
    l->setBuddy(maxSpeed_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.length"), t->elementAt(row, 0));
    length_ = new WDoubleSpinBox(t->elementAt(row, 1));
    length_->setDecimals(1);
    length_->setMaximum(20.0);
    length_->setMinimum(0.0);
    length_->setValue(5.0);
    l->setBuddy(length_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.maxaccel"), t->elementAt(row, 0));
    maxAccel_ = new WDoubleSpinBox(t->elementAt(row, 1));
    maxAccel_->setDecimals(1);
    maxAccel_->setMaximum(10.0);
    maxAccel_->setMinimum(0.0);
    maxAccel_->setValue(0.6);
    l->setBuddy(maxAccel_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.comfydecel"), t->elementAt(row, 0));
    comfyDecel_ = new WDoubleSpinBox(t->elementAt(row, 1));
    comfyDecel_->setDecimals(1);
    comfyDecel_->setMaximum(10.0);
    comfyDecel_->setMinimum(0.0);
    comfyDecel_->setValue(0.6);
    l->setBuddy(comfyDecel_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.jamdist"), t->elementAt(row, 0));
    jamDistance_ = new WDoubleSpinBox(t->elementAt(row, 1));
    jamDistance_->setDecimals(1);
    jamDistance_->setMaximum(5.0);
    jamDistance_->setMinimum(0.0);
    jamDistance_->setValue(2.0);
    l->setBuddy(jamDistance_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.t"), t->elementAt(row, 0));
    safeTimeHeadway_ = new WDoubleSpinBox(t->elementAt(row, 1));
    safeTimeHeadway_->setDecimals(1);
    safeTimeHeadway_->setMaximum(10.0);
    safeTimeHeadway_->setMinimum(0.0);
    safeTimeHeadway_->setValue(1.5);
    l->setBuddy(safeTimeHeadway_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.step"), t->elementAt(row, 0));
    step_ = new WDoubleSpinBox(t->elementAt(row, 1));
    step_->setDecimals(1);
    step_->setMaximum(10.0);
    step_->setMinimum(0.1);
    step_->setValue(0.9);
    l->setBuddy(step_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.stay"), t->elementAt(row, 0));
    stay_ = new WDoubleSpinBox(t->elementAt(row, 1));
    stay_->setDecimals(1);
    stay_->setMaximum(10.0);
    stay_->setMinimum(0.0);
    stay_->setValue(0.0);
    l->setBuddy(stay_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.bsave"), t->elementAt(row, 0));
    bsave_ = new WDoubleSpinBox(t->elementAt(row, 1));
    bsave_->setDecimals(1);
    bsave_->setMaximum(10.0);
    bsave_->setMinimum(0.0);
    bsave_->setValue(4.0);
    bsave_->setDisabled(true);
    l->setBuddy(bsave_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.p"), t->elementAt(row, 0));
    politeness_ = new WDoubleSpinBox(t->elementAt(row, 1));
    politeness_->setDecimals(1);
    politeness_->setMaximum(1.0);
    politeness_->setMinimum(0.0);
    politeness_->setValue(0.5);
    politeness_->setDisabled(true);
    l->setBuddy(politeness_);
    
    ++row;
    l = new WLabel(tr("vanet.property.form.mobility.athr"), t->elementAt(row, 0));
    accelThresh_ = new WDoubleSpinBox(t->elementAt(row, 1));
    accelThresh_->setDecimals(1);
    accelThresh_->setMaximum(10.0);
    accelThresh_->setMinimum(0.0);
    accelThresh_->setValue(0.2);
    accelThresh_->setDisabled(true);
    l->setBuddy(accelThresh_);
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    random_ = new WCheckBox(tr("vanet.property.form.mobility.random"), t->elementAt(row, 0));
    random_->setCheckState(Unchecked);
    
    ++row;
    t->elementAt(row, 0)->setColumnSpan(2);
    ignoreBorders_ = new WCheckBox(tr("vanet.property.form.mobility.ignoreborders"), t->elementAt(row, 0));
    ignoreBorders_->setCheckState(Unchecked);
}
void PriceEditDialog::update()
{


    /// 0 id
    /// 1 group type Группа / Элемент
    /// 2 value
    /// 3 value type Процент / Цена
    /// 4 price type Динамический / Статический
    /// 5 Изменять фиксированные цены
    /// 6 Дата принятия изменений

    //resize(450, WLength::Auto);

    char number[50];
    int modelRow = m_item.row();
    m_id            = boost::any_cast<std::string>(m_model->data(modelRow, 0,UserRole));
    //double price    = boost::any_cast<double>(m_model->data(modelRow, 2,UserRole));
    double value    = boost::any_cast<double>(m_model->data(modelRow, 2,UserRole));
    int valueType   = boost::any_cast<int>(m_model->data(modelRow, 3,UserRole));
    int button      = boost::any_cast<int>(m_model->data(modelRow, 4,UserRole));
    WDate chDate    = boost::any_cast<WDate>(m_model->data(modelRow,6,UserRole));
    int roundIndex  = boost::any_cast<int>(m_model->data(modelRow,7,UserRole));

    log("info")<<asString(m_model->data(modelRow, 5,UserRole))<<"  "<<__LINE__;
    //log("info")<<asString(m_model->data(modelRow, 5,UserRole))<<"  "<<__LINE__;

    std::string parent = boost::any_cast<std::string>(m_model->data(modelRow, 5,UserRole));
    int modifyStatic = 0;

    setWindowTitle(asString(m_model->data(modelRow, 3)));
    WGroupBox *container = new Wt::WGroupBox(WString("Вид расчета цены",UTF8));
    //container->setHeight(65);
    m_chbPercentEnabled = new WCheckBox();
    m_chbCostEnabled  = new WCheckBox();
    m_chbModifyStatic  = new WCheckBox(WString("Изменять статические цены ?:",UTF8));
    m_rbGroup = new WButtonGroup(this);
    m_rbDynamicCalc = new WRadioButton(WString("Динамически:",UTF8),container);
    new WBreak(container);
    m_rbStaticCalc = new WRadioButton(WString("Статически",UTF8),container);

    //boost::any d = m_model->data(modelRow, 2,UserRole);
    //int v = boost::lexical_cast<int>(d);
    m_rbGroup->addButton(m_rbDynamicCalc,Dynamic);
    m_rbGroup->addButton(m_rbStaticCalc,Static);

    if(button == 1)
        m_rbGroup->setCheckedButton(m_rbGroup->button(1));
    else
        m_rbGroup->setCheckedButton(m_rbGroup->button(2));

    m_rbGroup->checkedChanged().connect(this,&PriceEditDialog::onCalcTypeChanged);
    m_chbModifyStatic->setChecked(modifyStatic);

    /// Прицент / Цена

    m_leCost = new WLineEdit("0.00");
    m_lePercent = new WLineEdit("0.00");

    if(valueType == 2)
    {
        sprintf(number,"%.2f",value);
        m_chbPercentEnabled->setChecked();
        m_lePercent->setText(number);
    }
    else if(valueType == 1)
    {
        sprintf(number,"%.2f",value);
        m_chbCostEnabled->setChecked();
        m_leCost->setText(number);

    }

    m_lePercent->setValidator(new WRegExpValidator("[0-9]+\\.[0-9]{2}"));
    m_leCost->setValidator(new WRegExpValidator("[0-9]+\\.[0-9]{2}"));


    // created
    m_dpModified = new WDatePicker();
    m_dpModified->lineEdit()->validator()->setMandatory(true);
    m_dpModified->setFormat(FileModel::dateEditFormat);
    m_dpModified->setDate(chDate);
    m_dpModified->setGlobalPopup (true);
    //WDate d = WDate::fromString(item->text(), FileModel::dateEditFormat);
    //item->setData(boost::any(d), DisplayRole);


    /*
         * Use a grid layout for the labels and fields
         */
    WGridLayout *layout = new WGridLayout();

    WLabel *l;
    int row = 0;

    //layout->setContentsMargins(0,0,0,0);
    //layout->setVerticalSpacing(3);
    layout->addWidget(container, row, 0,3,0);
    layout->setRowStretch(1, 1);

    layout->addWidget(m_chbPercentEnabled, row, 1,AlignRight);
    layout->addWidget(m_lePercent, row, 2);
    layout->addWidget(l = new WLabel(WString("Процент:",UTF8)), row, 3);
    l->setBuddy(m_lePercent);
    ++row;

    layout->addWidget(m_chbCostEnabled, row, 1,AlignRight);
    layout->addWidget(m_leCost, row, 2);
    layout->addWidget(l = new WLabel(WString("Цена:",UTF8)), row, 3);
    l->setBuddy(m_leCost);
    ++row;
    ++row;
    //layout->addWidget(new WBreak(),row,0);
    layout->addWidget(l = new WLabel(WString("Дата принятия изменения:",UTF8)), row, 2,0,4,AlignLeft);
    layout->setColumnStretch(2, 1);
    //++row;
    //layout->addWidget(new WBreak(),row,0);
    ++row;
    layout->addWidget(m_chbModifyStatic, row, 0);
    layout->addWidget(m_dpModified->lineEdit(), row, 2);
    layout->addWidget(m_dpModified, row, 3);
    l->setBuddy(m_dpModified->lineEdit());
    ++row;

    WLabel* roundingMethodLabel = new WLabel(WString::fromUTF8("Метод округления:"));
    m_roundingMethod = ((Portal *)WApplication::instance())->getSession()->getRoundList(new WComboBox());
    roundingMethodLabel->setBuddy(m_roundingMethod) ;
    layout->addWidget(roundingMethodLabel, row, 0);
    m_roundingMethod->setCurrentIndex(roundIndex-1);
    layout->addWidget(m_roundingMethod, row, 2);

    //roundingMethod->setModel(model);


    WPushButton *b;
    //WContainerWidget *buttons = new WContainerWidget();
    footer()->addWidget(b = new WPushButton(tr("save")));
    b->clicked().connect(this, &WDialog::accept);
    b->setDefault(true);
    contents()->enterPressed().connect(this, &WDialog::accept);
    footer()->addWidget(b = new WPushButton(tr("cancel")));
    b->clicked().connect(this, &WDialog::reject);

    //layout->addWidget(buttons, row, 0, 0, 4, AlignCenter);
    layout->setColumnStretch(1, 1);

    contents()->setLayout(layout);

    finished().connect(this, &PriceEditDialog::handleFinish);

    show();

}
Example #18
0
TreeListExample::TreeListExample(WContainerWidget *parent)
  : WContainerWidget(parent),
    testCount_(0)
{
  tree_ = makeTreeMap(L"TreeListExample", 0);
  addWidget(tree_);
  tree_->expand();

  TreeNode *treelist = makeTreeMap(L"Tree List", tree_);
  TreeNode *wstateicon = makeTreeMap(L"class IconPair", treelist);
  makeTreeFile(L"IconPair.h", wstateicon);
  makeTreeFile(L"IconPair.C", wstateicon);
  TreeNode *wtreenode = makeTreeMap(L"class TreeNode", treelist);
  makeTreeFile(L"TreeNode.h", wtreenode);
  makeTreeFile(L"TreeNode.C", wtreenode);
  TreeNode *wtreeexample = makeTreeMap(L"class TreeListExample", treelist);
  makeTreeFile(L"TreeListExample.h", wtreeexample);
  makeTreeFile(L"TreeListExample.C", wtreeexample);

  testMap_ = makeTreeMap(L"Test map", tree_);

  /*
   * Buttons to demonstrate dynamically changing the tree contents
   * implies no magic at all.
   */
  addWidget
    (new WText(L"<p>Use the following buttons to change the "
	       "contents of the Test map:</p>"));

  WGroupBox *addBox = new WGroupBox(L"Add map", this);

  WLabel *mapNameLabel = new WLabel(L"Map name:", addBox);
  mapNameLabel->setMargin(WLength(1, WLength::FontEx), Right);
  mapNameEdit_ = new WLineEdit(L"Map", addBox);
  mapNameLabel->setBuddy(mapNameEdit_);

  /*
   * Example of validation: make the map name mandatory, and give
   * feedback when invalid.
   */
  mapNameEdit_->setValidator(new WValidator(true));
  WImage *invalid = new WImage("icons/invalid.png");
  WImage *invalidEmpty = new WImage("icons/invalid.png");

  WValidationStatus *statusIcon
    = new WValidationStatus(mapNameEdit_, 0, invalid, invalidEmpty, addBox);
  statusIcon->setMargin(WLength(5), Left | Right);

  addMapButton_ = new WPushButton(L"Add map", addBox);
  addMapButton_->clicked.connect(SLOT(this, TreeListExample::addMap));

  statusIcon->validated.connect(SLOT(addMapButton_, WFormWidget::setEnabled));

  new WBreak(this);

  WGroupBox *removeBox = new WGroupBox(L"Remove map", this);

  removeMapButton_
    = new WPushButton(L"Remove map", removeBox);
  removeMapButton_->clicked.connect(SLOT(this, TreeListExample::removeMap));
  removeMapButton_->disable();
}