m->addAction(tr("&Update Event List"),this,SLOT(updateEvents())) ->setEnabled(req->hasRole("geteventlist"));
m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) ->setEnabled(req->hasRole("geteventdata"));
m->addAction(tr("&New Event..."),this,SLOT(newEvent()))->setEnabled(req->hasRole("createevent"));
+ m->addSeparator();
+ showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents()));
+ showoldevents->setEnabled(req->hasRole("geteventlist"));
+ showoldevents->setCheckable(true);
+ showoldevents->setChecked(QSettings().value("profiles/"+pk+"/showOldEvents",false).toBool());
m=mb->addMenu(tr("&Customer"));
m->addAction(tr("&Show all customers"),this,SLOT(customerMgmt()));
QList<MEvent>evl=req->getAllEvents();
eventmodel->clear();
eventmodel->insertColumns(0,6);
- eventmodel->insertRows(0,evl.size());
eventmodel->setHorizontalHeaderLabels(QStringList()<<tr("Start Time")<<tr("Title")<<tr("Capacity")<<tr("Sold")<<tr("Reserved")<<tr("Free"));
- for(int i=0;i<evl.size();i++){
- eventmodel->setData(eventmodel->index(i,0),evl[i].eventId(),Qt::UserRole);
- eventmodel->setData(eventmodel->index(i,0),QDateTime::fromTime_t(evl[i].startTime()).toString(tr("ddd MMMM d yyyy, h:mm ap","time format")));
- eventmodel->setData(eventmodel->index(i,1),evl[i].title());
- eventmodel->setData(eventmodel->index(i,2),evl[i].capacity());
- eventmodel->setData(eventmodel->index(i,3),evl[i].amountSold());
- eventmodel->setData(eventmodel->index(i,4),evl[i].amountReserved());
- eventmodel->setData(eventmodel->index(i,5),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved());
+ QDateTime now=QDateTime::currentDateTime();
+ for(int i=0,j=0;i<evl.size();i++){
+ QDateTime stime=QDateTime::fromTime_t(evl[i].startTime());
+ if(stime<now && !showoldevents->isChecked())continue;
+ eventmodel->insertRow(j);
+ eventmodel->setData(eventmodel->index(j,0),evl[i].eventId(),Qt::UserRole);
+ eventmodel->setData(eventmodel->index(j,0),stime.toString(tr("ddd MMMM d yyyy, h:mm ap","time format")));
+ eventmodel->setData(eventmodel->index(j,1),evl[i].title());
+ eventmodel->setData(eventmodel->index(j,2),evl[i].capacity());
+ eventmodel->setData(eventmodel->index(j,3),evl[i].amountSold());
+ eventmodel->setData(eventmodel->index(j,4),evl[i].amountReserved());
+ eventmodel->setData(eventmodel->index(j,5),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved());
+ j++;
}
eventtable->resizeColumnsToContents();
+ //in case this was called from changing the check state
+ QSettings().setValue("profiles/"+profilekey+"/showOldEvents",showoldevents->isChecked());
}
void MOverview::closeEvent(QCloseEvent*ce)