]> Shamusworld >> Repos - schematic/commitdiff
Added Note capability.
authorShamus Hammons <jlhamm@acm.org>
Wed, 5 Dec 2012 17:35:03 +0000 (11:35 -0600)
committerShamus Hammons <jlhamm@acm.org>
Wed, 5 Dec 2012 17:35:03 +0000 (11:35 -0600)
.gitignore [new file with mode: 0644]
schematic-schema.sql
schematic.pro
src/configdialog.cpp
src/generaltab.cpp
src/mainwin.cpp
src/notedialog.cpp [new file with mode: 0644]
src/notedialog.h [new file with mode: 0644]
src/scmwidget.cpp
src/scmwidget.h

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..e04c9da
--- /dev/null
@@ -0,0 +1,4 @@
+*~
+obj/
+schematic
+Makefile
index d632f3b107a870526cc58ee6d889ce1a7943a7a9..7c4c15f9a8c979c934fab45bb4f943b415b83547 100644 (file)
@@ -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
index 150bd0c6dbfb3dd91eae943e663058f60bb1a3c7..1344544fd71d7bb5e9e64d2b7a73d816a97ecaec 100644 (file)
@@ -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 \
index b3c14ed769542df64ad593692b9c9f81afea42c7..c4a1660e6c37c8857ff513aa1d89e04c7749bc43 100644 (file)
@@ -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 <jlhamm@acm.org>
 //
index 7b18549619638885984e9e5fd77100ecce764c69..5277e2a1e40983542802e6eaf1776548428be998 100644 (file)
@@ -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 <jlhamm@acm.org>
 //
@@ -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()
 {
 }
+
index fc1ec2f44140a283c685a5259f3a4f7e276294e2..77ceed7d448c2e4a7692307523d7bd5cc3c95325 100644 (file)
@@ -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 (file)
index 0000000..c91b5bf
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// notedialog.cpp: Dialog for creating & editing notes
+//
+// Part of the SCheMatic Project
+// (C) 2012 Underground Software
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// 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 (file)
index 0000000..ada9970
--- /dev/null
@@ -0,0 +1,33 @@
+//
+// notedialog.h: Note entry/editing
+//
+// by James Hammons
+// (C) 2012 Underground Software
+//
+
+#ifndef __NOTEDIALOG_H__
+#define __NOTEDIALOG_H__
+
+#include <QtGui>
+
+//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__
+
index c9a175e34d784aa9ce753fef4164ee6d3e2a63eb..a04e8947050a424dcc4ba53e844b8ef8187796a3 100644 (file)
@@ -15,6 +15,7 @@
 #include <QtSql>
 #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);
+       }
+}
+
index a3aa7f5ea9e47718b94c0ec730503352ec12a554..e9edd01d8939acfc421c6e681de856db7b7e8965 100644 (file)
@@ -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<int> vendorID;
                int vidCursor;