From 6117049617df720fb744a90773a3580b3450b005 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Sat, 2 Oct 2010 18:50:09 +0200 Subject: Qt port is almost complete (at least it compiles) Major change: * struct DataEntry has become class Session with sub-classes XSession and VSession * functions from addInfo.cpp, addPrinters.cpp, addScanners.cpp, readLinSess.cpp, readXmlDir.cpp, runImage.cpp have been moved to XSession and VSession Several minor changes: * new files globals.h and globals.cpp for global variables (replaces constants.h and paths.h) * replaced (all) libxml2, (much) std:: and (most) boost:: stuff by Qt stuff Things left to do: * remove tons of debug printfs * show error messages on errors * tidy up anyoption stuff in main() * highlight session run previously * readGroupXml stuff * tree view (with "X Sessions" and "Virtual Sessions" sections) instead of list view for session selection --- src/vsession.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/vsession.h (limited to 'src/vsession.h') diff --git a/src/vsession.h b/src/vsession.h new file mode 100644 index 0000000..bb29f64 --- /dev/null +++ b/src/vsession.h @@ -0,0 +1,81 @@ +#ifndef VMCHOOSER_VSESSION_H_ +#define VMCHOOSER_VSESSION_H_ + +#include +#include +#include +#include +#include "session.h" + +// TODO: check #includes (in all files) + +enum ImgType { + VMWARE, + VBOX, + OTHER +}; + +class VSession : public Session { +public: + bool init(const QString& xml, const QString& baseDirPath); + + ImgType imgtype() const; + bool isActive() const; + bool isLocked() const; + int priority() const; + + QString shortDescription() const { + return getAttribute("short_description"); + } + + QString description() const { + return getAttribute("description"); + } + + QString icon() const { + QString icon(getAttribute("icon")); + if (icon.contains(".") && QDir::isRelativePath(icon)) { + icon.prepend(baseDirPath_ + "/"); + } + return icon; + } + + QString os() const { + return getAttribute("os"); + } + + QString getAttribute(const QString& nodeName, + const QString& attribute = "param") const; + QString getNodeText(const QString& nodeName) const; + + // TODO: remove next line + void addNode(const QString& nodeName); + void addNodeWithAttribute(const QString& nodeName, + const QString& value, + const QString& attribute = "param", + bool replace = true); + // TODO: remove next line + void addTODO(const QString& value, const QString& nodeName, + const QString& attribute = "param"); // TODO: this adds node and attribute + // TODO: remove next line + void addNodeText(const QString& text, const QString& nodeName); + + void addPrinters(const QString& script, const QString& type = "printer"); + void addScanners(const QString& script); + void addUserAndHostname(); + + QString toXml() const; + + bool run(); + + bool operator<(const Session& other) const; + + static QList readXmlDir(const QString& path); + static QList readXmlFile(const QString& filepath); + +private: + QDomDocument doc_; + QString baseDirPath_; +}; + +#endif /*VMCHOOSER_VSESSION_H_*/ -- cgit v1.2.3-55-g7522