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