started to use scriptability
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 20 Oct 2010 20:19:34 +0000 (20:19 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Wed, 20 Oct 2010 20:19:34 +0000 (20:19 +0000)
start of wizard class

git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@604 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

30 files changed:
debian/control
debian/gencl
src/dialogs/dialogs.pri
src/dialogs/wizard.cpp [new file with mode: 0644]
src/dialogs/wizard.h [new file with mode: 0644]
src/iface/msinterface.h
src/mwin/overview.cpp
src/mwin/overview.h
src/script/jsengine.cpp [new file with mode: 0644]
src/script/jsengine.h [new file with mode: 0644]
src/script/script.pri [new file with mode: 0644]
src/smoke.pro
src/wext/address.cpp
src/wext/address.h
src/wext/customer.cpp
src/wext/customer.h
src/wext/customerinfo.cpp
src/wext/customerinfo.h
src/wext/event.cpp
src/wext/event.h
src/wext/order.cpp
src/wext/order.h
src/wext/orderinfo.h
src/wext/role.h
src/wext/ticket.cpp
src/wext/ticket.h
src/wext/voucher.h
src/wext/wext.pri
wob/db/basics.wolf
wob/magicsmoke.wolf

index 44f37cc..05ab75c 100644 (file)
@@ -35,5 +35,6 @@ Description: MagicSmoke Ticket Sale System - Server
  incompatible with old databases.
  .
  This package makes MagicSmoke available on your system, but it does not
- create a database or install it into the web server directory, please 
- refer to the documentation files for details.
\ No newline at end of file
+ create a database or install it into the web server directory, please
+ refer to the documentation files for details on how to finalize the
+ installation process.
\ No newline at end of file
index ce963ac..b150b9c 100755 (executable)
@@ -2,6 +2,29 @@
 
 cl=debian/changelog
 
+test -x "`which svn`" || {
+       echo 'Warning: cannot find svn - do you have package subversion installed?' 2>&1
+       test -f $cl && {
+               echo cannot find svn, but $cl exists - accepting it
+               exit 0
+       } || {
+               echo 'Error: cannot find svn and' $cl 'does not exist - cannot proceed.' 1>&2
+               exit 1
+       }
+}
+test -d .svn || {
+       echo 'Warning: this is not a SVN checkout, building in non-dev mode...' 2>&1
+       test -f $cl && {
+               echo 'Info:' $cl 'does exist, accepting it for now'
+               exit 0
+       } || {
+               echo 'Error:' $cl 'does not exist, cannot proceed.' 2>&1
+               exit 1
+       }
+}
+
+echo Generating $cl ...
+
 REV="$(svn info|grep Revision:|cut -d " " -f 2)"
 REV="2$(echo -n $REV|wc -c|tr 0-9 c-l)$REV"
 
@@ -11,9 +34,16 @@ fi
 
 echo "magicsmoke2 ($REV) unstable; urgency=low" >$cl
 echo >>$cl
-echo "  Package Generated by" `whoami`@`hostname` `date -R`>>$cl
+echo "  Package Generated by" `whoami`@`hostname -f` `date -R`>>$cl
 echo >>$cl
-svn2cl --stdout -i --group-by-day | sed 's/^/  /' | sed 's/\t/   /' >>$cl
+test -x "`which svn2cl`" && {
+       svn2cl --stdout -i --group-by-day | sed 's/^/  /' | sed 's/\t/   /' >>$cl
+} || {
+       echo 'Warning: cannot find svn2cl - do you have subversion-tools installed?' 2>&1
+       echo 'Warning:' $cl 'will have an empty body, this may not be what you wanted.' 2>&1
+       echo ' ' `date +%Y-%m-%d` `whoami` >>$cl
+       echo '    * built package without subversion info available, sorry.' >>$cl
+}
 echo >>$cl
 echo -n ' -- konrad <konrad@silmor.de>  ' >>$cl
 date -R >>$cl
index be7790b..6d9abe6 100644 (file)
@@ -10,7 +10,8 @@ HEADERS += \
        dialogs/passwdchg.h \
        dialogs/pricecatdlg.h \
        dialogs/aclwin.h \
-       dialogs/flagedit.h
+       dialogs/flagedit.h \
+       dialogs/wizard.h
 
 SOURCES += \
        dialogs/configdialog.cpp \
@@ -24,6 +25,7 @@ SOURCES += \
        dialogs/passwdchg.cpp \
        dialogs/pricecatdlg.cpp \
        dialogs/aclwin.cpp \
-       dialogs/flagedit.cpp
+       dialogs/flagedit.cpp \
+       dialogs/wizard.cpp
 
 INCLUDEPATH += ./dialogs
\ No newline at end of file
diff --git a/src/dialogs/wizard.cpp b/src/dialogs/wizard.cpp
new file mode 100644 (file)
index 0000000..c3cf986
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// C++ Implementation: order wizard
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "wizard.h"
+#include "overview.h"
+#include "msinterface.h"
+#include "jsengine.h"
+
+#include <QBoxLayout>
+#include <QStackedLayout>
+#include <QPushButton>
+#include <QSignalMapper>
+
+MWizard::MWizard(MOverview* parent, Qt::WindowFlags f)
+       :QDialog(parent, f),m_parent(parent)
+{
+       //main layout
+       QVBoxLayout*vl;
+       QStackedLayout*stack;
+       QHBoxLayout*hl;
+       setLayout(vl=new QVBoxLayout);
+       vl->addLayout(stack=new QStackedLayout,1);
+       //bottom buttons
+       vl->addLayout(hl=new QHBoxLayout);
+       hl->addStretch(1);
+       QPushButton*p;
+       hl->addWidget(p=new QPushButton(tr("Close Wizard")));
+       connect(p,SIGNAL(clicked()),this,SLOT(accept()));
+       hl->addWidget(p=new QPushButton(tr("Exit")));
+       connect(p,SIGNAL(clicked()),this,SLOT(accept()));
+       connect(p,SIGNAL(clicked()),parent,SLOT(close()));
+       
+       //paging
+       QSignalMapper*map=new QSignalMapper(this);
+       connect(map,SIGNAL(mapped(int)),stack,SLOT(setCurrentIndex(int)));
+       QWidget*w;
+       int istart,ivou,ievt,icust,iexec;
+       
+       //page: start
+       istart=stack->addWidget(w=new QWidget);
+       w->setLayout(vl=new QVBoxLayout);
+       vl->addStretch(1);
+       vl->addWidget(p=new QPushButton(tr("Sell Tickets")));
+       p->setEnabled(req->hasRight(req->PCreateOrder_CanSell));
+       connect(p,SIGNAL(clicked()),map,SLOT(map()));
+       connect(p,SIGNAL(clicked()),this,SLOT(saleMode()));
+       map->setMapping(p,ievt);
+       vl->addWidget(p=new QPushButton(tr("Order Tickets")));
+       p->setEnabled(req->hasRight(req->PCreateOrder_CanSell));
+       connect(p,SIGNAL(clicked()),map,SLOT(map()));
+       connect(p,SIGNAL(clicked()),this,SLOT(orderMode()));
+       map->setMapping(p,ievt);
+       vl->addWidget(p=new QPushButton(tr("Sell Voucher")));
+       p->setEnabled(req->hasRight(req->PCreateOrder_CanOrder));
+       connect(p,SIGNAL(clicked()),map,SLOT(map()));
+       connect(p,SIGNAL(clicked()),this,SLOT(saleMode()));
+       map->setMapping(p,ivou);
+       vl->addWidget(p=new QPushButton(tr("Order Voucher")));
+       p->setEnabled(req->hasRight(req->PCreateOrder_CanOrder));
+       connect(p,SIGNAL(clicked()),map,SLOT(map()));
+       connect(p,SIGNAL(clicked()),this,SLOT(orderMode()));
+       map->setMapping(p,ivou);
+       vl->addStretch(1);
+       
+       //page: events
+       m_jseng=new MScriptEngine(parent);
+       m_jseng->addObject("Wizard",this);
+       m_jseng->evaluate("debugger");
+}
+
+MWizard::~MWizard()
+{
+       delete m_jseng;
+}
+
+
+void MWizard::orderMode()
+{
+       m_mode=OrderMode;
+}
+
+void MWizard::saleMode()
+{
+       m_mode=SaleMode;
+}
diff --git a/src/dialogs/wizard.h b/src/dialogs/wizard.h
new file mode 100644 (file)
index 0000000..d9451f4
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// C++ Interface: order wizard
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_WIZARD_H
+#define MAGICSMOKE_WIZARD_H
+
+#include <QDialog>
+
+class MScriptEngine;
+class MOverview;
+class MWizard:public QDialog
+{
+       Q_OBJECT
+       public:
+               MWizard(MOverview* parent = 0, Qt::WindowFlags f = 0);
+               virtual ~MWizard();
+       private slots:
+               void saleMode();
+               void orderMode();
+       private:
+               MOverview*m_parent;
+               enum Mode {SaleMode,OrderMode};
+               Mode m_mode;
+               MScriptEngine*m_jseng;
+};
+
+#endif
index 9f5abf0..db18893 100644 (file)
@@ -25,6 +25,13 @@ class MTemplateStore;
 class MSInterface:public MInterface
 {
        Q_OBJECT
+       Q_PROPERTY(QString currentUser READ currentUser)
+       Q_PROPERTY(QString hostName READ hostName)
+       Q_PROPERTY(QString dataDir READ dataDir)
+       Q_PROPERTY(QString settingsGroup READ settingsGroup)
+       Q_PROPERTY(QString sessionId READ sessionId)
+       Q_PROPERTY(QString repoPart READ repoPart)
+       Q_PROPERTY(QString profileId READ profileId)
        public:
                /**creates the interface object, expects the profile ID as parameter*/
                MSInterface(QString);
@@ -41,10 +48,10 @@ class MSInterface:public MInterface
                QString hostName()const{return m_host;}
                
                /**returns whether the user is part of this role*/
-               bool hasRole(QString s)const{return userroles.contains(s);}
+               Q_INVOKABLE bool hasRole(QString s)const{return userroles.contains(s);}
                
                /**returns whether the user has a particular right*/
-               bool hasRight(Right)const;
+               Q_INVOKABLE bool hasRight(Right)const;
                
                /**returns the directory where to store data retrieved from the server*/
                QString dataDir()const;
@@ -67,7 +74,7 @@ class MSInterface:public MInterface
                void initialize();
                
                /**returns a pointer to the template storage engine*/
-               MTemplateStore* templateStore(){return temp;}
+               Q_INVOKABLE MTemplateStore* templateStore(){return temp;}
                
                /**returns the profile ID of this session*/
                QString profileId()const{return profileid;}
index 365f2e9..f9ac0c5 100644 (file)
@@ -4,7 +4,7 @@
 // Description: 
 //
 //
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2010
 //
 // Copyright: See README/COPYING files that come with this distribution
 //
@@ -16,6 +16,7 @@
 #include "passwdchg.h"
 #include "shipping.h"
 #include "templatedlg.h"
+#include "wizard.h"
 
 #include "aclwin.h"
 #include "carttab.h"
@@ -27,6 +28,8 @@
 #include "centbox.h"
 #include "sclock.h"
 
+#include "jsengine.h"
+
 #include <TimeStamp>
 
 #include <QBoxLayout>
@@ -75,6 +78,8 @@ MOverview::MOverview(QString pk)
        m->addAction(tr("Change my &Password"),this,SLOT(setMyPassword()))
         ->setEnabled(req->hasRight(req->RChangeMyPassword));
        m->addSeparator();
+       m->addAction(tr("Switch to Wizard..."),this,SLOT(wizardMode()));
+       m->addSeparator();
        m->addAction(tr("&Edit Templates..."),this,SLOT(editTemplates()));
        m->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates()));
        m->addSeparator();
