//
#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()));
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();
+}
+