예제 #1
0
PurchaseEditor::PurchaseEditor( QWidget *parent )
: KDialog( parent )
{
    ui = new PurchaseEditorUI( this );
    setMainWidget( ui );
    setCaption( i18n("Purchase") );
    setButtons( KDialog::Ok|KDialog::Cancel );
    setDefaultButton(KDialog::None);
    ui->btnAddItem->setDefault(true);

    //Set Validators for input boxes
    QRegExp regexpC("[0-9]{1,13}"); //(EAN-13 y EAN-8) .. y productos sin codigo de barras?
    QRegExpValidator * validatorEAN13 = new QRegExpValidator(regexpC, this);
    ui->editCode->setValidator(validatorEAN13);
    ui->editTax->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3,ui->editTax));
    ui->editExtraTaxes->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3,ui->editExtraTaxes));
    ui->editCost->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3, ui->editCost));
    ui->editPoints->setValidator(new QIntValidator(0,999999999, ui->editPoints));
    ui->editFinalPrice->setValidator(new QDoubleValidator(0.00,999999999999.99, 3, ui->editFinalPrice));
    ui->editItemsPerBox->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editItemsPerBox));
    ui->editPricePerBox->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editPricePerBox));
    ui->editQty->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editQty));

    connect( ui->btnPhoto          , SIGNAL( clicked() ), this, SLOT( changePhoto() ) );
    connect( ui->btnCalculatePrice , SIGNAL( clicked() ), this, SLOT( calculatePrice() ) );
    connect( ui->editItemsPerBox , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editPricePerBox , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editCost , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editTax , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editExtraTaxes , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editUtility , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) );
    connect( ui->editCode, SIGNAL(textEdited(const QString &)), SLOT(checkIfCodeExists()));
    connect( ui->editCode, SIGNAL(returnPressed()), ui->editQty, SLOT(setFocus()));
    connect( ui->btnAddItem, SIGNAL( clicked() ), this, SLOT( addItemToList() ) );
    connect(ui->groupBoxedItem, SIGNAL(toggled(bool)), this, SLOT(focusItemsPerBox(bool)) );

    connect(ui->btnRemoveItem, SIGNAL( clicked() ), SLOT( deleteSelectedItem() ) );

    ui->chIsAGroup->setDisabled(true);
    

    status = estatusNormal;
    productExists = false;
    productsHash.clear();
    resetEdits();
    totalBuy = 0.0;
    itemCount = 0.0;
    totalTaxes = 0.0;
    QTimer::singleShot(500, this, SLOT(setupTable()));
}
예제 #2
0
ClientEditor::ClientEditor( QWidget *parent )
: KDialog( parent )
{
    ui = new ClientEditorUI( this );
    setMainWidget( ui );
    setCaption( i18n("Client Editor") );
    setButtons( KDialog::Ok|KDialog::Cancel );
    setDefaultButton(KDialog::NoDefault); //disable default button (return Pressed)
    enableButton(KDialog::Ok, false);

    connect( ui->btnChangeClientPhoto   , SIGNAL( clicked() ), this, SLOT( changePhoto() ) );
    connect( ui->editClientName, SIGNAL(textEdited(const QString &)),this, SLOT( checkNameDelayed()) );
    connect(ui->editClientCode, SIGNAL(returnPressed()),ui->editClientName, SLOT(setFocus()) );
    connect(ui->editClientCode, SIGNAL(editingFinished()),this, SLOT( checkNameDelayed() )); //both returnPressed and lost focus fires this signal. But only fired if validator is accepted.

    QRegExp regexpC("[0-9]{1,13}");
    QRegExpValidator * validator = new QRegExpValidator(regexpC, this);
    ui->editClientPoints->setValidator(validator);
    ui->editClientDiscount->setValidator((new QDoubleValidator(0.00, 100.000, 3,ui->editClientDiscount)));

    //code can contain letters (for ids with letters, like RFC in Mexico)
    QRegExp regexpName("[A-Za-z_0-9\\s\\\\/\\-]+");//any letter, number, both slashes, dash and lower dash. and any space
    QRegExpValidator *regexpAlpha = new QRegExpValidator(regexpName, this);
    ui->editClientCode->setValidator(regexpAlpha);
    //Set filter to the name. Do not allow .,&^% etc...
    ui->editClientName->setValidator(regexpAlpha);

    ui->editClientCode->setEmptyMessage(i18n("Enter a 6, 12, or 13 digits Bar Code."));
    ui->editClientName->setEmptyMessage(i18n("Enter client full name"));
    ui->editClientPhone->setEmptyMessage(i18n("Phone number"));
    ui->editClientCell->setEmptyMessage(i18n("Cell phone number"));
    ui->editClientPoints->setEmptyMessage(i18n("Accumulated points"));
    ui->editClientDiscount->setEmptyMessage(i18n("Personal discount"));

    //since date picker
    ui->sinceDatePicker->setDate(QDate::currentDate());
    
    QTimer::singleShot(750, this, SLOT(checkName()));
    ui->editClientCode->setFocus();
}
예제 #3
0
InputDialog::InputDialog(QWidget *parent, bool integer, DialogType type, QString msg, double min, double max)
{
  dialogType = type;
  _max = max;
  _min = min;
  setParent(parent);
  setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
  setWindowModality(Qt::ApplicationModal);
  setModal(true);

  vLayout       = new QVBoxLayout(this);
  titleLayout   = new QHBoxLayout();
  gridLayout    = new QGridLayout();
  lPixmap       = new QLabel(this);

  // Icons for each type
  if (type == dialogMeasures) lPixmap->setPixmap(DesktopIcon("kruler", 48));
  else if (type == dialogMoney) lPixmap->setPixmap(DesktopIcon("lemon-money", 48));
  else if (type==dialogCashOut) lPixmap->setPixmap(DesktopIcon("lemon-cashout", 48));
  else if (type == dialogTicket) lPixmap->setPixmap(DesktopIcon("lemon-ticket-cancel", 48));
  else if (type == dialogSpecialOrder) lPixmap->setPixmap(DesktopIcon("lemon-ticket", 48));
  else if (type == dialogStockCorrection) lPixmap->setPixmap(DesktopIcon("squeeze-stock-correction", 48));
  else if (type == dialogTerminalNum) lPixmap->setPixmap(DesktopIcon("lemon-money", 48)); //FIXME: add an icon
  else if (type == dialogTicketMsg)   lPixmap->setPixmap(DesktopIcon("lemon-ticket", 48));


  //labels
  titleLayout->addWidget(lPixmap);
  label = new QLabel(msg, this);
  label->setWordWrap(true);
  titleLayout->addWidget(label);
  QSpacerItem *spacerItem2 = new QSpacerItem(50, 50, QSizePolicy::Minimum, QSizePolicy::Maximum);
  vLayout->addLayout(titleLayout);
  vLayout->addItem(spacerItem2);
  productCodeEdit = new KLineEdit(this);
  reasonEdit = new KLineEdit(this);
  lineEdit = new KLineEdit(this);
  productCodeLabel = new QLabel("Product Code:", this);

  if (type == dialogTicketMsg) qLabel = new QLabel(i18n("Month or Season:"));
  else if (type == dialogStockCorrection) qLabel = new QLabel(i18n("New Stock Qty:"));
  else qLabel = new QLabel(i18n("Amount:"));

  if (type == dialogTicketMsg) reasonLabel = new QLabel(i18n("New Message:"), this);
  else reasonLabel = new QLabel(i18n("Reason:"), this);

  if (type == dialogTicket || type == dialogSpecialOrder) qLabel->setText(i18n("Ticket #:"));


  //layout
  gridLayout->addWidget(productCodeLabel, 0,0,0);//1,1);
  gridLayout->addWidget(productCodeEdit, 0,1,0);//1,1);
  gridLayout->addWidget(reasonLabel, 1,0,0);//1,1);
  gridLayout->addWidget(reasonEdit, 1,1,0);//1,1);
  gridLayout->addWidget(qLabel, 2,0,0);//1,1);
  gridLayout->addWidget(lineEdit, 2,1,0);//1,1);
  vLayout->addLayout(gridLayout);

 if (type == dialogCashOut) {
    lineEdit->setClickMessage(i18n("valid amount between %1 and %2", min,max));
    reasonLabel->show();
    reasonEdit->show();
    productCodeEdit->hide();
    productCodeLabel->hide();
  }
  else if (type == dialogStockCorrection ) {
    productCodeEdit->setClickMessage(i18n("Enter the product code here..."));
    lineEdit->setClickMessage(i18n("Enter the new stock quantity here..."));
    productCodeEdit->show();
    productCodeLabel->show();
    reasonLabel->show();
    reasonEdit->show();
  }
  else if (type == dialogTerminalNum) {
   qLabel->setText("Terminal Number:");
   lineEdit->setClickMessage(i18n("Enter the terminal number here..."));
   productCodeEdit->hide();
   productCodeLabel->hide();
   reasonLabel->hide();
   reasonEdit->hide();
  }
  else if (type == dialogTicketMsg) {
   lineEdit->setClickMessage(i18n("Enter the number of the month or season here..."));
   productCodeEdit->hide();
   productCodeLabel->hide();
  }
  else {
    reasonLabel->hide();
    reasonEdit->hide();
    productCodeEdit->hide();
    productCodeLabel->hide();
  }

  //qDebug()<<"Min:"<<min<<"Max:"<<max;
  if (integer) {
    int imin=min; int imax=0;
    if (max>2147483640) imax=2147483647; else imax=max; //max positive value for INT
    //qulonglong imax=max;
    //qDebug()<<"Min:"<<imin<<"Max:"<<imax;
    //FIXME: El valor pasado a max es un DOUBLE, y es mas chico que qulonglong. en mi compu ambos son de 8 bytes.
    //qDebug()<<"Size of qulonglong is "<<sizeof(qulonglong);
    //qDebug()<<"Size of a double is   "<<sizeof(double);
    //NOTE: Nov 21 2009. Returned value is a qulonglong, so integer validator is not good!
    QIntValidator *validator = new QIntValidator(imin, imax,this);
    lineEdit->setValidator(validator);
    //qintvalidator range is in int (not qlonglong)
    // I NEED TO MAKE VALIDATION WITH REGULAR EXPRESSIONS TO SUPPORT LARGE NUMBERS if we need to do so.. ticket numbers larger
    // than 2,147,483,647. For now, its ok, its at the order of billions (thousand millions).
  } else {
    QDoubleValidator *validator = new QDoubleValidator(min, max, 3,this);
    lineEdit->setValidator(validator);
  }
  QRegExp regexpC("[1-9]+[0-9]*[//.]{0,1}[0-9]{0,2}[xX]{0,1}[0-9]{0,13}");
  QRegExpValidator * validatorEAN13 = new QRegExpValidator(regexpC, this);
  productCodeEdit->setValidator(validatorEAN13);

  
  buttonsLayout = new QHBoxLayout();
  buttonAccept = new QPushButton(this);
  buttonAccept->setText(i18n("Ok"));
  buttonAccept->setDefault( true );
  buttonCancel = new QPushButton(this);
  buttonCancel->setText(i18n("Cancel"));
  buttonCancel->setShortcut(Qt::Key_Escape);
  buttonsLayout->addWidget(buttonCancel);
  buttonsLayout->addWidget(buttonAccept);
  if (type == dialogStockCorrection ) {
    buttonAccept->hide();
    buttonCancel->hide();
  }

  //QSpacerItem *spacerItem3 = new QSpacerItem(70, 70, QSizePolicy::Minimum, QSizePolicy::Maximum);
  //buttonsLayout->addItem(spacerItem3);
  vLayout->addLayout(buttonsLayout);

  buttonAccept->setMaximumSize(QSize(130, 27));
  buttonCancel->setMaximumSize(QSize(130, 27));
  lineEdit->setMaximumSize(QSize(260, 27));
  reasonEdit->setMaximumSize(QSize(260, 27));
  productCodeEdit->setMaximumSize(QSize(260, 27));
  
  iValue = 0;
  dValue = 0.0;
  reason = "";

  label->setObjectName("titleLabelInputDialog");

  //style
  //QRect geom = geometry();
  //qDebug()<<"Geometry before resize:"<<geom;
  resize(362,158);
  //geom = geometry();
  //qDebug()<<"Geometry after resize:"<<geom;
  QString path = KStandardDirs::locate("appdata", "styles/");
  QPixmap pixm = QPixmap(path + Settings::styleName() + "/dialog.png");
  setMask( pixm.mask() );
  
  connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
  connect(reasonEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
  connect(buttonAccept, SIGNAL(clicked()), this, SLOT(acceptIt()));
  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
  connect(productCodeEdit, SIGNAL(returnPressed()), this, SLOT(acceptIt()));
}