make it possible for user to deselect old events
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 17 Nov 2008 17:14:30 +0000 (17:14 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Mon, 17 Nov 2008 17:14:30 +0000 (17:14 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@189 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/overview.cpp
src/overview.h

index 4f5a946..9113a46 100644 (file)
@@ -72,6 +72,11 @@ MOverview::MOverview(MWebRequest*mw,QString pk)
        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()));
@@ -322,18 +327,24 @@ void MOverview::updateEvents()
        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)
index 4eae8a2..1128611 100644 (file)
 #include "customer.h"
 
 class MWebRequest;
+class QAction;
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QStandardItemModel;
 class QTabWidget;
 class QTableView;
-class QStandardItemModel;
-class QPushButton;
-class QLineEdit;
-class QLabel;
-class QComboBox;
 
 /**Main Overview Window*/
 class MOverview:public QMainWindow
@@ -150,6 +151,8 @@ class MOverview:public QMainWindow
                QTextEdit *cartaddr,*cartcomment;
                QComboBox*ordermode;
                QLineEdit*entrancescan;
+               //event list
+               QAction*showoldevents;
                //cart
                MCustomer customer;
                //barcode cache