From 6df1a447a1fa1b9e51fd177a806f910813657b09 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 27 Sep 2012 18:36:04 -0500 Subject: [PATCH] Added new classes, lots of new functionality. --- database-schema.txt | 2 +- phase1.ui | 257 +++++++++++++++++++++++++++++--------- schematic-schema.sql | 3 + schematic.pro | 16 ++- src/addresseditwidget.cpp | 33 +++++ src/addresseditwidget.h | 27 ++++ src/addresswidget.cpp | 43 +++++++ src/addresswidget.h | 29 +++++ src/contacteditwidget.cpp | 37 ++++++ src/contacteditwidget.h | 29 +++++ src/contactwidget.cpp | 51 ++++++++ src/contactwidget.h | 31 +++++ src/mainwin.cpp | 111 +++++++++++++++- src/mainwin.h | 8 ++ src/newvendordialog.cpp | 39 ++---- src/newvendordialog.h | 18 +-- src/scmwidget.cpp | 204 ++++++++++++++++++++++++++++++ src/scmwidget.h | 49 ++++++++ src/vendorclassdialog.cpp | 1 - src/vendorlevelwidget.cpp | 79 ++++++++++++ src/vendorlevelwidget.h | 34 +++++ 21 files changed, 988 insertions(+), 113 deletions(-) create mode 100644 src/addresseditwidget.cpp create mode 100644 src/addresseditwidget.h create mode 100644 src/addresswidget.cpp create mode 100644 src/addresswidget.h create mode 100644 src/contacteditwidget.cpp create mode 100644 src/contacteditwidget.h create mode 100644 src/contactwidget.cpp create mode 100644 src/contactwidget.h create mode 100644 src/scmwidget.cpp create mode 100644 src/scmwidget.h create mode 100644 src/vendorlevelwidget.cpp create mode 100644 src/vendorlevelwidget.h diff --git a/database-schema.txt b/database-schema.txt index 3b5a34b..7bfb709 100644 --- a/database-schema.txt +++ b/database-schema.txt @@ -8,7 +8,7 @@ VID (P-key) | VLID | signedNDA | Name CREATE TABLE Vendor (vid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vlid INT, signedNDA TINYINT(1) NOT NULL DEFAULT 0, name VARCHAR(100), FOREIGN KEY (vlid) REFERENCES VendorLevel(vlid)) ENGINE=INNODB; VendorLevel -VLID (P-key) | VendorUseable | Color | Description +VLID (P-key) | VendorUsable | Color | Description CREATE TABLE VendorLevel (vlid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vendorUsable TINYINT(1) NOT NULL DEFAULT 0, color INT(4), description VARCHAR(100)) ENGINE=INNODB; VendorType diff --git a/phase1.ui b/phase1.ui index 380c115..2ee39d8 100644 --- a/phase1.ui +++ b/phase1.ui @@ -6,8 +6,8 @@ 0 0 - 932 - 826 + 1023 + 883 @@ -17,8 +17,8 @@ - 790 - 230 + 870 + 720 141 111 @@ -52,7 +52,7 @@ p, li { white-space: pre-wrap; } - 240 + 750 10 51 16 @@ -65,7 +65,7 @@ p, li { white-space: pre-wrap; } - 290 + 800 10 191 22 @@ -77,7 +77,7 @@ p, li { white-space: pre-wrap; } 10 30 - 731 + 1001 16 @@ -116,7 +116,7 @@ p, li { white-space: pre-wrap; } 20 570 - 901 + 981 192 @@ -159,8 +159,8 @@ p, li { white-space: pre-wrap; } - 600 - 370 + 740 + 710 121 121 @@ -212,7 +212,7 @@ p, li { white-space: pre-wrap; } 290 - 370 + 380 131 121 @@ -409,8 +409,8 @@ p, li { white-space: pre-wrap; } 290 - 100 - 481 + 110 + 321 241 @@ -426,7 +426,7 @@ p, li { white-space: pre-wrap; } 0 10 - 471 + 311 201 @@ -556,18 +556,18 @@ p, li { white-space: pre-wrap; } - 740 - 360 - 171 - 161 + 770 + 80 + 231 + 271 - 297 - 350 + 290 + 360 121 20 @@ -580,7 +580,7 @@ p, li { white-space: pre-wrap; } 440 - 370 + 360 141 121 @@ -588,45 +588,6 @@ p, li { white-space: pre-wrap; } Vendor Actions - - - - 20 - 90 - 106 - 25 - - - - Add Location - - - - - - 20 - 60 - 106 - 25 - - - - Add Contact - - - - - - 20 - 30 - 106 - 25 - - - - Add Vendor - - @@ -699,13 +660,187 @@ p, li { white-space: pre-wrap; } Qt::Horizontal + + + + 460 + 470 + 61 + 25 + + + + Edit + + + + + + 770 + 60 + 51 + 16 + + + + Alerts + + + + + + 770 + 370 + 51 + 16 + + + + Notes + + + + + + 770 + 390 + 231 + 161 + + + + + + + 730 + 60 + 20 + 501 + + + + Qt::Vertical + + + + + + 935 + 50 + 61 + 25 + + + + Create + + + + + + 930 + 360 + 61 + 25 + + + + Create + + + + + + 670 + 540 + 61 + 25 + + + + Create + + + + + + 460 + 380 + 106 + 25 + + + + Add Vendor + + + + + + 460 + 410 + 106 + 25 + + + + Add Contact + + + + + + 460 + 440 + 106 + 25 + + + + Add Location + + + label + label_2 + lineEdit + line + checkBox + label_9 + tableWidget + groupBox + frame + treeWidget + tabWidget + tabWidget_2 + pushButton_4 + pushButton_5 + listView + label_17 + groupBox_2 + label_18 + toolButton + toolButton_2 + toolButton_3 + line_2 + pushButton_9 + label_19 + textBrowser + label_20 + listView_2 + line_3 + pushButton_10 + pushButton_11 + pushButton_12 + pushButton_6 + pushButton_7 + pushButton_8 0 0 - 932 + 1023 22 diff --git a/schematic-schema.sql b/schematic-schema.sql index 4d1a59d..d632f3b 100644 --- a/schematic-schema.sql +++ b/schematic-schema.sql @@ -390,6 +390,9 @@ CREATE TABLE `VendorLevel` ( LOCK TABLES `VendorLevel` WRITE; /*!40000 ALTER TABLE `VendorLevel` DISABLE KEYS */; +INSERT INTO `VendorLevel` VALUES (1,1,65280,'1;Trusted'); +INSERT INTO `VendorLevel` VALUES (2,1,255,'2;Caution Advised'); +INSERT INTO `VendorLevel` VALUES (3,0,16719904,'X;DO NOT USE'); /*!40000 ALTER TABLE `VendorLevel` ENABLE KEYS */; UNLOCK TABLES; diff --git a/schematic.pro b/schematic.pro index ffee4fb..150bd0c 100644 --- a/schematic.pro +++ b/schematic.pro @@ -23,22 +23,34 @@ RESOURCES += schematic.qrc # Source files HEADERS += src/about.h \ + src/addresseditwidget.h \ + src/addresswidget.h \ src/configdialog.h \ + src/contacteditwidget.h \ + src/contactwidget.h \ src/generaltab.h \ src/logindialog.h \ src/main.h \ src/mainwin.h \ src/newvendordialog.h \ + src/scmwidget.h \ src/sqlsettingsdialog.h \ - src/vendorclassdialog.h + src/vendorclassdialog.h \ + src/vendorlevelWidget.h SOURCES += src/about.cpp \ + src/addresseditwidget.cpp \ + src/addresswidget.cpp \ src/configdialog.cpp \ + src/contacteditwidget.cpp \ + src/contactwidget.cpp \ src/generaltab.cpp \ src/logindialog.cpp \ src/main.cpp \ src/mainwin.cpp \ src/newvendordialog.cpp \ + src/scmwidget.cpp \ src/sqlsettingsdialog.cpp \ - src/vendorclassdialog.cpp + src/vendorclassdialog.cpp \ + src/vendorlevelWidget.cpp diff --git a/src/addresseditwidget.cpp b/src/addresseditwidget.cpp new file mode 100644 index 0000000..15c3703 --- /dev/null +++ b/src/addresseditwidget.cpp @@ -0,0 +1,33 @@ +// +// addresseditwidget.cpp - Editable vendor address display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "addresseditwidget.h" + +AddressEditWidget::AddressEditWidget(QWidget * parent/*= 0*/): QWidget(parent), + field1(new QLineEdit), + field2(new QLineEdit), + field3(new QLineEdit), + field4(new QLineEdit), + field5(new QLineEdit) +{ + QFormLayout * form = new QFormLayout; + + form->addRow(tr("Address:"), field1); + form->addRow(tr("City:"), field2); + form->addRow(tr("State:"), field3); + form->addRow(tr("Country:"), field4); + form->addRow(tr("Postal Code:"), field5); + + setLayout(form); +} + diff --git a/src/addresseditwidget.h b/src/addresseditwidget.h new file mode 100644 index 0000000..5ac1a27 --- /dev/null +++ b/src/addresseditwidget.h @@ -0,0 +1,27 @@ +// +// addresseditwidget.h: Editable vendor address +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __ADDRESSEDITWIDGET_H__ +#define __ADDRESSEDITWIDGET_H__ + +#include + +class AddressEditWidget: public QWidget +{ + public: + AddressEditWidget(QWidget * parent = 0); + + public: + QLineEdit * field1; + QLineEdit * field2; + QLineEdit * field3; + QLineEdit * field4; + QLineEdit * field5; +}; + +#endif // __ADDRESSEDITWIDGET_H__ + diff --git a/src/addresswidget.cpp b/src/addresswidget.cpp new file mode 100644 index 0000000..6f3c20e --- /dev/null +++ b/src/addresswidget.cpp @@ -0,0 +1,43 @@ +// +// addresswidget.cpp - Vendor address display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "addresswidget.h" + +AddressWidget::AddressWidget(QWidget * parent/*= 0*/): QWidget(parent), + field1(new QLabel), + field2(new QLabel), + field3(new QLabel), + field4(new QLabel), + field5(new QLabel) +{ + QFormLayout * form = new QFormLayout; + + form->addRow(tr("Address:"), field1); + form->addRow(tr("City:"), field2); + form->addRow(tr("State:"), field3); + form->addRow(tr("Country:"), field4); + form->addRow(tr("Postal Code:"), field5); + + setLayout(form); +} + + +void AddressWidget::SetFields(QString s1, QString s2, QString s3, QString s4, QString s5) +{ + field1->setText(s1); + field2->setText(s2); + field3->setText(s3); + field4->setText(s4); + field5->setText(s5); +} + diff --git a/src/addresswidget.h b/src/addresswidget.h new file mode 100644 index 0000000..afb477c --- /dev/null +++ b/src/addresswidget.h @@ -0,0 +1,29 @@ +// +// addresswidget.h: Vendor address display +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __ADDRESSWIDGET_H__ +#define __ADDRESSWIDGET_H__ + +#include + +class AddressWidget: public QWidget +{ + public: + AddressWidget(QWidget * parent = 0); + + void SetFields(QString, QString, QString, QString, QString); + + public: + QLabel * field1; + QLabel * field2; + QLabel * field3; + QLabel * field4; + QLabel * field5; +}; + +#endif // __ADDRESSWIDGET_H__ + diff --git a/src/contacteditwidget.cpp b/src/contacteditwidget.cpp new file mode 100644 index 0000000..110a8c7 --- /dev/null +++ b/src/contacteditwidget.cpp @@ -0,0 +1,37 @@ +// +// contacteditwidget.cpp - Vendor contact display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "contacteditwidget.h" + +ContactEditWidget::ContactEditWidget(QWidget * parent/*= 0*/): QWidget(parent), + field1(new QComboBox), + field2(new QLineEdit), + field3(new QLineEdit), + field4(new QLineEdit), + field5(new QLineEdit), + field6(new QLineEdit), + field7(new QLineEdit) +{ + QFormLayout * form = new QFormLayout; + + form->addRow(tr("Type:"), field1); + form->addRow(tr("Name:"), field2); + form->addRow(tr("Email:"), field3); + form->addRow(tr("Address:"), field4); + form->addRow(tr("Phone 1:"), field5); + form->addRow(tr("Phone 2:"), field6); + form->addRow(tr("Fax:"), field7); + + setLayout(form); +} + diff --git a/src/contacteditwidget.h b/src/contacteditwidget.h new file mode 100644 index 0000000..d9e1c46 --- /dev/null +++ b/src/contacteditwidget.h @@ -0,0 +1,29 @@ +// +// contacteditwidget.h: Editable vendor contact +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __CONTACTEDITWIDGET_H__ +#define __CONTACTEDITWIDGET_H__ + +#include + +class ContactEditWidget: public QWidget +{ + public: + ContactEditWidget(QWidget * parent = 0); + + public: + QComboBox * field1; + QLineEdit * field2; + QLineEdit * field3; + QLineEdit * field4; + QLineEdit * field5; + QLineEdit * field6; + QLineEdit * field7; +}; + +#endif // __CONTACTEDITWIDGET_H__ + diff --git a/src/contactwidget.cpp b/src/contactwidget.cpp new file mode 100644 index 0000000..b9c43e4 --- /dev/null +++ b/src/contactwidget.cpp @@ -0,0 +1,51 @@ +// +// contactwidget.cpp - Vendor contact display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "contactwidget.h" + + +ContactWidget::ContactWidget(QWidget * parent/*= 0*/): QWidget(parent), + field1(new QLabel), + field2(new QLabel), + field3(new QLabel), + field4(new QLabel), + field5(new QLabel), + field6(new QLabel), + field7(new QLabel) +{ + QFormLayout * form = new QFormLayout; + + form->addRow(tr("Type:"), field1); + form->addRow(tr("Name:"), field2); + form->addRow(tr("Email:"), field3); + form->addRow(tr("Address:"), field4); + form->addRow(tr("Phone 1:"), field5); + form->addRow(tr("Phone 2:"), field6); + form->addRow(tr("Fax:"), field7); + + setLayout(form); +} + + +void ContactWidget::SetFields(QString s1, QString s2, QString s3, QString s4, + QString s5, QString s6, QString s7) +{ + field1->setText(s1); + field2->setText(s2); + field3->setText(s3); + field4->setText(s4); + field5->setText(s5); + field6->setText(s6); + field7->setText(s7); +} + diff --git a/src/contactwidget.h b/src/contactwidget.h new file mode 100644 index 0000000..2336452 --- /dev/null +++ b/src/contactwidget.h @@ -0,0 +1,31 @@ +// +// contactwidget.h: Vendor contact display +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __CONTACTWIDGET_H__ +#define __CONTACTWIDGET_H__ + +#include + +class ContactWidget: public QWidget +{ + public: + ContactWidget(QWidget * parent = 0); + + void SetFields(QString, QString, QString, QString, QString, QString, QString); + + public: + QLabel * field1; + QLabel * field2; + QLabel * field3; + QLabel * field4; + QLabel * field5; + QLabel * field6; + QLabel * field7; +}; + +#endif // __CONTACTWIDGET_H__ + diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 44161ba..fe7931f 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -20,11 +20,14 @@ #include "configdialog.h" #include "logindialog.h" #include "newvendordialog.h" +#include "scmwidget.h" #include "sqlsettingsdialog.h" #include "vendorclassdialog.h" MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), + scmWidget(new SCMWidget(this)), + boldFont(new QFont), loggedInUID(0) { setWindowIcon(QIcon(":/res/schematic.png")); @@ -99,6 +102,7 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), statusBar()->showMessage(tr("Ready")); ReadSettings(); + boldFont->setBold(true); // Finally, set up database connection @@ -122,6 +126,9 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), db.setPassword(dbPassword); ok = db.open(); +//printf("Error: %s\n", db.lastError().databaseText().toAscii().data()); +//printf("Error: %s\n", db.lastError().driverText().toAscii().data()); + // If unsuccessful, run the SQL settings/test dialog if (!ok) { @@ -141,12 +148,12 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), while (!ok); // Do Login dialog - LoginDialog login; + LoginDialog loginDlg; bool done = false; do { - bool accept = login.exec(); + bool accept = loginDlg.exec(); // Check to see if user cancelled out if (!accept) @@ -154,20 +161,26 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), else { // Search DB for this username/login pair - QSqlQuery query("SELECT UID FROM User WHERE Login=? AND Password=?"); - query.addBindValue(login.edit1->text()); - query.addBindValue(login.edit2->text()); + QSqlQuery query("SELECT UID, name, login FROM User WHERE Login=? AND Password=?"); + query.addBindValue(loginDlg.edit1->text()); + query.addBindValue(loginDlg.edit2->text()); query.exec(); while (query.next()) { // We have a winner! loggedInUID = query.value(0).toInt(); + fullName = query.value(1).toString(); + login = query.value(2).toString(); done = true; } } } while (!done); + + QString s = QString("User: %1 (%2)").arg(fullName).arg(login); + scmWidget->username->setText(s); + setCentralWidget(scmWidget); } @@ -208,9 +221,97 @@ void MainWindow::HandleVendorClassDialog(void) void MainWindow::HandleNewVendorDialog(void) { NewVendorDialog dialog(this); + FillVendorLevelCombo(dialog.combo1); + FillContactTypeCombo(dialog.contact->field1); + FillVendorClassList(dialog.list); if (!dialog.exec()) return; + + // Presumably, the user has given us good data, so we try to populate the + // database with this new vendor data. + QSqlQuery query1("INSERT INTO VALUES (?, ?, ?)"); + + +} + + +void MainWindow::FillVendorLevelCombo(QComboBox * combo) +{ + QSqlQuery query("SELECT VLID, Description FROM VendorLevel"); + query.exec(); + + while (query.next()) + { + int vlid = query.value(0).toInt(); + QString description = query.value(1).toString(); + + combo->addItem(description, vlid); + } +} + + +void MainWindow::FillContactTypeCombo(QComboBox * combo) +{ + QSqlQuery query("SELECT CTID, Description FROM ContactType"); + query.exec(); + + while (query.next()) + { + int ctid = query.value(0).toInt(); + QString description = query.value(1).toString(); + + combo->addItem(description, ctid); + } +} + + +void MainWindow::FillVendorClassList(QListWidget * list) +{ + std::vector groupList; + + // Pull in definitions from DB for Vendor Classes/Groups + QSqlQuery query1("SELECT vgid, description FROM VendorGroup ORDER BY seqNo"); + query1.exec(); + + while (query1.next()) + { + VendorType v; + v.key = query1.value(0).toInt(); + v.description = query1.value(1).toString(); + groupList.push_back(v); + } + + QSqlQuery query2("SELECT vtid, vgid, description FROM VendorType ORDER BY seqNo"); + query2.exec(); + + int previousID = -1, groupListIndex = 0; + QListWidgetItem * item; + + while (query2.next()) + { +// VendorType v; + int vtid = query2.value(0).toInt(); + int vgid = query2.value(1).toInt(); + QString description = query2.value(2).toString(); + + // Check to see if we need to insert new header yet. + // If we're not still in same group, push the next group header into the list + // and continue + if (previousID != vgid) + { + item = new QListWidgetItem(groupList[groupListIndex].description); + item->setData(Qt::UserRole, groupList[groupListIndex++].key); + item->setFont(*boldFont); + list->addItem(item); + previousID = vgid; + } + + item = new QListWidgetItem(description); + item->setData(Qt::UserRole, vtid); + item->setCheckState(Qt::Unchecked); + list->addItem(item); + } } diff --git a/src/mainwin.h b/src/mainwin.h index 5be8fd6..c277591 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -12,6 +12,7 @@ #include class AboutWindow; +class SCMWidget; class MainWindow: public QMainWindow { @@ -32,10 +33,14 @@ class MainWindow: public QMainWindow void HandleNewVendorDialog(void); private: + void FillVendorLevelCombo(QComboBox *); + void FillContactTypeCombo(QComboBox *); + void FillVendorClassList(QListWidget *); void ReadSettings(void); void WriteSettings(void); AboutWindow * aboutWin; + SCMWidget * scmWidget; QAction * quitAppAct; QAction * aboutAct; @@ -49,9 +54,12 @@ class MainWindow: public QMainWindow QString dbPassword; QSqlDatabase db; + QFont * boldFont; public: int loggedInUID; + QString login; + QString fullName; }; #endif // __MAINWINDOW_H__ diff --git a/src/newvendordialog.cpp b/src/newvendordialog.cpp index 8737af3..5db3d7d 100644 --- a/src/newvendordialog.cpp +++ b/src/newvendordialog.cpp @@ -10,6 +10,9 @@ // --- ---------- ------------------------------------------------------------ // JLH 09/21/2012 Created this file +// NOTE: This can also be used as a vendor editing dialog. It's up to the caller +// to change the window title and populate fields in that case. :-) + #include "newvendordialog.h" @@ -18,19 +21,9 @@ NewVendorDialog::NewVendorDialog(QWidget * parent/*= 0*/): QDialog(parent), edit1(new QLineEdit), combo1(new QComboBox), checkbox1(new QCheckBox(tr("NDA Signed"))), - edit2(new QLineEdit), - edit3(new QLineEdit), - edit4(new QLineEdit), - edit5(new QLineEdit), - edit6(new QLineEdit), - combo2(new QComboBox), - edit7(new QLineEdit), - edit8(new QLineEdit), - edit9(new QLineEdit), - edit10(new QLineEdit), - edit11(new QLineEdit), - edit12(new QLineEdit), - list(new QListWidget) + list(new QListWidget), + address(new AddressEditWidget(this)), + contact(new ContactEditWidget(this)) { connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); @@ -46,25 +39,13 @@ NewVendorDialog::NewVendorDialog(QWidget * parent/*= 0*/): QDialog(parent), QGroupBox * gb4 = new QGroupBox(tr("Vendor Classes")); QFormLayout * form1 = new QFormLayout; - QFormLayout * form2 = new QFormLayout; - QFormLayout * form3 = new QFormLayout; + QVBoxLayout * form2 = new QVBoxLayout; + QVBoxLayout * form3 = new QVBoxLayout; form1->addRow(tr("Name:"), edit1); form1->addRow(tr("Level:"), combo1); - - form2->addRow(tr("Address:"), edit2); - form2->addRow(tr("City:"), edit3); - form2->addRow(tr("State:"), edit4); - form2->addRow(tr("Country:"), edit5); - form2->addRow(tr("Postal Code:"), edit6); - - form3->addRow(tr("Type:"), combo2); - form3->addRow(tr("Name:"), edit7); - form3->addRow(tr("Email:"), edit8); - form3->addRow(tr("Address:"), edit9); - form3->addRow(tr("Phone 1:"), edit10); - form3->addRow(tr("Phone 2:"), edit11); - form3->addRow(tr("Fax:"), edit12); + form2->addWidget(address); + form3->addWidget(contact); vbox1->addLayout(form1); vbox1->addWidget(checkbox1); diff --git a/src/newvendordialog.h b/src/newvendordialog.h index e224bb1..e9fc177 100644 --- a/src/newvendordialog.h +++ b/src/newvendordialog.h @@ -2,6 +2,8 @@ #define __NEWVENDORDIALOG_H__ #include +#include "addresseditwidget.h" +#include "contacteditwidget.h" class NewVendorDialog: public QDialog { @@ -19,21 +21,9 @@ class NewVendorDialog: public QDialog QComboBox * combo1; QCheckBox * checkbox1; - QLineEdit * edit2; - QLineEdit * edit3; - QLineEdit * edit4; - QLineEdit * edit5; - QLineEdit * edit6; - - QComboBox * combo2; - QLineEdit * edit7; - QLineEdit * edit8; - QLineEdit * edit9; - QLineEdit * edit10; - QLineEdit * edit11; - QLineEdit * edit12; - QListWidget * list; + AddressEditWidget * address; + ContactEditWidget * contact; }; #endif // __NEWVENDORDIALOG_H__ diff --git a/src/scmwidget.cpp b/src/scmwidget.cpp new file mode 100644 index 0000000..78f757f --- /dev/null +++ b/src/scmwidget.cpp @@ -0,0 +1,204 @@ +// +// scmwidget.cpp - Main widget container +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "scmwidget.h" +#include "addresswidget.h" +#include "contactwidget.h" + + +SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent), + purchaseOrders(new QTreeView), + vendorName(new QLabel), + ndaSigned(new QLabel), + vendorAddress(new QTabWidget), + vendorContact(new QTabWidget), + vendorClass(new QListWidget), + username(new QLabel), + vendorLevel(new VendorLevelWidget), + alerts(new QListWidget), + notes(new QListWidget), + nextVendorButton(new QToolButton), + previousVendorButton(new QToolButton), + editVendor(new QPushButton("Edit Vendor")), + addVendor(new QPushButton("Add Vendor")), + addLocation(new QPushButton("Add Location")), + addContact(new QPushButton("Add Contact")), + createAlert(new QPushButton("Create")), + createNote(new QPushButton("Create")), + showOpen(new QPushButton("Open")), + showClosed(new QPushButton("Closed")), + showAll(new QPushButton("All")), + createPO(new QPushButton("Create")) +{ + // Create main page widgets & layout + + purchaseOrders->setRootIsDecorated(false); + purchaseOrders->setAlternatingRowColors(true); + + QAbstractItemModel * model = new QStandardItemModel(0, 7); + model->setHeaderData(0, Qt::Horizontal, tr("PO #")); + model->setHeaderData(1, Qt::Horizontal, tr("Vendor")); + model->setHeaderData(2, Qt::Horizontal, tr("Desc.")); + model->setHeaderData(3, Qt::Horizontal, tr("OAD")); + model->setHeaderData(4, Qt::Horizontal, tr("UAD")); + model->setHeaderData(5, Qt::Horizontal, tr("Docs")); + model->setHeaderData(6, Qt::Horizontal, tr("FAI")); + + model->insertRow(0); + model->setData(model->index(0, 0), "FE823724"); + model->setData(model->index(0, 1), "Sanford & Sons"); + model->setData(model->index(0, 2), "Misc. Junk"); + model->setData(model->index(0, 3), "09/30/2012"); + model->setData(model->index(0, 4), ""); + model->setData(model->index(0, 5), ""); + model->setData(model->index(0, 6), ""); + + model->insertRow(0); + model->setData(model->index(0, 0), "89237923-123"); + model->setData(model->index(0, 1), "Digikey"); + model->setData(model->index(0, 2), "Small capacitors"); + model->setData(model->index(0, 3), "10/08/2012"); + model->setData(model->index(0, 4), "11/30/2012"); + model->setData(model->index(0, 5), "1"); + model->setData(model->index(0, 6), "Yes"); + + model->insertRow(0); + model->setData(model->index(0, 0), "T9234CS32"); + model->setData(model->index(0, 1), "Big, Faceless Company"); + model->setData(model->index(0, 2), "Important Stuff you need RIGHT NOW"); + model->setData(model->index(0, 3), "09/28/2012"); + model->setData(model->index(0, 4), "09/29/2012"); + model->setData(model->index(0, 5), "5"); + model->setData(model->index(0, 6), "Yes"); + + purchaseOrders->setModel(model); + + nextVendorButton->setArrowType(Qt::RightArrow); + nextVendorButton->setToolTip(tr("Move to next Vendor in Database.")); + previousVendorButton->setArrowType(Qt::LeftArrow); + previousVendorButton->setToolTip(tr("Move to previous Vendor in Database.")); + + QFont * vendorFont = new QFont; + vendorFont->setPointSize(12); + vendorName->setFont(*vendorFont); + vendorName->setText("Vendor Name"); + + QHBoxLayout * hbox1 = new QHBoxLayout; + hbox1->addWidget(previousVendorButton); + hbox1->addWidget(nextVendorButton); + hbox1->addWidget(vendorName); + + // Vendor address widgets + + AddressWidget * vaw1 = new AddressWidget(this); + vaw1->SetFields("123 Any Street", "Any City", "Anywhere", "USA", "01234"); + vendorAddress->addTab(vaw1, tr("Primary")); + vendorAddress->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + + // Vendor contact widgets + + ContactWidget * vcw1 = new ContactWidget(this); + vcw1->SetFields("Sales", "Joe Blow", "joe.blow@widget.com", "Singapore", "512-222-2222", "", "512-122-2123"); + vendorContact->addTab(vcw1, tr("Contact #1")); + vendorContact->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + + // Vendor class list + + QVBoxLayout * vbox1 = new QVBoxLayout; + vbox1->addWidget(vendorClass); + QGroupBox * gb1 = new QGroupBox(tr("Vendor Classes")); + gb1->setLayout(vbox1); + + // Vendor action push buttons + + QVBoxLayout * vbox4 = new QVBoxLayout; + QHBoxLayout * hbox3 = new QHBoxLayout; + QGroupBox * gb2 = new QGroupBox(tr("Vendor Actions")); + + vbox4->addWidget(editVendor); + vbox4->addWidget(addVendor); + vbox4->addWidget(addLocation); + vbox4->addWidget(addContact); + gb2->setLayout(vbox4); + + hbox3->addWidget(vendorLevel); + hbox3->addWidget(gb2); + + // Alerts & notes + + QVBoxLayout * vbox5 = new QVBoxLayout; + QHBoxLayout * hbox4 = new QHBoxLayout; + QHBoxLayout * hbox5 = new QHBoxLayout; + + QLabel * label1 = new QLabel(tr("Alerts")); + QLabel * label2 = new QLabel(tr("Notes")); + hbox4->addWidget(label1); + hbox4->addStretch(); + hbox4->addWidget(createAlert); + hbox5->addWidget(label2); + hbox5->addStretch(); + hbox5->addWidget(createNote); + + vbox5->addLayout(hbox4); + vbox5->addWidget(alerts); + vbox5->addLayout(hbox5); + vbox5->addWidget(notes); + + // Purchase Order headers + + QHBoxLayout * hbox6 = new QHBoxLayout; + QLabel * label3 = new QLabel(tr("Purchase Orders")); + hbox6->addWidget(label3); + hbox6->addSpacing(32); + hbox6->addWidget(showOpen); + hbox6->addWidget(showClosed); + hbox6->addWidget(showAll); + hbox6->addStretch(); + hbox6->addWidget(createPO); + + // Horizontal line + + QFrame * hline = new QFrame(this); + hline->setFrameShape(QFrame::HLine); + hline->setFrameShadow(QFrame::Sunken); + + QFrame * hline2 = new QFrame(this); + hline2->setFrameShape(QFrame::HLine); + hline2->setFrameShadow(QFrame::Sunken); + + QHBoxLayout * hbox2 = new QHBoxLayout; + QVBoxLayout * vbox2 = new QVBoxLayout; + QVBoxLayout * vbox3 = new QVBoxLayout; + + vbox3->addWidget(vendorContact); +// vbox3->addWidget(vendorLevel); + vbox3->addLayout(hbox3); + + vbox2->addWidget(vendorAddress); + vbox2->addWidget(gb1); + + hbox2->addLayout(vbox2); + hbox2->addLayout(vbox3); + hbox2->addLayout(vbox5); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(username); + mainLayout->addWidget(hline); + mainLayout->addLayout(hbox1); + mainLayout->addLayout(hbox2); + mainLayout->addWidget(hline2); + mainLayout->addLayout(hbox6); + mainLayout->addWidget(purchaseOrders); + setLayout(mainLayout); +} + diff --git a/src/scmwidget.h b/src/scmwidget.h new file mode 100644 index 0000000..6081f71 --- /dev/null +++ b/src/scmwidget.h @@ -0,0 +1,49 @@ +// +// scmwidget.h: Main widget page container +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __SCMWIDGET_H__ +#define __SCMWIDGET_H__ + +#include +#include "vendorlevelwidget.h" + +class SCMWidget: public QWidget +{ + public: + SCMWidget(QWidget * parent = 0); + +// protected: +// void keyPressEvent(QKeyEvent *); + + public: + QTreeView * purchaseOrders; + QLabel * vendorName; + QLabel * ndaSigned; + QTabWidget * vendorAddress; + QTabWidget * vendorContact; + QListWidget * vendorClass; + QLabel * username; + VendorLevelWidget * vendorLevel; + QListWidget * alerts; + QListWidget * notes; + + private: + QToolButton * nextVendorButton; + QToolButton * previousVendorButton; + QPushButton * editVendor; + QPushButton * addVendor; + QPushButton * addLocation; + QPushButton * addContact; + QPushButton * createAlert; + QPushButton * createNote; + QPushButton * showOpen; + QPushButton * showClosed; + QPushButton * showAll; + QPushButton * createPO; +}; + +#endif // __SCMWIDGET_H__ diff --git a/src/vendorclassdialog.cpp b/src/vendorclassdialog.cpp index aef142b..d39a5a0 100644 --- a/src/vendorclassdialog.cpp +++ b/src/vendorclassdialog.cpp @@ -24,7 +24,6 @@ VendorClassDialog::VendorClassDialog(QWidget * parent/*= 0*/): QDialog(parent), normalFont(new QFont), boldFont(new QFont), list(new QListWidget) -// dbRef(db) { addItem->setToolButtonStyle(Qt::ToolButtonTextOnly); addItem->setText("+"); diff --git a/src/vendorlevelwidget.cpp b/src/vendorlevelwidget.cpp new file mode 100644 index 0000000..fde3ab1 --- /dev/null +++ b/src/vendorlevelwidget.cpp @@ -0,0 +1,79 @@ +// +// vendorlevelwidget.cpp - Vendor level display +// +// by James Hammons +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 09/24/2012 Created this file +// + +#include "vendorlevelwidget.h" +#include + + +VendorLevelWidget::VendorLevelWidget(QWidget * parent/*= 0*/): QWidget(parent), + topLine(new QLabel), + level(new QLabel), + color(0xFFFF00), + description("?;Unknown"), + usable(false) +{ + QVBoxLayout * layout = new QVBoxLayout; + + QFont * font = new QFont; + font->setPointSize(48); + level->setFont(*font); +// level->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + level->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); + level->setAlignment(Qt::AlignCenter); +// level->setStyleSheet("QLabel { background-color: yellow; color: blue; }"); + level->setStyleSheet("QLabel { background-color: yellow; }"); + + topLine->setAlignment(Qt::AlignCenter); + topLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + topLine->setMargin(0); + + layout->addStretch(); + layout->addWidget(topLine); + layout->addWidget(level); + + setLayout(layout); + + ParseDescription(); +} + + +void VendorLevelWidget::DoQuery(int key) +{ + QSqlQuery query("SELECT vendorUsable, color, description FROM VendorLevel WHERE VLID=?"); + query.addBindValue(key); + query.exec(); + + if (query.next()) + { + // We have a winner! + usable = query.value(0).toBool(); + color = query.value(1).toInt(); + description = query.value(2).toString(); + } + else + { + usable = false; + color = 0xFFFF00; + description = "?;Unknown"; + } + + ParseDescription(); +} + + +void VendorLevelWidget::ParseDescription(void) +{ + level->setText(description.left(1)); + topLine->setText(description.mid(2)); +} + diff --git a/src/vendorlevelwidget.h b/src/vendorlevelwidget.h new file mode 100644 index 0000000..124eed9 --- /dev/null +++ b/src/vendorlevelwidget.h @@ -0,0 +1,34 @@ +// +// addresswidget.h: Vendor address display +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __VENDORLEVELWIDGET_H__ +#define __VENDORLEVELWIDGET_H__ + +#include + +class VendorLevelWidget: public QWidget +{ + public: + VendorLevelWidget(QWidget * parent = 0); + + void DoQuery(int key); + + private: + void ParseDescription(void); + + private: + QLabel * topLine; + QLabel * level; + int color; + QString description; + + public: + bool usable; +}; + +#endif // __VENDORLEVELWIDGET_H__ + -- 2.37.2