void AddressBook::addToPopup(QPopupMenu* menu) { ActiveList::addToPopup(menu); menu->insertItem(tr("Send Email"), this, SLOT(slotEmail())); Card card; if (!_quasar->db()->lookup(currentId(), card)) return; if (card.dataType() == DataObject::PERSONAL) return; if (card.dataType() == DataObject::EMPLOYEE) return; menu->insertItem(tr("Inquiry"), this, SLOT(slotInquiry())); menu->insertItem(tr("Find Tx"), this, SLOT(slotFindTx())); if (card.dataType() == DataObject::CUSTOMER) { menu->insertItem(tr("Aged List"), this, SLOT(slotAgedAR())); menu->insertItem(tr("Sales"), this, SLOT(slotSales())); menu->insertItem(tr("Payment"), this, SLOT(slotReceipt())); menu->insertItem(tr("Withdraw"), this, SLOT(slotWithdraw())); menu->insertItem(tr("Write Cheque"), this, SLOT(slotCheque())); menu->insertItem(tr("Allocate"), this, SLOT(slotAllocate())); } if (card.dataType() == DataObject::VENDOR) { menu->insertItem(tr("Aged List"), this, SLOT(slotAgedAP())); menu->insertItem(tr("Purchases"), this, SLOT(slotPurchases())); menu->insertItem(tr("Payment"), this, SLOT(slotPayment())); menu->insertItem(tr("Allocate"), this, SLOT(slotAllocate())); } }
CustomerMaster::CustomerMaster(MainWindow* main, Id customer_id) : DataWindow(main, "CustomerMaster", customer_id) { _helpSource = "customer_master.html"; QPushButton* email = new QPushButton(tr("Email"), _buttons); connect(email, SIGNAL(clicked()), SLOT(slotEmail())); // Create widgets _company = new QCheckBox(tr("&Company?"), _frame); connect(_company, SIGNAL(toggled(bool)), SLOT(companyChanged(bool))); _label1 = new QLabel(_frame); _entry1 = new LineEdit(30, _frame); _label1->setBuddy(_entry1); _label2 = new QLabel(_frame); _entry2 = new LineEdit(30, _frame); _label2->setBuddy(_entry2); QLabel* numberLabel = new QLabel(tr("Number:"), _frame); _number = new LineEdit(12, _frame); numberLabel->setBuddy(_number); QLabel* typeLabel = new QLabel(tr("Type:"), _frame); _type = new LookupEdit(new CustomerTypeLookup(_main, this), _frame); _type->setSizeInfo(12, 'x'); _type->setMinCharWidth(12); _type->setMaxLength(20); typeLabel->setBuddy(_type); connect(_type, SIGNAL(validData()), this, SLOT(typeChanged())); QGroupBox* addr = new QGroupBox(tr("Address"), _frame); QGridLayout* grid1 = new QGridLayout(addr, 7, 4, addr->frameWidth() * 2); grid1->addRowSpacing(0, addr->fontMetrics().height()); grid1->setColStretch(2, 1); QLabel* streetLabel = new QLabel(tr("Street:"), addr); _street = new LineEdit(addr); _street->setLength(60); streetLabel->setBuddy(_street); _street2 = new LineEdit(addr); _street2->setLength(60); QLabel* cityLabel = new QLabel(tr("City:"), addr); _city = new LineEdit(20, addr); cityLabel->setBuddy(_city); QLabel* provLabel = new QLabel(tr("Prov/State:"), addr); _province = new LineEdit(20, addr); provLabel->setBuddy(_province); QLabel* postalLabel = new QLabel(tr("Postal/Zip:"), addr); _postal = new LineEdit(20, addr); postalLabel->setBuddy(_postal); QLabel* countryLabel = new QLabel(tr("Country:"), addr); _country = new LineEdit(20, addr); countryLabel->setBuddy(_country); QLabel* phoneLabel = new QLabel(tr("Phone #:"), addr); _phone_num = new LineEdit(20, addr); phoneLabel->setBuddy(_phone_num); QLabel* phone2Label = new QLabel(tr("Phone2 #:"), addr); _phone2_num = new LineEdit(20, addr); phone2Label->setBuddy(_phone2_num); QLabel* faxLabel = new QLabel(tr("Fax #:"), addr); _fax_num = new LineEdit(20, addr); faxLabel->setBuddy(_fax_num); QLabel* emailLabel = new QLabel(tr("Email:"), addr); _email = new LineEdit(60, addr); emailLabel->setBuddy(_email); QLabel* webLabel = new QLabel(tr("Web Page:"), addr); _web_page = new LineEdit(60,addr); webLabel->setBuddy(_web_page); grid1->addWidget(streetLabel, 1, 0); grid1->addMultiCellWidget(_street, 1, 1, 1, 4, AlignLeft | AlignVCenter); grid1->addMultiCellWidget(_street2, 2, 2, 1, 4, AlignLeft | AlignVCenter); grid1->addWidget(cityLabel, 3, 0); grid1->addWidget(_city, 3, 1, AlignLeft | AlignVCenter); grid1->addWidget(provLabel, 3, 3); grid1->addWidget(_province, 3, 4, AlignLeft | AlignVCenter); grid1->addWidget(postalLabel, 4, 0); grid1->addWidget(_postal, 4, 1, AlignLeft | AlignVCenter); grid1->addWidget(countryLabel, 4, 3); grid1->addWidget(_country, 4, 4, AlignLeft | AlignVCenter); grid1->addWidget(phoneLabel, 5, 0); grid1->addWidget(_phone_num, 5, 1, AlignLeft | AlignVCenter); grid1->addWidget(phone2Label, 5, 3); grid1->addWidget(_phone2_num, 5, 4, AlignLeft | AlignVCenter); grid1->addWidget(faxLabel, 6, 0); grid1->addWidget(_fax_num, 6, 1, AlignLeft | AlignVCenter); grid1->addWidget(emailLabel, 7, 0); grid1->addMultiCellWidget(_email, 7, 7, 1, 4, AlignLeft | AlignVCenter); grid1->addWidget(webLabel, 8, 0); grid1->addMultiCellWidget(_web_page, 8, 8, 1, 4, AlignLeft | AlignVCenter); QTabWidget* tabs = new QTabWidget(_frame); QFrame* control = new QFrame(tabs); QFrame* groupTab = new QFrame(tabs); QFrame* trans = new QFrame(tabs); QFrame* refsTab = new QFrame(tabs); QFrame* extraTab = new QFrame(tabs); tabs->addTab(control, tr("Control")); tabs->addTab(groupTab, tr("Groups")); tabs->addTab(trans, tr("Transactions")); tabs->addTab(refsTab, tr("References")); tabs->addTab(extraTab, tr("Extra Info")); QLabel* patgroupLabel = new QLabel(tr("Patronage Group:"), control); _patgroup_id = new LookupEdit(new PatGroupLookup(main, this), control); _patgroup_id->setLength(20); _patgroup_id->setFocusPolicy(NoFocus); patgroupLabel->setBuddy(_patgroup_id); QLabel* accountLabel = new QLabel(tr("AR Account:"), control); _account_id = new LookupEdit(new AccountLookup(main, this, Account::AR), control); _account_id->setLength(30); accountLabel->setBuddy(_account_id); QLabel* termLabel = new QLabel(tr("Terms:"), control); _term_id = new LookupEdit(new TermLookup(main, this), control); _term_id->setLength(30); termLabel->setBuddy(_term_id); QLabel* exemptLabel = new QLabel(tr("Tax Exempt:"), control); _exempt_id = new LookupEdit(new TaxLookup(main, this), control); _exempt_id->setLength(30); exemptLabel->setBuddy(_exempt_id); QLabel* creditLabel = new QLabel(tr("Credit Limit:"), control); _credit_limit = new MoneyEdit(control); _credit_limit->setLength(14); creditLabel->setBuddy(_credit_limit); _credit_hold = new QCheckBox(tr("Credit Hold?"), control); QLabel* scLabel = new QLabel(tr("Service Charge:"), control); _sc_rate = new PercentEdit(control); _sc_rate->setLength(8); scLabel->setBuddy(_sc_rate); _print_stmts = new QCheckBox(tr("Statements?"), control); QGridLayout* conGrid = new QGridLayout(control); conGrid->setSpacing(3); conGrid->setMargin(3); conGrid->setColStretch(3, 1); conGrid->addWidget(patgroupLabel, 0, 0); conGrid->addMultiCellWidget(_patgroup_id, 0,0,1,2,AlignLeft|AlignVCenter); conGrid->addWidget(accountLabel, 1, 0); conGrid->addMultiCellWidget(_account_id, 1,1,1,2,AlignLeft|AlignVCenter); conGrid->addWidget(termLabel, 2, 0); conGrid->addMultiCellWidget(_term_id, 2, 2, 1, 2, AlignLeft|AlignVCenter); conGrid->addWidget(exemptLabel, 3, 0); conGrid->addMultiCellWidget(_exempt_id, 3, 3, 1, 2,AlignLeft|AlignVCenter); conGrid->addWidget(creditLabel, 4, 0); conGrid->addWidget(_credit_limit, 4, 1, AlignLeft | AlignVCenter); conGrid->addWidget(_credit_hold, 4, 2, AlignLeft | AlignVCenter); conGrid->addWidget(scLabel, 5, 0); conGrid->addWidget(_sc_rate, 5, 1, AlignLeft | AlignVCenter); conGrid->addWidget(_print_stmts, 5, 2, AlignLeft | AlignVCenter); _groups = new Table(groupTab); _groups->setVScrollBarMode(QScrollView::AlwaysOn); _groups->setDisplayRows(2); _groups->setLeftMargin(fontMetrics().width("999")); connect(_groups, SIGNAL(cellChanged(int,int,Variant)), SLOT(groupCellChanged(int,int,Variant))); GroupLookup* groupLookup = new GroupLookup(_main, this, Group::CUSTOMER); new LookupColumn(_groups, tr("Group Name"), 20, groupLookup); new LookupEditor(_groups, 0, new LookupEdit(groupLookup, _groups)); QGridLayout* groupGrid = new QGridLayout(groupTab); groupGrid->setSpacing(6); groupGrid->setMargin(3); groupGrid->setRowStretch(0, 1); groupGrid->setColStretch(0, 1); groupGrid->addWidget(_groups, 0, 0); _charge = new QCheckBox(tr("Can Charge?"), trans); _withdraw = new QCheckBox(tr("Can Withdraw?"), trans); _payment = new QCheckBox(tr("Can Make Payment?"), trans); _check_bal = new QCheckBox(tr("Check Withdraw Balance?"), trans); _second_rcpt = new QCheckBox(tr("Second Receipt?"), trans); _discs = new Table(trans); _discs->setVScrollBarMode(QScrollView::AlwaysOn); _discs->setDisplayRows(2); _discs->setLeftMargin(fontMetrics().width("999")); connect(_discs, SIGNAL(cellChanged(int,int,Variant)), SLOT(discountCellChanged(int,int,Variant))); DiscountLookup* discLookup = new DiscountLookup(_main, this); discLookup->txOnly = true; new LookupColumn(_discs, tr("Discount"), 20, discLookup); new LookupEditor(_discs, 0, new LookupEdit(discLookup, _discs)); QGridLayout* transGrid = new QGridLayout(trans); transGrid->setSpacing(6); transGrid->setMargin(3); transGrid->setRowStretch(5, 1); transGrid->setColStretch(1, 1); transGrid->addWidget(_charge, 0, 0, AlignLeft | AlignVCenter); transGrid->addWidget(_withdraw, 1, 0, AlignLeft | AlignVCenter); transGrid->addWidget(_payment, 2, 0, AlignLeft | AlignVCenter); transGrid->addWidget(_check_bal, 3, 0, AlignLeft | AlignVCenter); transGrid->addWidget(_second_rcpt, 4, 0, AlignLeft | AlignVCenter); transGrid->addMultiCellWidget(_discs, 0, 5, 2, 2); _refs = new Table(refsTab); _refs->setVScrollBarMode(QScrollView::AlwaysOn); _refs->setDisplayRows(2); _refs->setLeftMargin(fontMetrics().width("999")); connect(_refs, SIGNAL(cellChanged(int,int,Variant)), SLOT(refCellChanged(int,int,Variant))); new TextColumn(_refs, tr("Reference"), 16); LineEdit* refEdit = new LineEdit(_refs); refEdit->setMaxLength(16); new LineEditor(_refs, 0, refEdit); QGridLayout* refGrid = new QGridLayout(refsTab); refGrid->setSpacing(6); refGrid->setMargin(3); refGrid->setRowStretch(0, 1); refGrid->setColStretch(0, 1); refGrid->addWidget(_refs, 0, 0); _extra = new Table(extraTab); _extra->setVScrollBarMode(QScrollView::AlwaysOn); _extra->setDisplayRows(2); _extra->setLeftMargin(fontMetrics().width("999")); connect(_extra, SIGNAL(focusNext(bool&,int&,int&,int)), SLOT(extraFocusNext(bool&,int&,int&,int))); ExtraLookup* extraLookup = new ExtraLookup(_main, this, "Customer"); new LookupColumn(_extra, tr("Data Name"), 30, extraLookup); new TextColumn(_extra, tr("Value"), 30); new LineEditor(_extra, 1, new LineEdit(_extra)); QPushButton* createData = new QPushButton(tr("Create Data"), extraTab); QPushButton* deleteData = new QPushButton(tr("Delete Data"), extraTab); QPushButton* renameData = new QPushButton(tr("Rename Data"), extraTab); connect(createData, SIGNAL(clicked()), SLOT(slotCreateData())); connect(deleteData, SIGNAL(clicked()), SLOT(slotDeleteData())); connect(renameData, SIGNAL(clicked()), SLOT(slotRenameData())); QGridLayout* extraGrid = new QGridLayout(extraTab); extraGrid->setSpacing(6); extraGrid->setMargin(3); extraGrid->setRowStretch(0, 1); extraGrid->setColStretch(0, 1); extraGrid->addMultiCellWidget(_extra, 0, 0, 0, 3); extraGrid->addWidget(createData, 1, 1); extraGrid->addWidget(deleteData, 1, 2); extraGrid->addWidget(renameData, 1, 3); _open_bal = new QGroupBox(tr("Opening Balance"), _frame); QGridLayout* i_grid = new QGridLayout(_open_bal, 2, 2, _open_bal->frameWidth() * 2); i_grid->addRowSpacing(0, _open_bal->fontMetrics().height()); QLabel* asOfLabel = new QLabel(tr("As of"), _open_bal); _as_of = new DatePopup(_open_bal); asOfLabel->setBuddy(_as_of); QLabel* openBalLabel = new QLabel(tr("Balance:"), _open_bal); _open_balance = new MoneyEdit(_open_bal); _open_balance->setLength(20); openBalLabel->setBuddy(_open_balance); i_grid->setColStretch(2, 1); i_grid->addWidget(asOfLabel, 1, 0, AlignLeft); i_grid->addWidget(_as_of, 2, 0, AlignLeft | AlignVCenter); i_grid->addWidget(openBalLabel, 1, 1, AlignLeft); i_grid->addWidget(_open_balance, 2, 1, AlignLeft | AlignVCenter); Company company; _quasar->db()->lookup(company); if (_id != INVALID_ID || company.historicalBalancing() == INVALID_ID) _open_bal->hide(); QGridLayout* grid = new QGridLayout(_frame); grid->setSpacing(3); grid->setMargin(3); grid->setRowStretch(4, 1); grid->setColStretch(2, 1); grid->addColSpacing(2, 10); grid->addWidget(_company, 0, 0); grid->addWidget(_label1, 1, 0, AlignLeft | AlignVCenter); grid->addWidget(_entry1, 1, 1, AlignLeft | AlignVCenter); grid->addWidget(_label2, 2, 0, AlignLeft | AlignVCenter); grid->addWidget(_entry2, 2, 1, AlignLeft | AlignVCenter); grid->addWidget(numberLabel, 1, 3, AlignLeft | AlignVCenter); grid->addWidget(_number, 1, 4, AlignLeft | AlignVCenter); grid->addWidget(typeLabel, 2, 3, AlignLeft | AlignVCenter); grid->addWidget(_type, 2, 4, AlignLeft | AlignVCenter); grid->addMultiCellWidget(addr, 3, 3, 0, 4); grid->addMultiCellWidget(tabs, 4, 4, 0, 4); grid->addMultiCellWidget(_open_bal, 5, 5, 0, 4); setCaption(tr("Customer Master")); finalize(); }
QmvFormTool::QmvFormTool( QmvRelationWidget * rlw, QmvApplication * parent, const char * name ) : QmvToolWindow( rlw->getRelation(), parent, name ) { // ------------------------------------------------------------ // Query Objects // ------------------------------------------------------------ // Form header fh = 0; pagesize = background.size(); if ( rlw ) rlw_form = rlw; else throw( QmvException( QString( "<h3>QmvFormTool::QmvFormTool</h2>" "Failed to build FORM object" ), QmvException::Critical) ); reln_form = rlw->getRelation(); if ( !reln_form ) throw( QmvException( QString( "<h3>QmvFormTool::QmvFormTool</h2>" "Failed to build FORM object" ), QmvException::Critical) ); // Form details. QmvSqlClass * fmdt_existing = (QmvSqlClass *) reln_form->dataBase()->dbRelation( "fmdt" ); if ( fmdt_existing ) reln_fmdt = new QmvSqlClass( *fmdt_existing ); else throw( QmvException( QString( "<h3>QmvFormTool::QmvFormTool</h2>" "Failed to build FMDT object" ), QmvException::Critical) ); // ------------------------------------------- // Mouse Clicks ------------------------------ // ------------------------------------------- // notice button clicks on grid connect( canvasView(), SIGNAL( clicked( QCanvasItem *, const QPoint &, ButtonState, ButtonState ) ), this, SLOT( popupEventDetails( QCanvasItem *, const QPoint &, ButtonState, ButtonState ) ) ); // doubleclick - edit connect( canvasView(), SIGNAL( doubleClicked( QCanvasItem *, const QPoint &, ButtonState, ButtonState ) ), this, SLOT( dataChangeRequested( QCanvasItem *, const QPoint &, ButtonState, ButtonState ) ) ); // notice grid movements connect( canvasView(), SIGNAL( moved( QCanvasItem *, const QPoint &, const QPoint & ) ), this, SLOT( eventLabelMoved( QCanvasItem *, const QPoint &, const QPoint & ) ) ); // notice resizes connect( canvasView(), SIGNAL( resized( QCanvasItem *, const QRect &, const QRect & ) ), this, SLOT( eventLabelResized( QCanvasItem *, const QRect &, const QRect & ) ) ); // --- ACCELERATORS --------------------------------------- // ------------------------------------------------------------ QAccel * ap_accel = new QAccel( this, "forms" ); int a_id; // line down a_id = ap_accel->insertItem( Key_Down ); ap_accel->connectItem( a_id, this, SLOT( slotLineDown() ) ); ap_accel->setWhatsThis( a_id, "Scroll down one line" ); // line up a_id = ap_accel->insertItem( Key_Up ); ap_accel->connectItem( a_id, this, SLOT( slotLineUp() ) ); ap_accel->setWhatsThis( a_id, "Scroll up one line" ); // page down a_id = ap_accel->insertItem( Key_Next ); ap_accel->connectItem( a_id, this, SLOT( slotPageDown() ) ); ap_accel->setWhatsThis( a_id, "Scroll down one page" ); // page up a_id = ap_accel->insertItem( Key_Prior ); ap_accel->connectItem( a_id, this, SLOT( slotPageUp() ) ); ap_accel->setWhatsThis( a_id, "Scroll up one page" ); QAction * ac; QActionGroup * ag_insert = new QActionGroup( this, "ag_insert" ); // ------------------------------------------------------------ // Navigation Toolbar // ------------------------------------------------------------ // clear the navigation toolbar - not needed yet navigationToolBar()->clear(); // ------------------------------------------------------------ // Tool buttons for adding detail objects // ------------------------------------------------------------ ag_insert->setExclusive(TRUE); QSignalMapper *ndt_sigmap = new QSignalMapper( this ); connect( ndt_sigmap, SIGNAL( mapped(int) ), this, SLOT( slotAddNewDetail(int) ) ); // Label ----------------------------------------------------- ac = new QAction( "Text", *stdicons->makeTextPixmap( new QPixmap(stdicons->getPixmap(QmvIcons::BlankPageIcon)), tr("T"), QFont("Times"), QColor( blue ), QRect() ), "Text", ALT+SHIFT+Key_T, ag_insert, "text", FALSE ); ndt_sigmap->setMapping( ac, formDetail::Label ); connect( ac, SIGNAL( activated() ), ndt_sigmap, SLOT( map() ) ); // Field ----------------------------------------------------- ac = new QAction( "Field", *stdicons->makeTextPixmap( new QPixmap(stdicons->getPixmap(QmvIcons::BlankPageIcon)), tr("F"), QFont("Times"), QColor( blue ), QRect() ), "Field", ALT+SHIFT+Key_F, ag_insert, "Field", FALSE ); ndt_sigmap->setMapping( ac, formDetail::Field ); connect( ac, SIGNAL( activated() ), ndt_sigmap, SLOT( map() ) ); // Line ----------------------------------------------------- ac = new QAction( "Line", *stdicons->makeTextPixmap( new QPixmap(stdicons->getPixmap(QmvIcons::BlankPageIcon)), tr("L"), QFont("Times"), QColor( blue ), QRect() ), "Line", ALT+SHIFT+Key_L, ag_insert, "Line", FALSE ); ndt_sigmap->setMapping( ac, formDetail::Line ); connect( ac, SIGNAL( activated() ), ndt_sigmap, SLOT( map() ) ); // Calc ----------------------------------------------------- ac = new QAction( "Calculation", *stdicons->makeTextPixmap( new QPixmap(stdicons->getPixmap(QmvIcons::BlankPageIcon)), tr("C"), QFont("Times"), QColor( blue ), QRect() ), "Calculation", ALT+SHIFT+Key_C, ag_insert, "Calculation", FALSE ); ndt_sigmap->setMapping( ac, formDetail::Calc ); connect( ac, SIGNAL( activated() ), ndt_sigmap, SLOT( map() ) ); // Special ----------------------------------------------------- ac = new QAction( "Special", *stdicons->makeTextPixmap( new QPixmap(stdicons->getPixmap(QmvIcons::BlankPageIcon)), tr("S"), QFont("Times"), QColor( blue ), QRect() ), "Special", ALT+SHIFT+Key_S, ag_insert, "Special", FALSE ); ndt_sigmap->setMapping( ac, formDetail::Special ); connect( ac, SIGNAL( activated() ), ndt_sigmap, SLOT( map() ) ); // Print ------------------------------------------------------ ac = new QAction( "Print", QPixmap( QmvFormToolIcons::print_xpm ), "&Print", Key_P, ag_insert, "form_print", FALSE ); connect( ac, SIGNAL( activated() ), this, SLOT( slotPrint() ) ); // Fax ------------------------------------------------------ ac = new QAction( "Fax", QPixmap( QmvFormToolIcons::fax_xpm ), "Fa&x", Key_X, ag_insert, "form_fax", FALSE ); connect( ac, SIGNAL( activated() ), this, SLOT( slotFax() ) ); // Email ------------------------------------------------------ ac = new QAction( "Email", QPixmap( QmvFormToolIcons::email_xpm ), "&Email", Key_E, ag_insert, "form_email", FALSE ); connect( ac, SIGNAL( activated() ), this, SLOT( slotEmail() ) ); // Add actiongroup to toolbar otherToolBar()->clear(); new QLabel( "Add new detail: ", otherToolBar(), "display_label" ); ag_insert->addTo( otherToolBar() ); // prepare for display setToolBarsMovable(FALSE); adjustSize(); updateGeometry(); setFocus(); // adjust canvas to the base magnification. setCanvasSize(); }