From: konrad Date: Mon, 28 Dec 2009 14:19:31 +0000 (+0000) Subject: move remaining helper classes to iface and dialogs X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=567e82c7d6beae9975f17bd2df5196cf224f8e22;p=web%2Fkonrad%2Fsmoke.git move remaining helper classes to iface and dialogs git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@363 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/README b/src/README index 473d435..3a6b138 100644 --- a/src/README +++ b/src/README @@ -4,7 +4,7 @@ README for src Directory The following (sub-)directories exist: . - main build directory, contains main widget and some global classes + main build directory, contains main application stub wbase Web object base classes. diff --git a/src/customer.cpp b/src/dialogs/customerdlg.cpp similarity index 89% rename from src/customer.cpp rename to src/dialogs/customerdlg.cpp index aed971b..c15affa 100644 --- a/src/customer.cpp +++ b/src/dialogs/customerdlg.cpp @@ -10,7 +10,7 @@ // // -#include "customer.h" +#include "customerdlg.h" #include "msinterface.h" #include @@ -30,42 +30,6 @@ #define req (MSInterface::instance()) -MCustomer::MCustomer(qint64 i) -{ - MTGetCustomer gc=req->queryGetCustomer(i); - if(gc.stage()==gc.Success) - operator=(gc.getcustomer().value()); -} - -bool MCustomer::isValid() -{ - //TODO: reconsider isValid - return id()>-1; -} - -QString MCustomer::address(int i) -{ - if(i<0)return ""; - QListadrs=addresses(); - if(i>=adrs.size())return ""; - QString ret; - MOAddress adr=adrs[i]; - if(adr.name().isNull())ret=name(); - else ret=adr.name().value(); - ret+="\n"; - if(!adr.company().isNull())ret+=adr.company().value()+"\n"; - if(!adr.addr1().isNull())ret+=adr.addr1().value()+"\n"; - if(!adr.addr2().isNull())ret+=adr.addr2().value()+"\n"; - if(!adr.city().isNull())ret+=adr.city().value()+"\n"; - if(!adr.state().isNull())ret+=adr.state().value()+"\n"; - if(!adr.zipcode().isNull())ret+=adr.zipcode().value()+"\n"; - if(!adr.country().isNull())ret+=adr.country().value().name(); - return ret; -} - - -/*********************************************************/ - MCustomerListDialog::MCustomerListDialog(QWidget*par,bool isselect,qint64 presel) :QDialog(par) { diff --git a/src/customer.h b/src/dialogs/customerdlg.h similarity index 68% rename from src/customer.h rename to src/dialogs/customerdlg.h index 3653381..cc242f2 100644 --- a/src/customer.h +++ b/src/dialogs/customerdlg.h @@ -10,38 +10,14 @@ // // -#ifndef MAGICSMOKE_CUSTOMER_H -#define MAGICSMOKE_CUSTOMER_H +#ifndef MAGICSMOKE_CUSTOMERDLG_H +#define MAGICSMOKE_CUSTOMERDLG_H #include #include #include -#include "MOCustomerShort.h" -#include "MOCustomer.h" - -/**this class expands on MOCustomer to add some convenience methods*/ -class MCustomer:public MOCustomer -{ - public: - /**creates an empty/invalid customer*/ - MCustomer(){} - /**fetches customer from the Database*/ - MCustomer(qint64); - /**copies a customer*/ - MCustomer(const MCustomer&c):MOCustomer(c){} - MCustomer(const MOCustomer&c):MOCustomer(c){} - - /**copies a customer*/ - MCustomer& operator=(const MCustomer&c){MOCustomer::operator=(c);return *this;} - MCustomer& operator=(const MOCustomer&c){MOCustomer::operator=(c);return *this;} - - /**returns whether the customer is valid*/ - bool isValid(); - - /**returns the address of the customer*/ - QString address(int i=0); -}; +#include "customer.h" class QListView; class QStandardItemModel; diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index b18df66..c5377a2 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -5,6 +5,8 @@ HEADERS += \ dialogs/orderwin.h \ dialogs/moneylog.h \ dialogs/login.h \ + dialogs/shipping.h \ + dialogs/customerdlg.h \ dialogs/passwdchg.h SOURCES += \ @@ -14,6 +16,8 @@ SOURCES += \ dialogs/orderwin.cpp \ dialogs/moneylog.cpp \ dialogs/login.cpp \ + dialogs/shipping.cpp \ + dialogs/customerdlg.cpp \ dialogs/passwdchg.cpp INCLUDEPATH += ./dialogs \ No newline at end of file diff --git a/src/shipping.cpp b/src/dialogs/shipping.cpp similarity index 100% rename from src/shipping.cpp rename to src/dialogs/shipping.cpp diff --git a/src/shipping.h b/src/dialogs/shipping.h similarity index 100% rename from src/shipping.h rename to src/dialogs/shipping.h diff --git a/src/iface/customer.cpp b/src/iface/customer.cpp new file mode 100644 index 0000000..281518e --- /dev/null +++ b/src/iface/customer.cpp @@ -0,0 +1,49 @@ +// +// C++ Implementation: customer +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2008 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "customer.h" +#include "msinterface.h" + +#define req (MSInterface::instance()) + +MCustomer::MCustomer(qint64 i) +{ + MTGetCustomer gc=req->queryGetCustomer(i); + if(gc.stage()==gc.Success) + operator=(gc.getcustomer().value()); +} + +bool MCustomer::isValid() +{ + //TODO: reconsider isValid + return id()>-1; +} + +QString MCustomer::address(int i) +{ + if(i<0)return ""; + QListadrs=addresses(); + if(i>=adrs.size())return ""; + QString ret; + MOAddress adr=adrs[i]; + if(adr.name().isNull())ret=name(); + else ret=adr.name().value(); + ret+="\n"; + if(!adr.company().isNull())ret+=adr.company().value()+"\n"; + if(!adr.addr1().isNull())ret+=adr.addr1().value()+"\n"; + if(!adr.addr2().isNull())ret+=adr.addr2().value()+"\n"; + if(!adr.city().isNull())ret+=adr.city().value()+"\n"; + if(!adr.state().isNull())ret+=adr.state().value()+"\n"; + if(!adr.zipcode().isNull())ret+=adr.zipcode().value()+"\n"; + if(!adr.country().isNull())ret+=adr.country().value().name(); + return ret; +} diff --git a/src/iface/customer.h b/src/iface/customer.h new file mode 100644 index 0000000..55c7589 --- /dev/null +++ b/src/iface/customer.h @@ -0,0 +1,44 @@ +// +// C++ Interface: customer +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2008 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_CUSTOMER_H +#define MAGICSMOKE_CUSTOMER_H + +#include + +#include "MOCustomerShort.h" +#include "MOCustomer.h" + +/**this class expands on MOCustomer to add some convenience methods*/ +class MCustomer:public MOCustomer +{ + public: + /**creates an empty/invalid customer*/ + MCustomer(){} + /**fetches customer from the Database*/ + MCustomer(qint64); + /**copies a customer*/ + MCustomer(const MCustomer&c):MOCustomer(c){} + MCustomer(const MOCustomer&c):MOCustomer(c){} + + /**copies a customer*/ + MCustomer& operator=(const MCustomer&c){MOCustomer::operator=(c);return *this;} + MCustomer& operator=(const MOCustomer&c){MOCustomer::operator=(c);return *this;} + + /**returns whether the customer is valid*/ + bool isValid(); + + /**returns the address of the customer*/ + QString address(int i=0); +}; + +#endif diff --git a/src/event.cpp b/src/iface/event.cpp similarity index 100% rename from src/event.cpp rename to src/iface/event.cpp diff --git a/src/event.h b/src/iface/event.h similarity index 100% rename from src/event.h rename to src/iface/event.h diff --git a/src/iface/iface.pri b/src/iface/iface.pri index ac98ba4..f38a1b1 100644 --- a/src/iface/iface.pri +++ b/src/iface/iface.pri @@ -1,10 +1,16 @@ HEADERS += \ iface/msinterface.h \ - iface/sslexception.h + iface/event.h \ + iface/order.h \ + iface/sslexception.h \ + iface/customer.h SOURCES += \ iface/msinterface.cpp \ - iface/sslexception.cpp + iface/event.cpp \ + iface/order.cpp \ + iface/sslexception.cpp \ + iface/customer.cpp INCLUDEPATH += ./iface \ No newline at end of file diff --git a/src/order.cpp b/src/iface/order.cpp similarity index 100% rename from src/order.cpp rename to src/iface/order.cpp diff --git a/src/order.h b/src/iface/order.h similarity index 100% rename from src/order.h rename to src/iface/order.h diff --git a/src/smoke.pro b/src/smoke.pro index f487a77..1200bd8 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -20,19 +20,8 @@ MOC_DIR = .ctmp RCC_DIR = .ctmp -SOURCES = \ - main.cpp \ - event.cpp \ - order.cpp \ - shipping.cpp \ - customer.cpp - -HEADERS = \ - main.h \ - event.h \ - order.h \ - shipping.h \ - customer.h +SOURCES = main.cpp +HEADERS = main.h RESOURCES += images/files.qrc