Пример #1
0
ProvidersEditor::ProvidersEditor( QWidget *parent, bool newProvider, const QSqlDatabase& database )
    : KDialog( parent )
{
    modelCreated = false;
    db = database;
    enableButtonOk(false);

    ui = new ProvidersEditorUI( this );
    setMainWidget( ui );
    setCaption( i18n("Product Editor") );
    setButtons( KDialog::Ok|KDialog::Cancel );

    connect( ui->btnRemove, SIGNAL(clicked()), SLOT( removeItem()) );
    connect( ui->btnAttach, SIGNAL(clicked()), SLOT( addItem()) );
    connect( ui->editName, SIGNAL(editingFinished()), this, SLOT(checkFieldsState()));
    connect( ui->editAddress, SIGNAL(textChanged()), this, SLOT(checkFieldsState()));
    connect( ui->editPhone, SIGNAL(editingFinished()), this, SLOT(checkFieldsState()));
    connect( ui->editCell, SIGNAL(textChanged(const QString &)), this, SLOT(checkFieldsState()));

    QString path = KStandardDirs::locate("appdata", "styles/");
    path = path+"floating_bottom.svg";
    panel = new MibitFloatPanel(this, path, Bottom);
    panel->setSize(350,200);
    panel->setMode(pmManual);
    panel->setHiddenTotally(true);
    panel->addWidget(ui->attachment);

    connect( ui->btnAdd,    SIGNAL(clicked()), panel, SLOT( showPanel() ) );
    connect( ui->btnAttach, SIGNAL(clicked()), panel, SLOT( hidePanel() ) );
    connect( ui->btnCancelAttach, SIGNAL(clicked()), panel, SLOT( hidePanel()) );

    m_pInfo.id = 0;
    m_pInfo.name = "";
    m_pInfo.address = "";
    m_pInfo.phone = "";
    m_pInfo.cell = "";
}
SpecialOrderEditor::SpecialOrderEditor( QWidget *parent, bool newOne )
: KDialog( parent )
{
    m_modelAssigned = false;
    priceEach   = 0;
    paymentEach = 0;
    
    groupInfo.isAvailable = true;
    groupInfo.cost  = 0;
    groupInfo.price = 0;
    groupInfo.count = 0;
    groupInfo.name  = "";

    ui = new SpecialOrderUI( this );
    setMainWidget( ui );
    setCaption( i18n("Special Orders") );
    setButtons( KDialog::Ok|KDialog::Cancel );

    //Set Validators for input boxes
    ui->editAddQty->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3, ui->editAddQty));

    ui->editQty->setValue(1);
    ui->editAddQty->setText("1.00");

    connect( ui->editQty, SIGNAL(editingFinished()), this, SLOT(calculateCost()));
    connect( ui->editQty, SIGNAL(valueChanged(int)), this, SLOT(calculateCost()));

    connect( ui->editQty, SIGNAL(editingFinished()), this, SLOT(checkFieldsState()));
    connect( ui->editPayment, SIGNAL(valueChanged(double)), this, SLOT(checkFieldsState()));
    

    connect( ui->editFilter, SIGNAL(textEdited ( const QString &)), SLOT(applyFilter(const QString &)) );
    connect( ui->btnAdd,    SIGNAL(clicked()), SLOT(addItem()) );
    connect( ui->editAddQty,    SIGNAL(returnPressed()), SLOT(addItem()) );
    connect( ui->btnRemove, SIGNAL(clicked()), SLOT(removeItem()) );
    connect( ui->groupView, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), SLOT(itemDoubleClicked(QTableWidgetItem*)) );

    connect( ui->deliveryDT, SIGNAL(valueChanged(QDateTime)), this, SLOT(checkDate(QDateTime)) );

    connect( ui->editNotes, SIGNAL(textChanged()), SLOT(updateNoteLength()) );

    //for now, when creating a s.o. the status cannot be modified. It can be when edited.
    if (newOne) {
      dateTime         = QDateTime::currentDateTime();
      ui->deliveryDT->setDateTime(QDateTime::currentDateTime().addDays(1));
    }

    //tip
    QString path = KStandardDirs::locate("appdata", "styles/");
    path = path+"tip.svg";
    qtyTip   = new MibitTip(this, ui->editQty, path, DesktopIcon("dialog-warning",32) );
    path = KStandardDirs::locate("appdata", "styles/")+"rotated_tip.svg";
    groupTip = new MibitTip(this, ui->groupView, path, DesktopIcon("dialog-warning",32), tpAbove );

    path = KStandardDirs::locate("appdata", "styles/");
    path = path+"floating_bottom.svg";
    newClientPanel = new MibitFloatPanel(this, path, Top);
    newClientPanel->setSize(550,250);
    newClientPanel->addWidget(ui->frameClient);
    newClientPanel->setMode(pmManual);
    newClientPanel->setHiddenTotally(true);
    ui->editClientName->setEmptyMessage(i18n("Enter client name here..."));
    ui->editClientPhone->setEmptyMessage(i18n("Enter client phone here..."));
    ui->editClientCell->setEmptyMessage(i18n("Enter client cell phone here..."));

    connect( ui->btnNewClient, SIGNAL(clicked()), newClientPanel, SLOT(showPanel() ));
    connect( ui->btnNewClient, SIGNAL(clicked()), this, SLOT(enableCreateClient() ));
    connect( ui->btnClientCancel, SIGNAL(clicked()), newClientPanel, SLOT(hidePanel()));
    connect( ui->btnClientAdd, SIGNAL(clicked()), this, SLOT(createClient()));
    connect( ui->editClientName, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );
    connect( ui->editClientAddress, SIGNAL(textChanged()), this, SLOT(checkValidInfo()) );
    connect( ui->editClientPhone, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );
    connect( ui->editClientCell, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );

    setDefaultButton(KDialog::None);
    ui->btnFilter->setDefault(true);
    ui->btnFilter->hide(); //hack to dont have a default OK or Cancel button

    ui->clientsCombo->setFocus();
    enableButtonOk(false);
}