]> Shamusworld >> Repos - schematic/commitdiff
Move DB access to NoteDialog class, new AlertDialog class. master
authorShamus Hammons <jlhamm@acm.org>
Thu, 13 Dec 2012 21:41:48 +0000 (15:41 -0600)
committerShamus Hammons <jlhamm@acm.org>
Thu, 13 Dec 2012 21:41:48 +0000 (15:41 -0600)
docs/README
schematic.pro
src/alertdialog.cpp [new file with mode: 0644]
src/alertdialog.h [new file with mode: 0644]
src/notedialog.cpp
src/notedialog.h
src/scmwidget.cpp
src/scmwidget.h

index 1ea1a15c39c9bba04025c485bec5a7f16868829a..63b33ad56e9887e0226dce67612015da4bedb6cb 100644 (file)
@@ -1,3 +1,3 @@
-When installing on Windows client machines, be sure to install the *32-bit* version of the
-MyODBC connector, otherwise it won't work!
+When installing on Windows client machines, be sure to install the *32-bit*
+version of the MyODBC connector, otherwise it won't work!
 
index 1344544fd71d7bb5e9e64d2b7a73d816a97ecaec..2ff5a0d9234ec31558f811bc8688766973872328 100644 (file)
@@ -25,6 +25,7 @@ RESOURCES += schematic.qrc
 HEADERS += src/about.h \
        src/addresseditwidget.h \
        src/addresswidget.h \
+       src/alertdialog.h \
        src/configdialog.h \
        src/contacteditwidget.h \
        src/contactwidget.h \
@@ -42,6 +43,7 @@ HEADERS += src/about.h \
 SOURCES += src/about.cpp \
        src/addresseditwidget.cpp \
        src/addresswidget.cpp \
+       src/alertdialog.cpp \
        src/configdialog.cpp \
        src/contacteditwidget.cpp \
        src/contactwidget.cpp \
diff --git a/src/alertdialog.cpp b/src/alertdialog.cpp
new file mode 100644 (file)
index 0000000..d748c1f
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// alertdialog.cpp: Dialog for creating & editing alerts
+//
+// Part of the SCheMatic Project
+// (C) 2012 Underground Software
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// WHO  WHEN        WHAT
+// ---  ----------  ------------------------------------------------------------
+// JLH  12/13/2012  Created this file
+//
+
+#include "alertdialog.h"
+#include <QtSql>
+
+
+AlertDialog::AlertDialog(int uidToUse, QWidget * parent/*= 0*/): QDialog(parent), uid(uidToUse)
+{
+       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("Alert"));
+}
+
+
+AlertDialog::~AlertDialog()
+{
+}
+
+
+void AlertDialog::accept(void)
+{
+       // Call base class version, so things work right
+       QDialog::accept();
+
+#if 0
+       // Add note to DB for this user
+       QString noteText = note->document()->toPlainText();
+
+       if (noteText.isEmpty())
+               return;
+
+       QSqlQuery query;
+       query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
+       query.addBindValue(uid);
+//     query.addBindValue(NULL);
+       query.addBindValue(noteText.toAscii());
+       query.exec();
+#endif
+}
+
diff --git a/src/alertdialog.h b/src/alertdialog.h
new file mode 100644 (file)
index 0000000..560318e
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// alertdialog.h: Alert entry/editing
+//
+// by James Hammons
+// (C) 2012 Underground Software
+//
+
+#ifndef __ALERTDIALOG_H__
+#define __ALERTDIALOG_H__
+
+#include <QtGui>
+
+
+class AlertDialog: public QDialog
+{
+       Q_OBJECT
+
+       public:
+               AlertDialog(int uidToUse, QWidget * parent = 0);
+               ~AlertDialog();
+
+       public slots:
+               virtual void accept(void);
+
+       private:
+               QDialogButtonBox * buttonBox;
+
+       public:
+               QTextEdit * note;
+               int uid;
+};
+
+#endif // __ALERTDIALOG_H__
+
index c91b5bf571cd24c2cdc8eb8f1b7cca54db5b1b27..0b2fbf9ba1b81153f2a75c12aae4471c2a7c62e3 100644 (file)
 //
 
 #include "notedialog.h"
