void ReportSection::resizeBarDragged(int delta) {
    if(canvasview->document() && canvasview->document()->pageOptions
        && canvasview->document()->pageOptions->getPageSize() == "Labels") {
        return; // we don't want to allow this on reports that are for labels
    }

    int h = canvas->height() + delta;
    if(h < 1) h = 1;
    if(grid->isSnap()) {
        int incr = (int)(grid->yInterval() * dpiY);
        int nh = (h / incr) * incr;
        if(nh == 0) nh = incr;
        h = nh;
    }
    canvas->resize(canvas->width(), h);

    //resize(width(), h + title->height() + 5);
    if(canvasview->document()) canvasview->document()->setModified(TRUE);

    adjustSize();
    QWidget * w = parentWidget();
    if(w)
    {
      w->adjustSize();
      if(w->isA("ReportSectionDetail"))
        w->parentWidget()->adjustSize();
    }
}
void ZLQtOptionsDialog::raiseTab(int i) {
	myTabWidget->raiseWidget(i);
	QWidget *title = getTitleBarWidget();
	if(title->isA("QLabel")) {
		QString s = ::qtString(ZLOptionsDialog::caption());
		s.append(" - ");
		s.append(::qtString((*myTabs[i]).displayName()));
		s.replace(QRegExp("[<]"), "&lt;");
		s.replace(QRegExp("[>]"), "&gt;");
		((QLabel *)title)->setText(s);
	}
}
ZLQtOptionsDialog::ZLQtOptionsDialog(const ZLResource &resource, shared_ptr<ZLRunnable> applyAction) : ZLFullScreenDialog(std::string("X3")), ZLOptionsDialog(resource, applyAction) {
	QWidget *title = getTitleBarWidget();
	if (title->isA("QLabel")) {
		((QLabel *)title)->setText(::qtString(ZLOptionsDialog::caption()));
	}

	myTabWidget = new MyQTabWidget(this);
	setContentWidget(myTabWidget);

	UTIL_CST *cst = (UTIL_CST*)getCSTWidget();
	myMenu = new QPopupMenu(cst);
	QFont f(qApp->font());
	f.setPointSize(15);
	myMenu->setFont(f);
	connect(myMenu, SIGNAL(activated(int)), this, SLOT(selectTab(int)));
	cst->getLeftBtn()->setEnabled(true);
	cst->getLeftBtn()->setPopup(myMenu);
}
Exemple #4
0
enum SetResponse purchaseOrder::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;
  int      itemsiteid;
  int      parentwo = -1;
  int      parentso = -1;
  int      prjid = -1;
  double   qty;
  QDate    dueDate;

  setPoheadid(-1);
  int _prid = -1;
  param = pParams.value("pr_id", &valid);
  if (valid)
    _prid = param.toInt();

  param = pParams.value("itemsite_id", &valid);
  if (valid)
    itemsiteid = param.toInt();
  else
    itemsiteid = -1;

  param = pParams.value("qty", &valid);
  if (valid)
    qty = param.toDouble();
  else
    qty = 0.0;

  param = pParams.value("dueDate", &valid);
  if (valid)
    dueDate = param.toDate();

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if ( (param.toString() == "new") || (param.toString() == "releasePr") )
    {
      _mode = cNew;

      if (param.toString() == "releasePr")
      {
        q.prepare( "SELECT pr_itemsite_id, pr_qtyreq, pr_duedate,"
                   "       CASE WHEN(pr_order_type='W') THEN"
                   "              COALESCE((SELECT womatl_wo_id FROM womatl WHERE womatl_id=pr_order_id),-1)"
                   "            ELSE -1"
                   "       END AS parentwo,"
                   "       CASE WHEN(pr_order_type='S') THEN pr_order_id"
                   "            ELSE -1"
                   "       END AS parentso,"
                   "       pr_prj_id "
                   "FROM pr "
                   "WHERE (pr_id=:pr_id);" );
        q.bindValue(":pr_id", _prid);
        q.exec();
        if (q.first())
        {
          itemsiteid = q.value("pr_itemsite_id").toInt();
          qty = q.value("pr_qtyreq").toDouble();
          dueDate = q.value("pr_duedate").toDate();
          parentwo = q.value("parentwo").toInt();
          parentso = q.value("parentso").toInt();
          prjid = q.value("pr_prj_id").toInt();
        }
        else
        {
          systemError(this, tr("A System Error occurred at %1::%2.")
                            .arg(__FILE__)
                            .arg(__LINE__) );
          return UndefinedError;
        }
      }

      connect(_poitem, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
      connect(_poitem, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_poitem, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
      connect(_vendor, SIGNAL(valid(bool)), _new, SLOT(setEnabled(bool)));
      //_new->setEnabled(TRUE);

      if (itemsiteid != -1)
      {
	      q.prepare( "SELECT itemsite_item_id, itemsrc_id "
                   "FROM itemsite, itemsrc "
                   "WHERE ( (itemsrc_item_id=itemsite_item_id)"
                   " AND (itemsite_id=:itemsite_id) ) "
                    "LIMIT 1;" );
        q.bindValue(":itemsite_id", itemsiteid);
        q.exec();
        if (!q.first())
        {
          QMessageBox::warning(omfgThis, tr("Cannot Create P/O"),
                               tr("<p>A Purchase Order cannot be automatically "
                                  "created for this Item as there are no Item "
                                  "Sources for it.  You must create one or "
                                  "more Item Sources for this Item before "
                                  "the application can automatically create "
                                  "Purchase Orders for it." ) );
          return UndefinedError;
        }

        ParameterList itemSourceParams;
        itemSourceParams.append("item_id", q.value("itemsite_item_id").toInt());
        itemSourceParams.append("qty", qty);
  
        itemSourceList newdlg(omfgThis, "", TRUE);
        newdlg.set(itemSourceParams);
        int itemsrcid = newdlg.exec();
        if (itemsrcid == XDialog::Rejected)
      	{
          deleteLater();
          return UndefinedError;
        }

        q.prepare( "SELECT itemsrc_vend_id "
                   "FROM itemsrc "
                   "WHERE (itemsrc_id=:itemsrc_id);" );
        q.bindValue(":itemsrc_id", itemsrcid);
        q.exec();
        if (!q.first())
        {
          systemError(this, tr("A System Error occurred at %1::%2.")
                            .arg(__FILE__)
                            .arg(__LINE__) );
          return UndefinedError;
        }
        else
        {
          int vendid = q.value("itemsrc_vend_id").toInt();;

          q.prepare( "SELECT pohead_id "
                     "FROM pohead "
                     "WHERE ( (pohead_status='U')"
                     " AND (pohead_vend_id=:vend_id) ) "
                     "ORDER BY pohead_number "
                     "LIMIT 1;" );
          q.bindValue(":vend_id", vendid);
          q.exec();
          if (q.first())
          {
            if(QMessageBox::question( this, tr("An Open Purchase Order Exists"),
                tr("An Open Purchase Order already exists for this Vendor.\n"
                   "Would you like to use this Purchase Order?\n"
                   "Click Yes to use the existing Purchase Order otherwise a new one will be created."),
                QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
            {
//  Use an existing pohead
              _mode = cEdit;

              setPoheadid(q.value("pohead_id").toInt());
              _orderNumber->setEnabled(FALSE);
              _orderDate->setEnabled(FALSE);
              _vendor->setReadOnly(TRUE);
              populate();
            }
            else
            {
              _vendor->setId(vendid);
              createHeader();
            }
          }
          else
          {
//  Create a new pohead for the chosen vend
            _vendor->setId(vendid);
            createHeader();
          }

//  Start to create the new Poitem
          ParameterList newItemParams;
          newItemParams.append("mode", "new");
          newItemParams.append("pohead_id", _poheadid);
          newItemParams.append("itemsrc_id", itemsrcid);

          if (qty > 0.0)
            newItemParams.append("qty", qty);

          if (!dueDate.isNull())
            newItemParams.append("dueDate", dueDate);

          if (parentwo != -1)
            newItemParams.append("parentWo", parentwo);

          if (parentso != -1)
            newItemParams.append("parentSo", parentso);

          if (prjid != -1)
            newItemParams.append("prj_id", prjid);

          purchaseOrderItem poItem(this, "", TRUE);
          poItem.set(newItemParams);
          if (poItem.exec() != XDialog::Rejected)
          {
            if(_mode == cEdit)
            {
              // check for another open window
              QWidgetList list = omfgThis->windowList();
              for(int i = 0; i < list.size(); i++)
              {
                QWidget * w = list.at(i);
                if(w->isA("purchaseOrder") && w != this)
                {
                  purchaseOrder *other = (purchaseOrder*)w;
                  if(_poheadid == other->_poheadid)
                  {
                    if(_prid != -1 && cEdit == other->_mode)
                    {
                      q.prepare("SELECT deletePr(:pr_id) AS _result;");
                      q.bindValue(":pr_id", _prid);
                      q.exec();
                      omfgThis->sPurchaseRequestsUpdated();
                    }
                    other->sFillList();
                    other->setFocus();
                    return UndefinedError;
                  }
                }
              }
            }
            sFillList();
          }
          else
            _prid = -1;
        }
      }
      else
//  This is a new P/O without a chosen Itemsite Line Item
        createHeader();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _orderNumber->setEnabled(FALSE);
      _orderDate->setEnabled(FALSE);
      _warehouse->setEnabled(FALSE);
      _vendor->setReadOnly(TRUE);

      connect(_poitem, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_poitem, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));

      _new->setEnabled(TRUE);

    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _orderNumber->setEnabled(FALSE);
      _orderDate->setEnabled(FALSE);
      _warehouse->setEnabled(FALSE);
	  _taxZone->setEnabled(FALSE);
      _agent->setEnabled(FALSE);
      _terms->setEnabled(FALSE);
      _terms->setType(XComboBox::Terms);
      _vendor->setReadOnly(TRUE);
      _shipVia->setEnabled(FALSE);
      _fob->setEnabled(FALSE);
      _notes->setEnabled(FALSE);
      _new->setEnabled(FALSE);
      _freight->setEnabled(FALSE);
      _tax->setEnabled(FALSE);
      _vendaddrList->hide();
      _purchaseOrderInformation->removePage(_quickEntryTab);
      _poCurrency->setEnabled(FALSE);
      _qeitemView->setEnabled(FALSE);
      _qesave->setEnabled(FALSE);
      _qedelete->setEnabled(FALSE);
      _qecurrency->setEnabled(FALSE);
      _comments->setReadOnly(TRUE);

      _delete->hide();
      _edit->setText(tr("&View"));
      _close->setText(tr("&Close"));
      _save->hide();

      connect(_poitem, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
      connect(_poitem, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));

      _close->setFocus();
    }
  }

  if (_prid != -1 && cNew != _mode)
  {
    q.prepare("SELECT deletePr(:pr_id) AS _result;");
    q.bindValue(":pr_id", _prid);
    q.exec();
    _prid = -1;
    omfgThis->sPurchaseRequestsUpdated();
  }

  if(_prid != -1)
    _pridList.append(_prid);

  param = pParams.value("pohead_id", &valid);
  if (valid)
  {
    setPoheadid(param.toInt());
    populate();
  }

  return NoError;
}
Exemple #5
0
void toMain::commandCallback ( int cmd )
{
    QWidget * focus = qApp->focusWidget();

    if ( focus ) {
        toEditWidget * edit = findEdit ( focus );
        if ( edit && edit != Edit )
            setEditWidget ( edit );
        else if ( focus->inherits ( "QLineEdit" ) ||
                  focus->isA ( "QSpinBox" ) )
            editDisable ( Edit );
    }

    if ( Tools[cmd] )
        Tools[cmd]->createWindow();
    else if ( cmd >= TO_TOOL_ABOUT_ID && cmd <= TO_TOOL_ABOUT_ID_END ) {
        if ( Tools[cmd-TO_ABOUT_ID_OFFSET] )
            Tools[cmd-TO_ABOUT_ID_OFFSET]->about ( this );
    } else if ( cmd >= TO_WINDOWS_WINDOWS && cmd <= TO_WINDOWS_END ) {
        if ( cmd - TO_WINDOWS_WINDOWS < int ( workspace() ->windowList().count() ) )
            workspace() ->windowList().at ( cmd - TO_WINDOWS_WINDOWS ) ->setFocus();
    } else if ( cmd >= TO_STATUS_ID && cmd <= TO_STATUS_ID_END ) {
        QString str = StatusMenu->text ( cmd );
        new toMemoEditor ( this, str );
    } else {
        QWidget *currWidget = qApp->focusWidget();
        toEditWidget *edit = NULL;
        while ( currWidget && !edit ) {
            edit = dynamic_cast<toEditWidget *> ( currWidget );
            currWidget = currWidget->parentWidget();
        }
        if ( edit ) {
            switch ( cmd ) {
            case TO_EDIT_REDO:
                edit->editRedo();
                break;
            case TO_EDIT_UNDO:
                edit->editUndo();
                break;
            case TO_EDIT_COPY:
                edit->editCopy();
                break;
            case TO_EDIT_PASTE:
                edit->editPaste();
                break;
            case TO_EDIT_CUT:
                edit->editCut();
                break;
            case TO_EDIT_SELECT_ALL:
                edit->editSelectAll();;
                break;
            case TO_EDIT_READ_ALL:
                edit->editReadAll();
                break;
            case TO_EDIT_SEARCH:
                if ( !Search )
                    Search = new toSearchReplace ( this );
                edit->editSearch ( Search );
                break;
            case TO_FILE_OPEN:
                edit->editOpen();
                break;
            case TO_FILE_SAVE_AS:
                edit->editSave ( true );
                break;
            case TO_FILE_SAVE:
                edit->editSave ( false );
                break;
            case TO_FILE_PRINT:
                edit->editPrint();
                break;
            }
        }
        switch ( cmd ) {
        case TO_FILE_COMMIT:
            try {
                toConnection & conn = currentConnection();
                emit willCommit ( conn, true );
                conn.commit();
                setNeedCommit ( conn, false );
            }
            TOCATCH
            break;
        case TO_FILE_CLEARCACHE:
            try {
                currentConnection().rereadCache();
            }
            TOCATCH
            toMainWidget() ->checkCaching();
            break;
        case TO_FILE_ROLLBACK:
            try {
                toConnection &conn = currentConnection();
                emit willCommit ( conn, false );
                conn.rollback();
                setNeedCommit ( conn, false );
            }
            TOCATCH
            break;
        case TO_FILE_CURRENT:
            ConnectionSelection->setFocus();
            break;
        case TO_FILE_QUIT:
            close ( true );
            break;
        case TO_EDIT_SEARCH_NEXT:
            if ( Search )
                Search->searchNext();
            break;
        case TO_WINDOWS_CASCADE:
            workspace() ->cascade();
            break;
        case TO_WINDOWS_TILE:
            workspace() ->tile();
            break;
        case TO_NEW_CONNECTION:
            addConnection();
            break;
        case TO_HELP_CONTEXT:
            contextHelp();
            break;
        case TO_HELP_CONTENTS:
            toHelp::displayHelp ( "toc.htm" );
            break;
        case TO_HELP_ABOUT:
        case TO_HELP_LICENSE:
        case TO_HELP_QUOTES: {
            toAbout *about = new toAbout ( cmd - TO_HELP_ABOUT, this, "About TOra", true );
            about->exec();
            delete about;
        }
        break;
        case TO_HELP_REGISTER:
            toCheckLicense ( true );
            break;
        case TO_EDIT_OPTIONS:
            toPreferences::displayPreferences ( this );
            break;
        case TO_WINDOWS_CLOSE_ALL:
            while ( workspace() ->windowList().count() > 0 && workspace() ->windowList().at ( 0 ) )
                if ( workspace() ->windowList().at ( 0 ) &&
                        !workspace() ->windowList().at ( 0 ) ->close ( true ) )
                    return;
            break;
        case TO_WINDOWS_CLOSE:
            QWidget *widget = workspace() ->activeWindow();
            if ( widget )
                widget->close ( true );
            break;
        }
    }
}