LoggerPlugin.h
#ifndef LOGGERPLUGIN_H
#define LOGGERPLUGIN_H
#include <QTextStream>
#include <QtPlugin>
#include <QStringList>
#include <QMessageBox>
#include <QString>
#include <QtCore/QDebug>
#include <Logger/xmlproxy.h>
class LoggerPlugin : public ExtensionSystem::IPlugin
{
private:
public:
XMLLoggerPlugin();
~XMLLoggerPlugin();
void extensionsInitialized();
void shutdown();
// this is the method called by CppEditor. It just instantiate my proxy object.
XMLProxy pr(name, filename, type);
}
};
#endif // LOGGERPLUGIN_H
#ifndef LOGGERPLUGIN_H
#define LOGGERPLUGIN_H
#include <QTextStream>
#include <QtPlugin>
#include <QStringList>
#include <QMessageBox>
#include <QString>
#include <QtCore/QDebug>
#include <Logger/xmlproxy.h>
class LoggerPlugin : public ExtensionSystem::IPlugin
{
private:
QString lookupName(int id);
int lookupID(QString name);
public:
XMLLoggerPlugin();
~XMLLoggerPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
// this is the method called by CppEditor. It just instantiate my proxy object.
static void register(QString name, QString filename, QString type){
XMLProxy pr(name, filename, type);
}
};
#endif // LOGGERPLUGIN_H
To copy to clipboard, switch view to plain text mode
LoggerPlugin.cpp then contains the implementation of the initialize and shutdown methods, but nothing tricky just clean-up code.
XMLProxy.h
#ifndef XMLPROXY_H
#define XMLPROXY_H
class XMLProxy
{
public:
XMLProxy();
~XMLProxy();
void serializeXML();
};
#endif // XMLPROXY_H
#ifndef XMLPROXY_H
#define XMLPROXY_H
class XMLProxy
{
public:
XMLProxy();
~XMLProxy();
XMLProxy(QString name, QString filename, QString type);
void serializeXML();
QString _name, _filename, _type;
};
#endif // XMLPROXY_H
To copy to clipboard, switch view to plain text mode
and the class implementation
XMLProxy.cpp
#include <QDateTime>
#include <QFile>
#include <QXmlStreamWriter>
#include <QDate>
#include <extensionsystem/iplugin.h>
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomText>
#include "xmlproxy.h"
XMLProxy::XMLProxy(){}
this->_name=name;
this->_filename=namefilename;
this->_type=type;
}
XMLProxy::serializeXML(){
//stub of the method to serialize a XMLProxy to a XML file
QFile file("Logfile.xml");
QDomText typeTxt
= doc.
createTextNode(this
->_type
);
typeNode.appendChild(typeTxt);
ev.appendChild(typeNode);
//...to be cont´d
}
#include <QDateTime>
#include <QFile>
#include <QXmlStreamWriter>
#include <QDate>
#include <extensionsystem/iplugin.h>
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomText>
#include "xmlproxy.h"
XMLProxy::XMLProxy(){}
XMLProxy::XMLProxy(QString name, QString filename, QString type){
this->_name=name;
this->_filename=namefilename;
this->_type=type;
}
XMLProxy::serializeXML(){
//stub of the method to serialize a XMLProxy to a XML file
QFile file("Logfile.xml");
QDomDocument doc("Events");
QDomElement ev = doc.createElement("event");
QDomElement typeNode = doc.createElement("type");
QDomText typeTxt = doc.createTextNode(this->_type);
typeNode.appendChild(typeTxt);
ev.appendChild(typeNode);
//...to be cont´d
}
To copy to clipboard, switch view to plain text mode
it´s not working like this but if I move the code from XMLProxy.cpp to XMLProxy.h it works
To compile I do "qmake ..\qtcreator.pro -recursive CONFIG+=debug QT+=xml" from the build directory of qtcreator folder and then, from the same dir, "mingw32-make debug"
Thank you for any help
Bookmarks