+#include <QtSql>
 
 
-NoteDialog::NoteDialog(QWidget * parent/*= 0*/): QDialog(parent)
+NoteDialog::NoteDialog(int uidToUse, QWidget * parent/*= 0*/): QDialog(parent), uid(uidToUse)
 {
-//     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()));
@@ -36,7 +31,28 @@ NoteDialog::NoteDialog(QWidget * parent/*= 0*/): QDialog(parent)
        setWindowTitle(tr("Note"));
 }
 
+
 NoteDialog::~NoteDialog()
 {
 }
 
+
+void NoteDialog::accept(void)
+{
+       // Call base class version, so things work right
+       QDialog::accept();
+
+       // Add note to DB for this user
+       QString noteText = note->document()->toPlainText();
+
+       if (noteText.isEmpty())
+               return;
+
+       QSqlQuery query;
+       query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
+       query.addBindValue(uid);
+//     query.addBindValue(NULL);
+       query.addBindValue(noteText.toAscii());
+       query.exec();
+}
+
index ada9970934834909650ba0e5c32d991028d4f96a..533f84169d27753c1a559b2308b98b3b55dd9b9b 100644 (file)
 
 #include <QtGui>
 
-//class GeneralTab;
 
 class NoteDialog: public QDialog
 {
        Q_OBJECT
 
        public:
-               NoteDialog(QWidget * parent = 0);
+               NoteDialog(int uidToUse, QWidget * parent = 0);
                ~NoteDialog();
 
+       public slots:
+               virtual void accept(void);
+
        private:
-//             QTabWidget * tabWidget;
                QDialogButtonBox * buttonBox;
 
        public:
                QTextEdit * note;
-//             GeneralTab * generalTab;
+               int uid;
 };
 
 #endif // __NOTEDIALOG_H__
index a04e8947050a424dcc4ba53e844b8ef8187796a3..4c531ad756c58e80967cad14d155021d0fbae1c0 100644 (file)
@@ -14,6 +14,7 @@
 #include "scmwidget.h"
 #include <QtSql>
 #include "addresswidget.h"
+#include "alertdialog.h"
 #include "contactwidget.h"
 #include "notedialog.h"
 
@@ -250,28 +251,24 @@ void SCMWidget::GetPreviousVendor(void)
 
 void SCMWidget::CreateNote(void)
 {
-       NoteDialog dlg;
-       
-       if (dlg.exec() == true)
-       {
-               // Add note to DB for this user
-               QString note = dlg.note->document()->toPlainText();
+       NoteDialog dlg(currentUID);
 
-               QSqlQuery query;
-               query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
-               query.addBindValue(currentUID);
-//             query.addBindValue(NULL);
-               query.addBindValue(note.toAscii());
-               query.exec();
+       if (dlg.exec() == false)
+               return;
 
-               UpdateNotes();
-       }
+       UpdateNotes();
 }
 
 
 void SCMWidget::CreateAlert(void)
 {
+       AlertDialog dlg(currentUID);
+
+       if (dlg.exec() == false)
+               return;
+
        QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+//     UpdateAlerts();
 }
 
 
@@ -392,10 +389,6 @@ void SCMWidget::UpdateNotes(void)
 
        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();
 
@@ -408,3 +401,9 @@ void SCMWidget::UpdateNotes(void)
        }
 }
 
+
+void SCMWidget::UpdateAlerts(void)
+{
+       // TODO: Implementation
+}
+
index e9edd01d8939acfc421c6e681de856db7b7e8965..9dddfcf7b001d4eada9cf5f7dffb2d982d46c052 100644 (file)
@@ -42,6 +42,7 @@ class SCMWidget: public QWidget
                void GetVendorIDs(void);
                void GetVendor(int);
                void UpdateNotes(void);
+               void UpdateAlerts(void);
 
        public:
                QTreeView * purchaseOrders;