modelmanager.h 1.43 KB
Newer Older
Leander Schulten's avatar
New  
Leander Schulten committed
1
2
3
4
5
#ifndef MODELMANAGER_H
#define MODELMANAGER_H

#include <QObject>
#include "device.h"
6
#include "programmprototype.h"
7
#include "programm.h"
Leander Schulten's avatar
New  
Leander Schulten committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

class ModelManager : public QObject{
    Q_OBJECT
public:
    Q_INVOKABLE void remove(QObject * item){
        if(item)
            delete item;
    }
    Q_INVOKABLE bool addDevice(int row, int startDMXChannel, QString name, QString desciption="",QPoint position = QPoint(-1,-1)){
        qDebug()<<"addDevice : "<<row<<' ' << startDMXChannel<< ' ' << name << ' '<<desciption<<'\n';
        DevicePrototype * prototype = IDBaseDataModel<DevicePrototype>::singletone()->data(row);
        if(prototype){
            new Device(prototype,startDMXChannel,name,desciption,position);
            return true;
        }
        return false;
    }
25
26
27
28
29
30
31
32
33
34
35
36
37
    Q_INVOKABLE bool addDevicePrototype(QString name, QString description=""){
        new DevicePrototype(name,description);
        return true;
    }
    Q_INVOKABLE bool addProgrammPrototype(int row/*DevicePrototype*/,QString name, QString description=""){
        DevicePrototype * prototype = IDBaseDataModel<DevicePrototype>::singletone()->data(row);
        if(prototype){
            new ProgrammPrototype(prototype,name,description);
            return true;
        }
        return false;

    }
38
39
40
41
42
    Q_INVOKABLE bool addProgramm(QString name, QString description=""){
        new Programm(name,description);
        return true;
    }

Leander Schulten's avatar
New  
Leander Schulten committed
43
44
45
};

#endif // MODELMANAGER_H