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