@@ -422,6 +427,12 @@ void MOverview::displaySettings()
        gl->addWidget(oage=new QSpinBox,cl,1);
        oage->setRange(0,99999);
        oage->setValue(maxageo);
+       gl->setRowMinimumHeight(++cl,5);
+       QComboBox*udeb;
+       gl->addWidget(new QLabel(tr("Show script debugger:")),++cl,0);
+       gl->addWidget(udeb=new QComboBox,cl,1);
+       udeb->addItems(MScriptEngine::debugModes());
+       udeb->setCurrentIndex(MScriptEngine::debugMode());
        gl->setRowMinimumHeight(++cl,15);
        gl->addLayout(hl=new QHBoxLayout,++cl,0,1,2);
        hl->addStretch(10);
@@ -436,6 +447,7 @@ void MOverview::displaySettings()
        maxageo=oage->value();
        set.setValue("maxeventage",maxage);
        set.setValue("maxorderage",maxageo);
+       MScriptEngine::setDebugMode(udeb->currentIndex());
 }
 
 
@@ -509,6 +521,15 @@ void MOverview::editTemplates()
        te.exec();
 }
 
+void MOverview::wizardMode()
+{
+       MWizard wiz(this);
+       hide();
+       wiz.exec();
+       show();
+}
+
+
 /**********************************************/
 
 MBackupDialog::MBackupDialog(QWidget*par,QString pk)
