#include "orderwin.h"
#include <QBoxLayout>
+#include <QCheckBox>
#include <QComboBox>
#include <QCryptographicHash>
#include <QDomDocument>
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();
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..."));
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();
+}
/**********************************************/