From: konrad Date: Mon, 17 Nov 2008 12:39:24 +0000 (+0000) Subject: automatic update of display X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=ac728d1ecb437386ddf773f9a210897c1342d44e;p=web%2Fkonrad%2Fsmoke.git automatic update of display git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@187 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/overview.cpp b/src/overview.cpp index f449073..4f5a946 100644 --- a/src/overview.cpp +++ b/src/overview.cpp @@ -18,6 +18,7 @@ #include "orderwin.h" #include +#include #include #include #include @@ -48,9 +49,13 @@ MOverview::MOverview(MWebRequest*mw,QString pk) { + profilekey=pk; req=mw; setAttribute(Qt::WA_DeleteOnClose); setWindowTitle("MagicSmoke: "+QSettings().value("profiles/"+pk+"/name").toString()); + rtimer.setInterval(QSettings().value("profiles/"+pk+"/refresh",300).toInt()*1000); + rtimer.start(); + connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData())); //menu QMenuBar*mb=menuBar(); @@ -80,6 +85,9 @@ MOverview::MOverview(MWebRequest*mw,QString pk) m=mb->addMenu(tr("&Misc")); m->addAction(tr("&Return ticket..."),this,SLOT(ticketReturn())); + m=mb->addMenu(tr("C&onfigure")); + m->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); + m=mb->addMenu(tr("&Admin")); m->setEnabled(req->hasRole("_admin")); m->addAction(tr("&Schedule Backup...")); @@ -1142,6 +1150,61 @@ void MOverview::ticketReturn() if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8())); } +void MOverview::refreshData() +{ + QSettings set; + set.beginGroup("profiles/"+profilekey); + if(set.value("refreshEvents",false).toBool() && req->hasRole("geteventlist")) + updateEvents(); + if(set.value("refreshUsers",false).toBool() && req->hasRole("getusers")) + updateUsers(); + if(set.value("refreshHosts",false).toBool() && req->hasRole("gethosts")) + updateHosts(); +} + +void MOverview::setRefresh() +{ + QSettings set; + set.beginGroup("profiles/"+profilekey); + //dialog + QDialog d; + d.setWindowTitle(tr("Refresh Settings")); + QVBoxLayout*vl; + QHBoxLayout*hl; + d.setLayout(vl=new QVBoxLayout); + vl->addLayout(hl=new QHBoxLayout); + hl->addWidget(new QLabel(tr("Refresh Rate (minutes):")),1); + QSpinBox*rate; + hl->addWidget(rate=new QSpinBox,0); + rate->setRange(1,999); + rate->setValue(set.value("refresh",300).toInt()/60); + QCheckBox *rev,*rus,*rho; + vl->addWidget(rev=new QCheckBox(tr("refresh &event list"))); + rev->setChecked(set.value("refreshEvents",false).toBool()); + vl->addWidget(rus=new QCheckBox(tr("refresh &user list"))); + rus->setChecked(set.value("refreshUsers",false).toBool()); + vl->addWidget(rho=new QCheckBox(tr("refresh &host list"))); + rho->setChecked(set.value("refreshHosts",false).toBool()); + vl->addSpacing(15); + vl->addStretch(10); + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(10); + 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())); + if(d.exec()!=QDialog::Accepted)return; + //write settings + set.setValue("refreshEvents",rev->isChecked()); + set.setValue("refreshUsers",rus->isChecked()); + set.setValue("refreshHosts",rho->isChecked()); + set.setValue("refresh",rate->value()*60); + //reset timer + rtimer.stop(); + rtimer.setInterval(rate->value()*60000); + rtimer.start(); +} /**********************************************/ diff --git a/src/overview.h b/src/overview.h index 2a747a6..4eae8a2 100644 --- a/src/overview.h +++ b/src/overview.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "customer.h" @@ -129,6 +130,11 @@ class MOverview:public QMainWindow /**find/select orders by customer*/ void orderByCustomer(); + /**refresh data that we can refresh*/ + void refreshData(); + /**set refresh timeout*/ + void setRefresh(); + private: //my session object QPointerreq; @@ -149,6 +155,8 @@ class MOverview:public QMainWindow //barcode cache QString lastbarcode; QDateTime lastbcscan; + //refresh timers + QTimer rtimer; }; /**Helper dialog for changing passwords*/