From: Shamus Hammons Date: Wed, 5 Dec 2012 17:35:03 +0000 (-0600) Subject: Added Note capability. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=schematic;a=commitdiff_plain;h=8eb70a8369511a54803410b9bc5918b3077bfb52 Added Note capability. --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e04c9da --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +obj/ +schematic +Makefile diff --git a/schematic-schema.sql b/schematic-schema.sql index d632f3b..7c4c15f 100644 --- a/schematic-schema.sql +++ b/schematic-schema.sql @@ -1,4 +1,4 @@ --- MySQL dump 10.13 Distrib 5.1.62, for pc-linux-gnu (x86_64) +-- MySQL dump 10.13 Distrib 5.5.28, for Linux (x86_64) -- -- Host: localhost Database: schematic -- ------------------------------------------------------ @@ -65,7 +65,7 @@ CREATE TABLE `Contact` ( KEY `CTID` (`CTID`), CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`vid`) REFERENCES `Vendor` (`vid`), CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`CTID`) REFERENCES `ContactType` (`ctid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -74,6 +74,7 @@ CREATE TABLE `Contact` ( LOCK TABLES `Contact` WRITE; /*!40000 ALTER TABLE `Contact` DISABLE KEYS */; +INSERT INTO `Contact` VALUES (2,4,1,'Jo Pesci','jo.pesci@samsung.com','Shanghai','48-3483-23848 x2177','',''),(3,5,2,'John Gearhead','jg@harleydavidson.com','OK City','732-133-1233','','732-133-1240'),(4,6,3,'','','','','',''); /*!40000 ALTER TABLE `Contact` ENABLE KEYS */; UNLOCK TABLES; @@ -88,7 +89,7 @@ CREATE TABLE `ContactType` ( `ctid` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`ctid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -97,6 +98,7 @@ CREATE TABLE `ContactType` ( LOCK TABLES `ContactType` WRITE; /*!40000 ALTER TABLE `ContactType` DISABLE KEYS */; +INSERT INTO `ContactType` VALUES (1,'Sales'),(2,'Engineer'),(3,'PR'); /*!40000 ALTER TABLE `ContactType` ENABLE KEYS */; UNLOCK TABLES; @@ -197,7 +199,7 @@ CREATE TABLE `Location` ( PRIMARY KEY (`lid`), KEY `vid` (`vid`), CONSTRAINT `Location_ibfk_1` FOREIGN KEY (`vid`) REFERENCES `Vendor` (`vid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -206,6 +208,7 @@ CREATE TABLE `Location` ( LOCK TABLES `Location` WRITE; /*!40000 ALTER TABLE `Location` DISABLE KEYS */; +INSERT INTO `Location` VALUES (1,4,'723 Pine Scent Way','Shanghai','','China','8W-94732'),(2,5,'1 Harley Way','Oklahoma City','Oklahoma','USA','24678'),(3,6,'','','','',''); /*!40000 ALTER TABLE `Location` ENABLE KEYS */; UNLOCK TABLES; @@ -218,9 +221,12 @@ DROP TABLE IF EXISTS `Notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Notes` ( `nid` int(11) NOT NULL AUTO_INCREMENT, + `uid` int(11) NOT NULL, `poid` int(11) DEFAULT NULL, `note` varchar(200) DEFAULT NULL, - PRIMARY KEY (`nid`) + PRIMARY KEY (`nid`), + KEY `uid` (`uid`), + CONSTRAINT `Notes_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `User` (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -332,7 +338,7 @@ CREATE TABLE `Vendor` ( PRIMARY KEY (`vid`), KEY `vlid` (`vlid`), CONSTRAINT `Vendor_ibfk_1` FOREIGN KEY (`vlid`) REFERENCES `VendorLevel` (`vlid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -341,6 +347,7 @@ CREATE TABLE `Vendor` ( LOCK TABLES `Vendor` WRITE; /*!40000 ALTER TABLE `Vendor` DISABLE KEYS */; +INSERT INTO `Vendor` VALUES (1,1,0,'Sanford & Sons'),(2,3,0,'Haliburton'),(3,2,1,'Digikey'),(4,2,1,'Samsung'),(5,1,1,'Harley Davidson'),(6,1,0,'Amazing Scientific'); /*!40000 ALTER TABLE `Vendor` ENABLE KEYS */; UNLOCK TABLES; @@ -356,7 +363,7 @@ CREATE TABLE `VendorGroup` ( `seqNo` int(4) NOT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`vgid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -365,6 +372,7 @@ CREATE TABLE `VendorGroup` ( LOCK TABLES `VendorGroup` WRITE; /*!40000 ALTER TABLE `VendorGroup` DISABLE KEYS */; +INSERT INTO `VendorGroup` VALUES (1,1,'Machine'); /*!40000 ALTER TABLE `VendorGroup` ENABLE KEYS */; UNLOCK TABLES; @@ -381,7 +389,7 @@ CREATE TABLE `VendorLevel` ( `color` int(4) DEFAULT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`vlid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -390,9 +398,7 @@ 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'); +INSERT INTO `VendorLevel` VALUES (1,1,65280,'1;Trusted'),(2,1,255,'2;Caution Advised'),(3,0,16719904,'X;DO NOT USE'); /*!40000 ALTER TABLE `VendorLevel` ENABLE KEYS */; UNLOCK TABLES; @@ -419,6 +425,7 @@ CREATE TABLE `VendorSpecificTypes` ( LOCK TABLES `VendorSpecificTypes` WRITE; /*!40000 ALTER TABLE `VendorSpecificTypes` DISABLE KEYS */; +INSERT INTO `VendorSpecificTypes` VALUES (1,2),(1,3),(1,5),(3,1),(3,3),(3,4),(5,1),(5,2),(5,3),(5,4); /*!40000 ALTER TABLE `VendorSpecificTypes` ENABLE KEYS */; UNLOCK TABLES; @@ -437,7 +444,7 @@ CREATE TABLE `VendorType` ( PRIMARY KEY (`vtid`), KEY `vgid` (`vgid`), CONSTRAINT `VendorType_ibfk_1` FOREIGN KEY (`vgid`) REFERENCES `VendorGroup` (`vgid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -446,6 +453,7 @@ CREATE TABLE `VendorType` ( LOCK TABLES `VendorType` WRITE; /*!40000 ALTER TABLE `VendorType` DISABLE KEYS */; +INSERT INTO `VendorType` VALUES (1,1,2,'Cutter'),(2,1,3,'Sheet Metal'),(3,1,4,'EDM Wire'),(4,1,5,'CNC'),(5,1,6,'Casting'); /*!40000 ALTER TABLE `VendorType` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -458,4 +466,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2012-09-19 21:10:12 +-- Dump completed on 2012-12-05 10:13:50 diff --git a/schematic.pro b/schematic.pro index 150bd0c..1344544 100644 --- a/schematic.pro +++ b/schematic.pro @@ -33,6 +33,7 @@ HEADERS += src/about.h \ src/main.h \ src/mainwin.h \ src/newvendordialog.h \ + src/notedialog.h \ src/scmwidget.h \ src/sqlsettingsdialog.h \ src/vendorclassdialog.h \ @@ -49,6 +50,7 @@ SOURCES += src/about.cpp \ src/main.cpp \ src/mainwin.cpp \ src/newvendordialog.cpp \ + src/notedialog.cpp \ src/scmwidget.cpp \ src/sqlsettingsdialog.cpp \ src/vendorclassdialog.cpp \ diff --git a/src/configdialog.cpp b/src/configdialog.cpp index b3c14ed..c4a1660 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -1,9 +1,8 @@ // -// settingsdialog.cpp: Dialog for changing Architektonas settings +// settingsdialog.cpp: Dialog for changing SCheMatic settings // -// Part of the Architektonas Project -// (C) 2011 Underground Software -// See the README and GPLv3 files for licensing and warranty information +// Part of the SCheMatic Project +// (C) 2012 Underground Software // // JLH = James Hammons // diff --git a/src/generaltab.cpp b/src/generaltab.cpp index 7b18549..5277e2a 100644 --- a/src/generaltab.cpp +++ b/src/generaltab.cpp @@ -1,9 +1,8 @@ // // generaltab.cpp: "General" tab on the settings dialog // -// Part of the Architektonas Project -// (C) 2011 Underground Software -// See the README and GPLv3 files for licensing and warranty information +// Part of the SCheMatic Project +// (C) 2012 Underground Software // // JLH = James Hammons // @@ -16,7 +15,7 @@ GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent) { - antialiasChk = new QCheckBox(tr("Use Qt's built-in antialiasing")); + antialiasChk = new QCheckBox(tr("Please make my life better")); QVBoxLayout * layout = new QVBoxLayout; layout->addWidget(antialiasChk); @@ -26,3 +25,4 @@ GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent) GeneralTab::~GeneralTab() { } + diff --git a/src/mainwin.cpp b/src/mainwin.cpp index fc1ec2f..77ceed7 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -196,6 +196,7 @@ MainWindow::MainWindow(): aboutWin(new AboutWindow(this)), } scmWidget = new SCMWidget(this); + scmWidget->currentUID = loggedInUID; QString s = QString("User: %1 (%2)").arg(fullName).arg(login); scmWidget->username->setText(s); setCentralWidget(scmWidget); diff --git a/src/notedialog.cpp b/src/notedialog.cpp new file mode 100644 index 0000000..c91b5bf --- /dev/null +++ b/src/notedialog.cpp @@ -0,0 +1,42 @@ +// +// notedialog.cpp: Dialog for creating & editing notes +// +// Part of the SCheMatic Project +// (C) 2012 Underground Software +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 12/05/2012 Created this file +// + +#include "notedialog.h" + + +NoteDialog::NoteDialog(QWidget * parent/*= 0*/): QDialog(parent) +{ +// tabWidget = new QTabWidget; +// generalTab = new GeneralTab(this); +// tabWidget->addTab(generalTab, tr("General")); +// tabWidget->addTab(new PermissionsTab(fileInfo), tr("Permissions")); +// tabWidget->addTab(new ApplicationsTab(fileInfo), tr("Applications")); + note = new QTextEdit; + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(note); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("Note")); +} + +NoteDialog::~NoteDialog() +{ +} + diff --git a/src/notedialog.h b/src/notedialog.h new file mode 100644 index 0000000..ada9970 --- /dev/null +++ b/src/notedialog.h @@ -0,0 +1,33 @@ +// +// notedialog.h: Note entry/editing +// +// by James Hammons +// (C) 2012 Underground Software +// + +#ifndef __NOTEDIALOG_H__ +#define __NOTEDIALOG_H__ + +#include + +//class GeneralTab; + +class NoteDialog: public QDialog +{ + Q_OBJECT + + public: + NoteDialog(QWidget * parent = 0); + ~NoteDialog(); + + private: +// QTabWidget * tabWidget; + QDialogButtonBox * buttonBox; + + public: + QTextEdit * note; +// GeneralTab * generalTab; +}; + +#endif // __NOTEDIALOG_H__ + diff --git a/src/scmwidget.cpp b/src/scmwidget.cpp index c9a175e..a04e894 100644 --- a/src/scmwidget.cpp +++ b/src/scmwidget.cpp @@ -15,6 +15,7 @@ #include #include "addresswidget.h" #include "contactwidget.h" +#include "notedialog.h" SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent), @@ -217,7 +218,7 @@ SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent), connect(showOpen, SIGNAL(clicked()), this, SLOT(ShowOpenPOs())); connect(showClosed, SIGNAL(clicked()), this, SLOT(ShowClosedPOs())); connect(showAll, SIGNAL(clicked()), this, SLOT(ShowAllPOs())); - connect(addVendor, SIGNAL(clicked()), this, SLOT(AddVendor())); +// connect(addVendor, SIGNAL(clicked()), this, SLOT(AddVendor())); connect(addLocation, SIGNAL(clicked()), this, SLOT(AddLocation())); connect(addContact, SIGNAL(clicked()), this, SLOT(AddContact())); connect(editVendor, SIGNAL(clicked()), this, SLOT(EditVendor())); @@ -249,7 +250,22 @@ void SCMWidget::GetPreviousVendor(void) void SCMWidget::CreateNote(void) { - QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation"); + NoteDialog dlg; + + if (dlg.exec() == true) + { + // Add note to DB for this user + QString note = dlg.note->document()->toPlainText(); + + QSqlQuery query; + query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)"); + query.addBindValue(currentUID); +// query.addBindValue(NULL); + query.addBindValue(note.toAscii()); + query.exec(); + + UpdateNotes(); + } } @@ -368,3 +384,27 @@ void SCMWidget::GetVendor(int key) } } + +void SCMWidget::UpdateNotes(void) +{ +// QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation"); +//NID (P-key) | UID | POID | Note + + QSqlQuery query; + query.prepare("SELECT note FROM Notes WHERE uid = ?"); +// "c.name, email, c.address, phone1, phone2, fax, description, v.vlid FROM " +// "Vendor AS v LEFT OUTER JOIN Location AS l ON v.vid = l.vid " +// "LEFT OUTER JOIN (Contact AS c JOIN ContactType AS ct ON c.ctid = ct.ctid) " +// "ON v.vid = c.vid WHERE v.vid = ?"); + query.addBindValue(currentUID); + query.exec(); + + notes->clear(); + + while (query.next()) + { + QListWidgetItem * item = new QListWidgetItem(query.value(0).toString()); + notes->addItem(item); + } +} + diff --git a/src/scmwidget.h b/src/scmwidget.h index a3aa7f5..e9edd01 100644 --- a/src/scmwidget.h +++ b/src/scmwidget.h @@ -41,6 +41,7 @@ class SCMWidget: public QWidget public: void GetVendorIDs(void); void GetVendor(int); + void UpdateNotes(void); public: QTreeView * purchaseOrders; @@ -71,6 +72,8 @@ class SCMWidget: public QWidget QPushButton * createPO; QCheckBox * vendorRelated; + int currentUID; + private: std::vector vendorID; int vidCursor;