Logo Search packages:      
Sourcecode: lemonpos-kde4 version File versions  Download package

void lemonView::itemDoubleClicked ( QTableWidgetItem *  item  )  [private, slot]

Slot used to increment qty on doubleclick on an item

Definition at line 998 of file lemonview.cpp.

References refreshTotalLabel().

Referenced by doInsertItem(), and itemSearchDoubleClicked().

{
  int row = item->row();
  QTableWidgetItem *i2Modify = ui_mainview.tableWidget->item(row, colCode);
  qulonglong code = i2Modify->data(Qt::DisplayRole).toULongLong();
  ProductInfo info = productsHash.take(code);
  double dmaxItems = info.stockqty;
  int    imaxItems = info.stockqty;
  QString msg = i18n("Enter the number of %1", info.unitStr); //Added on Dec 15, 2007

  //Launch a dialog to as the new qty
  double dqty = 0.0;
  bool   ok   = false;
  int    iqty = 0;
  if (info.units == uPiece) {
    InputDialog *dlg = new InputDialog(this, true, dialogMeasures, msg, 0.0, imaxItems);
    if (dlg->exec() ) {
      iqty = dlg->iValue;
      ok=true;
    }
  }
  else {
    InputDialog *dlg = new InputDialog(this, false, dialogMeasures, msg, 0.001, dmaxItems);
    if (dlg->exec() ) {
      dqty = dlg->dValue;
      ok=true;
    }
  }
  if (ok) {
    double newqty = dqty+iqty; //one must be cero
    //modify Qty and discount...
    i2Modify = ui_mainview.tableWidget->item(row, colQty);
    i2Modify->setData(Qt::EditRole, QVariant(newqty));
    double price    = info.price;
    double discountperitem = info.disc;
    double newdiscount = discountperitem*newqty;
    i2Modify = ui_mainview.tableWidget->item(row, colDue);
    i2Modify->setData(Qt::EditRole, QVariant((newqty*price)-newdiscount));
    i2Modify = ui_mainview.tableWidget->item(row, colDisc);
    i2Modify->setData(Qt::EditRole, QVariant(newdiscount));
    info.qtyOnList = newqty;

    ui_mainview.editItemCode->setFocus();
  }
  productsHash.insert(code, info);
  refreshTotalLabel();
}


Generated by  Doxygen 1.6.0   Back to index