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