index 86fdce7..8efba67 100644 (file)
@@ -100,7 +100,11 @@ class MOverview:public QMainWindow
                /**open template editor*/
                void editTemplates();
                
+               /**switch to wizard mode*/
+               void wizardMode();
+               
        private:
+               friend class MWizard;
                //the profile associated with this session
                QString profilekey;
                //widgets
diff --git a/src/script/jsengine.cpp b/src/script/jsengine.cpp
new file mode 100644 (file)
index 0000000..91b2e31
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// C++ Implementation: JScript Engine for MSmoke
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "jsengine.h"
+#include "overview.h"
+#include "msinterface.h"
+
+#include <QAction>
+#include <QScriptEngineDebugger>
+#include <QSettings>
+
+MScriptEngine::MScriptEngine(MOverview* par)
+       :QScriptEngine(par)
+{
+       addObject("MainWindow",par);
+       req->initScriptEngine(this);
+       int dm=debugMode();
+       if(dm>0){
+               QScriptEngineDebugger* deb=new QScriptEngineDebugger(this);
+               deb->attachTo(this);
+               if(dm>1)
+                       deb->action(QScriptEngineDebugger::InterruptAction)->trigger();
+       }
+}
+void MScriptEngine::addObject(QString name, QObject* object)
+{
+       if(name.size()==0)return;
+       QScriptValue gval=globalObject();
+       name[0]=name[0].toUpper();
+       gval.setProperty(name, newQMetaObject(object->metaObject()));
+       name[0]=name[0].toLower();
+       gval.setProperty(name, newQObject(object, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater));
+}
+
+QStringList MScriptEngine::debugModes()
+{
+       //hint: the semantics of those entries must not change, because their indices are used
+       return QStringList()
+               <<tr("Never show debugger")
+               <<tr("Show on error")
+               <<tr("Show immediately on script start");
+}
+
+int MScriptEngine::debugMode()
+{
+       return QSettings().value("profiles/"+req->profileId()+"/JSdebugMode",0).toInt();
+}
+
+void MScriptEngine::setDebugMode(int v)
+{
+       if(v>=0 && v<debugModes().size())
+               QSettings().setValue("profiles/"+req->profileId()+"/JSdebugMode",v);
+}
diff --git a/src/script/jsengine.h b/src/script/jsengine.h
new file mode 100644 (file)
index 0000000..35ce06d
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// C++ Interface: JScript Engine for MSmoke
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_JSENGINE_H
+#define MAGICSMOKE_JSENGINE_H
+
+#include <QScriptEngine>
+#include <QStringList>
+
+class MOverview;
+
+class MScriptEngine:public QScriptEngine
+{
+       Q_OBJECT
+       public:
+               MScriptEngine(MOverview*);
+               
+               void addObject(QString name,QObject*object);
+               
+               static QStringList debugModes();
+               static int debugMode();
+               static void setDebugMode(int);
+};
+
+#endif
diff --git a/src/script/script.pri b/src/script/script.pri
new file mode 100644 (file)
index 0000000..d7bdab0
--- /dev/null
@@ -0,0 +1,7 @@
+SOURCES += \
+       script/jsengine.cpp
+
+HEADERS += \
+       script/jsengine.h
+
+INCLUDEPATH += ./script
\ No newline at end of file
index 95e15d9..a6e6474 100644 (file)
@@ -6,7 +6,7 @@ TARGET = ../src/msmoke
 CONFIG += debug
 
 CONFIG += qt thread link_prl
