make entrance usable
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 21 Dec 2008 16:10:29 +0000 (16:10 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 21 Dec 2008 16:10:29 +0000 (16:10 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@222 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/overview.cpp
src/overview.h

index 8b32fac..d323dcc 100644 (file)
@@ -250,6 +250,10 @@ MOverview::MOverview(MWebRequest*mw,QString pk)
        //Entrance Control Tab
        tab->addTab(entrancetab=new QWidget,tr("Entrance"));
        entrancetab->setLayout(vl=new QVBoxLayout);
+       vl->addWidget(entranceevent=new QComboBox,0);
+       entranceevent->setEditable(false);
+       vl->addSpacing(30);
+       vl->addWidget(new QLabel(tr("Enter or scan Ticket-ID:")),0);
        vl->addWidget(entrancescan=new QLineEdit,0);
        connect(entrancescan,SIGNAL(editingFinished()),this,SLOT(entranceValidate()));
        vl->addWidget(entrancelabel=new QLabel("  "),10);
@@ -1024,6 +1028,21 @@ void MOverview::tabChanged()
 {
        QWidget*w=tab->currentWidget();
        if(w==entrancetab){
+               //fill combobox from eventmodel
+               int ci=entranceevent->currentIndex();
+               int cev=-1;
+               if(ci>=0)cev=entranceevent->itemData(ci).toInt();
+               ci=-1;
+               entranceevent->clear();
+               for(int i=0;i<eventmodel->rowCount();i++){
+                       QString ev=eventmodel->data(eventmodel->index(i,0)).toString()+" "+
+                        eventmodel->data(eventmodel->index(i,1)).toString();
+                       int eid=eventmodel->data(eventmodel->index(i,0),Qt::UserRole).toInt();
+                       entranceevent->addItem(ev,eid);
+                       if(eid==cev)ci=i;
+               }
+               if(ci>=0)entranceevent->setCurrentIndex(ci);
+               //set focus on scanner
                entrancescan->setFocus(Qt::OtherFocusReason);
                entrancescan->setText("");
        }
@@ -1031,6 +1050,10 @@ void MOverview::tabChanged()
 
 void MOverview::entranceValidate()
 {
+       //get event ID
+       int ci=entranceevent->currentIndex();
+       if(ci<0)return;
+       int cev=entranceevent->itemData(ci).toInt();
        //check content
        QString tid=entrancescan->text().trimmed();
        //avoid spurious events
@@ -1052,6 +1075,10 @@ void MOverview::entranceValidate()
                entrancelabel->setText(tr("Ticket \"%1\" Not Valid").arg(tid));
                pal.setColor(rl,Qt::red);
        }else
+       if(tick.eventID()!=cev){
+               entrancelabel->setText(tr("Ticket \"%1\" is not for this event.").arg(tid));
+               pal.setColor(rl,Qt::red);
+       }else
        if(tick.status()==MTicket::Used){
                entrancelabel->setText(tr("Ticket \"%1\" has already been used").arg(tid));
                pal.setColor(rl,Qt::magenta);
index bda83a5..d7279e4 100644 (file)
@@ -167,7 +167,7 @@ class MOverview:public QMainWindow
                QPushButton*thishostbutton;
                QLabel*cartcustomer,*entrancelabel;
                QTextEdit *cartaddr,*cartcomment;
-               QComboBox*ordermode,*cartship;
+               QComboBox*ordermode,*cartship,*entranceevent;
                QLineEdit*entrancescan;
                //event list
                QAction*showoldevents;