summaryrefslogtreecommitdiffstats
path: root/src/vsession.h
blob: 69ecf135eccc7657f41ad6dbda91281e96b3e634 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef VMCHOOSER_VSESSION_H_
#define VMCHOOSER_VSESSION_H_

#include <QString>
#include <QList>
#include <QDomDocument>
#include <QDir>
#include "session.h"
#include "globals.h"

class VSession : public Session {
  public:
    bool init(const QDomElement& xml);

    bool isActive() const;
    bool isLocked() const;

    int priority() const;

    bool isTemplate() const {
        return getAttribute(QStringLiteral("is_template")).toInt() != 0;
    }

    bool isForLocation() const {
        return getAttribute(QStringLiteral("for_location")).toInt() != 0;
    }

    bool canEdit() const {
        return getAttribute(QStringLiteral("allow_edit")).toInt() != 0;
    }

    QString virtualizer() const {
        return getAttribute(QStringLiteral("virtualmachine"));
    }

    QString shortDescription() const {
        return getAttribute(QStringLiteral("short_description"));
    }

    QString description() const {
        return getAttribute(QStringLiteral("long_description"));
    }

    QIcon icon() const;

    QString os() const {
        return getAttribute(QStringLiteral("os"));
    }

    QString uuid() const {
        return getAttribute(QStringLiteral("uuid"));
    }

    SectionType section() const {
        if (g_forLocationHandling != LOCATION_IGNORE && isForLocation()) {
            return SECTION_FOR_LOCATION;
        }
        if (g_templateHandling == TEMPLATES_BUMP && isTemplate()) {
            return SECTION_TEMPLATES;
        }
        return SECTION_GENERIC;
    }

    bool needsVtx() const;
    QVariant foregroundRole() const;

    QString getAttribute(const QString& nodeName,
                             const QString& attribute = QStringLiteral("param")) const;
    QList<QString> keywords() const;
    bool containsKeywords(const QList<QString>& keywords) const;
    QString getNodeText(const QString& nodeName) const;

    void addNodeWithAttribute(const QString& nodeName,
                              const QString& value,
                              const QString& attribute = QStringLiteral("param"),
                              bool replace = true);

    QString toXml() const;

    bool run() const;

    int type() const;

    bool operator<(const Session& other) const;

    static QList<Session*> loadFromXmlDocument(const QDomDocument& doc);

protected:
    virtual QString checkCanRunInternal() const;

  private:

    QList<QString> keywords_;
    QDomDocument doc_;
    QDomElement eintrag_;

    void readKeywords();

};

#endif /*VMCHOOSER_VSESSION_H_*/