Beispiel #1
0
// ---------------------------------------------------------------------
void DateEdit::set(string p,string v)
{
  QDateEdit *w=(QDateEdit*) widget;
  QString cmd=s2q(p);
  QStringList arg=qsplit(v);
  if (arg.isEmpty()) {
    Child::set(p,v);
    return;
  }
  int i,y,m,d;
  if (cmd=="format") {
    w->setDisplayFormat(s2q(remquotes(v)));
  } else if (cmd=="min") {
    i=c_strtoi(q2s(arg.at(0)));
    toymd(i, &y, &m, &d);
    w->setMinimumDate(QDate(y,m,d));
  } else if (cmd=="max") {
    i=c_strtoi(q2s(arg.at(0)));
    toymd(i, &y, &m, &d);
    w->setMaximumDate(QDate(y,m,d));
  } else if (p=="readonly") {
    w->setReadOnly(remquotes(v)!="0");
  } else if (cmd=="value") {
// TODO actually null date does not work because of input mask
    i=c_strtoi(q2s(arg.at(0)));
    if (i) {
      toymd(i, &y, &m, &d);
      w->setDate(QDate(y,m,d));
    } else w->setDate(QDate());
  } else Child::set(p,v);
}
Beispiel #2
0
// ---------------------------------------------------------------------
SpinBox::SpinBox(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="spinbox";
  QSpinBox *w=new QSpinBox;
  QString qn=s2q(n);
  widget=(QWidget*) w;
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"")) return;
  w->setObjectName(qn);
  childStyle(opt);
  w->setLocale(QLocale::C);

  int i=0;
  if (i<opt.size()) {
    w->setMinimum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setSingleStep(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setMaximum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setValue(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  connect(w,SIGNAL(valueChanged(int)),
          this,SLOT(valueChanged()));
}
Beispiel #3
0
// ---------------------------------------------------------------------
ProgressBar::ProgressBar(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="progressbar";
  QProgressBar *w=new QProgressBar;
  widget=(QWidget*) w;
  QString qn=s2q(n);
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"")) return;
  w->setObjectName(qn);
  childStyle(opt);

  int i=0;
  if ((i<opt.size()) && (opt.at(i)=="v")) {
    i++;
    w->setOrientation(Qt::Vertical);
  }
  if (i<opt.size()) {
    w->setMinimum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setMaximum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setValue(c_strtoi(q2s(opt.at(i))));
    i++;
  }
}
Beispiel #4
0
// ---------------------------------------------------------------------
ToolBar::ToolBar(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="toolbar";

  QToolBar *w=new QToolBar;
  widget=(QWidget*) w;
  QString qn=s2q(n);
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"vertical")) return;
  w->setObjectName(qn);
  childStyle(opt);

  if (opt.contains("vertical"))
    w->setOrientation(Qt::Vertical);
  if (opt.size()) {
    QString t=opt.at(0);
    if (qshasonly(t,"0123456789x")) {
      QStringList sizes=t.split('x');
      if (sizes.size()<2) {
        error("invalid icon width, height: " + q2s(t));
        return;
      }
      w->setIconSize(QSize(c_strtoi(q2s(sizes.at(0))),c_strtoi(q2s(sizes.at(1)))));
    }
  }

  connect(w,SIGNAL(actionTriggered(QAction *)),
          this,SLOT(actionTriggered(QAction *)));
}
Beispiel #5
0
// ---------------------------------------------------------------------
void ToolBar::setbutton(string p, QStringList opt)
{
  bool n=true;
  if (opt.isEmpty()) {
    error("set toolbar requires button_id: " + p);
    return;
  } else if (1<opt.size())
    n=!!c_strtoi(q2s(opt.at(1)));
  QString btnid= opt.at(0);
  QAction * a=getaction(btnid);
  if (!a) {
    error("set toolbar cannot find button_id: " + p + " " + q2s(btnid));
    return;
  }
  if (p=="checkable")
    a->setCheckable(n);
  else if (p=="checked")
    a->setChecked(n);
  else if (p=="enable")
    a->setEnabled(n);
  else {
    error("set toolbar attribute error: " + p);
    return;
  }
}
Beispiel #6
0
// ---------------------------------------------------------------------
void Form::settimer(string p)
{
  int n=c_strtoi(p);
  if (n)
    timer->start(n);
  else
    timer->stop();
}
Beispiel #7
0
// ---------------------------------------------------------------------
void ProgressBar::set(string p,string v)
{
  QProgressBar *w=(QProgressBar*) widget;
  QString cmd=s2q(p);
  QStringList arg=qsplit(v);
  if (arg.isEmpty()) {
    Child::set(p,v);
    return;
  }
  if (cmd=="min")
    w->setMinimum(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="max")
    w->setMaximum(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="pos" || cmd=="value")
    w->setValue(c_strtoi((v)));
  else Child::set(p,v);
}
Beispiel #8
0
// ---------------------------------------------------------------------
void ScrollBar::set(string p,string v)
{
  QScrollBar *w=(QScrollBar*) widget;
  QString cmd=s2q(p);
  QStringList arg=qsplit(v);
  if (arg.isEmpty()) {
    Child::set(p,v);
    return;
  }
  if (cmd=="min")
    w->setMinimum(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="max")
    w->setMaximum(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="step")
    w->setSingleStep(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="page")
    w->setPageStep(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="pos"|| cmd=="value")
    w->setSliderPosition(c_strtoi(v));
  else Child::set(p,v);
}
Beispiel #9
0
// ---------------------------------------------------------------------
void SpinBox::set(string p,string v)
{
  QSpinBox *w=(QSpinBox*) widget;
  QString cmd=s2q(p);
  QStringList arg=qsplit(v);
  if (arg.isEmpty()) {
    Child::set(p,v);
    return;
  }
  if (cmd=="min")
    w->setMinimum(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="max")
    w->setMaximum(c_strtoi(q2s(arg.at(0))));
  else if (p=="readonly")
    w->setReadOnly(remquotes(v)!="0");
  else if (cmd=="step")
    w->setSingleStep(c_strtoi(q2s(arg.at(0))));
  else if (cmd=="value")
    w->setValue(c_strtoi(v));
  else Child::set(p,v);
}
Beispiel #10
0
// ---------------------------------------------------------------------
ScrollBar::ScrollBar(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="scrollbar";
  QScrollBar *w=new QScrollBar(Qt::Horizontal);
  QString qn=s2q(n);
  widget=(QWidget*) w;
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"v")) return;
  w->setObjectName(qn);
  childStyle(opt);

  int i=0;
  if ((i<opt.size()) && (opt.at(i)=="v")) {
    w->setOrientation(Qt::Vertical);
    i++;
  }
  if (i<opt.size()) {
    w->setMinimum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setSingleStep(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setPageStep(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setMaximum(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  if (i<opt.size()) {
    w->setSliderPosition(c_strtoi(q2s(opt.at(i))));
    i++;
  }
  connect(w,SIGNAL(valueChanged(int)),
          this,SLOT(valueChanged()));
}
Beispiel #11
0
// ---------------------------------------------------------------------
DateEdit::DateEdit(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="dateedit";
  QDateEdit *w=new QDateEdit;
  QString qn=s2q(n);
  widget=(QWidget*) w;
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"")) return;
  w->setObjectName(qn);
  childStyle(opt);

  w->setCalendarPopup(true);

  int i=0;
  int v,y,m,d;
  if (i<opt.size()) {
    v=c_strtoi(q2s(opt.at(i)));
    toymd(v, &y, &m, &d);
    w->setMinimumDate(QDate(y,m,d));
    i++;
  }
  if (i<opt.size()) {
    v=c_strtoi(q2s(opt.at(i)));
    toymd(v, &y, &m, &d);
    w->setMaximumDate(QDate(y,m,d));
    i++;
  }
  if (i<opt.size()) {
    v=c_strtoi(q2s(opt.at(i)));
    if (v) {
      toymd(v, &y, &m, &d);
      w->setDate(QDate(y,m,d));
    } else w->setDate(QDate());
    i++;
  }
  connect(w,SIGNAL(dateChanged(QDate)),
          this,SLOT(valueChanged()));
}