<file>arrowright.png</file>
<file>arrowdown.png</file>
<file>arrowdiag.png</file>
- <file>version.xml</file>
</qresource>
</RCC>
#include <QDesktopServices>
#include <QFile>
#include <QFileDialog>
+#include <QFontDatabase>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QHttp>
m->addAction(tr("&Generate Host Key..."),this,SLOT(generateKey()));
m->addSeparator();
m->addAction(tr("&OpenOffice.org Settings..."),this,SLOT(openOfficeCfg()));
+ m->addAction(tr("Set &Default Label Font..."),this,SLOT(setDefaultFont()));
mb->addMenu(MApplication::helpMenu());
//create central widget
MOfficeConfig c(this);
c.exec();
}
+
+void MMainWindow::setDefaultFont()
+{
+ QStringList fonts=QFontDatabase().families();
+ QString df=QInputDialog::getItem(this,tr("Chose Default Font"),tr("Please chose a default font:"),fonts,fonts.indexOf(QSettings().value("defaultfont","").toString()),false);
+ if(df.isEmpty())return;
+ QSettings().setValue("defaultfont",df);
+}
void importKey();
void generateKey();
void openOfficeCfg();
+ void setDefaultFont();
};
#endif
QMessageBox::warning(0,tr("Warning"),tr("Login failed: %1").arg(tr(lg.errorString().toAscii())));
else
setSessionId(lg.getsessionid());
- return lg.stage()==lg.Success;
+ if(lg.stage()!=lg.Success)return false;
+ //get rights
+ MTGetMyRights mrt=MTGetMyRights::query();
+ QStringList rsl=mrt.getright();
+ for(int i=0;i<rsl.size();i++){
+// qDebug("have right %s",rsl[i].toAscii().data());
+ Right x=stringToRight(rsl[i]);
+ if(x!=NoRight)userrights<<x;
+ }
+ //get roles
+ MTGetMyRoles mrl=MTGetMyRoles::query();
+ userroles=mrl.getrole();
+// for(int i=0;i<userroles.size();i++)qDebug("have role %s",userroles[i].toAscii().data());
+
+ return true;
}
void MSInterface::logout()
if(l.size()>1)return l[1];
else return svnRepositoryUrl();
}
+
+bool MSInterface::hasRight(Right r)const
+{
+ if(userroles.contains("_admin"))return true;
+ return userrights.contains(r);
+}
QString currentUser()const{return m_uname;}
bool hasRole(QString)const{return false;}
+ bool hasRight(Right)const;
QString dataDir()const;
QString settingsGroup()const;
/**returns the current session ID*/
private:
QString profileid,m_sessid,m_uname,m_passwd,m_host,m_hostkey;
+ mutable QList<Right>userrights;
+ mutable QStringList userroles;
};
QMenu*m=mb->addMenu(tr("&Session"));
m->addAction(tr("&Re-Login"),this,SLOT(relogin()));
m->addAction(tr("&Offline mode"))->setEnabled(false);
- m->addAction(tr("Change my &Password"),this,SLOT(setMyPassword())) ->setEnabled(req->hasRole("setmypasswd"));
+ m->addAction(tr("Change my &Password"),this,SLOT(setMyPassword()))
+ ->setEnabled(req->hasRight(req->RChangeMyPassword));
m->addSeparator();
m->addAction(tr("&Edit Templates..."),req,SLOT(editTemplates()));
m->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates()));
m->addAction(tr("&Close Session"),this,SLOT(close()));
m=mb->addMenu(tr("&Event"));
- m->addAction(tr("&Update Event List"),this,SLOT(updateEvents())) ->setEnabled(req->hasRole("geteventlist"));
- m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) ->setEnabled(req->hasRole("geteventdata"));
+ m->addAction(tr("&Update Event List"),this,SLOT(updateEvents()))
+ ->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->addSeparator();
showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents()));
- showoldevents->setEnabled(req->hasRole("geteventlist"));
+ showoldevents->setEnabled(req->hasRight(req->RGetAllEvents));
showoldevents->setCheckable(true);
showoldevents->setChecked(QSettings().value("profiles/"+pk+"/showOldEvents",false).toBool());
connect(entrancescan,SIGNAL(editingFinished()),this,SLOT(entranceValidate()));
vl->addWidget(entrancelabel=new QLabel(" "),10);
entrancelabel->setAutoFillBackground(true);
+ QFont fnt=entrancelabel->font();
+ fnt.setBold(true);fnt.setPointSize(24);
+ entrancelabel->setFont(fnt);
+ entrancelabel->setAlignment(Qt::AlignCenter);
//user tab
tab->addTab(usertab=new QWidget,tr("Users"));
//make sure webrequest knows its settings
webSettings(false);
//fill tables
- if(req->hasRole("geteventlist")){
+ if(req->hasRight(req->RGetAllEvents)){
updateEvents();
}else{
eventtab->setEnabled(false);
int cev=entranceevent->itemData(ci).toInt();
//check content
QString tid=entrancescan->text().trimmed();
+ entrancescan->setText("");
//avoid spurious events
if(tid=="")return;
//avoid double scans
QDateTime now=QDateTime::currentDateTime();
- if(tid==lastbarcode && lastbcscan.addSecs(20)>=now){
- entrancescan->setText("");
+ if(tid==lastbarcode && lastbcscan.addSecs(20)>=now)
return;
- }
lastbarcode=tid;
lastbcscan=now;
+ //reset display
+ QPalette pal=entrancelabel->palette();
+ QPalette::ColorRole rl=QPalette::Window;
+ pal.setColor(rl,Qt::lightGray);
+ entrancelabel->setPalette(pal);
+ entrancelabel->setText(tr("searching...","entrance control"));
//ask the server
MTicket tick(req,tid);
//decide what to do
- QPalette pal=entrancelabel->palette();
- QPalette::ColorRole rl=QPalette::Window;
if(!tick.isValid()){
entrancelabel->setText(tr("Ticket \"%1\" Not Valid").arg(tid));
pal.setColor(rl,Qt::red);
#use genphpscan.sh to regenerate it!
HEADERS += \
+../www/admin.php \
../www/wob.php \
-../www/index.php \
../www/machine.php \
-../www/admin.php \
-../www/test.php \
-../www/info.php \
-../www/inc/loader_nonadmin.php \
-../www/inc/listing.php \
-../www/inc/rendering/event_listing.php \
-../www/inc/rendering/cart_listing.php \
-../www/inc/rendering/submit.php \
-../www/inc/rendering/order_listing.php \
-../www/inc/loader.php \
-../www/inc/classes/websession.php \
-../www/inc/classes/customer.php \
-../www/inc/classes/voucher.php \
-../www/inc/classes/parser.php \
-../www/inc/classes/random.php \
-../www/inc/classes/error.php \
-../www/inc/classes/room.php \
-../www/inc/classes/ticket.php \
-../www/inc/classes/autoload.php \
-../www/inc/classes/cart.php \
-../www/inc/classes/event.php \
-../www/inc/classes/order.php \
-../www/inc/classes/language_manager.php \
-../www/inc/classes/config_manager.php \
../www/inc/wbase/schema.php \
../www/inc/wbase/table.php \
+../www/inc/wbase/exception.php \
../www/inc/wbase/autoload.php \
../www/inc/wbase/object.php \
../www/inc/wbase/transaction.php \
-../www/inc/wbase/exception.php \
-../www/inc/db/db_mysql.php \
-../www/inc/db/db_scheme.php \
-../www/inc/db/autoload.php \
-../www/inc/db/db.php \
+../www/inc/global_variables.php \
+../www/inc/loader.php \
../www/inc/tr.php \
-../www/inc/wob/wtr_GetAllCustomerNames.php \
-../www/inc/wob/wtr_CreateUser.php \
+../www/inc/loader_nonadmin.php \
../www/inc/wob/schema.php \
-../www/inc/wob/wt_order.php \
-../www/inc/wob/wt_session.php \
-../www/inc/wob/wt_event.php \
-../www/inc/wob/wt_cart.php \
-../www/inc/wob/wo_User.php \
-../www/inc/wob/wtr_SetUserDescription.php \
-../www/inc/wob/wtr_GetAllHostNames.php \
-../www/inc/wob/wt_room.php \
+../www/inc/wob/wtr_CreateUser.php \
+../www/inc/wob/wtr_DeleteHost.php \
+../www/inc/wob/wtr_DeleteUser.php \
../www/inc/wob/wt_item.php \
-../www/inc/wob/wt_eventprice.php \
-../www/inc/wob/wtr_GetAllShipping.php \
-../www/inc/wob/wt_customer.php \
-../www/inc/wob/wo_CartVoucher.php \
-../www/inc/wob/wo_Shipping.php \
-../www/inc/wob/wt_host.php \
-../www/inc/wob/wt_country.php \
-../www/inc/wob/wo_Country.php \
-../www/inc/wob/wo_CustomerShort.php \
-../www/inc/wob/wtr_Logout.php \
-../www/inc/wob/wtr_GetUserRoles.php \
-../www/inc/wob/wt_seatplan.php \
-../www/inc/wob/wo_Ticket.php \
-../www/inc/wob/wt_config.php \
-../www/inc/wob/wt_artist.php \
-../www/inc/wob/wtr_SetUserRoles.php \
-../www/inc/wob/wtr_ChangePassword.php \
../www/inc/wob/wt_contact.php \
-../www/inc/wob/wtr_DeleteUser.php \
-../www/inc/wob/wo_Voucher.php \
-../www/inc/wob/wtr_GetTicket.php \
-../www/inc/wob/wtr_CancelEvent.php \
-../www/inc/wob/wo_Host.php \
-../www/inc/wob/wo_CartOrder.php \
-../www/inc/wob/wt_userhost.php \
-../www/inc/wob/wt_cart_voucher.php \
-../www/inc/wob/wt_voucher.php \
-../www/inc/wob/wo_CartTicket.php \
-../www/inc/wob/wt_ticket.php \
-../www/inc/wob/wtr_GetAllRooms.php \
-../www/inc/wob/wt_moneylog.php \
-../www/inc/wob/wtr_GetMyRights.php \
-../www/inc/wob/wtr_ServerInfo.php \
+../www/inc/wob/wt_cart_item.php \
+../www/inc/wob/wt_user.php \
../www/inc/wob/wtr_Login.php \
-../www/inc/wob/wtr_GetVoucher.php \
+../www/inc/wob/wtr_GetAllHostNames.php \
+../www/inc/wob/wo_CartTicket.php \
+../www/inc/wob/wt_session.php \
+../www/inc/wob/wo_ContactType.php \
+../www/inc/wob/wo_Room.php \
+../www/inc/wob/wtr_GetMyRoles.php \
../www/inc/wob/wt_documentlog.php \
-../www/inc/wob/wt_role.php \
-../www/inc/wob/wtr_GetAllHosts.php \
+../www/inc/wob/wtr_CancelEvent.php \
../www/inc/wob/wtr_GetCustomer.php \
-../www/inc/wob/wo_ContactType.php \
-../www/inc/wob/wt_cart_ticket.php \
-../www/inc/wob/wt_product.php \
-../www/inc/wob/wtr_GetOrder.php \
+../www/inc/wob/wo_CartVoucher.php \
../www/inc/wob/wtr_SetHost.php \
-../www/inc/wob/wt_template.php \
-../www/inc/wob/wo_Room.php \
+../www/inc/wob/wtr_GetAllUsers.php \
../www/inc/wob/wtr_GetEvent.php \
+../www/inc/wob/wt_country.php \
+../www/inc/wob/wtr_ChangePassword.php \
+../www/inc/wob/wt_ticket.php \
+../www/inc/wob/wo_Host.php \
+../www/inc/wob/wt_host.php \
../www/inc/wob/wt_shipping.php \
-../www/inc/wob/wt_user.php \
-../www/inc/wob/wt_contacttype.php \
-../www/inc/wob/wt_address.php \
-../www/inc/wob/wtr_GetMyRoles.php \
-../www/inc/wob/wtr_GetAllUsers.php \
-../www/inc/wob/autoload.php \
-../www/inc/wob/wt_cart_item.php \
-../www/inc/wob/wt_pricecategory.php \
-../www/inc/wob/wo_Address.php \
-../www/inc/wob/wo_Customer.php \
+../www/inc/wob/wo_Contact.php \
+../www/inc/wob/wtr_Logout.php \
../www/inc/wob/wt_websession.php \
../www/inc/wob/wtr_GetAllEvents.php \
+../www/inc/wob/wt_template.php \
+../www/inc/wob/wtr_GetTicket.php \
+../www/inc/wob/wt_artist.php \
+../www/inc/wob/wt_customer.php \
+../www/inc/wob/wt_cart_voucher.php \
+../www/inc/wob/wt_order.php \
+../www/inc/wob/wt_userhost.php \
+../www/inc/wob/wt_product.php \
+../www/inc/wob/wtr_SetUserDescription.php \
+../www/inc/wob/wtr_SetUserRoles.php \
+../www/inc/wob/wt_address.php \
+../www/inc/wob/wtr_GetUserRoles.php \
../www/inc/wob/wo_Order.php \
-../www/inc/wob/transaction.php \
+../www/inc/wob/wt_room.php \
+../www/inc/wob/wo_User.php \
+../www/inc/wob/wtr_GetOrder.php \
../www/inc/wob/wtr_SetUserHosts.php \
+../www/inc/wob/wtr_ServerInfo.php \
+../www/inc/wob/wt_voucher.php \
../www/inc/wob/wt_roleright.php \
-../www/inc/wob/wo_Contact.php \
-../www/inc/wob/wtr_GetUserHosts.php \
+../www/inc/wob/wt_seatplan.php \
../www/inc/wob/wt_userrole.php \
+../www/inc/wob/wtr_GetVoucher.php \
+../www/inc/wob/wtr_GetAllShipping.php \
+../www/inc/wob/wtr_GetAllCustomerNames.php \
+../www/inc/wob/wo_CustomerShort.php \
+../www/inc/wob/wt_event.php \
+../www/inc/wob/wtr_GetUserHosts.php \
+../www/inc/wob/autoload.php \
+../www/inc/wob/wt_config.php \
+../www/inc/wob/wo_Customer.php \
+../www/inc/wob/wt_eventprice.php \
+../www/inc/wob/wt_contacttype.php \
+../www/inc/wob/wo_Ticket.php \
+../www/inc/wob/wo_Country.php \
+../www/inc/wob/wt_pricecategory.php \
+../www/inc/wob/wtr_GetAllHosts.php \
+../www/inc/wob/wtr_GetMyRights.php \
+../www/inc/wob/wt_cart_ticket.php \
+../www/inc/wob/wt_moneylog.php \
+../www/inc/wob/wt_cart.php \
../www/inc/wob/wo_Event.php \
-../www/inc/wob/wtr_DeleteHost.php \
-../www/inc/global_variables.php \
-../www/inc/global_functions.php \
-../www/inc/machine/host.php \
-../www/inc/machine/version.php \
-../www/inc/machine/template.php \
+../www/inc/wob/wo_Shipping.php \
+../www/inc/wob/wtr_GetAllRooms.php \
+../www/inc/wob/transaction.php \
+../www/inc/wob/wt_role.php \
+../www/inc/wob/wo_Address.php \
+../www/inc/wob/wo_CartOrder.php \
+../www/inc/wob/wo_Voucher.php \
+../www/inc/listing.php \
../www/inc/machine/session.php \
+../www/inc/machine/version.php \
+../www/inc/machine/host.php \
../www/inc/machine/autoload.php \
-../www/config.php \
+../www/inc/machine/template.php \
+../www/inc/global_functions.php \
+../www/inc/classes/parser.php \
+../www/inc/classes/config_manager.php \
+../www/inc/classes/ticket.php \
+../www/inc/classes/websession.php \
+../www/inc/classes/voucher.php \
+../www/inc/classes/event.php \
+../www/inc/classes/language_manager.php \
+../www/inc/classes/cart.php \
+../www/inc/classes/room.php \
+../www/inc/classes/random.php \
+../www/inc/classes/error.php \
+../www/inc/classes/customer.php \
+../www/inc/classes/autoload.php \
+../www/inc/classes/order.php \
+../www/inc/rendering/event_listing.php \
+../www/inc/rendering/submit.php \
+../www/inc/rendering/cart_listing.php \
+../www/inc/rendering/order_listing.php \
+../www/inc/db/db_scheme.php \
+../www/inc/db/db.php \
+../www/inc/db/autoload.php \
+../www/inc/db/db_mysql.php \
+../www/index.php \
#include "ticketrender.h"
+#include <QCryptographicHash>
#include <QDir>
#include <QDomDocument>
#include <QDomElement>
#include <QMap>
#include <QPaintDevice>
#include <QPainter>
+#include <QSettings>
#include <QStringList>
#include "../zip/qunzip.h"
MLabelRenderer*parent;
//internal font-IDs
QList<int> fdb;
+ QMap<QString,QStringList>fdbl;
+ QMap<QString,QString>getfontdb;
//image cache:
QMap<QString,QImage> idb;
//XML template cache (template.xml)
//converts a size to "natural" coordinates
QSizeF tonatural(const QPaintDevice&,QSizeF);
+
+ //returns a system font name
+ QString getfont(QString);
};
MLabelRenderer::MLabelRenderer(MTemplate file)
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
temp.getCurrentFile(buffer);
- int fid=QFontDatabase::addApplicationFontFromData(buffer.data());
+ QByteArray fdata=buffer.data();
+ int fid=QFontDatabase::addApplicationFontFromData(fdata);
if(fid<0){
- qDebug("Label renderer warning: Font could not be loaded: %s",fn.toAscii().data());
+ qDebug("Label renderer warning: Font could not be loaded: %s (size: %i, md5: %s)",fn.toAscii().data(),fdata.size(),QCryptographicHash::hash(fdata,QCryptographicHash::Md5).toHex().data());
continue;
}
fdb.append(fid);
+ fdbl.insert(fn,QFontDatabase::applicationFontFamilies(fid));
}
//check for pictures
nl=txml.elementsByTagName("Picture");
//get text
QString text=renderLine(tick,el.text().trimmed());
//get font; TODO: introduce weight and italic settings
- QString font=el.attribute("font","Helvetica");
+ QString font=getfont(el.attribute("font","%"));
int size=el.attribute("fontsize","10").toInt();
if(size<1)size=10;
paint->setFont(QFont(font,size));
else flag|=Qt::AlignVCenter;
//render
paint->drawText(QRectF(tonatural(pdev,off)+noff,tonatural(pdev,sz)),flag,text);
+ qDebug("test %s",text.toLatin1().data());
}else
if(enm=="Barcode"){
//get attributes
delete paint;
}
+QString MLabelRendererPrivate::getfont(QString fnt)
+{
+ QString dfont=QSettings().value("defaultfont","Helvetica").toString();
+ //did we already answer this?
+ if(getfontdb.contains(fnt))return getfontdb[fnt];
+ if(fnt=="%")return dfont;
+ //is it a file name?
+ if(fnt.size())if(fnt[0]=='@'){
+ QString font;
+ QString fnt2=fnt.mid(1);
+ if(fdbl.contains(fnt2))if(fdbl[fnt2].size())
+ font=fdbl[fnt2][0];
+ if(font.isEmpty()){
+ qDebug("Label renderer warning: font file %s did not contain font families, using %s instead.",fnt.toAscii().data(),dfont.toAscii().data());
+ font=dfont;
+ }
+ getfontdb.insert(fnt,font);
+ }
+ if(!getfontdb.contains(fnt)){
+ QStringList fonts=QFontDatabase().families();
+ if(!fonts.contains(fnt)){
+ qDebug("Label renderer warning: font %s not found, searching a close match...",fnt.toAscii().data());
+ QString font;
+ for(int i=0;i<fonts.size();i++){
+ if(i)font+=", ";
+ font+=fonts[i];
+ }
+ qDebug("Label renderer hint - found the following fonts: %s",font.toAscii().data());
+ font=dfont;
+ for(int i=0;i<fonts.size();i++)
+ if(fonts[i].startsWith(fnt)){
+ font=fonts[i];
+ break;
+ }
+ qDebug("Label renderer hint: replacing font %s with %s",fnt.toAscii().data(),font.toAscii().data());
+ getfontdb.insert(fnt,font);
+ }else
+ getfontdb.insert(fnt,fnt);
+ }
+ return getfontdb[fnt];
+}
+
QString MLabelRendererPrivate::renderLine(const MLabel&tick,QString line)
{
QString ret,vname;
<Transaction name="Logout" mode="auth">
<Input/>
- <Call lang="php" method="$::session->deleteSession();"/>
+ <Call lang="php" method="Session::instance()->deleteSession();"/>
<Output/>
</Transaction>
<Transaction name="GetMyRoles" mode="auth">
<Input/>
- <Call lang="php" method="$this->setrole(array_unique($::session->getRoles()));"/>
+ <Call lang="php" method="$this->setrole(array_unique(Session::instance()->getRoles()));"/>
<Output>
<Var name="role" type="List:astring"/>
</Output>
</Transaction>
<Transaction name="GetMyRights" mode="auth">
<Input/>
- <Call lang="php" method="$this->setrole(array_unique($::session->getRights()));"/>
+ <Call lang="php" method="$this->setright(array_unique(Session::instance()->getRights()));"/>
<Output>
<Var name="right" type="List:astring"/>
</Output>
</Transaction>
+ <Transaction name="ChangeMyPassword">
+ <Input>
+ <Var name="oldpassword" type="string"/>
+ <Var name="newpassword" type="string"/>
+ </Input>
+ <Output/>
+ </Transaction>
+
<Class name="User">
<Property name="name" type="astring"/>
<Property name="description" type="string"/>
m_error=true;
}
+QStringList WocProcessor::transactionNames()const
+{
+ QStringList l;
+ for(int i=0;i<m_transactions.size();i++)
+ l<<m_transactions[i].name();
+ return l;
+}
/******************************************************************************
* WocOutput
/**returns whether a class exists*/
bool hasClass(QString)const;
+
+ /**returns a list of transaction names*/
+ QStringList transactionNames()const;
signals:
void sfinalize();
void newClass(const WocClass&);
//create interface class
WocProcessor*woc=WocProcessor::instance();
QString pn=woc->projectName();
- m_iface.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"Interface.cpp");
- if(!m_iface.open(QIODevice::WriteOnly|QIODevice::Truncate)){
- qDebug("Error: cannot create Qt interface file %s.",m_iface.fileName().toAscii().data());
+ m_ifacecpp.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"Interface.cpp");
+ if(!m_ifacecpp.open(QIODevice::WriteOnly|QIODevice::Truncate)){
+ qDebug("Error: cannot create Qt interface file %s.",m_ifacecpp.fileName().toAscii().data());
emit errorFound();
return;
}
- m_iface.write(QByteArray(SRCSTART).replace('%',m_prefix+"Interface"));
- m_iface.write(SRCEND);
- m_iface.close();
+ m_ifacecpp.write(QByteArray(SRCSTART).replace('%',m_prefix+"Interface"));
m_iface.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"Interface.h");
if(!m_iface.open(QIODevice::WriteOnly|QIODevice::Truncate)){
qDebug("Error: cannot create Qt interface file %s.",m_iface.fileName().toAscii().data());
}
m_iface.write(QByteArray(HDRSTART).replace("%",m_prefix.toAscii()+"INTERFACE_H"));
m_iface.write(QByteArray("#include \""+m_prefix.toAscii()+"Include.h\"\n#include \"WInterface.h\"\n"));
+ m_iface.write(QByteArray("#include <QStringList>\n"));
m_iface.write(QString("class "+m_prefix+"Interface:public WInterface\n{\n Q_OBJECT\n").toAscii());
m_iface.write(QString(" public:\n "+m_prefix+"Interface(QString name=\""+pn+"\"):WInterface(name){}\n").toAscii());
m_iface.write(QString(" static "+m_prefix+"Interface*instance(QString name=\""+pn+"\")\n\t{return qobject_cast<"+m_prefix+"Interface*>(WInterface::instance(name));}\n\n").toAscii());
void WocQtClientOut::finalize()
{
+ trnList();
+ m_ifacecpp.write(SRCEND);
+ m_ifacecpp.close();
m_iface.write(QByteArray("};\n")+HDREND);
m_iface.close();
m_pri.write(QByteArray("\n#END OF AUTOGENERATED PRI FILE\n"));
return code;
}
+void WocQtClientOut::trnList()
+{
+ QString code;
+ //header
+ code+=" enum Right {\n NoRight";
+ QStringList r=WocProcessor::instance()->transactionNames();
+ for(int i=0;i<r.size();i++)
+ code+=",\n R"+r[i];
+ code+="\n };\n";
+ code+=" static QString rightToString(Right);\n";
+ code+=" static Right stringToRight(QString);\n";
+ code+=" static QStringList allKnownRightsString();\n";
+ code+=" static QList<Right> allKnownRights();\n";
+ m_iface.write(code.toAscii());
+
+ code="QString "+m_prefix+"Interface::rightToString(Right r)\n{\n\tswitch(r){\n";
+ for(int i=0;i<r.size();i++)
+ code+="\t\tcase R"+r[i]+":return \""+r[i]+"\";\n";
+ code+="\t\tdefault:return \"\";\n\t}\n}\n";
+ code+=m_prefix+"Interface::Right "+m_prefix+"Interface::stringToRight(QString s)\n{\n";
+ for(int i=0;i<r.size();i++)
+ code+="\tif(s==\""+r[i]+"\")return R"+r[i]+";else\n";
+ code+="\treturn NoRight;\n}\n";
+ code+="QList<"+m_prefix+"Interface::Right> "+m_prefix+"Interface::allKnownRights()\n{\n";
+ code+="\tQList<Right> ret;ret";
+ for(int i=0;i<r.size();i++)
+ code+="<<R"+r[i];
+ code+=";\n\treturn ret;\n}\n";
+ code+="QStringList "+m_prefix+"Interface::allKnownRightsString()\n{\n";
+ code+="\tQStringList ret;ret";
+ for(int i=0;i<r.size();i++)
+ code+="<<\""+r[i]+"\"";
+ code+=";\n\treturn ret;\n}\n";
+ m_ifacecpp.write(code.toAscii());
+}
+
QString WocQtClientOut::qttype(const WocTransaction&trn,QString v,InOut io)
{
QString tp=io==In?trn.inputType(v):trn.outputType(v);
virtual void newTransaction(const WocTransaction&);
private:
QString m_basedir,m_subdir,m_prefix;
- QFile m_pri,m_iface,m_hdr;
+ QFile m_pri,m_iface,m_ifacecpp,m_hdr;
/**helper: adds a file to the project file*/
void addFile(QString basename);
QString trnInput(const WocTransaction&);
/**helper generates the transaction output decoding*/
QString trnOutput(const WocTransaction&);
+ /**helper generates enums and strings for all transactions*/
+ void trnList();
};
#endif