]> Shamusworld >> Repos - schematic/blob - src/alertdialog.cpp
Move DB access to NoteDialog class, new AlertDialog class.
[schematic] / src / alertdialog.cpp
1 //
2 // alertdialog.cpp: Dialog for creating & editing alerts
3 //
4 // Part of the SCheMatic Project
5 // (C) 2012 Underground Software
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // WHO  WHEN        WHAT
10 // ---  ----------  ------------------------------------------------------------
11 // JLH  12/13/2012  Created this file
12 //
13
14 #include "alertdialog.h"
15 #include <QtSql>
16
17
18 AlertDialog::AlertDialog(int uidToUse, QWidget * parent/*= 0*/): QDialog(parent), uid(uidToUse)
19 {
20         note = new QTextEdit;
21         buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
22
23         connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
24         connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
25
26         QVBoxLayout * mainLayout = new QVBoxLayout;
27         mainLayout->addWidget(note);
28         mainLayout->addWidget(buttonBox);
29         setLayout(mainLayout);
30
31         setWindowTitle(tr("Alert"));
32 }
33
34
35 AlertDialog::~AlertDialog()
36 {
37 }
38
39
40 void AlertDialog::accept(void)
41 {
42         // Call base class version, so things work right
43         QDialog::accept();
44
45 #if 0
46         // Add note to DB for this user
47         QString noteText = note->document()->toPlainText();
48
49         if (noteText.isEmpty())
50                 return;
51
52         QSqlQuery query;
53         query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
54         query.addBindValue(uid);
55 //      query.addBindValue(NULL);
56         query.addBindValue(noteText.toAscii());
57         query.exec();
58 #endif
59 }
60