vehicleentrydialog.h

00001 /*********************************************************************************
00002 **
00003 **   $Id: //depot/WorkInProgress/ah2/AcctSelect.h#1 $
00004 **   Copyright (c) 2004 Joe Croft <joe@croftj.net>
00005 **   
00006 **   This file is part of ah3.
00007 **
00008 **   ah3 is free software; you can redistribute it and/or modify
00009 **   it under the terms of the GNU General Public License as published by
00010 **   the Free Software Foundation; either version 2 of the License, or
00011 **   (at your option) any later version.
00012 **
00013 **   Foobar is distributed in the hope that it will be useful,
00014 **   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 **   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 **   GNU General Public License for more details.
00017 **
00018 **   You should have received a copy of the GNU General Public License
00019 **   along with Foobar; if not, write to the Free Software
00020 **   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 **
00022 *********************************************************************************/
00023 
00024 #ifndef VEHICLEENTRYDIALOG_H
00025 #define VEHICLEENTRYDIALOG_H
00026 
00027 # include <QDialog>
00028 # include "QcjData/QcjDataStatics.h"
00029 # include "QcjData/QcjDataConfigure.h"
00030 # include "ui_vehicleentrydialog.h"
00031 
00032 extern QcjDataConfigure *pConfigDlg;
00033 
00034 class VehicleEntryDialog : public QDialog
00035 {
00036    Q_OBJECT
00037 
00038 public:
00039    VehicleEntryDialog(int cust_ident, bool setSelect = false, QWidget *parent = 0) : QDialog(parent)
00040    {
00041       printf("VehicleEntryDialog::VehicleEntryDialog(): Enter\n");
00042       fflush(stdout);
00043       ui.setupUi(this);
00044       if ( setSelect ) 
00045          ui.selectVehicleBtn->setText("Select");
00046       else
00047          ui.selectVehicleBtn->setText("Done");
00048       ui.searchVehicleBtn->setDefault(true);
00049       customer = cust_ident;
00050 //      ui.showAllVehiclesBtn->setChecked("Qt::Checked");
00051       printf("VehicleEntryDialog::VehicleEntryDialog(): Exit\n");
00052       fflush(stdout);
00053    };
00054 
00055    VehicleEntryDialog(bool setSelect = false, QWidget *parent = 0) : QDialog(parent)
00056    {
00057       printf("VehicleEntryDialog::VehicleEntryDialog(): Enter\n");
00058       fflush(stdout);
00059       ui.setupUi(this);
00060       if ( setSelect ) 
00061          ui.selectVehicleBtn->setText("Select");
00062       else
00063          ui.selectVehicleBtn->setText("Done");
00064       ui.searchVehicleBtn->setDefault(true);
00065 //      ui.showAllVehiclesBtn->setChecked("Qt::Checked");
00066       printf("VehicleEntryDialog::VehicleEntryDialog(): Exit\n");
00067       fflush(stdout);
00068    };
00069 
00070    void setDatabase() 
00071    {
00072       printf("VehicleEntryDialog::setDatabase(): Enter\n");
00073       fflush(stdout);
00074       ui.vehicleForm->setDatabase();
00075       ui.vehicleTable->setDatabase();
00076       ui.vehicleForm->clearForm();
00077       connect(ui.newVehicleBtn, SIGNAL(clicked()), this, SLOT(haveNewVehicleBtn()));
00078       connect(ui.deleteVehicleBtn, SIGNAL(clicked()), this, SLOT(haveDeleteVehicleBtn()));
00079       connect(ui.searchVehicleBtn, SIGNAL(clicked()), this, SLOT(haveSearchVehicleBtn()));
00080       connect(ui.clearFilterBtn, SIGNAL(clicked()), this, SLOT(haveClearVehicleBtn()));
00081       connect(ui.selectVehicleBtn, SIGNAL(clicked()), this, SLOT(haveSelectVehicleBtn()));
00082       if ( customer > 0 ) 
00083       {
00084          QString filter = "owner = " + QString::number(customer);
00085          ui.vehicleTable->setFilter(filter);
00086       }
00087       ui.vehicleTable->refresh();
00088       ui.vehicleTable->selectRow(0);
00089 //      connect(ui.selectVehicleBtn, SIGNAL(clicked()), this, SLOT(haveSelectVehicleBtn()));
00090       printf("VehicleEntryDialog::setDatabase(): Exit\n");
00091       fflush(stdout);
00092    };
00093 
00094 protected slots:
00095    void haveNewVehicleBtn()
00096    {
00097       QMap<QString, QString> fields;
00098       QString idx = pFormDef->getNewIndex(ui.vehicleForm->readXmlDef());
00099       QString idxname = pFormDef->getIndexField(ui.vehicleForm->readXmlDef());
00100 
00101       fields.insert(idxname, idx);
00102       fields.insert("owner", QString::number(customer));
00103       ui.vehicleForm->insertRecord(fields);
00104       ui.vehicleTable->refresh();
00105       ui.vehicleTable->findRow(fields);
00106    };
00107    void haveSearchVehicleBtn();
00108    void haveClearVehicleBtn();
00109    void setCustomer(int cust_ident)
00110    {
00111       customer = cust_ident;
00112       if ( customer > 0 ) 
00113       {
00114          QString filter = "owner = " + QString::number(customer);
00115          ui.vehicleTable->setFilter(filter);
00116       }
00117    }
00118    void haveSelectVehicleBtn()
00119    {
00120       QString xmldef = ui.vehicleForm->readXmlDef();
00121       QString index = pFormDef->getIndexField(xmldef);
00122       done(ui.vehicleForm->getFieldValue(index).toInt());
00123    };
00124    void haveDeleteVehicleBtn();
00125 
00126 private:
00127    int                     customer;
00128    Ui::VehicleEntryDialog  ui;
00129 };
00130 
00131 #endif

Generated on Tue Sep 11 07:00:01 2007 for Ah3 Invoicing and Inventory System for Repair Shops by  doxygen 1.5.0