From: Shamus Hammons Date: Fri, 21 Sep 2012 18:29:21 +0000 (-0500) Subject: Added a bunch of new functionality X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=schematic;a=commitdiff_plain;h=f3116511d09acfd5b32d3412c82c4337d89f2ad9 Added a bunch of new functionality Added Vendor Class dialog, New Vendor dialog, some new UI files, and an SQL configuration dialog for the case where it hasn't been configured or misconfigured. Also new main icon. --- diff --git a/database-schema.txt b/database-schema.txt index a7bc741..3b5a34b 100644 --- a/database-schema.txt +++ b/database-schema.txt @@ -4,28 +4,28 @@ Supply Chain Management Database (SCheMatic: The Supply Chain Manager-O-Matic) TABLES: Vendor -VID (P-key) | VLID | Name -CREATE TABLE Vendor (vid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vlid INT, name VARCHAR(100), FOREIGN KEY (vlid) REFERENCES VendorLevel(vlid)) ENGINE=INNODB; +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 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 -VTID (P-key) | VGID | Description -CREATE TABLE VendorType (vtid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vgid INT, description VARCHAR(100), FOREIGN KEY (vgid) REFERENCES VendorGroup(vgid)) ENGINE=INNODB; +VTID (P-key) | VGID | SeqNo | Description +CREATE TABLE VendorType (vtid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vgid INT, seqNo INT(4) NOT NULL, description VARCHAR(100), FOREIGN KEY (vgid) REFERENCES VendorGroup(vgid)) ENGINE=INNODB; VendorGroup -VGID (P-key) | Description -CREATE TABLE VendorGroup (vgid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, description VARCHAR(100)) ENGINE=INNODB; +VGID (P-key) | SeqNo | Description +CREATE TABLE VendorGroup (vgid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, seqNo INT(4) NOT NULL, description VARCHAR(100)) ENGINE=INNODB; VendorSpecificTypes VID (multi) | VTID (multi) CREATE TABLE VendorSpecificTypes (vid INT, vtid INT, FOREIGN KEY (vid) REFERENCES Vendor(vid), FOREIGN KEY (vtid) REFERENCES VendorType(vtid)) ENGINE=INNODB; Location -LID (P-key) | VID | Description -CREATE TABLE Location () ENGINE=INNODB; +LID (P-key) | VID | Address | City | State | Country | Code +CREATE TABLE Location (lid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vid INT, address VARCHAR(100), city VARCHAR(64), state VARCHAR(64), country VARCHAR(64), code VARCHAR(32), FOREIGN KEY (vid) REFERENCES Vendor(vid)) ENGINE=INNODB; Contact CID (P-key) | VID | CTID | Name | Email | Address | Phone1 | Phone2 | Fax @@ -44,12 +44,12 @@ UCID | PrivilegeLevel | Description CREATE TABLE UserClass (ucid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, privilegeLevel INT NOT NULL DEFAULT 0, description VARCHAR(100)) ENGINE=INNODB; PurchaseOrder -POID (P-key) | VID | Closed | Description -CREATE TABLE PurchaseOrder (poid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vid INT, closed TINYINT(1) NOT NULL DEFAULT 0, description VARCHAR(200), FOREIGN KEY (vid) REFERENCES Vendor(vid)) ENGINE=INNODB; +POID (P-key) | VID | Closed | PONumber | OriginalDate | AdjustedDate | Description +CREATE TABLE PurchaseOrder (poid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, vid INT, closed TINYINT(1) NOT NULL DEFAULT 0, poNumber VARCHAR(100), originalDate DATE, adjustedDate DATE, description VARCHAR(200), FOREIGN KEY (vid) REFERENCES Vendor(vid)) ENGINE=INNODB; Documents -DID (P-key) | DTID | VID | POID | Document -CREATE TABLE Documents (did INT NOT NULL PRIMARY KEY AUTO_INCREMENT, dtid INT, vid INT, poid INT, document LONGBLOB, FOREIGN KEY (dtid) REFERENCES DocumentType(dtid), FOREIGN KEY (vid) REFERENCES Vendor(vid), FOREIGN KEY (poid) REFERENCES PurchaseOrder(poid)) ENGINE=INNODB; +DID (P-key) | DTID | VID | POID | Filename | Document +CREATE TABLE Documents (did INT NOT NULL PRIMARY KEY AUTO_INCREMENT, dtid INT, vid INT, poid INT, filename VARCHAR(256), document LONGBLOB, FOREIGN KEY (dtid) REFERENCES DocumentType(dtid)) ENGINE=INNODB; DocumentType DTID (P-key) | Description diff --git a/new-vendor.ui b/new-vendor.ui new file mode 100644 index 0000000..a6d4399 --- /dev/null +++ b/new-vendor.ui @@ -0,0 +1,634 @@ + + + Dialog + + + + 0 + 0 + 728 + 652 + + + + + 0 + 0 + + + + New Vendor + + + + + 530 + 600 + 171 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 160 + 421 + 171 + + + + Primary Location + + + + + 10 + 30 + 401 + 141 + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + City: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + State: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Country: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Postal Code: + + + + + + + + + + + + + 10 + 350 + 421 + 231 + + + + Primary Contact + + + + + 10 + 30 + 401 + 201 + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Email: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Phone 1: + + + + + + + Phone 2: + + + + + + + + + + + + + + + + Fax: + + + + + + + true + + + + + + + + + + 10 + 10 + 421 + 141 + + + + Vendor + + + + + 10 + 40 + 401 + 61 + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Name: + + + + + + + + + + Level: + + + + + + + + + + + + 10 + 110 + 141 + 21 + + + + NDA Signed + + + + + + + 440 + 10 + 281 + 581 + + + + Vendor Classes + + + + + 10 + 40 + 256 + 531 + + + + + Machine + + + + + Cutter + + + Unchecked + + + + + Sheet Metal + + + Unchecked + + + + + EDM Wire + + + Unchecked + + + + + CNC + + + Unchecked + + + + + Casting + + + Unchecked + + + + + Electronic Parts + + + + + Distributor + + + Unchecked + + + + + Manufacturer + + + Unchecked + + + + + Broker Grey + + + Unchecked + + + + + Representative + + + Unchecked + + + + + Printed Circuit Boards + + + ItemIsSelectable|ItemIsDragEnabled|ItemIsEnabled + + + + + PCB + + + Unchecked + + + + + PCBA + + + Unchecked + + + + + Testing + + + Unchecked + + + + + Raw Materials + + + + + Metal + + + Unchecked + + + + + Plastic + + + Unchecked + + + + + Extruded + + + Unchecked + + + + + Lenses + + + + + Distributor + + + Unchecked + + + + + Manufacturer + + + Unchecked + + + + + Representative + + + Unchecked + + + + + Filters + + + Unchecked + + + + + Cubes + + + Unchecked + + + + + Lenses + + + Unchecked + + + + + COTS + + + + + Screws + + + Unchecked + + + + + O-Ring + + + Unchecked + + + + + Switches + + + Unchecked + + + + + Captive Fasteners + + + Unchecked + + + + + Springs & Pins + + + Unchecked + + + + + Retaining Rings + + + Unchecked + + + + + Coatings + + + + + Anodized + + + Unchecked + + + + + Nickel + + + Unchecked + + + + + Paint + + + Unchecked + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/phase1.ui b/phase1.ui index 768c40c..380c115 100644 --- a/phase1.ui +++ b/phase1.ui @@ -7,7 +7,7 @@ 0 0 932 - 626 + 826 @@ -17,8 +17,8 @@ - 570 - 410 + 790 + 230 141 111 @@ -27,14 +27,14 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Here's some stuff to look at, isn't it purty? :-)</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt;">Still need Action List &amp; Notes</span></p></body></html> - 10 + 60 50 221 16 @@ -85,37 +85,11 @@ p, li { white-space: pre-wrap; } Qt::Horizontal - - - - 20 - 230 - 61 - 14 - - - - Contact1: - - - - - - 90 - 230 - 221 - 22 - - - - Title, email, phone, fax, etc. - - - 90 - 200 + 10 + 80 121 21 @@ -124,93 +98,6 @@ p, li { white-space: pre-wrap; } NDA Signed - - - - 10 - 80 - 281 - 111 - - - - - - - Address: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - City: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - State: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - ZIP: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 20 - 250 - 61 - 14 - - - - Contact2: - - - - - - 90 - 250 - 113 - 22 - - - @@ -227,9 +114,9 @@ p, li { white-space: pre-wrap; } - 320 - 50 - 591 + 20 + 570 + 901 192 @@ -272,8 +159,8 @@ p, li { white-space: pre-wrap; } - 410 - 380 + 600 + 370 121 121 @@ -324,8 +211,8 @@ p, li { white-space: pre-wrap; } - 10 - 380 + 290 + 370 131 121 @@ -364,9 +251,9 @@ p, li { white-space: pre-wrap; } - 150 - 380 - 256 + 10 + 310 + 271 192 @@ -421,6 +308,397 @@ p, li { white-space: pre-wrap; } + + + + 10 + 110 + 271 + 181 + + + + 0 + + + + Primary + + + + + 0 + 10 + 261 + 141 + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + City: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + State: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Country: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Postal Code: + + + + + + + + + + + + 2nd + + + + + + + 290 + 100 + 481 + 241 + + + + 0 + + + + Contact #1 + + + + + 0 + 10 + 471 + 201 + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Email: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Phone 1: + + + + + + + Phone 2: + + + + + + + + + + + + + + + + Fax: + + + + + + + + + #2 + + + + + #3 + + + + + + + 10 + 50 + 21 + 25 + + + + < + + + + + + 30 + 50 + 21 + 25 + + + + > + + + + + + 740 + 360 + 171 + 161 + + + + + + + 297 + 350 + 121 + 20 + + + + Caution Advised + + + + + + 440 + 370 + 141 + 121 + + + + Vendor Actions + + + + + 20 + 90 + 106 + 25 + + + + Add Location + + + + + + 20 + 60 + 106 + 25 + + + + Add Contact + + + + + + 20 + 30 + 106 + 25 + + + + Add Vendor + + + + + + + 20 + 540 + 151 + 16 + + + + Purchase Orders + + + + + + 170 + 540 + 61 + 25 + + + + Open + + + true + + + true + + + + + + 240 + 540 + 61 + 25 + + + + Closed + + + + + + 310 + 540 + 61 + 25 + + + + All + + + + + + 20 + 510 + 701 + 16 + + + + Qt::Horizontal + + @@ -428,7 +706,7 @@ p, li { white-space: pre-wrap; } 0 0 932 - 20 + 22 diff --git a/res/schematic.png b/res/schematic.png index 2b9c7fd..d07c302 100644 Binary files a/res/schematic.png and b/res/schematic.png differ diff --git a/schematic b/schematic deleted file mode 100755 index 56c06a2..0000000 Binary files a/schematic and /dev/null differ diff --git a/schematic-schema.sql b/schematic-schema.sql index acc74fc..4d1a59d 100644 --- a/schematic-schema.sql +++ b/schematic-schema.sql @@ -135,6 +135,7 @@ CREATE TABLE `Documents` ( `dtid` int(11) DEFAULT NULL, `vid` int(11) DEFAULT NULL, `poid` int(11) DEFAULT NULL, + `filename` varchar(256) DEFAULT NULL, `document` longblob, PRIMARY KEY (`did`), KEY `dtid` (`dtid`), @@ -178,6 +179,36 @@ LOCK TABLES `History` WRITE; /*!40000 ALTER TABLE `History` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `Location` +-- + +DROP TABLE IF EXISTS `Location`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `Location` ( + `lid` int(11) NOT NULL AUTO_INCREMENT, + `vid` int(11) DEFAULT NULL, + `address` varchar(100) DEFAULT NULL, + `city` varchar(64) DEFAULT NULL, + `state` varchar(64) DEFAULT NULL, + `country` varchar(64) DEFAULT NULL, + `code` varchar(32) DEFAULT NULL, + PRIMARY KEY (`lid`), + KEY `vid` (`vid`), + CONSTRAINT `Location_ibfk_1` FOREIGN KEY (`vid`) REFERENCES `Vendor` (`vid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Location` +-- + +LOCK TABLES `Location` WRITE; +/*!40000 ALTER TABLE `Location` DISABLE KEYS */; +/*!40000 ALTER TABLE `Location` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `Notes` -- @@ -213,6 +244,9 @@ CREATE TABLE `PurchaseOrder` ( `poid` int(11) NOT NULL AUTO_INCREMENT, `vid` int(11) DEFAULT NULL, `closed` tinyint(1) NOT NULL DEFAULT '0', + `poNumber` varchar(100) DEFAULT NULL, + `originalDate` date DEFAULT NULL, + `adjustedDate` date DEFAULT NULL, `description` varchar(200) DEFAULT NULL, PRIMARY KEY (`poid`), KEY `vid` (`vid`), @@ -245,7 +279,7 @@ CREATE TABLE `User` ( PRIMARY KEY (`uid`), KEY `ucid` (`ucid`), CONSTRAINT `User_ibfk_1` FOREIGN KEY (`ucid`) REFERENCES `UserClass` (`ucid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -254,6 +288,7 @@ CREATE TABLE `User` ( LOCK TABLES `User` WRITE; /*!40000 ALTER TABLE `User` DISABLE KEYS */; +INSERT INTO `User` VALUES (1,1,'Administrator','admin','admin_123'); /*!40000 ALTER TABLE `User` ENABLE KEYS */; UNLOCK TABLES; @@ -269,7 +304,7 @@ CREATE TABLE `UserClass` ( `privilegeLevel` int(11) NOT NULL DEFAULT '0', `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`ucid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -278,6 +313,7 @@ CREATE TABLE `UserClass` ( LOCK TABLES `UserClass` WRITE; /*!40000 ALTER TABLE `UserClass` DISABLE KEYS */; +INSERT INTO `UserClass` VALUES (1,1,'Administrator'); /*!40000 ALTER TABLE `UserClass` ENABLE KEYS */; UNLOCK TABLES; @@ -291,6 +327,7 @@ DROP TABLE IF EXISTS `Vendor`; CREATE TABLE `Vendor` ( `vid` int(11) NOT NULL AUTO_INCREMENT, `vlid` int(11) DEFAULT NULL, + `signedNDA` tinyint(1) NOT NULL DEFAULT '0', `name` varchar(100) DEFAULT NULL, PRIMARY KEY (`vid`), KEY `vlid` (`vlid`), @@ -316,6 +353,7 @@ DROP TABLE IF EXISTS `VendorGroup`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `VendorGroup` ( `vgid` int(11) NOT NULL AUTO_INCREMENT, + `seqNo` int(4) NOT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`vgid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -391,6 +429,7 @@ DROP TABLE IF EXISTS `VendorType`; CREATE TABLE `VendorType` ( `vtid` int(11) NOT NULL AUTO_INCREMENT, `vgid` int(11) DEFAULT NULL, + `seqNo` int(4) NOT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`vtid`), KEY `vgid` (`vgid`), @@ -416,4 +455,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2012-09-18 19:39:04 +-- Dump completed on 2012-09-19 21:10:12 diff --git a/schematic.pro b/schematic.pro index 8cb9689..ffee4fb 100644 --- a/schematic.pro +++ b/schematic.pro @@ -27,12 +27,18 @@ HEADERS += src/about.h \ src/generaltab.h \ src/logindialog.h \ src/main.h \ - src/mainwin.h + src/mainwin.h \ + src/newvendordialog.h \ + src/sqlsettingsdialog.h \ + src/vendorclassdialog.h SOURCES += src/about.cpp \ src/configdialog.cpp \ src/generaltab.cpp \ src/logindialog.cpp \ src/main.cpp \ - src/mainwin.cpp + src/mainwin.cpp \ + src/newvendordialog.cpp \ + src/sqlsettingsdialog.cpp \ + src/vendorclassdialog.cpp diff --git a/src/about.cpp b/src/about.cpp index dc43bdb..86d3ac2 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -42,7 +42,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) "

