#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
+#include <QMenuBar>
#include <QMessageBox>
#include <QPushButton>
#include <QSettings>
#include <QStandardItemModel>
#include <QTimer>
+#include <QFormLayout>
+#include <QSpinBox>
MEntranceTab::MEntranceTab(QString pk)
{
tm->start(10000);
}
+QMenuBar* MEntranceTab::menu() const
+{
+ QMenuBar *mb=new QMenuBar;
+ QMenu*m=mb->addMenu("&Entrance");
+ m->addAction("&Configure...",this,SLOT(configure()));
+ m->addAction("&Recheck events",this,SLOT(initialize()));
+ return mb;
+}
/**while the object lives the tab handed to it is disabled, it automatically reenables when the disable object dies; it also refocuses the scan line*/
class METUtility
METUtility mdis(this);
//avoid double scans
QDateTime now=QDateTime::currentDateTime();
- if(tid==lastbarcode && lastbcscan.addSecs(20)>=now)
+ if(tid==lastbarcode && lastbcscan.addSecs(10)>=now)
return;
lastbarcode=tid;
lastbcscan=now;
orderbtn->setEnabled(false);
}
-void MEntranceTab::initialize()
+static bool eventIsEarlier(const MOEvent&e1,const MOEvent&e2)
+{
+ return e1.start()<e2.start();
+}
+
+void MEntranceTab::initialize(bool force)
{
METUtility mdis(this);
//check whether an update should be forced
QDateTime now=QDateTime::currentDateTime();
- if(lasteventupdate.addSecs(3600)>now)return;
+ if(!force)
+ if(lasteventupdate.addSecs(3600)>now)return;
//get currently displayed event
int ci=entranceevent->currentIndex();
int cev=-1;
if(ci>=0)cev=entranceevent->itemData(ci).toInt();
ci=-1;
//get event list
- MTGetEntranceEvents gee=MTGetEntranceEvents::query();
+ QSettings set;
+ set.beginGroup("profiles/"+profilekey+"/entrance");
+ MTGetEntranceEvents gee=MTGetEntranceEvents::query(
+ set.value("maxstart",24).toInt()*3600,
+ set.value("maxend",0).toInt()*3600
+ );
if(gee.hasError())return;
lasteventupdate=now;
QList<MOEvent>evlst=gee.getevents();
+ qSort(evlst.begin(),evlst.end(),eventIsEarlier);
//fill combobox from eventmodel
entranceevent->clear();
for(int i=0;i<evlst.size();i++){
amused->setText("0");
amopen->setText("0");
// amreserved->setText("0");
-}
\ No newline at end of file
+}
+
+void MEntranceTab::configure()
+{
+ QSettings set;
+ set.beginGroup("profiles/"+profilekey+"/entrance");
+ QDialog d(this);
+ d.setWindowTitle(tr("Entrance Configuration"));
+ QVBoxLayout*vl;
+ d.setLayout(vl=new QVBoxLayout);
+ QFormLayout*fl;
+ vl->addLayout(fl=new QFormLayout,1);
+ QSpinBox*maxstart,*maxend;
+ fl->addRow(tr("Show events that start within hours:"),maxstart=new QSpinBox);
+ maxstart->setRange(0,10000);
+ maxstart->setValue(set.value("maxstart",24).toInt());
+ fl->addRow(tr("Show events a maximum of hours after they end:"),maxend=new QSpinBox);
+ maxend->setRange(0,1000);
+ maxend->setValue(set.value("maxend",0).toInt());
+ fl->addRow(tr("Use Cache:"),new QLabel);
+ fl->addRow(tr("Cache update interval:"),new QLabel);
+ QHBoxLayout*hl;
+ vl->addLayout(hl=new QHBoxLayout,0);
+ hl->addStretch(1);
+ QPushButton*p;
+ hl->addWidget(p=new QPushButton(tr("Ok")));
+ connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
+ hl->addWidget(p=new QPushButton(tr("Cancel")));
+ connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
+ //show
+ if(d.exec()!=QDialog::Accepted)return;
+ //save
+ set.setValue("maxstart",maxstart->value());
+ set.setValue("maxend",maxend->value());
+}