예제 #1
0
파일: table.cpp 프로젝트: 0branch/qtide
// -------------------------------------------------------------------
Table::Table(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="table";
  initglobals();
  ifhdr=false;
  rws=cls=len=0;
  row1=col1=0;
  row2=col2=-1;
  markrow=markcol=0;
  dblclick=QDateTime::currentDateTime();

  QTableWidgex *w=new QTableWidgex(this);
  widget=(QWidget*) w;
  w->setObjectName(s2q(n));
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"selectrows sortable")) return;
  QStringList shape;

  if (opt.size()>=2) {
    if ((isint(q2s(opt.at(0)))) && ((isint(q2s(opt.at(1)))))) {
      shape=qsplit((q2s(opt.at(0)))+" "+(q2s(opt.at(1))));
      setshape(shape);
    }
  }

  w->resizeColumnsToContents();
  w->resizeRowsToContents();
  w->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
  w->horizontalHeader()->setHighlightSections(false);
  w->horizontalHeader()->setStretchLastSection(true);
  w->horizontalHeader()->setVisible(false);

  w->verticalHeader()->setHighlightSections(false);
  w->verticalHeader()->setVisible(false);
  QFontMetrics fm(w->font());
  w->verticalHeader()->setDefaultSectionSize(fm.height() + 6);

  w->setSelectionMode(QAbstractItemView::ContiguousSelection);
  w->setAlternatingRowColors(true);

  if (opt.contains("selectrows")) {
    w->setSelectionBehavior(QAbstractItemView::SelectRows);
    w->selectRow(0);
  }

#ifndef QT50
  if (opt.contains("sortable")) {
    w->horizontalHeader()->setClickable(true);
    connect(w->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),this,SLOT(on_headerClicked(int)));
  }
