better screen update
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 31 Dec 2009 12:03:16 +0000 (12:03 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Thu, 31 Dec 2009 12:03:16 +0000 (12:03 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@382 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/dialogs/orderwin.cpp
src/dialogs/orderwin.h

index 8cd7c5f..30b03ba 100644 (file)
@@ -106,35 +106,35 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o)
        QLabel*lab;
        gl->addWidget(new QLabel(tr("Order ID:")),rw,0);
        gl->addWidget(m_orderid=new QLabel(QString::number(m_order.orderid())),rw,1);
+       gl->addWidget(new QLabel(tr("Order State:")),++rw,0);
+       gl->addWidget(m_state=new QLabel(),rw,1);
        gl->addWidget(new QLabel(tr("Order Date:")),++rw,0);
-       gl->addWidget(m_orderdate=new QLabel(m_order.orderDateTimeStr()),rw,1);
+       gl->addWidget(m_orderdate=new QLabel(),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Date:")),++rw,0);
-       gl->addWidget(m_sentdate=new QLabel(m_order.sentDateTimeStr()),rw,1);
+       gl->addWidget(m_sentdate=new QLabel(),rw,1);
        gl->addWidget(new QLabel(tr("Customer:")),++rw,0);
-       gl->addWidget(new QLabel(m_order.customer().value().fullName()),rw,1);
+       gl->addWidget(m_custname=new QLabel(),rw,1);
        gl->addWidget(lab=new QLabel(tr("Delivery Address:")),++rw,0);
        lab->setAlignment(Qt::AlignTop);
-       gl->addWidget(lab=new QLabel(m_order.fullDeliveryAddress(false)),rw,1);
+       gl->addWidget(m_daddr=lab=new QLabel(),rw,1);
        lab->setWordWrap(true);lab->setFrameShape(lab->Box);lab->setFrameShadow(lab->Raised);
        gl->addWidget(lab=new QLabel(tr("Invoice Address:")),++rw,0);
        lab->setAlignment(Qt::AlignTop);
-       gl->addWidget(lab=new QLabel(m_order.fullInvoiceAddress(false)),rw,1);
+       gl->addWidget(m_iaddr=lab=new QLabel(),rw,1);
        lab->setWordWrap(true);lab->setFrameShape(lab->Box);lab->setFrameShadow(lab->Raised);
-       gl->addWidget(new QLabel(tr("Sold by:")),++rw,0);
-       gl->addWidget(new QLabel(m_order.soldby()),rw,1);
-       gl->addWidget(new QLabel(tr("Total Price:")),++rw,0);
-       gl->addWidget(m_total=new QLabel(m_order.totalPriceString()),rw,1);
-       gl->addWidget(new QLabel(tr("Already Paid:")),++rw,0);
-       gl->addWidget(m_paid=new QLabel(m_order.amountPaidString()),rw,1);
-       gl->addWidget(new QLabel(tr("Order State:")),++rw,0);
-       gl->addWidget(m_state=new QLabel(m_order.orderStatusString()),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Method:")),++rw,0);
-       gl->addWidget(m_shipmeth=new QLabel(m_order.shippingtype().value().description()),rw,1);
+       gl->addWidget(m_shipmeth=new QLabel(),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Costs:")),++rw,0);
-       gl->addWidget(m_shipprice=new QLabel(cent2str(m_order.shippingcosts())),rw,1);
-       gl->addWidget(lab=new QLabel(tr("Order Comment:")),++rw,0);
+       gl->addWidget(m_shipprice=new QLabel(),rw,1);
+       gl->addWidget(new QLabel(tr("Total Price:")),++rw,0);
+       gl->addWidget(m_total=new QLabel(),rw,1);
+       gl->addWidget(new QLabel(tr("Already Paid:")),++rw,0);
+       gl->addWidget(m_paid=new QLabel(),rw,1);
+       gl->addWidget(new QLabel(tr("Sold by:")),++rw,0);
+       gl->addWidget(m_soldby=new QLabel(),rw,1);
+       gl->addWidget(lab=new QLabel(tr("Order Comments:")),++rw,0);
        lab->setAlignment(Qt::AlignTop);
-       gl->addWidget(m_comment=lab=new QLabel(m_order.comments()),rw,1);
+       gl->addWidget(m_comment=lab=new QLabel(),rw,1);
        lab->setWordWrap(true);lab->setFrameShape(lab->Box);lab->setFrameShadow(lab->Raised);
        gl->setColumnStretch(0,0);
        gl->setColumnStretch(1,10);
@@ -145,7 +145,7 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o)
        vl->addWidget(m_table=new QTableView,10);
        m_table->setModel(m_model=new QStandardItemModel(this));
        m_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
-       updateTable();
+       updateData();
        //make sure everything is visible
        QSize vsz=m_table->maximumViewportSize();
        vsz.setWidth(vsz.width()+40);
@@ -159,8 +159,22 @@ static const int ITEM_TICKET=1;
 static const int ITEM_VOUCHER=2;
 static const int ITEM_ITEM=3;
 
-void MOrderWindow::updateTable()
+void MOrderWindow::updateData()
 {
+       //label data
+       m_orderid->setText(QString::number(m_order.orderid()));
+       m_state->setText(m_order.orderStatusString());
+       m_orderdate->setText(m_order.orderDateTimeStr());
+       m_sentdate->setText(m_order.sentDateTimeStr());
+       m_custname->setText(m_order.customer().value().fullName());
+       m_daddr->setText(m_order.fullDeliveryAddress(false));
+       m_iaddr->setText(m_order.fullInvoiceAddress(false));
+       m_shipmeth->setText(m_order.shippingtype().value().description());
+       m_shipprice->setText(cent2str(m_order.shippingcosts()));
+       m_total->setText(m_order.totalPriceString());
+       m_paid->setText(m_order.amountPaidString());
+       m_soldby->setText(m_order.soldby());
+       m_comment->setText(m_order.comments());
        //get detail data
        QList<MOTicket> tickets=m_order.tickets();
        QList<MOEvent> events;
@@ -202,7 +216,7 @@ void MOrderWindow::updateTable()
                m_model->setData(m_model->index(i+off,3),vouchers[i].statusString());
                m_model->setData(m_model->index(i+off,4),vouchers[i].priceString());
        }
-       //TODO: insert items
+       //insert items
        off+=vouchers.size();
        for(int i=0;i<items.size();i++){
                m_model->setData(m_model->index(i+off,0),ITEM_ITEM,Qt::UserRole);
@@ -215,16 +229,6 @@ void MOrderWindow::updateTable()
        m_table->resizeColumnsToContents();
 }
 
-void MOrderWindow::setChanged()
-{
-       m_changed=true;
-}
-
-bool MOrderWindow::isChanged()const
-{
-       return m_changed;
-}
-
 void MOrderWindow::itemView()
 {
        QList<MOTicket>tickets=m_order.tickets();
@@ -896,8 +900,7 @@ void MOrderWindow::shipOrder()
                        return;
                }
                m_order=ms.getorder();
-               m_state->setText(m_order.orderStatusString());
-               m_sentdate->setText(m_order.sentDateTimeStr());
+               updateData();
        }
 }
 
@@ -945,9 +948,7 @@ void MOrderWindow::changeShipping()
        }
        m_order=ocs.getorder();
        //reset display