" "The SCheMatic team would like to express their gratitude to:" "

" - "Tracking Point for underwriting the creation of SCheMatic
" + "Everyone who helped make SCheMatic a reality.
" // "David Raingeard for the original Virtual Jaguar sources
" // "Bernd Schmidt for his UAE 68K emulator
" // "Sam Lantinga for his amazing SDL libraries
" diff --git a/src/logindialog.cpp b/src/logindialog.cpp index fdd6ce6..e2a8018 100644 --- a/src/logindialog.cpp +++ b/src/logindialog.cpp @@ -8,14 +8,12 @@ // // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ -// JLH 06/04/2011 Created this file +// JLH 09/18/2011 Created this file #include "logindialog.h" LoginDialog::LoginDialog(QWidget * parent/*= 0*/): QDialog(parent), -// label1(new QLabel(tr("Username:"))), -// label2(new QLabel(tr("Password:"))), buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), edit1(new QLineEdit()), edit2(new QLineEdit()) @@ -30,7 +28,6 @@ LoginDialog::LoginDialog(QWidget * parent/*= 0*/): QDialog(parent), formLayout->addRow(tr("&Password:"), edit2); QVBoxLayout * mainLayout = new QVBoxLayout; -// mainLayout->addWidget(tabWidget); mainLayout->addLayout(formLayout); mainLayout->addWidget(buttonBox); setLayout(mainLayout); diff --git a/src/logindialog.h b/src/logindialog.h index d583c63..d9a1d83 100644 --- a/src/logindialog.h +++ b/src/logindialog.h @@ -12,9 +12,7 @@ class LoginDialog: public QDialog ~LoginDialog(); private: -// QLabel * label1; -// QLabel * label2; - QLabel * title; +// QLabel * title; QDialogButtonBox * buttonBox; public: diff --git a/src/mainwin.cpp b/src/mainwin.cpp index b7e1748..44161ba 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -16,10 +16,12 @@ //#define DEBUGTP // Toolpalette debugging... #include "mainwin.h" -#include -//#include "main.h" #include "about.h" +#include "configdialog.h" #include "logindialog.h" +#include "newvendordialog.h" +#include "sqlsettingsdialog.h" +#include "vendorclassdialog.h" MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), @@ -41,6 +43,18 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), aboutAct->setStatusTip(tr("Blatant self-promotion")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin())); + configAct = new QAction(QIcon(":/res/schematic.png"), tr("&Configure..."), this); + configAct->setStatusTip(tr("Configure SCheMatic")); + connect(configAct, SIGNAL(triggered()), this, SLOT(HandleConfigDialog())); + + vendorClassAct = new QAction(QIcon(":/res/schematic.png"), tr("&Edit Vendor Classes..."), this); + vendorClassAct->setStatusTip(tr("Edit Vendor Classes")); + connect(vendorClassAct, SIGNAL(triggered()), this, SLOT(HandleVendorClassDialog())); + + newVendorAct = new QAction(QIcon(":/res/schematic.png"), tr("&Add Vendor..."), this); + newVendorAct->setStatusTip(tr("Create a new vendor")); + connect(newVendorAct, SIGNAL(triggered()), this, SLOT(HandleNewVendorDialog())); + // helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this); // helpAct->setStatusTip(tr("Help is available, if you should need it")); // connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin())); @@ -56,6 +70,11 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), // fileMenu->addAction(configAct); menu->addAction(quitAppAct); + menu = menuBar()->addMenu(tr("&Edit")); + menu->addAction(configAct); + menu->addAction(vendorClassAct); + menu->addAction(newVendorAct); + menu = menuBar()->addMenu(tr("&Help")); // menu->addAction(helpAct); menu->addAction(aboutAct); @@ -83,17 +102,43 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), // Finally, set up database connection - QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); - db.setHostName("localhost"); - db.setDatabaseName("schematic"); - db.setUserName("scm_user"); - db.setPassword("scm_user"); - bool ok = db.open(); + db = QSqlDatabase::addDatabase("QMYSQL"); + bool ok = false; -#warning "!!! NEED TO SET UP DB SETUP DIALOG IF CONNECTION FAILED !!!" + // Prime the SQL Settings dialog (in case we need it) + SQLSettingsDialog sqlSettings; + sqlSettings.edit1->setText(dbHostName); + sqlSettings.edit2->setText(dbName); + sqlSettings.edit3->setText(dbUserName); + sqlSettings.edit4->setText(dbPassword); -// printf("Database connection was %sopened successfully.\n", (ok ? "" : "NOT ")); + do + { + // Set up the DB connection with saved settings + db.setHostName(dbHostName); + db.setDatabaseName(dbName); + db.setUserName(dbUserName); + db.setPassword(dbPassword); + ok = db.open(); + + // If unsuccessful, run the SQL settings/test dialog + if (!ok) + { + if (sqlSettings.exec()) + { + // User thinks this will work (hit OK button), so prime the variables + // for the next attempt + dbHostName = sqlSettings.edit1->text(); + dbName = sqlSettings.edit2->text(); + dbUserName = sqlSettings.edit3->text(); + dbPassword = sqlSettings.edit4->text(); + } + else + return; // User cancelled the dialog, so quit + } + } + while (!ok); // Do Login dialog LoginDialog login; @@ -144,6 +189,31 @@ void MainWindow::ShowAboutWin(void) } +void MainWindow::HandleConfigDialog(void) +{ + ConfigDialog dialog(this); + dialog.exec(); +} + + +void MainWindow::HandleVendorClassDialog(void) +{ + VendorClassDialog dialog(this); + + if (!dialog.exec()) + return; +} + + +void MainWindow::HandleNewVendorDialog(void) +{ + NewVendorDialog dialog(this); + + if (!dialog.exec()) + return; +} + + void MainWindow::ReadSettings(void) { QSettings settings("Underground Software", "SCheMatic"); @@ -155,6 +225,11 @@ void MainWindow::ReadSettings(void) // size = settings.value("charWndSize", QSize(200, 200)).toSize(); // ((TTEdit *)qApp)->charWnd->resize(size); // ((TTEdit *)qApp)->charWnd->move(pos); + + dbHostName = settings.value("dbHostName", "localhost").toString(); + dbName = settings.value("dbName", "schematic").toString(); + dbUserName = settings.value("dbUserName", "scm_user").toString(); + dbPassword = settings.value("dbPassword", "scm_user").toString(); } @@ -165,4 +240,10 @@ void MainWindow::WriteSettings(void) settings.setValue("size", size()); // settings.setValue("charWndPos", ((TTEdit *)qApp)->charWnd->pos()); // settings.setValue("charWndSize", ((TTEdit *)qApp)->charWnd->size()); + + settings.setValue("dbHostName", dbHostName); + settings.setValue("dbName", dbName); + settings.setValue("dbUserName", dbUserName); + settings.setValue("dbPassword", dbPassword); } + diff --git a/src/mainwin.h b/src/mainwin.h index 0f4cb24..5be8fd6 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -9,6 +9,7 @@ #define __MAINWINDOW_H__ #include +#include class AboutWindow; @@ -26,6 +27,9 @@ class MainWindow: public QMainWindow private slots: void Open(); void ShowAboutWin(void); + void HandleConfigDialog(void); + void HandleVendorClassDialog(void); + void HandleNewVendorDialog(void); private: void ReadSettings(void); @@ -35,6 +39,16 @@ class MainWindow: public QMainWindow QAction * quitAppAct; QAction * aboutAct; + QAction * configAct; + QAction * vendorClassAct; + QAction * newVendorAct; + + QString dbHostName; + QString dbName; + QString dbUserName; + QString dbPassword; + + QSqlDatabase db; public: int loggedInUID; diff --git a/src/newvendordialog.cpp b/src/newvendordialog.cpp new file mode 100644 index 0000000..8737af3 --- /dev/null +++ b/src/newvendordialog.cpp @@ -0,0 +1,98 @@ +// +// newvendordialog.cpp: Create New Vendor dialog +// +// Part of the SCheMatic Project +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 09/21/2012 Created this file + +#include "newvendordialog.h" + + +NewVendorDialog::NewVendorDialog(QWidget * parent/*= 0*/): QDialog(parent), + buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), + 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) +{ + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QVBoxLayout * vbox1 = new QVBoxLayout; + QVBoxLayout * vbox2 = new QVBoxLayout; + QVBoxLayout * vbox3 = new QVBoxLayout; + QHBoxLayout * hbox1 = new QHBoxLayout; + + QGroupBox * gb1 = new QGroupBox(tr("Vendor")); + QGroupBox * gb2 = new QGroupBox(tr("Primary Location")); + QGroupBox * gb3 = new QGroupBox(tr("Primary Contact")); + QGroupBox * gb4 = new QGroupBox(tr("Vendor Classes")); + + QFormLayout * form1 = new QFormLayout; + QFormLayout * form2 = new QFormLayout; + QFormLayout * form3 = new QFormLayout; + + 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); + + vbox1->addLayout(form1); + vbox1->addWidget(checkbox1); + gb1->setLayout(vbox1); + + gb2->setLayout(form2); + + gb3->setLayout(form3); + + vbox2->addWidget(gb1); + vbox2->addWidget(gb2); + vbox2->addWidget(gb3); + + vbox3->addWidget(list); + gb4->setLayout(vbox3); + + hbox1->addLayout(vbox2); + hbox1->addWidget(gb4); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addLayout(hbox1); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("New Vendor")); +} + +NewVendorDialog::~NewVendorDialog() +{ +} + diff --git a/src/newvendordialog.h b/src/newvendordialog.h new file mode 100644 index 0000000..e224bb1 --- /dev/null +++ b/src/newvendordialog.h @@ -0,0 +1,39 @@ +#ifndef __NEWVENDORDIALOG_H__ +#define __NEWVENDORDIALOG_H__ + +#include + +class NewVendorDialog: public QDialog +{ + Q_OBJECT + + public: + NewVendorDialog(QWidget * parent = 0); + ~NewVendorDialog(); + + private: + QDialogButtonBox * buttonBox; + + public: + QLineEdit * edit1; + 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; +}; + +#endif // __NEWVENDORDIALOG_H__ diff --git a/src/sqlsettingsdialog.cpp b/src/sqlsettingsdialog.cpp new file mode 100644 index 0000000..30b1a53 --- /dev/null +++ b/src/sqlsettingsdialog.cpp @@ -0,0 +1,44 @@ +// +// sqlsettingsdialog.cpp: The SQL Settings dialog +// +// Part of the SCheMatic Project +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 09/19/2012 Created this file + +#include "sqlsettingsdialog.h" + + +SQLSettingsDialog::SQLSettingsDialog(QWidget * parent/*= 0*/): QDialog(parent), + buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), + edit1(new QLineEdit()), + edit2(new QLineEdit()), + edit3(new QLineEdit()), + edit4(new QLineEdit()) +{ + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + edit4->setEchoMode(QLineEdit::Password); + + QFormLayout * formLayout = new QFormLayout; + formLayout->addRow(tr("&MySQL Server Hostname:"), edit1); + formLayout->addRow(tr("&Database Name:"), edit2); + formLayout->addRow(tr("&Database Username:"), edit3); + formLayout->addRow(tr("&Database Password:"), edit4); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addLayout(formLayout); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("MySQL Server Connection")); +} + +SQLSettingsDialog::~SQLSettingsDialog() +{ +} diff --git a/src/sqlsettingsdialog.h b/src/sqlsettingsdialog.h new file mode 100644 index 0000000..e1a9c8c --- /dev/null +++ b/src/sqlsettingsdialog.h @@ -0,0 +1,26 @@ +#ifndef __SQLSETTINGSDIALOG_H__ +#define __SQLSETTINGSDIALOG_H__ + +#include + +class SQLSettingsDialog: public QDialog +{ + Q_OBJECT + + public: + SQLSettingsDialog(QWidget * parent = 0); + ~SQLSettingsDialog(); + + private: +// QLabel * title; + QPushButton * testButton; + QDialogButtonBox * buttonBox; + + public: + QLineEdit * edit1; + QLineEdit * edit2; + QLineEdit * edit3; + QLineEdit * edit4; +}; + +#endif // __SQLSETTINGSDIALOG_H__ diff --git a/src/vendorclassdialog.cpp b/src/vendorclassdialog.cpp new file mode 100644 index 0000000..aef142b --- /dev/null +++ b/src/vendorclassdialog.cpp @@ -0,0 +1,218 @@ +// +// vendorclassdialog.cpp: Vendor Class editing dialog +// +// Part of the SCheMatic Project +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 09/20/2011 Created this file + +#include "vendorclassdialog.h" +#include + + +VendorClassDialog::VendorClassDialog(QWidget * parent/*= 0*/): QDialog(parent), + buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), + addItem(new QToolButton), + deleteItem(new QToolButton), + moveItemUp(new QToolButton), + moveItemDown(new QToolButton), + makeHeader(new QCheckBox(tr("&Heading"))), + normalFont(new QFont), + boldFont(new QFont), + list(new QListWidget) +// dbRef(db) +{ + addItem->setToolButtonStyle(Qt::ToolButtonTextOnly); + addItem->setText("+"); + addItem->setToolTip(tr("Add new vendor class or group.")); + deleteItem->setToolButtonStyle(Qt::ToolButtonTextOnly); + deleteItem->setText("-"); + deleteItem->setToolTip(tr("Delete highlighted item.")); + moveItemUp->setArrowType(Qt::UpArrow); + moveItemUp->setToolTip(tr("Move highlighted item up in the list.")); + moveItemDown->setArrowType(Qt::DownArrow); + moveItemDown->setToolTip(tr("Move highlighted item down in the list.")); + makeHeader->setToolTip(tr("Make highlighted item into a vendor group.")); +// list->setToolTip(tr("")); + + QHBoxLayout * buttonLayout = new QHBoxLayout; + buttonLayout->addWidget(addItem); + buttonLayout->addWidget(deleteItem); + buttonLayout->addWidget(moveItemUp); + buttonLayout->addWidget(moveItemDown); + buttonLayout->addStretch(); + buttonLayout->addWidget(makeHeader); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(list); + mainLayout->addLayout(buttonLayout); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("Vendor Class Editor")); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + connect(addItem, SIGNAL(clicked()), this, SLOT(AddItem())); + connect(deleteItem, SIGNAL(clicked()), this, SLOT(DeleteItem())); + connect(moveItemUp, SIGNAL(clicked()), this, SLOT(MoveItemUp())); + connect(moveItemDown, SIGNAL(clicked()), this, SLOT(MoveItemDown())); + connect(makeHeader, SIGNAL(clicked()), this, SLOT(SetHeaderStateOnItem())); + connect(list, SIGNAL(currentRowChanged(int)), this, SLOT(CurrentRowChanged(int))); + + boldFont->setBold(true); + LoadList(); +} + + +VendorClassDialog::~VendorClassDialog() +{ +} + + +void VendorClassDialog::AddItem(void) +{ + QListWidgetItem * item = new QListWidgetItem(tr("New Vendor Class")); + item->setFlags(item->flags() | Qt::ItemIsEditable); + + // We'll have to use the setData(Qt::UserRole, bool) to set the header/no header data... + +// item->setCheckState(Qt::Unchecked); +// Qt::ItemFlags f = item->flags(); +// //nope, this doesn't work. the above fucks something up that's not unfuckable. +// f &= ~Qt::ItemIsUserCheckable; +// item->setFlags(f | Qt::ItemIsEditable); + + int row = list->row(list->currentItem()); + list->insertItem(row + 1, item); +} + + +void VendorClassDialog::DeleteItem(void) +{ + int row = list->row(list->currentItem()); + QListWidgetItem * item = list->takeItem(row); + + // This could be called on an empty list, so we have a sanity check here... + if (item) + delete item; +} + + +void VendorClassDialog::MoveItemUp(void) +{ + int row = list->row(list->currentItem()); + + if (row == 0) + return; + + QListWidgetItem * item = list->takeItem(row); + list->insertItem(row - 1, item); + list->setCurrentItem(item); +} + + +void VendorClassDialog::MoveItemDown(void) +{ + int row = list->row(list->currentItem()); + + if (row == list->count() - 1) + return; + + QListWidgetItem * item = list->takeItem(row); + list->insertItem(row + 1, item); + list->setCurrentItem(item); +} + + +void VendorClassDialog::SetHeaderStateOnItem(void) +{ + QListWidgetItem * item = list->currentItem(); + item->setData(Qt::UserRole, makeHeader->isChecked()); + + if (makeHeader->isChecked()) + item->setFont(*boldFont); + else + item->setFont(*normalFont); +} + + +void VendorClassDialog::CurrentRowChanged(int /*row*/) +{ + // Show our indicator that this item is a header/group or not + QListWidgetItem * item = list->currentItem(); + bool isHeader = item->data(Qt::UserRole).toBool(); + makeHeader->setChecked(isHeader); +} + + +// This probably should be in the mainwin class... +void VendorClassDialog::LoadList(void) +{ + std::vector groupList; + + // Pull in definitions from DB for Vendor Classes/Groups + QSqlQuery query1("SELECT vgid, seqNo, description FROM VendorGroup ORDER BY seqNo"); + query1.exec(); + + while (query1.next()) + { + VendorType v; + v.key = query1.value(0).toInt(); + v.seqNo = query1.value(1).toInt(); + v.description = query1.value(2).toString(); + v.isHeader = true; + + groupList.push_back(v); + } + + QSqlQuery query2("SELECT vtid, vgid, seqNo, description FROM VendorType ORDER BY seqNo"); + query2.exec(); + + int previousID = -1, groupListIndex = 0; + + while (query2.next()) + { + VendorType v; + v.key = query2.value(0).toInt(); + int vgid = query2.value(1).toInt(); + v.seqNo = query2.value(2).toInt(); + v.description = query2.value(3).toString(); + v.isHeader = false; + + // 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) + { + oldList.push_back(groupList[groupListIndex++]); + previousID = vgid; + } + + oldList.push_back(v); + } + + // Finally, populate the QListWidget + for(int i=0; isetFlags(item->flags() | Qt::ItemIsEditable); + item->setData(Qt::UserRole, oldList[i].isHeader); + + if (oldList[i].isHeader) + item->setFont(*boldFont); + + list->insertItem(i, item); + } +} + + +void VendorClassDialog::SaveList(void) +{ +} + diff --git a/src/vendorclassdialog.h b/src/vendorclassdialog.h new file mode 100644 index 0000000..4a0b702 --- /dev/null +++ b/src/vendorclassdialog.h @@ -0,0 +1,52 @@ +#ifndef __VENDORCLASSDIALOG_H__ +#define __VENDORCLASSDIALOG_H__ + +#include +#include + +struct VendorType +{ + int key; + int seqNo; + bool isHeader; + QString description; +}; + + +class VendorClassDialog: public QDialog +{ + Q_OBJECT + + public: + VendorClassDialog(QWidget * parent = 0); + ~VendorClassDialog(); + + private slots: + void AddItem(void); + void DeleteItem(void); + void MoveItemUp(void); + void MoveItemDown(void); + void SetHeaderStateOnItem(void); + void CurrentRowChanged(int); + + private: + void LoadList(void); + void SaveList(void); + + private: + QDialogButtonBox * buttonBox; + QToolButton * addItem; + QToolButton * deleteItem; + QToolButton * moveItemUp; + QToolButton * moveItemDown; + QCheckBox * makeHeader; + std::vector oldList; + QFont * normalFont; + QFont * boldFont; + + public: + QListWidget * list; +// QSqlDatabase & dbRef; +}; + +#endif // __VENDORCLASSDIALOG_H__ diff --git a/vendor-classes.ui b/vendor-classes.ui new file mode 100644 index 0000000..0c6e050 --- /dev/null +++ b/vendor-classes.ui @@ -0,0 +1,332 @@ + + + Dialog + + + + 0 + 0 + 343 + 439 + + + + Dialog + + + + + 130 + 310 + 171 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 50 + 50 + 256 + 201 + + + + + Machine + + + + + Cutter + + + + + Sheet Metal + + + + + EDM Wire + + + + + CNC + + + + + Casting + + + + + Electronic Parts + + + + + Distributor + + + + + Manufacturer + + + + + Broker Grey + + + + + Representative + + + + + Printed Circuit Boards + + + ItemIsSelectable|ItemIsDragEnabled|ItemIsEnabled + + + + + PCB + + + + + PCBA + + + + + Testing + + + + + Raw Materials + + + + + Metal + + + + + Plastic + + + + + Extruded + + + + + Lenses + + + + + Distributor + + + + + Manufacturer + + + + + Representative + + + + + Filters + + + + + Cubes + + + + + Lenses + + + + + COTS + + + + + Screws + + + + + O-Ring + + + + + Switches + + + + + Captive Fasteners + + + + + Springs & Pins + + + + + Retaining Rings + + + + + Coatings + + + + + Anodized + + + + + Nickel + + + + + Paint + + + + + + + 50 + 260 + 251 + 31 + + + + + + + + + + + + + + + - + + + + + + + ^ + + + Qt::UpArrow + + + + + + + + + + Qt::DownArrow + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Heading + + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +