File: notepage.cpp

package info (click to toggle)
qbrew 0.4.1-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,724 kB
  • ctags: 1,355
  • sloc: cpp: 7,503; sh: 414; makefile: 18
file content (78 lines) | stat: -rw-r--r-- 2,441 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/***************************************************************************
  notepage.cpp
  -------------------
  A dialog page for notes
  -------------------
  Copyright 2003-2008, David Johnson
  Please see the header file for copyright and license information
 ***************************************************************************/

#include <QTextEdit>

#include "recipe.h"
#include "notepage.h"

//////////////////////////////////////////////////////////////////////////////
// Construction, Destruction                                                //
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// NotePage()
// ----------
// Constructor

NotePage::NotePage(QWidget *parent, Recipe *recipe)
    : QWidget(parent), recipe_(recipe)
{
    ui.setupUi(this);

    // set up connections
    connect(ui.recipeedit, SIGNAL(textChanged()),
            this, SLOT(updateRecipeNotes()));
    connect(ui.batchedit, SIGNAL(textChanged()),
            this, SLOT(updateBatchNotes()));
}

NotePage::~NotePage() { ; }

//////////////////////////////////////////////////////////////////////////////
// refresh()
// ---------
// initialize

void NotePage::refresh()
{
    ui.recipeedit->blockSignals(true);
    ui.batchedit->blockSignals(true);
    ui.recipeedit->setPlainText(recipe_->recipeNotes());
    ui.batchedit->setPlainText(recipe_->batchNotes());
    ui.recipeedit->blockSignals(false);
    ui.batchedit->blockSignals(false);
}

//////////////////////////////////////////////////////////////////////////////
// updateRecipeNotes()
// -----------------
// Update the notes in the model

void NotePage::updateRecipeNotes()
{
    // TODO: this is very inefficient, particularly for large amounts of text
    // consider making character have a list of paragraphs, then only update
    // the paragraph that changed.
    recipe_->setRecipeNotes(ui.recipeedit->toPlainText());
}

//////////////////////////////////////////////////////////////////////////////
// updateBatchNotes()
// -----------------
// Update the notes in the model

void NotePage::updateBatchNotes()
{
    // TODO: this is very inefficient, particularly for large amounts of text
    // consider making character have a list of paragraphs, then only update
    // the paragraph that changed.
    recipe_->setBatchNotes(ui.batchedit->toPlainText());
}