Logo Search packages:      
Sourcecode: udav version File versions  Download package

argsdialog.cpp

/***************************************************************************
 *   Copyright (C) 2008 by Alexey Balakin                                  *
 *   mathgl.abalakin@gmail.com                                             *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlayout.h>
#include <mgl/mgl_parse.h>
//-----------------------------------------------------------------------------
#include "argsdialog.h"
extern mglParse parser;
//-----------------------------------------------------------------------------
ArgsDialog::ArgsDialog(QWidget *parent) : QDialog(parent)
{
      setWindowTitle(tr("UDAV - Set script arguments"));
      QHBoxLayout *h;
      QVBoxLayout *v;
      QGridLayout *g;
      QLabel *l;
      QPushButton *b;
      
      v = new QVBoxLayout(this);
      g = new QGridLayout();        v->addLayout(g);
      l = new QLabel(tr("String for $1"), this);      g->addWidget(l, 0, 0);
      a[1] = new QLineEdit(this);                           g->addWidget(a[1], 1, 0);
      l = new QLabel(tr("String for $2"), this);      g->addWidget(l, 0, 1);
      a[2] = new QLineEdit(this);                           g->addWidget(a[2], 1, 1);
      l = new QLabel(tr("String for $3"), this);      g->addWidget(l, 2, 0);
      a[3] = new QLineEdit(this);                           g->addWidget(a[3], 3, 0);
      l = new QLabel(tr("String for $4"), this);      g->addWidget(l, 2, 1);
      a[4] = new QLineEdit(this);                           g->addWidget(a[4], 3, 1);
      l = new QLabel(tr("String for $5"), this);      g->addWidget(l, 4, 0);
      a[5] = new QLineEdit(this);                           g->addWidget(a[5], 5, 0);
      l = new QLabel(tr("String for $6"), this);      g->addWidget(l, 4, 1);
      a[6] = new QLineEdit(this);                           g->addWidget(a[6], 5, 1);
      l = new QLabel(tr("String for $7"), this);      g->addWidget(l, 6, 0);
      a[7] = new QLineEdit(this);                           g->addWidget(a[7], 7, 0);
      l = new QLabel(tr("String for $8"), this);      g->addWidget(l, 6, 1);
      a[8] = new QLineEdit(this);                           g->addWidget(a[8], 7, 1);
      l = new QLabel(tr("String for $9"), this);      g->addWidget(l, 8, 0);
      a[9] = new QLineEdit(this);                           g->addWidget(a[9], 9, 0);
      l = new QLabel(tr("String for $0"), this);      g->addWidget(l, 8, 1);
      a[0] = new QLineEdit(this);                           g->addWidget(a[0], 9, 1);
      
      h = new QHBoxLayout();  h->addStretch(1); v->addLayout(h);
      b = new QPushButton(tr("Cancel"), this);  h->addWidget(b);
      connect(b, SIGNAL(clicked()),this, SLOT(reject()));
      b = new QPushButton(tr("OK"), this);            h->addWidget(b);
      connect(b, SIGNAL(clicked()),this, SLOT(putArguments()));
      b->setDefault(true);
}
//-----------------------------------------------------------------------------
ArgsDialog::~ArgsDialog()
{
}
//-----------------------------------------------------------------------------
void ArgsDialog::putArguments()
{
      int len=0, i, j, n;
      for(i=0;i<10;i++)
                  if(a[i]->text().length()>len)
                        len = a[i]->text().length();
      wchar_t *str = new wchar_t[len+2];
      QString s;
      for(i=0;i<10;i++)
      {
            s = a[i]->text(); n = s.length();
            for(j=0;j<n;j++)  str[j] = (s[j]).unicode();
            str[j] = 0;
            parser.AddParam(i, str);
      }
      accept();
}
//-----------------------------------------------------------------------------

Generated by  Doxygen 1.6.0   Back to index