-QT += xml network
+QT += xml network script scripttools
 
 win32-* {
  #RC-File containing the icon:
@@ -40,6 +40,7 @@ include(misc/misc.pri)
 include(crypto/crypto.pri)
 include(dialogs/dialogs.pri)
 include(mwin/mwin.pri)
+include(script/script.pri)
 
 #build generated stuff last
 include(wext/wext.pri)
index e136c13..8c00da7 100644 (file)
 #include "MOAddress"
 
 #include <QStringList>
+#include <QScriptEngine>
 
-static int moaid=qRegisterMetaType<MOAddress>("MOAddress");
+WOSCRIPT_IMP(MOAddress)
+
+static int moaid=
+       qRegisterMetaType<MOAddress>()+
+       qRegisterMetaType<QList<MOAddress> >()+
+       qRegisterMetaType<Nullable<MOAddress> >();
 
 QString MOAddress::fullAddress(QString nm)const
 {
index 2555ac9..9405639 100644 (file)
@@ -19,7 +19,9 @@
 
 class MOAddress:public MOAddressAbstract
 {
-       WOBJECT(MOAddress);
+       Q_OBJECT
+       WOBJECT(MOAddress)
+       WOSCRIPT(MOAddress)
        public:
                /**returns the full address, if name is given and the address does not have its own name, it is included as top line*/
                QString fullAddress(QString name=QString())const;
@@ -28,6 +30,8 @@ class MOAddress:public MOAddressAbstract
                bool isValid()const{return !addressid().isNull() && addressid().value()>=0;}
 };
 
-Q_DECLARE_METATYPE(MOAddress);
+Q_DECLARE_METATYPE(MOAddress)
+Q_DECLARE_METATYPE(QList<MOAddress>)
+Q_DECLARE_METATYPE(Nullable<MOAddress>)
 
 #endif
index ea62427..b9e3d4f 100644 (file)
 #include "MOCustomer"
 #include "MOCustomerInfo"
 #include "msinterface.h"
+#include <QScriptEngine>
+
+static int mymeta=
+       qRegisterMetaType<MOCustomer>()+
+       qRegisterMetaType<QList<MOCustomer> >()+
+       qRegisterMetaType<Nullable<MOCustomer> >();
+
+WOSCRIPT_IMP(MOCustomer)
 
 MOCustomer::MOCustomer(qint64 i)
 {
index c671e90..fbc7e9b 100644 (file)
@@ -19,7 +19,9 @@ class MOCustomerInfo;
 
 class MOCustomer:public MOCustomerAbstract
 {
-       WOBJECT(MOCustomer);
+       Q_OBJECT
+       WOBJECT(MOCustomer)
+       WOSCRIPT(MOCustomer)
        public:
                /**shortcut: gets the customer from the DB*/
                MOCustomer(qint64);
@@ -39,4 +41,8 @@ class MOCustomer:public MOCustomerAbstract
 
 };
 
+Q_DECLARE_METATYPE(MOCustomer)
+Q_DECLARE_METATYPE(QList<MOCustomer>)
+Q_DECLARE_METATYPE(Nullable<MOCustomer>)
+
 #endif
index 1640591..6937f41 100644 (file)
 //
 
 #include "MOCustomerInfo"
+#include <QScriptEngine>
+
+static int mymeta=
+       qRegisterMetaType<MOCustomerInfo>()+
+       qRegisterMetaType<QList<MOCustomerInfo> >()+
+       qRegisterMetaType<Nullable<MOCustomerInfo> >();
+WOSCRIPT_IMP(MOCustomerInfo)
 
 QString MOCustomerInfo::fullName()const
 {
index 9f2199d..200899d 100644 (file)
@@ -16,7 +16,9 @@
 #include "MOCustomerInfoAbstract"
 class MOCustomerInfo:public MOCustomerInfoAbstract
 {
-       WOBJECT(MOCustomerInfo);
+       Q_OBJECT
+       WOBJECT(MOCustomerInfo)
+       WOSCRIPT(MOCustomerInfo)
        public:
                /**returns the full name (incl. title)*/
                QString fullName()const;
@@ -25,4 +27,8 @@ class MOCustomerInfo:public MOCustomerInfoAbstract
                Nullable<qint64> id()const{return customerid();}
 };
 
+Q_DECLARE_METATYPE(MOCustomerInfo)
+Q_DECLARE_METATYPE(QList<MOCustomerInfo>)
+Q_DECLARE_METATYPE(Nullable<MOCustomerInfo>)
+
 #endif
index f24f234..044ac2f 100644 (file)
 #include <QCoreApplication>
 #include <QRegExp>
 #include <QStringList>
+#include <QScriptEngine>
 
 #include "msinterface.h"
 
+static int mymeta=
+       qRegisterMetaType<MOEvent>()+
+       qRegisterMetaType<QList<MOEvent> >()+
+       qRegisterMetaType<Nullable<MOEvent> >();
+WOSCRIPT_IMP(MOEvent)
+
 MOEvent::MOEvent(qint64 i)
 {
        MTGetEvent ge=MSInterface::instance()->queryGetEvent(i);
index 8b00584..58bc418 100644 (file)
@@ -19,7 +19,9 @@
 /**encapsulation of an event, this class wraps the auto-generated event class to provide some convenience methods*/
 class MOEvent:public MOEventAbstract
 {
-       WOBJECT(MOEvent);
+       Q_OBJECT
+       WOBJECT(MOEvent)
+       WOSCRIPT(MOEvent)
        public:
                /**get event directly from server*/
                MOEvent(qint64);
@@ -44,4 +46,8 @@ class MOEvent:public MOEventAbstract
                bool isValid()const{return !eventid().isNull() && eventid().value()>0;}
 };
 
+Q_DECLARE_METATYPE(MOEvent)
+Q_DECLARE_METATYPE(QList<MOEvent>)
+Q_DECLARE_METATYPE(Nullable<MOEvent>)
+
 #endif
index 7a3c32e..55ec7e7 100644 (file)
 //
 
 #include "MOOrder"
+#include "MOOrderInfo"
+#include "MORole"
 
 #include "msinterface.h"
+#include <QScriptEngine>
+
+static int mymeta=
+       qRegisterMetaType<MOOrder>()+
+       qRegisterMetaType<QList<MOOrder> >()+
+       qRegisterMetaType<Nullable<MOOrder> >()+
+       qRegisterMetaType<MOOrderInfo>()+
+       qRegisterMetaType<QList<MOOrderInfo> >()+
+       qRegisterMetaType<Nullable<MOOrderInfo> >()+
+       qRegisterMetaType<MORole>()+
+       qRegisterMetaType<QList<MORole> >()+
+       qRegisterMetaType<Nullable<MORole> >();
 
 MOOrder::MOOrder(qint64 id)
 {
index af0b3b9..384634a 100644 (file)
 /**this class represents a complete order*/
 class MOOrder:public MOOrderAbstract
 {
+       Q_OBJECT
+       WOBJECT(MOOrder)
+       WOSCRIPT(MOOrder)
        public:
-               /**creates an invalid/empty order object*/
-               MOOrder():MOOrderAbstract(){}
                /**create order by id, retrieves it automatically from the database*/
                MOOrder(qint64);
-               /**copy constructor*/
-               MOOrder(const MOOrder&o):MOOrderAbstract(o){}
-               /**used by transactions to create order from xml*/
-               MOOrder(const QDomElement&e):MOOrderAbstract(e){}
 
                /**returns whether the order is valid (it comes from the DB and it has been understood by the parser)*/
                bool isValid()const{return !orderid().isNull();}
@@ -91,4 +88,8 @@ class MOOrder:public MOOrderAbstract
                QString fullDeliveryAddress(bool allowfallback=true)const;
 };
 
+Q_DECLARE_METATYPE(MOOrder)
+Q_DECLARE_METATYPE(QList<MOOrder>)
+Q_DECLARE_METATYPE(Nullable<MOOrder>)
+
 #endif
index 6b658d5..76c411c 100644 (file)
 
 class MOOrderInfo:public MOOrderInfoAbstract
 {
+       Q_OBJECT
+       WOBJECT(MOOrderInfo)
+       WOSCRIPT(MOOrderInfo)
        public:
-               MOOrderInfo(const MOOrderInfo&o):MOOrderInfoAbstract(o){}
-               MOOrderInfo(const QDomElement&e):MOOrderInfoAbstract(e){}
-               
                QString totalPriceString()const{return cent2str(totalprice());}
                QString amountPaidString()const{return cent2str(amountpaid());}
                QString orderStatusString()const{return OrderState2str(status());}
@@ -33,4 +33,8 @@ class MOOrderInfo:public MOOrderInfoAbstract
                bool isCancelled()const{return status()==Cancelled;}
 };
 
+Q_DECLARE_METATYPE(MOOrderInfo)
+Q_DECLARE_METATYPE(QList<MOOrderInfo>)
+Q_DECLARE_METATYPE(Nullable<MOOrderInfo>)
+
 #endif
\ No newline at end of file
index 6c5e012..e0c99ca 100644 (file)
 #define MAGICSMOKE_MOROLE_H
 
 #include "MORoleAbstract"
-typedef MORoleAbstract MORole;
+class MORole:public MORoleAbstract
+{
+       Q_OBJECT
+       WOBJECT(MORole)
+       WOSCRIPT(MORole)
+};
+
+Q_DECLARE_METATYPE(MORole)
+Q_DECLARE_METATYPE(QList<MORole>)
+Q_DECLARE_METATYPE(Nullable<MORole>)
 
 #endif
\ No newline at end of file
index 1bf75e3..d442698 100644 (file)
 //
 
 #include "MOTicket"
+#include "MOVoucher"
 #include "msinterface.h"
+#include <QScriptEngine>
+
+static int mymeta=
+       qRegisterMetaType<MOTicket>()+
+       qRegisterMetaType<QList<MOTicket> >()+
+       qRegisterMetaType<Nullable<MOTicket> >()+
+       qRegisterMetaType<MOVoucher>()+
+       qRegisterMetaType<QList<MOVoucher> >()+
+       qRegisterMetaType<Nullable<MOVoucher> >();
 
 MOEvent MOTicket::event()const
 {
index 34ab3bd..be9d99a 100644 (file)
@@ -19,7 +19,9 @@
 
 class MOTicket:public MOTicketAbstract
 {
-       WOBJECT(MOTicket);
+       Q_OBJECT
+       WOBJECT(MOTicket)
+       WOSCRIPT(MOTicket)
        public:
                /**returns the amount to be paid for this ticket; this may be 0 even if there is a price attached*/
                int amountToPay()const{if(status()&MaskPay)return price();else return 0;}
@@ -42,4 +44,8 @@ class MOTicket:public MOTicketAbstract
                mutable MOEvent m_event;
 };
 
+Q_DECLARE_METATYPE(MOTicket)
+Q_DECLARE_METATYPE(QList<MOTicket>)
+Q_DECLARE_METATYPE(Nullable<MOTicket>)
+
 #endif
index 620684d..908ad84 100644 (file)
@@ -18,7 +18,9 @@
 
 class MOVoucher:public MOVoucherAbstract
 {
-       WOBJECT(MOVoucher);
+       Q_OBJECT
+       WOBJECT(MOVoucher)
+       WOSCRIPT(MOVoucher)
        public:
                /**returns whether this is a valid voucher object (ie. it has a voucher ID)*/
                bool isValid()const{return !voucherid().isNull();}
@@ -30,4 +32,8 @@ class MOVoucher:public MOVoucherAbstract
                QString priceString()const{return cent2str(price());}
 };
 
+Q_DECLARE_METATYPE(MOVoucher)
+Q_DECLARE_METATYPE(QList<MOVoucher>)
+Q_DECLARE_METATYPE(Nullable<MOVoucher>)
+
 #endif
index 2e5b9a3..95b4de0 100644 (file)
@@ -6,6 +6,7 @@ HEADERS += \
        wext/orderinfo.h \
        wext/role.h \
        wext/ticket.h \
+       wext/voucher.h \
        wext/address.h \
        wext/event.h \
        wext/customer.h \
index 0f4e0a2..25bfd32 100644 (file)
@@ -19,5 +19,6 @@
                <Preset><V col="ckey" val="VoucherIDChars"/><V col="cval" val="10"/></Preset>
                <Preset><V col="ckey" val="Flag _admin"/><V col="cval" val="User is Admin"/></Preset>
                <Preset><V col="ckey" val="Flag _web"/><V col="cval" val="User is Customer"/></Preset>
+               <Preset><V col="ckey" val="Flag _useWizard"/><V col="cval" val="User starts with the wizard mode"/></Preset>
        </Table>
 </Wolf>
index 30e3b7b..3a98892 100644 (file)
@@ -15,7 +15,7 @@
        <Include file="db/db.wolf"/>
        
        <!-- configure output -->
-       <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes" transactionBase="MTransaction"/>
+       <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes" transactionBase="MTransaction" scriptable="yes"/>
        <PHPServerOutput sourceDir="www" subDir="inc/wob" extension=".php" clean="yes" transactionBase="MSmokeTransaction"/>
        <HtmlOutput sourceDir="doc" subDir="wob" clean="yes"/>
        <!-- SchemaOutput sourceDir="wob" filename="test.xsd" compound="cmp.xsd"/ -->