From: konrad Date: Mon, 3 Jan 2011 08:00:50 +0000 (+0000) Subject: configurable entrance X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=ebed30f1a39490f35b4bc333944be8fc704ad958;p=web%2Fkonrad%2Fsmoke.git configurable entrance git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@703 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/mwin/entrancetab.cpp b/src/mwin/entrancetab.cpp index 1c978cb..f8c3e0a 100644 --- a/src/mwin/entrancetab.cpp +++ b/src/mwin/entrancetab.cpp @@ -21,11 +21,14 @@ #include #include #include +#include #include #include #include #include #include +#include +#include MEntranceTab::MEntranceTab(QString pk) { @@ -82,6 +85,14 @@ 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 @@ -116,7 +127,7 @@ void MEntranceTab::entranceValidate() 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; @@ -172,22 +183,34 @@ void MEntranceTab::entranceValidate() orderbtn->setEnabled(false); } -void MEntranceTab::initialize() +static bool eventIsEarlier(const MOEvent&e1,const MOEvent&e2) +{ + return e1.start()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; QListevlst=gee.getevents(); + qSort(evlst.begin(),evlst.end(),eventIsEarlier); //fill combobox from eventmodel entranceevent->clear(); for(int i=0;isetText("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()); +} diff --git a/src/mwin/entrancetab.h b/src/mwin/entrancetab.h index 3b15279..013c70d 100644 --- a/src/mwin/entrancetab.h +++ b/src/mwin/entrancetab.h @@ -16,6 +16,7 @@ #include #include +class QMenuBar; class QComboBox; class QLabel; class QLineEdit; @@ -31,9 +32,13 @@ class MEntranceTab:public QWidget public: /**construct the window with web-request/session handler and QSettings-key for current profile*/ MEntranceTab(QString); + + ///creates a menu for the entrance tab + QMenuBar*menu()const; public slots: - /**initializes the tab*/ - void initialize(); + /**initializes the tab + \param force if true an update is forced, if false the update is only done if the last update has been more than an hour in the past*/ + void initialize(bool force=true); private slots: /**react on entry in Entrance tab*/ void entranceValidate(); @@ -43,6 +48,8 @@ class MEntranceTab:public QWidget void openOrder(); /**resets the amount labels*/ void resetAmounts(); + /**configure the entrance*/ + void configure(); private: friend class METUtility; //the profile associated with this session diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 19224cf..971807f 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -134,7 +134,8 @@ MOverview::MOverview(QString pk) connect(ordertab,SIGNAL(eventModel()), eventtab,SLOT(eventModel()), Qt::DirectConnection); //Entrance Control Tab - addTab(entrancetab=new MEntranceTab(pk),tr("Entrance")); + entrancetab=new MEntranceTab(pk); + addTab(entrancetab,tr("Entrance"),entrancetab->menu()); //unused tab disabling... @@ -217,7 +218,7 @@ void MOverview::tabChanged(int idx) MTabWin::tabChanged(idx); QWidget*w=currentTab(); if(w==entrancetab){ - entrancetab->initialize(); + entrancetab->initialize(false); } }