Subversion Repositories public iLand

Rev

Rev 179 | Rev 182 | 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"
173 werner 14
 
178 werner 15
 
16
 
173 werner 17
OutputManager::OutputManager()
18
{
19
    // add all the outputs
20
    mOutputs.append(new TreeOut);
179 werner 21
    mOutputs.append(new StandOut);
173 werner 22
}
23
 
24
OutputManager::~OutputManager()
25
{
26
    qDeleteAll(mOutputs);
27
}
28
 
29
void OutputManager::setup()
30
{
31
    XmlHelper &xml = const_cast<XmlHelper&>(GlobalSettings::instance()->settings());
32
    QString nodepath;
33
    foreach(Output *o, mOutputs) {
176 werner 34
        nodepath = QString("output.%1").arg(o->tableName());
173 werner 35
        xml.setCurrentNode(nodepath);
36
        qDebug() << "setup of output" << o->name();
37
        o->setup();
181 werner 38
        bool enabled = xml.valueBool(".enabled", false);
39
        o->setEnabled(enabled);
40
        if (enabled)
41
            o->open();
173 werner 42
    }
43
}
176 werner 44
 
45
Output *OutputManager::find(const QString& tableName)
46
{
47
    foreach(Output* p,mOutputs)
48
        if (p->tableName()==tableName)
49
            return p;
50
    return NULL;
51
}
52
 
53
bool OutputManager::execute(const QString& tableName)
54
{
55
    Output *p = find(tableName);
56
    if (p) {
177 werner 57
        p->startTransaction();
176 werner 58
        p->exec();
177 werner 59
        p->endTransaction();
176 werner 60
        return true;
61
    }
62
    qDebug() << "output" << tableName << "not found!";
63
    return false; // no output found
64
}