show price category in event summary
authorKonrad Rosenbaum <konrad@silmor.de>
Mon, 7 Oct 2013 18:53:38 +0000 (20:53 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Mon, 7 Oct 2013 18:53:38 +0000 (20:53 +0200)
src/dialogs/eventsummary.cpp
src/dialogs/eventsummary.h

index bed6b5d..707c88d 100644 (file)
@@ -68,15 +68,16 @@ MEventSummary::MEventSummary(QWidget*par,qint64 eid)
        tab->addTab(table=new QTableView,tr("Tickets"));
        table->setEditTriggers(QAbstractItemView::NoEditTriggers);
        table->setModel(model=new QStandardItemModel(this));
-       model->insertColumns(0,4);
+       model->insertColumns(0,5);
        model->insertRows(0,tickets.size());
-       model->setHorizontalHeaderLabels(QStringList()<<tr("Price")<<tr("Bought")<<tr("Used")<<tr("Unused"));
+       model->setHorizontalHeaderLabels(QStringList() <<tr("Price") <<tr("Category") <<tr("Bought") <<tr("Used") <<tr("Unused"));
        for(int i=0;i<tickets.size();i++){
                Tickets tc=tickets[i];
                model->setData(model->index(i,0),cent2str(tc.price));
-               model->setData(model->index(i,1),tc.bought);
-               model->setData(model->index(i,2),tc.used);
-               model->setData(model->index(i,3),tc.unused);
+                model->setData(model->index(i,1),tc.category);
+                model->setData(model->index(i,2),tc.bought);
+               model->setData(model->index(i,3),tc.used);
+               model->setData(model->index(i,4),tc.unused);
        }
        table->resizeColumnsToContents();
        
@@ -126,7 +127,7 @@ void MEventSummary::getSummaryData()
        QList<MOOrder>ord=ges.getorders();
        
        nreserved=ncancelled=ntotaltickets=ntotalmoney=0;
-       QMap<int,Tickets>maptickets;
+       QMap<QPair<int,QString>,Tickets>maptickets;
 
        //parse orders
        for(int i=0;i<ord.size();i++){
@@ -140,18 +141,20 @@ void MEventSummary::getSummaryData()
                        if(ticks[j].eventid()!=eventid)
                                continue;
                        //count accumulated prices
-                       int p=ticks[j].price();
-                       if(!maptickets.contains(p))
-                               maptickets.insert(p,Tickets(p));
+                       const int p=ticks[j].price();
+                        const QString c=ticks[j].priceCategoryName();
+                        const QPair<int,QString>pkey(p,c);
+                       if(!maptickets.contains(pkey))
+                               maptickets.insert(pkey,Tickets(p,c));
                        //count up
                        if(ticks[j].status().value()&MOTicket::MaskBlock){
                                ntotaltickets++;
                                ntotalmoney+=ticks[j].price();
-                               maptickets[p].bought++;
+                               maptickets[pkey].bought++;
                                if(ticks[j].status()==MOTicket::Used)
-                                       maptickets[p].used++;
+                                       maptickets[pkey].used++;
                                else
-                                       maptickets[p].unused++;
+                                       maptickets[pkey].unused++;
                        }
                        if(ticks[j].status()==MOTicket::Reserved)
                                nreserved++;
index 06e7191..6104550 100644 (file)
@@ -54,8 +54,10 @@ class MEventSummary:public QDialog
                MOEvent event;
                int nreserved,ncancelled,ntotaltickets,ntotalmoney;
                struct Tickets{
-                       Tickets(int p=0){price=p;bought=used=unused=0;}
-                       int price,bought,used,unused;
+                        Tickets(){}
+                       Tickets(int p,QString c=QString()):price(p),category(c){}
+                       int price=0,bought=0,used=0,unused=0;
+                        QString category;
                };
                QList<Tickets>tickets;
                struct Comment{