From 6919ac084b0ced587b1a5ebfbd5b26ad49b0f92d Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 26 Sep 2010 19:03:21 +0000 Subject: [PATCH] make MagicSmoke compatible with new include mode of libs git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@592 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- Makefile.mingw | 4 +- Makefile.unix | 2 +- README | 4 + src/dialogs/customerdlg.h | 4 +- src/dialogs/eventedit.cpp | 4 +- src/dialogs/eventedit.h | 2 +- src/dialogs/eventsummary.h | 4 +- src/dialogs/flagedit.cpp | 2 +- src/dialogs/flagedit.h | 2 +- src/dialogs/orderwin.cpp | 2 +- src/dialogs/orderwin.h | 4 +- src/dialogs/pricecatdlg.h | 2 +- src/dialogs/shipping.cpp | 2 +- src/dialogs/shipping.h | 2 +- src/iface/msinterface.h | 2 +- src/libs.pri | 13 ++++- src/misc/misc.cpp | 4 +- src/misc/sclock.cpp | 2 +- src/mwin/carttab.h | 2 +- src/mwin/eventstab.cpp | 2 +- src/mwin/orderstab.cpp | 2 +- src/mwin/overview.cpp | 3 +- src/templates/odtrender.cpp | 4 +- src/templates/ticketrender.cpp | 4 +- src/wext/MOAddress | 1 + src/wext/MOAddress.cpp | 40 ------------- src/wext/MOAddress.h | 33 ----------- src/wext/MOCustomer | 1 + src/wext/MOCustomer.cpp | 53 ------------------ src/wext/MOCustomer.h | 42 -------------- src/wext/MOCustomerInfo | 1 + src/wext/MOCustomerInfo.cpp | 29 ---------- src/wext/MOCustomerInfo.h | 28 --------- src/wext/MOEvent | 1 + src/wext/MOEvent.cpp | 56 ------------------- src/wext/MOEvent.h | 47 ---------------- src/wext/MOOrder | 1 + src/wext/MOOrder.cpp | 120 ---------------------------------------- src/wext/MOOrder.h | 94 ------------------------------- src/wext/MOOrderInfo | 1 + src/wext/MOOrderInfo.h | 36 ------------ src/wext/MORole | 1 + src/wext/MORole.h | 19 ------ src/wext/MOTicket | 1 + src/wext/MOTicket.cpp | 38 ------------- src/wext/MOTicket.h | 45 --------------- src/wext/MOVoucher | 1 + src/wext/MOVoucher.h | 33 ----------- src/wext/MTransaction | 1 + src/wext/MTransaction.cpp | 26 --------- src/wext/MTransaction.h | 30 ---------- src/wext/address.cpp | 40 +++++++++++++ src/wext/address.h | 33 +++++++++++ src/wext/customer.cpp | 53 ++++++++++++++++++ src/wext/customer.h | 42 ++++++++++++++ src/wext/customerinfo.cpp | 29 ++++++++++ src/wext/customerinfo.h | 28 +++++++++ src/wext/event.cpp | 56 +++++++++++++++++++ src/wext/event.h | 47 ++++++++++++++++ src/wext/order.cpp | 120 ++++++++++++++++++++++++++++++++++++++++ src/wext/order.h | 94 +++++++++++++++++++++++++++++++ src/wext/orderinfo.h | 36 ++++++++++++ src/wext/role.h | 19 ++++++ src/wext/ticket.cpp | 38 +++++++++++++ src/wext/ticket.h | 45 +++++++++++++++ src/wext/transaction.cpp | 26 +++++++++ src/wext/transaction.h | 30 ++++++++++ src/wext/voucher.h | 33 +++++++++++ src/wext/wext.pri | 32 +++++----- 69 files changed, 841 insertions(+), 817 deletions(-) create mode 100644 src/wext/MOAddress delete mode 100644 src/wext/MOAddress.cpp delete mode 100644 src/wext/MOAddress.h create mode 100644 src/wext/MOCustomer delete mode 100644 src/wext/MOCustomer.cpp delete mode 100644 src/wext/MOCustomer.h create mode 100644 src/wext/MOCustomerInfo delete mode 100644 src/wext/MOCustomerInfo.cpp delete mode 100644 src/wext/MOCustomerInfo.h create mode 100644 src/wext/MOEvent delete mode 100644 src/wext/MOEvent.cpp delete mode 100644 src/wext/MOEvent.h create mode 100644 src/wext/MOOrder delete mode 100644 src/wext/MOOrder.cpp delete mode 100644 src/wext/MOOrder.h create mode 100644 src/wext/MOOrderInfo delete mode 100644 src/wext/MOOrderInfo.h create mode 100644 src/wext/MORole delete mode 100644 src/wext/MORole.h create mode 100644 src/wext/MOTicket delete mode 100644 src/wext/MOTicket.cpp delete mode 100644 src/wext/MOTicket.h create mode 100644 src/wext/MOVoucher delete mode 100644 src/wext/MOVoucher.h create mode 100644 src/wext/MTransaction delete mode 100644 src/wext/MTransaction.cpp delete mode 100644 src/wext/MTransaction.h create mode 100644 src/wext/address.cpp create mode 100644 src/wext/address.h create mode 100644 src/wext/customer.cpp create mode 100644 src/wext/customer.h create mode 100644 src/wext/customerinfo.cpp create mode 100644 src/wext/customerinfo.h create mode 100644 src/wext/event.cpp create mode 100644 src/wext/event.h create mode 100644 src/wext/order.cpp create mode 100644 src/wext/order.h create mode 100644 src/wext/orderinfo.h create mode 100644 src/wext/role.h create mode 100644 src/wext/ticket.cpp create mode 100644 src/wext/ticket.h create mode 100644 src/wext/transaction.cpp create mode 100644 src/wext/transaction.h create mode 100644 src/wext/voucher.h diff --git a/Makefile.mingw b/Makefile.mingw index bc09d08..da785e6 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -50,8 +50,8 @@ client: wob zip qwbase tzone cd src && $(MAKE) zip: - cd zip && $(QMAKE) $(QOPT) - cd zip && $(MAKE) + cd zip/src && $(QMAKE) $(QOPT) + cd zip/src && $(MAKE) qwbase: cd pack/qtbase && $(QMAKE) $(QOPT) diff --git a/Makefile.unix b/Makefile.unix index 3527525..13e9e86 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -47,7 +47,7 @@ client: wob zip wbase tzone cd src ; $(QMAKE) && $(MAKE) zip: - cd zip ; $(QMAKE) && $(MAKE) + cd zip/src ; $(QMAKE) && $(MAKE) tzone: cd tzone ; $(QMAKE) && $(MAKE) diff --git a/README b/README index 7e1eb8c..21e8a47 100644 --- a/README +++ b/README @@ -17,9 +17,13 @@ See the Debian README for server installation. Copyrights ----------- +MagicSmoke itself is copyrighted by (c) Konrad Rosenbaum, 2007-2010 (c) Peter Keller, 2007/8 +There are several external sources that are used by MagicSmoke, which are +(partly or wholly) under different copyrights, see below. + Documenation License - - - - - - - - - - - diff --git a/src/dialogs/customerdlg.h b/src/dialogs/customerdlg.h index 88775a6..6a5dacf 100644 --- a/src/dialogs/customerdlg.h +++ b/src/dialogs/customerdlg.h @@ -20,8 +20,8 @@ #include #include -#include "MOCustomerInfo.h" -#include "MOCustomer.h" +#include "MOCustomerInfo" +#include "MOCustomer" class QLineEdit; class QListView; diff --git a/src/dialogs/eventedit.cpp b/src/dialogs/eventedit.cpp index 9a145f1..f45367a 100644 --- a/src/dialogs/eventedit.cpp +++ b/src/dialogs/eventedit.cpp @@ -12,7 +12,7 @@ #include "eventedit.h" -#include "tzdata.h" +#include #include #include @@ -32,7 +32,7 @@ #include #include "msinterface.h" -#include "MTGetEvent.h" +#include "MTGetEvent" #include "centbox.h" #include "pricecatdlg.h" diff --git a/src/dialogs/eventedit.h b/src/dialogs/eventedit.h index befb253..bf460ea 100644 --- a/src/dialogs/eventedit.h +++ b/src/dialogs/eventedit.h @@ -15,7 +15,7 @@ #include -#include "MOEvent.h" +#include "MOEvent" class QCheckBox; class QDateTime; diff --git a/src/dialogs/eventsummary.h b/src/dialogs/eventsummary.h index 394297d..a788a5f 100644 --- a/src/dialogs/eventsummary.h +++ b/src/dialogs/eventsummary.h @@ -16,8 +16,8 @@ #include #include -#include "MOOrder.h" -#include "MOEvent.h" +#include "MOOrder" +#include "MOEvent" #include "odtrender.h" class QTableView; diff --git a/src/dialogs/flagedit.cpp b/src/dialogs/flagedit.cpp index 4fb2a24..4ab2085 100644 --- a/src/dialogs/flagedit.cpp +++ b/src/dialogs/flagedit.cpp @@ -11,7 +11,7 @@ // #include "flagedit.h" -#include "MTGetValidFlags.h" +#include "MTGetValidFlags" #include #include diff --git a/src/dialogs/flagedit.h b/src/dialogs/flagedit.h index e61a18d..e501483 100644 --- a/src/dialogs/flagedit.h +++ b/src/dialogs/flagedit.h @@ -16,7 +16,7 @@ #include #include -#include "MOFlag.h" +#include "MOFlag" class QStandardItemModel; class QTableView; diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 184848f..5997f57 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -19,7 +19,7 @@ #include "msinterface.h" #include "templates.h" -#include "MOEvent.h" +#include "MOEvent" #include #include diff --git a/src/dialogs/orderwin.h b/src/dialogs/orderwin.h index a846756..dd4881a 100644 --- a/src/dialogs/orderwin.h +++ b/src/dialogs/orderwin.h @@ -17,8 +17,8 @@ #include #include "odtrender.h" -#include "MOOrder.h" -#include "MOShipping.h" +#include "MOOrder" +#include "MOShipping" class QAction; class QLabel; diff --git a/src/dialogs/pricecatdlg.h b/src/dialogs/pricecatdlg.h index 37e3a95..8012dbe 100644 --- a/src/dialogs/pricecatdlg.h +++ b/src/dialogs/pricecatdlg.h @@ -15,7 +15,7 @@ #include -#include "MOPriceCategory.h" +#include "MOPriceCategory" class QListWidget; diff --git a/src/dialogs/shipping.cpp b/src/dialogs/shipping.cpp index 86e3767..60197f9 100644 --- a/src/dialogs/shipping.cpp +++ b/src/dialogs/shipping.cpp @@ -15,7 +15,7 @@ #include "centbox.h" #include "flagedit.h" -#include "MOShipping.h" +#include "MOShipping" #include "msinterface.h" diff --git a/src/dialogs/shipping.h b/src/dialogs/shipping.h index 58815aa..e689a97 100644 --- a/src/dialogs/shipping.h +++ b/src/dialogs/shipping.h @@ -19,7 +19,7 @@ class QStandardItemModel; class QTableView; -#include "MOShipping.h" +#include "MOShipping" class MShippingEditor:public QDialog { diff --git a/src/iface/msinterface.h b/src/iface/msinterface.h index dbe0b19..5fa9929 100644 --- a/src/iface/msinterface.h +++ b/src/iface/msinterface.h @@ -13,7 +13,7 @@ #ifndef MAGICSMOKE_MSINTERFACE_H #define MAGICSMOKE_MSINTERFACE_H -#include "MInterface.h" +#include "MInterface" #define req (MSInterface::instance()) diff --git a/src/libs.pri b/src/libs.pri index 56c723c..cba5f01 100644 --- a/src/libs.pri +++ b/src/libs.pri @@ -1,4 +1,13 @@ # Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2010 -LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase -L../tzone -ltzdata -INCLUDEPATH += ../zip ../pack/qtbase ../tzone +# ZIP library +LIBS += -L../zip -lQZip +INCLUDEPATH += ../zip/include + +# PACK library +LIBS += -L../pack/qtbase -lqwbase +INCLUDEPATH += ../pack/qtbase/include + +# Time Zone DB library +LIBS += -L../tzone -ltzdata +INCLUDEPATH += ../tzone/include diff --git a/src/misc/misc.cpp b/src/misc/misc.cpp index a2829f8..71b1798 100644 --- a/src/misc/misc.cpp +++ b/src/misc/misc.cpp @@ -12,11 +12,11 @@ #include "misc.h" -#include +#include #include -#include "MOServerFormat.h" +#include "MOServerFormat" #include #include diff --git a/src/misc/sclock.cpp b/src/misc/sclock.cpp index 611d390..c383afb 100644 --- a/src/misc/sclock.cpp +++ b/src/misc/sclock.cpp @@ -23,7 +23,7 @@ #include #include -#include "tzdata.h" +#include #include "misc.h" MServerClock::MServerClock() diff --git a/src/mwin/carttab.h b/src/mwin/carttab.h index 384114a..8006db3 100644 --- a/src/mwin/carttab.h +++ b/src/mwin/carttab.h @@ -19,7 +19,7 @@ #include #include -#include "MOCustomer.h" +#include "MOCustomer" class QAction; class QCheckBox; diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index 51f9ceb..a21ce9e 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -20,7 +20,7 @@ #include "eventstab.h" -#include "tzdata.h" +#include #include #include diff --git a/src/mwin/orderstab.cpp b/src/mwin/orderstab.cpp index 4379753..9f1ce17 100644 --- a/src/mwin/orderstab.cpp +++ b/src/mwin/orderstab.cpp @@ -20,7 +20,7 @@ #include "orderstab.h" -#include "tzdata.h" +#include #include #include diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index dc044c4..365f2e9 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -26,7 +26,8 @@ #include "centbox.h" #include "sclock.h" -#include "tzdata.h" + +#include #include #include diff --git a/src/templates/odtrender.cpp b/src/templates/odtrender.cpp index b5934a6..3d6d734 100644 --- a/src/templates/odtrender.cpp +++ b/src/templates/odtrender.cpp @@ -20,8 +20,8 @@ #include #include -#include "qunzip.h" -#include "qzip.h" +#include "QUnZip" +#include "QZip" class MOdtRendererPrivate diff --git a/src/templates/ticketrender.cpp b/src/templates/ticketrender.cpp index d637661..f0ed150 100644 --- a/src/templates/ticketrender.cpp +++ b/src/templates/ticketrender.cpp @@ -30,8 +30,8 @@ #include "qzip.h" #include "code39.h" -#include "MOTicket.h" -#include "MOVoucher.h" +#include "MOTicket" +#include "MOVoucher" class MLabelRendererPrivate diff --git a/src/wext/MOAddress b/src/wext/MOAddress new file mode 100644 index 0000000..d85f82c --- /dev/null +++ b/src/wext/MOAddress @@ -0,0 +1 @@ +#include"address.h" diff --git a/src/wext/MOAddress.cpp b/src/wext/MOAddress.cpp deleted file mode 100644 index 9a7d8cf..0000000 --- a/src/wext/MOAddress.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// C++ Implementation: MOAddress -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOAddress.h" - -#include - -static int moaid=qRegisterMetaType("MOAddress"); - -QString MOAddress::fullAddress(QString nm)const -{ - //collect lines - QStringList rl; - if(name().isNull()){ - if(nm!="")rl<, (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MADDRESS_H -#define MAGICSMOKE_MADDRESS_H - -#include "MOAddressAbstract.h" - -#include - -class MOAddress:public MOAddressAbstract -{ - WOBJECT(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; - - /**returns true if this is a valid address stored in the DB (ie. it has an address ID)*/ - bool isValid()const{return !addressid().isNull() && addressid().value()>=0;} -}; - -Q_DECLARE_METATYPE(MOAddress); - -#endif diff --git a/src/wext/MOCustomer b/src/wext/MOCustomer new file mode 100644 index 0000000..396763a --- /dev/null +++ b/src/wext/MOCustomer @@ -0,0 +1 @@ +#include"customer.h" diff --git a/src/wext/MOCustomer.cpp b/src/wext/MOCustomer.cpp deleted file mode 100644 index 6d487de..0000000 --- a/src/wext/MOCustomer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// C++ Implementation: customer -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2008 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOCustomer.h" -#include "MOCustomerInfo.h" -#include "msinterface.h" - -MOCustomer::MOCustomer(qint64 i) -{ - MTGetCustomer gc=req->queryGetCustomer(i); - if(gc.stage()==gc.Success) - operator=(gc.getcustomer().value()); -} - -MOCustomer::MOCustomer(const MOCustomerInfo&ci) -{ - MTGetCustomer gc=req->queryGetCustomer(ci.id()); - if(gc.stage()==gc.Success) - operator=(gc.getcustomer().value()); -} - -QString MOCustomer::address(int i) -{ - if(i<0)return ""; - QListadrs=addresses(); - if(i>=adrs.size())return ""; - return adrs[i].fullAddress(fullName()); -} - -QString MOCustomer::fullName()const -{ - QString ret=title().value().trimmed(); - QString s=name().value().trimmed(); - if(s!=""){ - if(ret!="")ret+=" "; - ret+=s; - } - s=firstname().value().trimmed(); - if(s!=""){ - if(ret!="")ret+=", "; - ret+=s; - } - return ret; -} diff --git a/src/wext/MOCustomer.h b/src/wext/MOCustomer.h deleted file mode 100644 index bde3b20..0000000 --- a/src/wext/MOCustomer.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// C++ Interface: MOCustomer -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOCUSTOMER_H -#define MAGICSMOKE_MOCUSTOMER_H - -#include "MOCustomerAbstract.h" - -class MOCustomerInfo; - -class MOCustomer:public MOCustomerAbstract -{ - WOBJECT(MOCustomer); - public: - /**shortcut: gets the customer from the DB*/ - MOCustomer(qint64); - /**shortcut: extracts the ID from the info and retrieves the customer from the DB*/ - MOCustomer(const MOCustomerInfo&); - /**returns whether the customer is valid*/ - bool isValid(){return !id().isNull();} - - /**alias for id()*/ - Nullable customerid()const{return id();} - - /**returns the address of the customer*/ - QString address(int i=0); - - /**returns the full name (incl. title)*/ - QString fullName()const; - -}; - -#endif diff --git a/src/wext/MOCustomerInfo b/src/wext/MOCustomerInfo new file mode 100644 index 0000000..468bee4 --- /dev/null +++ b/src/wext/MOCustomerInfo @@ -0,0 +1 @@ +#include"customerinfo.h" diff --git a/src/wext/MOCustomerInfo.cpp b/src/wext/MOCustomerInfo.cpp deleted file mode 100644 index 336d1a2..0000000 --- a/src/wext/MOCustomerInfo.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// C++ Implementation: MOCustomerInfo -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOCustomerInfo.h" - -QString MOCustomerInfo::fullName()const -{ - QString ret=title().value().trimmed(); - QString s=name().value().trimmed(); - if(s!=""){ - if(ret!="")ret+=" "; - ret+=s; - } - s=firstname().value().trimmed(); - if(s!=""){ - if(ret!="")ret+=", "; - ret+=s; - } - return ret; -} diff --git a/src/wext/MOCustomerInfo.h b/src/wext/MOCustomerInfo.h deleted file mode 100644 index 76b8900..0000000 --- a/src/wext/MOCustomerInfo.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// C++ Interface: unabstract -// -// Description: removes abstract flag from classes that only need to be abstract in PHP -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOCUSTOMERI_H -#define MAGICSMOKE_MOCUSTOMERI_H - -#include "MOCustomerInfoAbstract.h" -class MOCustomerInfo:public MOCustomerInfoAbstract -{ - WOBJECT(MOCustomerInfo); - public: - /**returns the full name (incl. title)*/ - QString fullName()const; - - /**alias for customerid()*/ - Nullable id()const{return customerid();} -}; - -#endif diff --git a/src/wext/MOEvent b/src/wext/MOEvent new file mode 100644 index 0000000..0da8fbb --- /dev/null +++ b/src/wext/MOEvent @@ -0,0 +1 @@ +#include"event.h" diff --git a/src/wext/MOEvent.cpp b/src/wext/MOEvent.cpp deleted file mode 100644 index 1e858b6..0000000 --- a/src/wext/MOEvent.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// C++ Implementation: event -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2007 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOEvent.h" - -#include -#include -#include - -#include "msinterface.h" - -MOEvent::MOEvent(qint64 i) -{ - MTGetEvent ge=MSInterface::instance()->queryGetEvent(i); - if(ge.stage()==ge.Success) - operator=(ge.getevent().value()); -} - -QRegExp MOEvent::priceRegExp()const -{ - return ::priceRegExp(); -} - -QString MOEvent::priceString()const -{ - qint64 dp=/*defaultprice()*/0; - QString ret=QString::number(dp/100); - ret+=QCoreApplication::translate("MOEvent",".","price decimal dot"); - ret+=QString::number((dp/10)%10); - ret+=QString::number(dp%10); - return ret; -} - -QString MOEvent::startTimeString()const -{ - return unix2dateTime(start()); -} - -QString MOEvent::startDateString()const -{ - return unix2date(start()); -} - -QString MOEvent::endTimeString()const -{ - return unix2dateTime(end()); -} diff --git a/src/wext/MOEvent.h b/src/wext/MOEvent.h deleted file mode 100644 index 3abc028..0000000 --- a/src/wext/MOEvent.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// C++ Interface: event -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2007 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef EVENT_H -#define EVENT_H - -#include -#include - -/**encapsulation of an event, this class wraps the auto-generated event class to provide some convenience methods*/ -class MOEvent:public MOEventAbstract -{ - WOBJECT(MOEvent); - public: - /**get event directly from server*/ - MOEvent(qint64); - - /**alias for id()*/ - inline Nullable eventid()const{return id();} - - /**returns the start time of the event as localized string*/ - QString startTimeString()const; - /**returns the start date as localized string*/ - QString startDateString()const; - /**returns the end time of the event as localized string*/ - QString endTimeString()const; - /**returns the room of the event, the room must be one out of the list of valid rooms*/ - - /**returns the price as a localized string*/ - QString priceString()const; - /**returns the local regular expression for prices*/ - QRegExp priceRegExp()const; - - /**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/ - bool isValid()const{return !eventid().isNull() && eventid().value()>0;} -}; - -#endif diff --git a/src/wext/MOOrder b/src/wext/MOOrder new file mode 100644 index 0000000..4222ffc --- /dev/null +++ b/src/wext/MOOrder @@ -0,0 +1 @@ +#include"order.h" diff --git a/src/wext/MOOrder.cpp b/src/wext/MOOrder.cpp deleted file mode 100644 index 75d010c..0000000 --- a/src/wext/MOOrder.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// -// C++ Implementation: MOOrder -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOOrder.h" - -#include "msinterface.h" - -MOOrder::MOOrder(qint64 id) -{ - MTGetOrder go=req->queryGetOrder(id); - if(go.stage()==go.Success) - operator=(go.getorder().value()); -} - -bool MOOrder::needsPayment()const -{ - if(status()==Placed || status()==Sent) - if(amountpaid()0; - if(status()==Placed || status()==Sent) - return amountpaid()>totalprice(); - return false; -} - -int MOOrder::amountToPay()const -{ - if(status()==Placed || status()==Sent) - if(amountpaid()totalprice()) - return amountpaid()-totalprice(); - return 0; -} - -bool MOOrder::isSent()const -{ - //only in placed mode there is a need for action, hence in all other modes we assume sent - return status()!=Placed; -} - -TimeStamp MOOrder::orderDateTime() -{ - if(ordertime().value()==0)return TimeStamp(); - return TimeStamp(ordertime()); -} - -QString MOOrder::orderDateTimeStr() -{ - if(ordertime().value()==0)return ""; - return unix2dateTime(ordertime()); -} - -QString MOOrder::orderDateStr() -{ - if(ordertime().value()==0)return ""; - return unix2date(ordertime()); -} - -TimeStamp MOOrder::sentDateTime() -{ - return TimeStamp(senttime()); -} - -QString MOOrder::sentDateTimeStr() -{ - if(senttime().value()==0)return ""; - return unix2dateTime(senttime()); -} - -QString MOOrder::sentDateStr() -{ - if(senttime().value()==0)return ""; - return unix2date(senttime()); -} - -QString MOOrder::fullInvoiceAddress(bool allowfallback)const -{ - if(!invoiceaddress().isNull() && invoiceaddress().value().isValid()) - return invoiceaddress().value().fullAddress(customer().value().fullName()); - //fall back - if(!allowfallback)return ""; - if(!deliveryaddress().isNull() && deliveryaddress().value().isValid()) - return deliveryaddress().value().fullAddress(customer().value().fullName()); - //give up - return ""; -} - -QString MOOrder::fullDeliveryAddress(bool allowfallback)const -{ - if(!deliveryaddress().isNull() && deliveryaddress().value().isValid()) - return deliveryaddress().value().fullAddress(customer().value().fullName()); - //fall back - if(!allowfallback)return ""; - if(!invoiceaddress().isNull() && invoiceaddress().value().isValid()) - return invoiceaddress().value().fullAddress(customer().value().fullName()); - //give up - return ""; -} diff --git a/src/wext/MOOrder.h b/src/wext/MOOrder.h deleted file mode 100644 index 2f6f467..0000000 --- a/src/wext/MOOrder.h +++ /dev/null @@ -1,94 +0,0 @@ -// -// C++ Interface: unabstract -// -// Description: removes abstract flag from classes that only need to be abstract in PHP -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOORDER_H -#define MAGICSMOKE_MOORDER_H - -#include "MOOrderAbstract.h" -#include "misc.h" - -#include "tzdata.h" - -/**this class represents a complete order*/ -class MOOrder:public MOOrderAbstract -{ - 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();} - - /**returns whether this order is a reservation*/ - bool isReservation()const{return status()==Reserved;} - - /**returns whether the tickets of this order have already been shipped*/ - bool isSent()const; - - /**returns the status of the order as localized string*/ - QString orderStatusString()const{return OrderState2locstr(status());} - - /**returns how much money needs to be paid in total for this order, in cents*/ - QString totalPriceString()const{return cent2str(totalprice());} - - /**returns how much money has already been paid for this order, in cents*/ - QString amountPaidString()const{return cent2str(amountpaid());} - - /**returns whether there is anything left to pay*/ - bool needsPayment()const; - - /**returns whether there is anything left to refund*/ - bool needsRefund()const; - - /**returns how much there is to be paid, in cents*/ - int amountToPay()const; - - /**returns how much there is to be paid, as localized string*/ - QString amountToPayStr()const{return cent2str(amountToPay());} - - /**returns how much there is to be refunded, in cents*/ - int amountToRefund()const; - - /**returns how much there is to be refunded, as localized string*/ - QString amountToRefundStr()const{return cent2str(amountToRefund());} - - /**return the order date+time*/ - TimeStamp orderDateTime(); - - /**returns the order date+time as string*/ - QString orderDateTimeStr(); - - /**returns the order date only as string*/ - QString orderDateStr(); - - /**returns the shipping date+time*/ - TimeStamp sentDateTime(); - - /**returns the shipping date+time as string*/ - QString sentDateTimeStr(); - - /**returns the shipping date only as string*/ - QString sentDateStr(); - - /**returns the full invoice address, or delivery address if no explicit invoice address was given and allowfallback==true*/ - QString fullInvoiceAddress(bool allowfallback=true)const; - /**returns the full delivery address, or invoice address if no explicit delivery address was given and allowfallback==true*/ - QString fullDeliveryAddress(bool allowfallback=true)const; -}; - -#endif diff --git a/src/wext/MOOrderInfo b/src/wext/MOOrderInfo new file mode 100644 index 0000000..61ee41e --- /dev/null +++ b/src/wext/MOOrderInfo @@ -0,0 +1 @@ +#include"orderinfo.h" diff --git a/src/wext/MOOrderInfo.h b/src/wext/MOOrderInfo.h deleted file mode 100644 index a033669..0000000 --- a/src/wext/MOOrderInfo.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// C++ Interface: unabstract -// -// Description: removes abstract flag from classes that only need to be abstract in PHP -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOORDERI_H -#define MAGICSMOKE_MOORDERI_H - -#include "MOOrderInfoAbstract.h" -#include "misc.h" - -class MOOrderInfo:public MOOrderInfoAbstract -{ - 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());} - - bool needsPayment()const{return amountpaid()totalprice();} - bool isSent()const{return status()==Sent;} - bool isReservation()const{return status()==Reserved;} - bool isCancelled()const{return status()==Cancelled;} -}; - -#endif \ No newline at end of file diff --git a/src/wext/MORole b/src/wext/MORole new file mode 100644 index 0000000..9a0512e --- /dev/null +++ b/src/wext/MORole @@ -0,0 +1 @@ +#include"role.h" diff --git a/src/wext/MORole.h b/src/wext/MORole.h deleted file mode 100644 index ac961a5..0000000 --- a/src/wext/MORole.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// C++ Interface: unabstract -// -// Description: removes abstract flag from classes that only need to be abstract in PHP -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOROLE_H -#define MAGICSMOKE_MOROLE_H - -#include "MORoleAbstract.h" -typedef MORoleAbstract MORole; - -#endif \ No newline at end of file diff --git a/src/wext/MOTicket b/src/wext/MOTicket new file mode 100644 index 0000000..056e50f --- /dev/null +++ b/src/wext/MOTicket @@ -0,0 +1 @@ +#include"ticket.h" diff --git a/src/wext/MOTicket.cpp b/src/wext/MOTicket.cpp deleted file mode 100644 index c3e4bf1..0000000 --- a/src/wext/MOTicket.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// C++ Implementation: MOTicket -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "MOTicket.h" -#include "msinterface.h" - -MOEvent MOTicket::event()const -{ - //if I am valid... - if(!ticketid().isNull() && !eventid().isNull()) - //...and the event is not... - if(m_event.eventid().isNull()){ - //...then retrieve the event - MTGetEvent ge=req->queryGetEvent(eventid()); - if(!ge.hasError()) - m_event=ge.getevent(); - } - //return whatever we have by now - return m_event; -} - -QString MOTicket::priceCategoryName()const -{ - return pricecategory().value().name(); -} -QString MOTicket::priceCategoryShort()const -{ - return pricecategory().value().abbreviation(); -} diff --git a/src/wext/MOTicket.h b/src/wext/MOTicket.h deleted file mode 100644 index 2136d76..0000000 --- a/src/wext/MOTicket.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// C++ Interface: MOTicket -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOTICKET_H -#define MAGICSMOKE_MOTICKET_H - -#include "MOTicketAbstract.h" -#include "misc.h" -#include "MOEvent.h" - -class MOTicket:public MOTicketAbstract -{ - WOBJECT(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;} - - /**returns the price as string*/ - QString priceString()const{return cent2str(price());} - - /**returns the ticket status as localized string*/ - QString statusString()const{return TicketState2locstr(status());} - - /**returns the full price category name*/ - QString priceCategoryName()const; - /**returns the abbreviation for the price category*/ - QString priceCategoryShort()const; - - /**returns the event that this ticket belongs to - does a roundtrip to the database the first time this is called!*/ - MOEvent event()const; - private: - //this must be mutable, since event() is semantically and technically const - mutable MOEvent m_event; -}; - -#endif diff --git a/src/wext/MOVoucher b/src/wext/MOVoucher new file mode 100644 index 0000000..81cd139 --- /dev/null +++ b/src/wext/MOVoucher @@ -0,0 +1 @@ +#include"voucher.h" diff --git a/src/wext/MOVoucher.h b/src/wext/MOVoucher.h deleted file mode 100644 index 4971f1f..0000000 --- a/src/wext/MOVoucher.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// C++ Interface: MOVoucher -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MOVOUCHER_H -#define MAGICSMOKE_MOVOUCHER_H - -#include "MOVoucherAbstract.h" -#include "misc.h" - -class MOVoucher:public MOVoucherAbstract -{ - WOBJECT(MOVoucher); - public: - /**returns whether this is a valid voucher object (ie. it has a voucher ID)*/ - bool isValid()const{return !voucherid().isNull();} - /**returns the current value as string*/ - QString valueString()const{return cent2str(value());} - /**returns the status of the voucher as string*/ - QString statusString()const{return VoucherState2locstr(status());} - /**returns the price as string*/ - QString priceString()const{return cent2str(price());} -}; - -#endif diff --git a/src/wext/MTransaction b/src/wext/MTransaction new file mode 100644 index 0000000..1fadece --- /dev/null +++ b/src/wext/MTransaction @@ -0,0 +1 @@ +#include "transaction.h" diff --git a/src/wext/MTransaction.cpp b/src/wext/MTransaction.cpp deleted file mode 100644 index 482abd2..0000000 --- a/src/wext/MTransaction.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// C++ Implementation: MTransaction -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#include "MTransaction.h" -#include "waitcursor.h" - -QByteArray MTransaction::executeQuery(QString hreq,QByteArray data) -{ - //show the user we are waiting - WaitCursor wc; - //call parent - return WTransaction::executeQuery(hreq,data); -} - -MTransaction::MTransaction(QString iface):WTransaction(iface){} -MTransaction::MTransaction(const WTransaction&t):WTransaction(t){} -MTransaction::MTransaction(const MTransaction&t):WTransaction(t){} diff --git a/src/wext/MTransaction.h b/src/wext/MTransaction.h deleted file mode 100644 index c90705c..0000000 --- a/src/wext/MTransaction.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// C++ Interface: MTransaction -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2010 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#ifndef MSMOKE_MTRANSACTION_H -#define MSMOKE_MTRANSACTION_H - -#include "WTransaction.h" - -class MTransaction:public WTransaction{ - protected: - /**internal: construct the transaction*/ - MTransaction(QString iface=QString()); - /**internal: copy the transaction*/ - MTransaction(const WTransaction&); - /**internal: copy the transaction*/ - MTransaction(const MTransaction&); - /**internal: extend executeQuery to show a wait cursor*/ - QByteArray executeQuery(QString,QByteArray); -}; - -#endif diff --git a/src/wext/address.cpp b/src/wext/address.cpp new file mode 100644 index 0000000..e136c13 --- /dev/null +++ b/src/wext/address.cpp @@ -0,0 +1,40 @@ +// +// C++ Implementation: MOAddress +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOAddress" + +#include + +static int moaid=qRegisterMetaType("MOAddress"); + +QString MOAddress::fullAddress(QString nm)const +{ + //collect lines + QStringList rl; + if(name().isNull()){ + if(nm!="")rl<, (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MADDRESS_H +#define MAGICSMOKE_MADDRESS_H + +#include "MOAddressAbstract" + +#include + +class MOAddress:public MOAddressAbstract +{ + WOBJECT(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; + + /**returns true if this is a valid address stored in the DB (ie. it has an address ID)*/ + bool isValid()const{return !addressid().isNull() && addressid().value()>=0;} +}; + +Q_DECLARE_METATYPE(MOAddress); + +#endif diff --git a/src/wext/customer.cpp b/src/wext/customer.cpp new file mode 100644 index 0000000..ea62427 --- /dev/null +++ b/src/wext/customer.cpp @@ -0,0 +1,53 @@ +// +// C++ Implementation: customer +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2008 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOCustomer" +#include "MOCustomerInfo" +#include "msinterface.h" + +MOCustomer::MOCustomer(qint64 i) +{ + MTGetCustomer gc=req->queryGetCustomer(i); + if(gc.stage()==gc.Success) + operator=(gc.getcustomer().value()); +} + +MOCustomer::MOCustomer(const MOCustomerInfo&ci) +{ + MTGetCustomer gc=req->queryGetCustomer(ci.id()); + if(gc.stage()==gc.Success) + operator=(gc.getcustomer().value()); +} + +QString MOCustomer::address(int i) +{ + if(i<0)return ""; + QListadrs=addresses(); + if(i>=adrs.size())return ""; + return adrs[i].fullAddress(fullName()); +} + +QString MOCustomer::fullName()const +{ + QString ret=title().value().trimmed(); + QString s=name().value().trimmed(); + if(s!=""){ + if(ret!="")ret+=" "; + ret+=s; + } + s=firstname().value().trimmed(); + if(s!=""){ + if(ret!="")ret+=", "; + ret+=s; + } + return ret; +} diff --git a/src/wext/customer.h b/src/wext/customer.h new file mode 100644 index 0000000..c671e90 --- /dev/null +++ b/src/wext/customer.h @@ -0,0 +1,42 @@ +// +// C++ Interface: MOCustomer +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOCUSTOMER_H +#define MAGICSMOKE_MOCUSTOMER_H + +#include "MOCustomerAbstract" + +class MOCustomerInfo; + +class MOCustomer:public MOCustomerAbstract +{ + WOBJECT(MOCustomer); + public: + /**shortcut: gets the customer from the DB*/ + MOCustomer(qint64); + /**shortcut: extracts the ID from the info and retrieves the customer from the DB*/ + MOCustomer(const MOCustomerInfo&); + /**returns whether the customer is valid*/ + bool isValid(){return !id().isNull();} + + /**alias for id()*/ + Nullable customerid()const{return id();} + + /**returns the address of the customer*/ + QString address(int i=0); + + /**returns the full name (incl. title)*/ + QString fullName()const; + +}; + +#endif diff --git a/src/wext/customerinfo.cpp b/src/wext/customerinfo.cpp new file mode 100644 index 0000000..1640591 --- /dev/null +++ b/src/wext/customerinfo.cpp @@ -0,0 +1,29 @@ +// +// C++ Implementation: MOCustomerInfo +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOCustomerInfo" + +QString MOCustomerInfo::fullName()const +{ + QString ret=title().value().trimmed(); + QString s=name().value().trimmed(); + if(s!=""){ + if(ret!="")ret+=" "; + ret+=s; + } + s=firstname().value().trimmed(); + if(s!=""){ + if(ret!="")ret+=", "; + ret+=s; + } + return ret; +} diff --git a/src/wext/customerinfo.h b/src/wext/customerinfo.h new file mode 100644 index 0000000..9f2199d --- /dev/null +++ b/src/wext/customerinfo.h @@ -0,0 +1,28 @@ +// +// C++ Interface: unabstract +// +// Description: removes abstract flag from classes that only need to be abstract in PHP +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOCUSTOMERI_H +#define MAGICSMOKE_MOCUSTOMERI_H + +#include "MOCustomerInfoAbstract" +class MOCustomerInfo:public MOCustomerInfoAbstract +{ + WOBJECT(MOCustomerInfo); + public: + /**returns the full name (incl. title)*/ + QString fullName()const; + + /**alias for customerid()*/ + Nullable id()const{return customerid();} +}; + +#endif diff --git a/src/wext/event.cpp b/src/wext/event.cpp new file mode 100644 index 0000000..f24f234 --- /dev/null +++ b/src/wext/event.cpp @@ -0,0 +1,56 @@ +// +// C++ Implementation: event +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOEvent" + +#include +#include +#include + +#include "msinterface.h" + +MOEvent::MOEvent(qint64 i) +{ + MTGetEvent ge=MSInterface::instance()->queryGetEvent(i); + if(ge.stage()==ge.Success) + operator=(ge.getevent().value()); +} + +QRegExp MOEvent::priceRegExp()const +{ + return ::priceRegExp(); +} + +QString MOEvent::priceString()const +{ + qint64 dp=/*defaultprice()*/0; + QString ret=QString::number(dp/100); + ret+=QCoreApplication::translate("MOEvent",".","price decimal dot"); + ret+=QString::number((dp/10)%10); + ret+=QString::number(dp%10); + return ret; +} + +QString MOEvent::startTimeString()const +{ + return unix2dateTime(start()); +} + +QString MOEvent::startDateString()const +{ + return unix2date(start()); +} + +QString MOEvent::endTimeString()const +{ + return unix2dateTime(end()); +} diff --git a/src/wext/event.h b/src/wext/event.h new file mode 100644 index 0000000..8b00584 --- /dev/null +++ b/src/wext/event.h @@ -0,0 +1,47 @@ +// +// C++ Interface: event +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef EVENT_H +#define EVENT_H + +#include +#include + +/**encapsulation of an event, this class wraps the auto-generated event class to provide some convenience methods*/ +class MOEvent:public MOEventAbstract +{ + WOBJECT(MOEvent); + public: + /**get event directly from server*/ + MOEvent(qint64); + + /**alias for id()*/ + inline Nullable eventid()const{return id();} + + /**returns the start time of the event as localized string*/ + QString startTimeString()const; + /**returns the start date as localized string*/ + QString startDateString()const; + /**returns the end time of the event as localized string*/ + QString endTimeString()const; + /**returns the room of the event, the room must be one out of the list of valid rooms*/ + + /**returns the price as a localized string*/ + QString priceString()const; + /**returns the local regular expression for prices*/ + QRegExp priceRegExp()const; + + /**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/ + bool isValid()const{return !eventid().isNull() && eventid().value()>0;} +}; + +#endif diff --git a/src/wext/order.cpp b/src/wext/order.cpp new file mode 100644 index 0000000..7a3c32e --- /dev/null +++ b/src/wext/order.cpp @@ -0,0 +1,120 @@ +// +// C++ Implementation: MOOrder +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOOrder" + +#include "msinterface.h" + +MOOrder::MOOrder(qint64 id) +{ + MTGetOrder go=req->queryGetOrder(id); + if(go.stage()==go.Success) + operator=(go.getorder().value()); +} + +bool MOOrder::needsPayment()const +{ + if(status()==Placed || status()==Sent) + if(amountpaid()0; + if(status()==Placed || status()==Sent) + return amountpaid()>totalprice(); + return false; +} + +int MOOrder::amountToPay()const +{ + if(status()==Placed || status()==Sent) + if(amountpaid()totalprice()) + return amountpaid()-totalprice(); + return 0; +} + +bool MOOrder::isSent()const +{ + //only in placed mode there is a need for action, hence in all other modes we assume sent + return status()!=Placed; +} + +TimeStamp MOOrder::orderDateTime() +{ + if(ordertime().value()==0)return TimeStamp(); + return TimeStamp(ordertime()); +} + +QString MOOrder::orderDateTimeStr() +{ + if(ordertime().value()==0)return ""; + return unix2dateTime(ordertime()); +} + +QString MOOrder::orderDateStr() +{ + if(ordertime().value()==0)return ""; + return unix2date(ordertime()); +} + +TimeStamp MOOrder::sentDateTime() +{ + return TimeStamp(senttime()); +} + +QString MOOrder::sentDateTimeStr() +{ + if(senttime().value()==0)return ""; + return unix2dateTime(senttime()); +} + +QString MOOrder::sentDateStr() +{ + if(senttime().value()==0)return ""; + return unix2date(senttime()); +} + +QString MOOrder::fullInvoiceAddress(bool allowfallback)const +{ + if(!invoiceaddress().isNull() && invoiceaddress().value().isValid()) + return invoiceaddress().value().fullAddress(customer().value().fullName()); + //fall back + if(!allowfallback)return ""; + if(!deliveryaddress().isNull() && deliveryaddress().value().isValid()) + return deliveryaddress().value().fullAddress(customer().value().fullName()); + //give up + return ""; +} + +QString MOOrder::fullDeliveryAddress(bool allowfallback)const +{ + if(!deliveryaddress().isNull() && deliveryaddress().value().isValid()) + return deliveryaddress().value().fullAddress(customer().value().fullName()); + //fall back + if(!allowfallback)return ""; + if(!invoiceaddress().isNull() && invoiceaddress().value().isValid()) + return invoiceaddress().value().fullAddress(customer().value().fullName()); + //give up + return ""; +} diff --git a/src/wext/order.h b/src/wext/order.h new file mode 100644 index 0000000..af0b3b9 --- /dev/null +++ b/src/wext/order.h @@ -0,0 +1,94 @@ +// +// C++ Interface: unabstract +// +// Description: removes abstract flag from classes that only need to be abstract in PHP +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOORDER_H +#define MAGICSMOKE_MOORDER_H + +#include "MOOrderAbstract" +#include "misc.h" + +#include + +/**this class represents a complete order*/ +class MOOrder:public MOOrderAbstract +{ + 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();} + + /**returns whether this order is a reservation*/ + bool isReservation()const{return status()==Reserved;} + + /**returns whether the tickets of this order have already been shipped*/ + bool isSent()const; + + /**returns the status of the order as localized string*/ + QString orderStatusString()const{return OrderState2locstr(status());} + + /**returns how much money needs to be paid in total for this order, in cents*/ + QString totalPriceString()const{return cent2str(totalprice());} + + /**returns how much money has already been paid for this order, in cents*/ + QString amountPaidString()const{return cent2str(amountpaid());} + + /**returns whether there is anything left to pay*/ + bool needsPayment()const; + + /**returns whether there is anything left to refund*/ + bool needsRefund()const; + + /**returns how much there is to be paid, in cents*/ + int amountToPay()const; + + /**returns how much there is to be paid, as localized string*/ + QString amountToPayStr()const{return cent2str(amountToPay());} + + /**returns how much there is to be refunded, in cents*/ + int amountToRefund()const; + + /**returns how much there is to be refunded, as localized string*/ + QString amountToRefundStr()const{return cent2str(amountToRefund());} + + /**return the order date+time*/ + TimeStamp orderDateTime(); + + /**returns the order date+time as string*/ + QString orderDateTimeStr(); + + /**returns the order date only as string*/ + QString orderDateStr(); + + /**returns the shipping date+time*/ + TimeStamp sentDateTime(); + + /**returns the shipping date+time as string*/ + QString sentDateTimeStr(); + + /**returns the shipping date only as string*/ + QString sentDateStr(); + + /**returns the full invoice address, or delivery address if no explicit invoice address was given and allowfallback==true*/ + QString fullInvoiceAddress(bool allowfallback=true)const; + /**returns the full delivery address, or invoice address if no explicit delivery address was given and allowfallback==true*/ + QString fullDeliveryAddress(bool allowfallback=true)const; +}; + +#endif diff --git a/src/wext/orderinfo.h b/src/wext/orderinfo.h new file mode 100644 index 0000000..6b658d5 --- /dev/null +++ b/src/wext/orderinfo.h @@ -0,0 +1,36 @@ +// +// C++ Interface: unabstract +// +// Description: removes abstract flag from classes that only need to be abstract in PHP +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOORDERI_H +#define MAGICSMOKE_MOORDERI_H + +#include "MOOrderInfoAbstract" +#include "misc.h" + +class MOOrderInfo:public MOOrderInfoAbstract +{ + 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());} + + bool needsPayment()const{return amountpaid()totalprice();} + bool isSent()const{return status()==Sent;} + bool isReservation()const{return status()==Reserved;} + bool isCancelled()const{return status()==Cancelled;} +}; + +#endif \ No newline at end of file diff --git a/src/wext/role.h b/src/wext/role.h new file mode 100644 index 0000000..6c5e012 --- /dev/null +++ b/src/wext/role.h @@ -0,0 +1,19 @@ +// +// C++ Interface: unabstract +// +// Description: removes abstract flag from classes that only need to be abstract in PHP +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOROLE_H +#define MAGICSMOKE_MOROLE_H + +#include "MORoleAbstract" +typedef MORoleAbstract MORole; + +#endif \ No newline at end of file diff --git a/src/wext/ticket.cpp b/src/wext/ticket.cpp new file mode 100644 index 0000000..1bf75e3 --- /dev/null +++ b/src/wext/ticket.cpp @@ -0,0 +1,38 @@ +// +// C++ Implementation: MOTicket +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOTicket" +#include "msinterface.h" + +MOEvent MOTicket::event()const +{ + //if I am valid... + if(!ticketid().isNull() && !eventid().isNull()) + //...and the event is not... + if(m_event.eventid().isNull()){ + //...then retrieve the event + MTGetEvent ge=req->queryGetEvent(eventid()); + if(!ge.hasError()) + m_event=ge.getevent(); + } + //return whatever we have by now + return m_event; +} + +QString MOTicket::priceCategoryName()const +{ + return pricecategory().value().name(); +} +QString MOTicket::priceCategoryShort()const +{ + return pricecategory().value().abbreviation(); +} diff --git a/src/wext/ticket.h b/src/wext/ticket.h new file mode 100644 index 0000000..34ab3bd --- /dev/null +++ b/src/wext/ticket.h @@ -0,0 +1,45 @@ +// +// C++ Interface: MOTicket +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOTICKET_H +#define MAGICSMOKE_MOTICKET_H + +#include "MOTicketAbstract" +#include "misc.h" +#include "MOEvent" + +class MOTicket:public MOTicketAbstract +{ + WOBJECT(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;} + + /**returns the price as string*/ + QString priceString()const{return cent2str(price());} + + /**returns the ticket status as localized string*/ + QString statusString()const{return TicketState2locstr(status());} + + /**returns the full price category name*/ + QString priceCategoryName()const; + /**returns the abbreviation for the price category*/ + QString priceCategoryShort()const; + + /**returns the event that this ticket belongs to - does a roundtrip to the database the first time this is called!*/ + MOEvent event()const; + private: + //this must be mutable, since event() is semantically and technically const + mutable MOEvent m_event; +}; + +#endif diff --git a/src/wext/transaction.cpp b/src/wext/transaction.cpp new file mode 100644 index 0000000..80da582 --- /dev/null +++ b/src/wext/transaction.cpp @@ -0,0 +1,26 @@ +// +// C++ Implementation: MTransaction +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "MTransaction" +#include "waitcursor.h" + +QByteArray MTransaction::executeQuery(QString hreq,QByteArray data) +{ + //show the user we are waiting + WaitCursor wc; + //call parent + return WTransaction::executeQuery(hreq,data); +} + +MTransaction::MTransaction(QString iface):WTransaction(iface){} +MTransaction::MTransaction(const WTransaction&t):WTransaction(t){} +MTransaction::MTransaction(const MTransaction&t):WTransaction(t){} diff --git a/src/wext/transaction.h b/src/wext/transaction.h new file mode 100644 index 0000000..fd244c9 --- /dev/null +++ b/src/wext/transaction.h @@ -0,0 +1,30 @@ +// +// C++ Interface: MTransaction +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef MSMOKE_MTRANSACTION_H +#define MSMOKE_MTRANSACTION_H + +#include + +class MTransaction:public WTransaction{ + protected: + /**internal: construct the transaction*/ + MTransaction(QString iface=QString()); + /**internal: copy the transaction*/ + MTransaction(const WTransaction&); + /**internal: copy the transaction*/ + MTransaction(const MTransaction&); + /**internal: extend executeQuery to show a wait cursor*/ + QByteArray executeQuery(QString,QByteArray); +}; + +#endif diff --git a/src/wext/voucher.h b/src/wext/voucher.h new file mode 100644 index 0000000..620684d --- /dev/null +++ b/src/wext/voucher.h @@ -0,0 +1,33 @@ +// +// C++ Interface: MOVoucher +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2009 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_MOVOUCHER_H +#define MAGICSMOKE_MOVOUCHER_H + +#include "MOVoucherAbstract" +#include "misc.h" + +class MOVoucher:public MOVoucherAbstract +{ + WOBJECT(MOVoucher); + public: + /**returns whether this is a valid voucher object (ie. it has a voucher ID)*/ + bool isValid()const{return !voucherid().isNull();} + /**returns the current value as string*/ + QString valueString()const{return cent2str(value());} + /**returns the status of the voucher as string*/ + QString statusString()const{return VoucherState2locstr(status());} + /**returns the price as string*/ + QString priceString()const{return cent2str(price());} +}; + +#endif diff --git a/src/wext/wext.pri b/src/wext/wext.pri index 910210d..2e5b9a3 100644 --- a/src/wext/wext.pri +++ b/src/wext/wext.pri @@ -1,21 +1,21 @@ INCLUDEPATH += ./wext HEADERS += \ - wext/MOCustomerInfo.h \ - wext/MOOrder.h \ - wext/MOOrderInfo.h \ - wext/MORole.h \ - wext/MOTicket.h \ - wext/MOAddress.h \ - wext/MOEvent.h \ - wext/MOCustomer.h \ - wext/MTransaction.h + wext/customerinfo.h \ + wext/order.h \ + wext/orderinfo.h \ + wext/role.h \ + wext/ticket.h \ + wext/address.h \ + wext/event.h \ + wext/customer.h \ + wext/transaction.h SOURCES += \ - wext/MOCustomerInfo.cpp \ - wext/MOOrder.cpp \ - wext/MOTicket.cpp \ - wext/MOAddress.cpp \ - wext/MOEvent.cpp \ - wext/MOCustomer.cpp \ - wext/MTransaction.cpp + wext/customerinfo.cpp \ + wext/order.cpp \ + wext/ticket.cpp \ + wext/address.cpp \ + wext/event.cpp \ + wext/customer.cpp \ + wext/transaction.cpp -- 1.7.2.5