2 // notedialog.cpp: Dialog for creating & editing notes
4 // Part of the SCheMatic Project
5 // (C) 2012 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 12/05/2012 Created this file
14 #include "notedialog.h"
18 NoteDialog::NoteDialog(int uidToUse, QWidget * parent/*= 0*/): QDialog(parent), uid(uidToUse)
21 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
23 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
24 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
26 QVBoxLayout * mainLayout = new QVBoxLayout;
27 mainLayout->addWidget(note);
28 mainLayout->addWidget(buttonBox);
29 setLayout(mainLayout);
31 setWindowTitle(tr("Note"));
35 NoteDialog::~NoteDialog()
40 void NoteDialog::accept(void)
42 // Call base class version, so things work right
45 // Add note to DB for this user
46 QString noteText = note->document()->toPlainText();
48 if (noteText.isEmpty())
52 query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
53 query.addBindValue(uid);
54 // query.addBindValue(NULL);
55 query.addBindValue(noteText.toAscii());