Rev 200 | Rev 222 | 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" |
||
179 | werner | 13 | #include "standout.h" |
184 | werner | 14 | #include "dynamicstandout.h" |
173 | werner | 15 | |
178 | werner | 16 | |
17 | |||
173 | werner | 18 | OutputManager::OutputManager() |
19 | { |
||
20 | // add all the outputs |
||
200 | werner | 21 | #ifndef FONSTUDIO |
173 | werner | 22 | mOutputs.append(new TreeOut); |
179 | werner | 23 | mOutputs.append(new StandOut); |
184 | werner | 24 | mOutputs.append(new DynamicStandOut); |
200 | werner | 25 | #endif |
184 | werner | 26 | |
173 | werner | 27 | } |
28 | |||
29 | OutputManager::~OutputManager() |
||
30 | { |
||
31 | qDeleteAll(mOutputs); |
||
32 | } |
||
33 | |||
34 | void OutputManager::setup() |
||
35 | { |
||
36 | XmlHelper &xml = const_cast<XmlHelper&>(GlobalSettings::instance()->settings()); |
||
37 | QString nodepath; |
||
38 | foreach(Output *o, mOutputs) { |
||
176 | werner | 39 | nodepath = QString("output.%1").arg(o->tableName()); |
173 | werner | 40 | xml.setCurrentNode(nodepath); |
41 | qDebug() << "setup of output" << o->name(); |
||
42 | o->setup(); |
||
181 | werner | 43 | bool enabled = xml.valueBool(".enabled", false); |
44 | o->setEnabled(enabled); |
||
45 | if (enabled) |
||
46 | o->open(); |
||
173 | werner | 47 | } |
48 | } |
||
176 | werner | 49 | |
50 | Output *OutputManager::find(const QString& tableName) |
||
51 | { |
||
52 | foreach(Output* p,mOutputs) |
||
53 | if (p->tableName()==tableName) |
||
54 | return p; |
||
55 | return NULL; |
||
56 | } |
||
57 | |||
58 | bool OutputManager::execute(const QString& tableName) |
||
59 | { |
||
60 | Output *p = find(tableName); |
||
61 | if (p) { |
||
182 | werner | 62 | if (!p->isEnabled()) |
63 | return false; |
||
64 | if(!p->isOpen()) |
||
65 | return false; |
||
207 | werner | 66 | if (!p->onNewRow()) { |
67 | qWarning() << "Output" << p->name() << "invalid (not at new row)!!!"; |
||
68 | return false; |
||
69 | } |
||
70 | |||
177 | werner | 71 | p->startTransaction(); |
176 | werner | 72 | p->exec(); |
177 | werner | 73 | p->endTransaction(); |
176 | werner | 74 | return true; |
75 | } |
||
76 | qDebug() << "output" << tableName << "not found!"; |
||
77 | return false; // no output found |
||
78 | } |