예제 #2
0
파일: math.cpp 프로젝트: zetaPRIME/asar-tc
const char * createuserfunc(const char * name, const char * arguments, const char * content)
{
	if (!confirmqpar(content)) return "Mismatched parentheses";
	for (int i=0;i<numuserfunc;i++)
	{
		if (!strcmp(name, userfunc[i].name))
		{
			return "Duplicate function name";
		}
	}
	funcdat& thisone=userfunc[numuserfunc];
	thisone.name=strdup(name);
	thisone.argbuf=strdup(arguments);
	thisone.arguments=qsplit(thisone.argbuf, ",", &(thisone.numargs));
	thisone.content=strdup(content);
	for (int i=0;thisone.arguments[i];i++)
	{
		if (!confirmname(thisone.arguments[i]))
		{
			userfunc.remove(numuserfunc);
			return "Invalid argument name";
		}
	}
	numuserfunc++;
	return NULL;
}
예제 #3
0
파일: toolbar.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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 *)));
}
예제 #4
0
파일: dateedit.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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);
}
예제 #5
0
파일: spinbox.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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()));
}
예제 #6
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++;
  }
}
예제 #7
0
파일: sm.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
// set vertical scroll
string smsetscroll(Bedit *e, string q)
{
  if (!e) return"";
  QList<int> s=qsl2intlist(qsplit(q));
  if (s.size()!= 1)
    return smerror("sm set scroll should have a single parameter of scroll size");
  e->settop(s[0]);
  return"";
}
예제 #8
0
파일: sm.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
string smsetselect(Bedit *e, string q)
{
  if (!e) return"";
  QList<int> s=qsl2intlist(qsplit(q));
  if (s.size()!= 2)
    return smerror("sm set select should have begin and end parameters");
  int m=e->toPlainText().size();
  if (s[1]==-1) s[1]=m;
  s[1]=qMin(m,s[1]);
  s[0]=qMin(s[0],s[1]);
  e->setselect(s[0],s[1]-s[0]);
  return"";
}
예제 #9
0
파일: sm.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
string smactive()
{
  string p=cmd.getparms();
  QStringList opt=qsplit(p);
  if (note==0 || note->editIndex()<0)
    return smerror ("No active edit window");
  if (opt[0]!="tab")
    return smerror ("unrecognized sm command parameters: " + p);
  int ndx=opt[1].toInt();
  if (ndx<0 || ndx>=note->count())
    return smerror ("invalid tab index: " + p);
  note->setindex(ndx);
  return "";
}
예제 #10
0
파일: menus.cpp 프로젝트: jsoftware/qtide
// ---------------------------------------------------------------------
QAction *Menus::makeact(string id, string p)
{
  QStringList s=qsplit(p);
  QString text=s.value(0);
  QString shortcut=s.value(1);
  QAction *r = new QAction(text,widget);
  QString name=s2q(id);
  r->setObjectName(name);
  r->setMenuRole(QAction::NoRole);
  if (shortcut.size())
    r->setShortcut(shortcut);
  items[name]=r;
  return r;
}
예제 #11
0
파일: editm.cpp 프로젝트: jsoftware/qtide
// ---------------------------------------------------------------------
Editm::Editm(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="editm";
  EditmPTE *w=new EditmPTE;
  w->pchild=this;
  widget=(QWidget*) w;
  QString qn=s2q(n);
  QStringList opt=qsplit(s);
  if (invalidopt(n,opt,"readonly selectable")) return;
  w->setObjectName(qn);
  childStyle(opt);
  if (opt.contains("readonly")) {
    w->setReadOnly(true);
    if (opt.contains("selectable"))
      w->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
  }
}
예제 #12
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);
}
예제 #13
0
파일: editm.cpp 프로젝트: jsoftware/qtide
// ---------------------------------------------------------------------
void Editm::cmd(string p,string v)
{
  QStringList opt=qsplit(v);
  if (p=="print") {
#ifndef QT_NO_PRINTER
    ((EditmPTE*) widget)->printPreview(config.Printer);
#endif
  } else if (p=="printpreview") {
#ifndef QT_NO_PRINTER
    QPrintPreviewDialog *dlg = new QPrintPreviewDialog(config.Printer, pform);
    dlg->setWindowTitle("Preview Document");
    QObject::connect(dlg,SIGNAL(paintRequested(QPrinter *)),((EditmPTE*) widget),SLOT(printPreview(QPrinter *)));
    dlg->exec();
    delete dlg;
    config.Printer->setPrintRange(QPrinter::AllPages);
#endif
  } else Child::set(p,v);
예제 #14
0
파일: opengl.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
Opengl::Opengl(string n, string s, Form *f, Pane *p) : Child(n,s,f,p)
{
  type="opengl";
  QString qn=s2q(n);
  QStringList opt=qsplit(s);
  if (invalidoptn(n,opt,"version compatibility")) return;
#ifdef USE_QOpenGLWidget
  QSurfaceFormat qglFormat;
#else
  QGLFormat qglFormat;
  qglFormat.setSampleBuffers(true);
#endif
#ifdef QT47
  int l=opt.indexOf("version");
  if ((l!=-1) && (l<opt.size()-1) && 0!=opt.at(l+1).toDouble()) {
    int ver1,ver2;
    QString s=opt.at(l+1);
    int d=s.indexOf(".");
    if (d==-1) {
      ver1=s.toInt();
      ver2=0;
    } else {
      ver1=s.mid(0,d).toInt();
      ver2=s.mid(d+1).toInt();
    }
//    qDebug() << QString::number(ver1) << QString::number(ver2);
    qglFormat.setVersion(ver1,ver2);
  }
#ifdef USE_QOpenGLWidget
  if (opt.contains("compatibility")) qglFormat.setProfile(QSurfaceFormat::CompatibilityProfile);
  else qglFormat.setProfile(QSurfaceFormat::CoreProfile);
#else
  if (opt.contains("compatibility")) qglFormat.setProfile(QGLFormat::CompatibilityProfile);
  else qglFormat.setProfile(QGLFormat::CoreProfile);
#endif
#endif

  Opengl2 *w= new Opengl2(this, qglFormat);
  widget=(QWidget *) w;
  w->setObjectName(qn);
  childStyle(opt);
  opengl = this;
}
예제 #15
0
파일: sm.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
string smsetxywh(string m,string q)
{
  QWidget *w;
  if (m=="term")
    w=term;
  else if (m=="edit")
    w=note;
  else
    w=note2;
  QList<int> s=qsl2intlist(qsplit(q));
  QPoint p=w->pos();
  QSize z=w->size();
  if (s[0]==-1) s[0]=p.rx();
  if (s[1]==-1) s[1]=p.ry();
  if (s[2]==-1) s[2]=z.width();
  if (s[3]==-1) s[3]=z.height();
  w->move(s[0],s[1]);
  w->resize(s[2],s[3]);
  return"";
}
예제 #16
0
파일: toolbar.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
void ToolBar::set(string p,string v)
{

  QToolBar *w=(QToolBar *)widget;
  QStringList opt=qsplit(v);
  if (p=="add")
    makeact(opt);
  else if (p=="addsep")
    w->addSeparator();
  else if (p=="checkable")
    setbutton(p,opt);
  else if (p=="checked")
    setbutton(p,opt);
  else if (p=="enable") {
    if (opt.isEmpty()) Child::set(p,v);
    else if (1==opt.size() && (!opt.at(0).isEmpty()) && opt.at(0)[0].isNumber()) Child::set(p,v);
    else setbutton(p,opt);
  } else
    Child::set(p,v);
}
예제 #17
0
파일: scrollbar.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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);
}
예제 #18
0
파일: spinbox.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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);
}
예제 #19
0
// ---------------------------------------------------------------------
void Form::settaborder(string p)
{
  Child *c0,*c1;
  QStringList cs=qsplit(p);
  if (2>cs.size()) {
    error("taborder requires at least 2 child ids: " + p);
    return;
  }
  for (int i=0; cs.size()-1>i; i++) {
    c0=this->id2child(q2s(cs.at(i)));
    if (!c0 || !c0->widget) {
      error("taborder invalid child id: '" + q2s(cs.at(i)) + "' in " + p);
      return;
    }
    c1=this->id2child(q2s(cs.at(i+1)));
    if (!c1 || !c1->widget) {
      error("taborder invalid child id: '" + q2s(cs.at(i+1)) + "' in " + p);
      return;
    }
    QWidget::setTabOrder(c0->widget,c1->widget);
  }
}
예제 #20
0
파일: scrollbar.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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()));
}
예제 #21
0
파일: dateedit.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
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()));
}
예제 #22
0
파일: sm.cpp 프로젝트: 0branch/qtide
// ---------------------------------------------------------------------
string smget()
{
  string p=cmd.getparms();
  if (p.size()==0)
    return smerror("sm get needs additional parameters");
  if (p=="active")
    return smgetactive();
  if (p=="term" || p=="edit" || p=="edit2")
    return smgetwin(p);
  if (p=="termcwh")
    return smgettermcwh();
  if (p=="inputlog")
    return smgetinputlog();
  if (p=="xywh")
    return smgetxywh();
  QStringList s=qsplit(p);
  if (s[0]=="tabs") {
    if(s.size()<=1)
      return smerror("sm command requires another parameter: get tabs");
    else
      return smgettabs(s[1]);
  }
  return smerror("unrecognized sm command: get " + p);
}