-       m_shipmeth->setText(m_order.shippingtype().value().description());
-       m_shipprice->setText(cent2str(m_order.shippingcosts()));
-       m_total->setText(m_order.totalPriceString());
+       updateData();
 }
 
 void MOrderWindow::moneyLogOrder()
index d08819c..a82d9ba 100644 (file)
@@ -31,20 +31,14 @@ class MOrderWindow:public QMainWindow
        public:
                /**creates the order window*/
                MOrderWindow(QWidget*,const MOOrder&);
-               
-               /**returns whether the order has been changed by this window*/
-               bool isChanged()const;
        
        private:
                /**helper enum for create* methods*/
                enum Create{CreateOrder,CreateSale,CreateReservation};
                
        private slots:
-               /**internal: mark order as changed*/
-               void setChanged();
-               
-               /**internal: updates the ticket table*/
-               void updateTable();
+               /**internal: updates the labels and the ticket table*/
+               void updateData();
                
                /**internal: show the tickets as graphics*/
                void itemView();
@@ -105,7 +99,7 @@ class MOrderWindow:public QMainWindow
                MOOrder m_order;
                bool m_changed;
                QLabel *m_orderid,*m_orderdate,*m_sentdate,*m_state,*m_paid,*m_total,*m_comment,
-                *m_shipmeth,*m_shipprice;
+                *m_shipmeth,*m_shipprice,*m_daddr,*m_iaddr,*m_soldby,*m_custname;
                QTableView *m_table;
                QStandardItemModel *m_model;