Rev 177 | Rev 179 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
178 | werner | 2 | /** @class OutputManager |
3 | Global container that handles data output. |
||
4 | |||
5 | */ |
||
6 | |||
173 | werner | 7 | #include "global.h" |
8 | #include "outputmanager.h" |
||
9 | #include <QtCore> |
||
10 | |||
11 | // tree outputs |
||
12 | #include "treeout.h" |
||
13 | |||
178 | werner | 14 | |
15 | |||
173 | werner | 16 | OutputManager::OutputManager() |
17 | { |
||
18 | // add all the outputs |
||
19 | mOutputs.append(new TreeOut); |
||
20 | } |
||
21 | |||
22 | OutputManager::~OutputManager() |
||
23 | { |
||
24 | qDeleteAll(mOutputs); |
||
25 | } |
||
26 | |||
27 | void OutputManager::setup() |
||
28 | { |
||
29 | XmlHelper &xml = const_cast<XmlHelper&>(GlobalSettings::instance()->settings()); |
||
30 | QString nodepath; |
||
31 | foreach(Output *o, mOutputs) { |
||
176 | werner | 32 | nodepath = QString("output.%1").arg(o->tableName()); |
173 | werner | 33 | xml.setCurrentNode(nodepath); |
34 | qDebug() << "setup of output" << o->name(); |
||
35 | o->setup(); |
||
176 | werner | 36 | o->open(); |
173 | werner | 37 | } |
38 | } |
||
176 | werner | 39 | |
40 | Output *OutputManager::find(const QString& tableName) |
||
41 | { |
||
42 | foreach(Output* p,mOutputs) |
||
43 | if (p->tableName()==tableName) |
||
44 | return p; |
||
45 | return NULL; |
||
46 | } |
||
47 | |||
48 | bool OutputManager::execute(const QString& tableName) |
||
49 | { |
||
50 | Output *p = find(tableName); |
||
51 | if (p) { |
||
177 | werner | 52 | p->startTransaction(); |
176 | werner | 53 | p->exec(); |
177 | werner | 54 | p->endTransaction(); |
176 | werner | 55 | return true; |
56 | } |
||
57 | qDebug() << "output" << tableName << "not found!"; |
||
58 | return false; // no output found |
||
59 | } |