Debian Codegraph @

src/notepage.cpp

raw symbols SCIP
1 /***************************************************************************
2 notepage.cpp
3 -------------------
4 A dialog page for notes
5 -------------------
6 Copyright 2003-2008, David Johnson
7 Please see the header file for copyright and license information
8 ***************************************************************************/
9
10 #include <QTextEdit>
11
12 #include "recipe.h"
13 #include "notepage.h"
14
15 //////////////////////////////////////////////////////////////////////////////
16 // Construction, Destruction //
17 //////////////////////////////////////////////////////////////////////////////
18
19 //////////////////////////////////////////////////////////////////////////////
20 // NotePage()
21 // ----------
22 // Constructor
23
24 NotePage::NotePage(QWidget *parent, Recipe *recipe)
25 : QWidget(parent), recipe_(recipe)
26 {
27 ui.setupUi(this);
28
29 // set up connections
30 connect(ui.recipeedit, SIGNAL(textChanged()),
31 this, SLOT(updateRecipeNotes()));
32 connect(ui.batchedit, SIGNAL(textChanged()),
33 this, SLOT(updateBatchNotes()));
34 }
35
36 NotePage::~NotePage() { ; }
37
38 //////////////////////////////////////////////////////////////////////////////
39 // refresh()
40 // ---------
41 // initialize
42
43 void NotePage::refresh()
44 {
45 ui.recipeedit->blockSignals(true);
46 ui.batchedit->blockSignals(true);
47 ui.recipeedit->setPlainText(recipe_->recipeNotes());
48 ui.batchedit->setPlainText(recipe_->batchNotes());
49 ui.recipeedit->blockSignals(false);
50 ui.batchedit->blockSignals(false);
51 }
52
53 //////////////////////////////////////////////////////////////////////////////
54 // updateRecipeNotes()
55 // -----------------
56 // Update the notes in the model
57
58 void NotePage::updateRecipeNotes()
59 {
60 // TODO: this is very inefficient, particularly for large amounts of text
61 // consider making character have a list of paragraphs, then only update
62 // the paragraph that changed.
63 recipe_->setRecipeNotes(ui.recipeedit->toPlainText());
64 }
65
66 //////////////////////////////////////////////////////////////////////////////
67 // updateBatchNotes()
68 // -----------------
69 // Update the notes in the model
70
71 void NotePage::updateBatchNotes()
72 {
73 // TODO: this is very inefficient, particularly for large amounts of text
74 // consider making character have a list of paragraphs, then only update
75 // the paragraph that changed.
76 recipe_->setBatchNotes(ui.batchedit->toPlainText());
77 }
78