]> Shamusworld >> Repos - schematic/blobdiff - src/alertdialog.cpp
Move DB access to NoteDialog class, new AlertDialog class.
[schematic] / src / alertdialog.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
+}
+