From 7592ca042f9ff199ecc02cb44d0a76dc269b828c Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 1 Jan 2010 20:32:42 +0000 Subject: [PATCH] *create room *some basic display for event *fix: normal elementsByTagName traverses the tree, while I only need direct children git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@395 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/eventedit.cpp | 21 +++++++++---- src/dialogs/eventedit.h | 2 +- src/mwin/eventstab.cpp | 13 ++++---- src/wbase/WHelper.cpp | 29 ++++++++++++++++++ src/wbase/WHelper.h | 29 ++++++++++++++++++ src/wbase/WObject.h | 3 +- src/wbase/WTransaction.cpp | 2 +- src/wbase/WTransaction.h | 3 +- src/wbase/wbase.pri | 2 + wob/event.wolf | 39 ++++++++++++++++++------- woc/phpout.cpp | 6 ++-- woc/processor.cpp | 69 ++++++++++++++++++++++++++------------------ woc/processor.h | 2 + woc/qtout.cpp | 13 ++++---- www/inc/wbase/object.php | 11 +++++++ www/inc/wext/autoload.php | 1 + www/inc/wext/room.php | 36 +++++++++++++++++++++++ 17 files changed, 216 insertions(+), 65 deletions(-) create mode 100644 src/wbase/WHelper.cpp create mode 100644 src/wbase/WHelper.h create mode 100644 www/inc/wext/room.php diff --git a/src/dialogs/eventedit.cpp b/src/dialogs/eventedit.cpp index aee87fe..0a8779c 100644 --- a/src/dialogs/eventedit.cpp +++ b/src/dialogs/eventedit.cpp @@ -73,6 +73,11 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id) gl->addWidget(description=new QTextEdit,lctr,1); description->setPlainText(event.description()); + gl->addWidget(lab=new QLabel(tr("Comment:")),++lctr,0); + lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + gl->addWidget(comment=new QTextEdit,lctr,1); + comment->setPlainText(event.comment()); + gl->addWidget(lab=new QLabel(tr("Start Time:")),++lctr,0); lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); gl->addWidget(starttime=new QDateTimeEdit,lctr,1); @@ -123,7 +128,7 @@ MEventEditor::MEventEditor(QWidget*w,qint64 id) vl->addLayout(hl=new QHBoxLayout,0); hl->addStretch(); hl->addWidget(p=new QPushButton(tr("Save"))); -// connect(p,SIGNAL(clicked()),this,SLOT(accept())); + connect(p,SIGNAL(clicked()),this,SLOT(accept())); connect(p,SIGNAL(clicked()),this,SLOT(writeBack())); hl->addWidget(p=new QPushButton(tr("Cancel"))); connect(p,SIGNAL(clicked()),this,SLOT(reject())); @@ -170,6 +175,7 @@ void MEventEditor::selectRoom() hl->addWidget(p=new QPushButton(tr("New...","new room")),0); connect(p,SIGNAL(clicked()),this,SLOT(newRoom())); connect(p,SIGNAL(clicked()),&d,SLOT(reject())); + p->setEnabled(req->hasRight(req->RCreateRoom)); hl->addWidget(p=new QPushButton(tr("Select","select room")),0); connect(p,SIGNAL(clicked()),&d,SLOT(accept())); hl->addWidget(p=new QPushButton(tr("Cancel")),0); @@ -182,14 +188,17 @@ void MEventEditor::selectRoom() } void MEventEditor::newRoom() -{/*TODO +{ + //TODO: do more intelligent input for new room QString rid=QInputDialog::getText(this,tr("New Room"),tr("Name of new room:")); if(rid!=""){ - MRoom rm(req,rid); - rm.makeValid(); - rm.save(); + MTCreateRoom cr=req->queryCreateRoom(rid,0,rid); + if(cr.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while creating new room: %1").arg(cr.errorString())); + return; + } room->setText(rid); - }*/ + } } void MEventEditor::startTimeChanged(const QDateTime&st) diff --git a/src/dialogs/eventedit.h b/src/dialogs/eventedit.h index 96f5046..8fa2207 100644 --- a/src/dialogs/eventedit.h +++ b/src/dialogs/eventedit.h @@ -41,7 +41,7 @@ class MEventEditor:public QDialog MOEvent event; QDateTimeEdit*starttime,*endtime; QLineEdit*title,*artist,*room,*price,*cancelreason; - QTextEdit*description; + QTextEdit*description,*comment; QCheckBox*cancelcheck; QSpinBox*capacity; QLabel*eventid; diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index dfd0eed..01f868b 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -53,21 +53,21 @@ MEventsTab::MEventsTab(QString pk) QPushButton*p; vl->addWidget(p=new QPushButton(tr("New Event...")),0); connect(p,SIGNAL(clicked()),this,SLOT(newEvent())); - p->setEnabled(req->hasRole("createevent")); + p->setEnabled(req->hasRight(req->RCreateEvent)); vl->addWidget(p=new QPushButton(tr("Details...")),0); connect(p,SIGNAL(clicked()),this,SLOT(editEvent())); - p->setEnabled(req->hasRole("geteventdata")); + p->setEnabled(req->hasRight(req->RGetEvent)); vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Order Ticket...")),0); - connect(p,SIGNAL(clicked()),this,SLOT(eventOrderTicket())); - p->setEnabled(req->hasRole("createorder")); + connect(p,SIGNAL(clicked()),this,SIGNAL(eventOrderTicket())); + p->setEnabled(req->hasRight(req->RCreateOrder)||req->hasRight(req->RCreateReservation)); vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Event Summary...")),0); connect(p,SIGNAL(clicked()),this,SLOT(eventSummary())); p->setEnabled(req->hasRole("eventsummary")); vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Cancel Event...")),0); - p->setEnabled(req->hasRole("cancelevent")); + p->setEnabled(req->hasRight(req->RCancelEvent)); connect(p,SIGNAL(clicked()),this,SLOT(eventCancel())); vl->addStretch(10); @@ -85,7 +85,8 @@ QMenu*MEventsTab::menu() ->setEnabled(req->hasRight(req->RGetAllEvents)); m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) ->setEnabled(req->hasRight(req->RGetEvent)); - m->addAction(tr("&New Event..."),this,SLOT(newEvent()))->setEnabled(req->hasRole("createevent")); + m->addAction(tr("&New Event..."),this,SLOT(newEvent())) + ->setEnabled(req->hasRight(req->RCreateEvent)); m->addSeparator(); showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents())); showoldevents->setEnabled(req->hasRight(req->RGetAllEvents)); diff --git a/src/wbase/WHelper.cpp b/src/wbase/WHelper.cpp new file mode 100644 index 0000000..84ec965 --- /dev/null +++ b/src/wbase/WHelper.cpp @@ -0,0 +1,29 @@ +// +// C++ Implementation: WHelper +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "WHelper.h" + +#include +#include + +QListWHelper::elementsByTagName(const QDomElement&root,QString tag) +{ + QDomNodeList cn=root.childNodes(); + QListret; + for(int i=0;i, (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef WOLF_HELPER_H +#define WOLF_HELPER_H + +#include +#include + +class QDomElement; +class QDomNode; + +class WHelper:public QObject +{ + protected: + /**helper for de-serializers: returns direct child elements with given tag name (necessary because QDomElement::elementsByTagName traverses all children)*/ + static QListelementsByTagName(const QDomElement&,QString); +}; + +#endif diff --git a/src/wbase/WObject.h b/src/wbase/WObject.h index afce3bd..1da59ad 100644 --- a/src/wbase/WObject.h +++ b/src/wbase/WObject.h @@ -18,12 +18,13 @@ #include "nullable.h" #include "exception.h" +#include "WHelper.h" class QDomElement; class QDomDocument; /**base class of all web based objects*/ -class WObject:public QObject +class WObject:public WHelper { protected: WObject(){} diff --git a/src/wbase/WTransaction.cpp b/src/wbase/WTransaction.cpp index 8005179..c50556d 100644 --- a/src/wbase/WTransaction.cpp +++ b/src/wbase/WTransaction.cpp @@ -29,7 +29,7 @@ WTransaction::WTransaction(QString ifc) m_iface=ifc; } WTransaction::WTransaction(const WTransaction&t) - :QObject() + :WHelper() { m_stage=t.m_stage; m_errstr=t.m_errstr; diff --git a/src/wbase/WTransaction.h b/src/wbase/WTransaction.h index faed0c1..74b0afc 100644 --- a/src/wbase/WTransaction.h +++ b/src/wbase/WTransaction.h @@ -18,9 +18,10 @@ #include #include "nullable.h" +#include "WHelper.h" /**base class of all transactions*/ -class WTransaction:public QObject +class WTransaction:public WHelper { Q_OBJECT public: diff --git a/src/wbase/wbase.pri b/src/wbase/wbase.pri index 389787b..656be41 100644 --- a/src/wbase/wbase.pri +++ b/src/wbase/wbase.pri @@ -1,11 +1,13 @@ HEADERS += \ wbase/nullable.h \ + wbase/WHelper.h \ wbase/WObject.h \ wbase/WTransaction.h \ wbase/WInterface.h SOURCES += \ wbase/WObject.cpp \ + wbase/WHelper.cpp \ wbase/WTransaction.cpp \ wbase/WInterface.cpp diff --git a/wob/event.wolf b/wob/event.wolf index 0c474d7..f98ef76 100644 --- a/wob/event.wolf +++ b/wob/event.wolf @@ -107,13 +107,14 @@ + - + @@ -130,15 +131,16 @@ - - - - - - - - - + + + + + + + + + + @@ -169,6 +171,9 @@ + + + @@ -179,9 +184,21 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/woc/phpout.cpp b/woc/phpout.cpp index d265edf..74cfbc8 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -31,7 +31,7 @@ WocPHPServerOut::WocPHPServerOut(const QDomElement&el) m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir","."); m_subdir=el.attribute("subDir","phpwob"); m_fileext=el.attribute("extension",".inc"); - QDomNodeList nl=el.elementsByTagName("Authenticator"); + QList nl=elementsByTagName(el,"Authenticator"); if(nl.size()){ QDomElement el2=nl.at(0).toElement(); m_isauth=el2.attribute("isAuthenticated","false"); @@ -907,7 +907,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn) }else{ if(trn.isListType(t)){ QString pt=trn.plainType(t); - code+="\t\tforeach($root->getElementsByTagName(\""+sl[i]+"\") as $el){\n"; + code+="\t\tforeach(WObject::elementsByTagName($root,\""+sl[i]+"\") as $el){\n"; if(trn.isObjectType(t)){ code+="\t\t\t$this->ainput[\""+sl[i]+"\"][]=WO"+pt+"::fromXml($xml,$el);\n"; }else if(trn.isBlobType(t)){ @@ -920,7 +920,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn) } code+="\t\t}\n"; }else{ - code+="\t\tforeach($root->getElementsByTagName(\""+sl[i]+"\") as $el){\n"; + code+="\t\tforeach(WObject::elementsByTagName($root,\""+sl[i]+"\") as $el){\n"; if(trn.isObjectType(t)){ code+="\t\t\t$this->ainput[\""+sl[i]+"\"]=WO"+t+"::fromXml($xml,$el);\n"; }else if(trn.isBlobType(t)){ diff --git a/woc/processor.cpp b/woc/processor.cpp index 16f84c8..5ec9e2b 100644 --- a/woc/processor.cpp +++ b/woc/processor.cpp @@ -23,6 +23,19 @@ #include #include +QListelementsByTagName(const QDomElement&root,QString tag) +{ + QDomNodeList cn=root.childNodes(); + QListret; + for(int i=0;i nl=elementsByTagName(el,"AuditTables"); for(int i=0;i nl=elementsByTagName(cls,"Property"); for(int i=0;i nl2=elementsByTagName(el,"Value"); int nxval=0; for(int j=0;jmap; - QDomNodeList nl2=el.elementsByTagName("Map"); + QList nl2=elementsByTagName(el,"Map"); for(int j=0;j nl3=elementsByTagName(el2,"Call"); for(int k=0;k nl=elementsByTagName(tbl,"Column"); for(int i=0;ips; - QDomNodeList nl2=el.elementsByTagName("V"); + QList nl2=elementsByTagName(el,"V"); for(int j=0;j WocTable::parseColumn(const QDomElement&el,QString m } cl.defaultval=el.attribute("default"); //TODO: validate default against type - QDomNodeList nl2=el.elementsByTagName("Value"); + QList nl2=elementsByTagName(el,"Value"); int nxval=0; //enum values for(int j=0;j WocTable::parseColumn(const QDomElement&el,QString m nxval++; } //default calls - nl2=el.elementsByTagName("Call"); + nl2=elementsByTagName(el,"Call"); for(int j=0;j WocTable::parseColumn(const QDomElement&el,QString m cl.methodcalls.insert(lang,meth); } //docu - nl2=el.childNodes(); - for(int j=0;jWocTable::m_staticauditcolumns; void WocTable::parseAuditStatic(const QDomElement&el) { - QDomNodeList nl=el.elementsByTagName("Column"); + QList nl=elementsByTagName(el,"Column"); for(int i=0;i nl=elementsByTagName(root,"Input"); for(int i=0;i nl2=elementsByTagName(el,"Var"); for(int j=0;j nl2=elementsByTagName(el,"Var"); for(int j=0;jelementsByTagName(const QDomElement&,QString); + inline bool str2bool(QString s) { bool b; diff --git a/woc/qtout.cpp b/woc/qtout.cpp index 3be218d..813b448 100644 --- a/woc/qtout.cpp +++ b/woc/qtout.cpp @@ -30,7 +30,6 @@ static const QByteArray SRCSTART= "//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!\n" "#include \"%.h\"\n" "#include \n" - "#include \n" "#include \n"; //end section of all source files static const QByteArray SRCEND="\n//END OF AUTOMATICALLY GENERATED FILE\n"; @@ -290,10 +289,10 @@ void WocQtClientOut::classDeserializer(const WocClass&cls,MFile&hdr,MFile&src,QS //implement deserializer (as constructor) hcd+="\t"+cn+"(const QDomElement&);\n"; scd+=cn+"::"+cn+"(const QDomElement&root)\n\t:WObject()\n{\n"; - scd+="\tQDomNodeList nl;\n"; + scd+="\tQList nl;\n"; for(int i=0;ichildNodes as $node){ + if($node->nodeType == XML_ELEMENT_NODE) + if($node->tagName == $tag) + $list[]=$node; + } + return $list; + } }; ?> diff --git a/www/inc/wext/autoload.php b/www/inc/wext/autoload.php index 22a289d..d51e01e 100644 --- a/www/inc/wext/autoload.php +++ b/www/inc/wext/autoload.php @@ -16,4 +16,5 @@ $AUTOCLASS["WOOrderInfo"]="inc/wext/order.php"; $AUTOCLASS["WOOrder"]="inc/wext/order.php"; $AUTOCLASS["WOTicket"]="inc/wext/ticket.php"; $AUTOCLASS["WOTemplate"]="inc/wext/template.php"; +$AUTOCLASS["WORoom"]="inc/wext/room.php"; ?> \ No newline at end of file diff --git a/www/inc/wext/room.php b/www/inc/wext/room.php new file mode 100644 index 0000000..59ce2ee --- /dev/null +++ b/www/inc/wext/room.php @@ -0,0 +1,36 @@ +, (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +class WORoom extends WORoomAbstract +{ + /**called from the CreateRoom transaction*/ + public static function createRoom($trans) + { + //check + $rm=WTroom::getFromDB($trans->getroomid()); + if($rm!==false){ + $trans->abortWithError(tr("Room already exists")); + return; + } + //create + $rm=WTroom::newRow(); + $rm->roomid=$trans->getroomid(); + $rm->capacity=$trans->getcapacity(); + $rm->description=$trans->getdescription(); + $rm->insert(); + //return + $trans->setroom(WORoom::fromTableroom($rm)); + } +}; + +?> \ No newline at end of file -- 1.7.2.5