Exemplo n.º 1
0
void WItemDelegate::setEditState(WWidget *editor, const boost::any& value) const
{
  WContainerWidget *w = dynamic_cast<WContainerWidget *>(editor);
  WLineEdit *lineEdit = dynamic_cast<WLineEdit *>(w->widget(0));

  lineEdit->setText(boost::any_cast<WT_USTRING>(value));
}
Exemplo n.º 2
0
WWidget *WItemDelegate::createEditor(const WModelIndex& index,
				     WFlags<ViewItemRenderFlag> flags) const
{
  IndexContainerWidget *const result =
      new IndexContainerWidget(index);
  result->setSelectable(true);

  WLineEdit *lineEdit = new WLineEdit();
  lineEdit->setText(asString(index.data(EditRole), textFormat_));
  lineEdit->enterPressed().connect
    (boost::bind(&WItemDelegate::doCloseEditor, this, result, true));
  lineEdit->escapePressed().connect
    (boost::bind(&WItemDelegate::doCloseEditor, this, result, false));
  lineEdit->escapePressed().preventPropagation();

  if (flags & RenderFocused)
    lineEdit->setFocus(true);

  // We use a layout so that the line edit fills the entire cell.
  // Somehow, this does not work with konqueror, but it does respond
  // properly to width, height being set to 100% !
  WApplication *app = WApplication::instance();
  if (app->environment().agent() != WEnvironment::Konqueror) {
    result->setLayout(new WHBoxLayout());
    result->layout()->setContentsMargins(1, 1, 1, 1);
    result->layout()->addWidget(lineEdit);
  } else {
    lineEdit->resize(WLength(100, WLength::Percentage),
		     WLength(100, WLength::Percentage));
    result->addWidget(lineEdit);
  }

  return result;
}
Exemplo n.º 3
0
 GravatarApp(const WEnvironment& env):
     WApplication(env) {
     GravatarImage* gravatar = new GravatarImage("*****@*****.**", root());
     new WBreak(root());
     WLineEdit* email = new WLineEdit(root());
     email->changed().connect(boost::bind(set_email, gravatar, email));
     email->setText("*****@*****.**");
     new WBreak(root());
     WSlider* size = new WSlider(root());
     size->setRange(1, 512);
     size->setValue(80);
     size->valueChanged().connect(boost::bind(set_size, gravatar, size));
     new WBreak(root());
     WButtonGroup* builtin = new WButtonGroup(this);
     builtin->addButton(new WRadioButton("default", root()),
                        GravatarImage::DEFAULT);
     builtin->addButton(new WRadioButton("404", root()),
                        GravatarImage::RETURN_404);
     builtin->addButton(new WRadioButton("mm", root()),
                        GravatarImage::MM);
     builtin->addButton(new WRadioButton("identicon", root()),
                        GravatarImage::IDENTICON);
     builtin->addButton(new WRadioButton("monsterid", root()),
                        GravatarImage::MONSTERID);
     builtin->addButton(new WRadioButton("wavatar", root()),
                        GravatarImage::WAVATAR);
     builtin->addButton(new WRadioButton("retro", root()),
                        GravatarImage::RETRO);
     builtin->addButton(new WRadioButton("custom url", root()),
                        9000);
     WLineEdit* custom_url = new WLineEdit(root());
     custom_url->setText("https://www.google.com/favicon.ico");
     builtin->setCheckedButton(builtin->button(GravatarImage::DEFAULT));
     builtin->checkedChanged().connect(boost::bind(set_default,
                                       gravatar, builtin, custom_url));
     new WBreak(root());
     WButtonGroup* rating = new WButtonGroup(this);
     rating->addButton(new WRadioButton("G", root()), GravatarImage::G);
     rating->addButton(new WRadioButton("PG", root()), GravatarImage::PG);
     rating->addButton(new WRadioButton("R", root()), GravatarImage::R);
     rating->addButton(new WRadioButton("X", root()), GravatarImage::X);
     rating->setCheckedButton(rating->button(GravatarImage::G));
     rating->checkedChanged().connect(boost::bind(set_rating,
                                      gravatar, rating));
     new WBreak(root());
     WCheckBox* fd = new WCheckBox("Force default", root());
     fd->checked().connect(boost::bind(&GravatarImage::set_force_default,
                                       gravatar, true));
     fd->unChecked().connect(boost::bind(&GravatarImage::set_force_default,
                                         gravatar, false));
     new WBreak(root());
     WCheckBox* sr = new WCheckBox("Use https", root());
     sr->setTristate();
     sr->setCheckState(PartiallyChecked);
     sr->checked().connect(boost::bind(&GravatarImage::set_secure_requests,
                                       gravatar, GravatarImage::ALWAYS));
     sr->unChecked().connect(boost::bind(&GravatarImage::set_secure_requests,
                                         gravatar, GravatarImage::NEVER));
 }