UserEditor::UserEditor( QWidget *parent ) : KDialog( parent ) { ui = new UserEditorUI( this ); setMainWidget( ui ); setCaption( i18n("User Editor") ); setButtons( KDialog::Ok|KDialog::Cancel ); connect( ui->btnChangeUserPhoto , SIGNAL( clicked() ), this, SLOT( changePhoto() ) ); connect( ui->editUsersUsername, SIGNAL(textEdited(const QString &)),this, SLOT(checkName()) ); QTimer::singleShot(750, this, SLOT(checkName())); }
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())); }
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(); }