From b0903688e8c020a55d1685d2b80609f9072b5143 Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 12 Dec 2010 15:29:02 +0000 Subject: [PATCH] split order age to more useful values git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@663 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/mwin/orderstab.cpp | 21 +++++++++++----- src/mwin/orderstab.h | 10 +++++++- src/mwin/overview.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 15 deletions(-) diff --git a/src/mwin/orderstab.cpp b/src/mwin/orderstab.cpp index 869092e..6ca5ce3 100644 --- a/src/mwin/orderstab.cpp +++ b/src/mwin/orderstab.cpp @@ -101,12 +101,19 @@ MOrdersTab::MOrdersTab(QString pk) } } -qint64 MOrdersTab::oldestOrderStamp(int age) +qint64 MOrdersTab::oldestOrderStamp(OrderTimeStampMode mode,int age) { if(age<0){//age not given, get configuration QSettings set; set.beginGroup("profiles/"+profilekey); - age=set.value("maxorderage",0).toInt(); + switch(mode){ + case OldestForAll:age=set.value("maxorderage",0).toInt();break; + case OldestForOpen:age=set.value("maxorderageopen",0).toInt();break; + case OldestForEvent:age=set.value("maxorderageevent",0).toInt();break; + case OldestForCustomer:age=set.value("maxorderagecust",0).toInt();break; + case OldestForSince:age=set.value("deforderagesince",7).toInt();break; + default: age=0;break; + } } //zero means no limit if(age<=0)return 0; @@ -164,7 +171,7 @@ void MOrdersTab::updateOrders() int omode=ordermode->itemData(ordermode->currentIndex()).toInt(); if(omode==ORDERNONE)return; resetModel(); - MTGetOrderList ol=req->queryGetOrderList(oldestOrderStamp()); + MTGetOrderList ol=req->queryGetOrderList(oldestOrderStamp(omode==ORDERALL?OldestForAll:OldestForOpen)); if(ol.hasError()){ QMessageBox::warning(this,tr("Warning"),tr("There was a problem retrieving the order list: %1").arg(ol.errorString())); return; @@ -188,9 +195,9 @@ void MOrdersTab::orderSinceDate() d.setLayout(vl=new QVBoxLayout); vl->addWidget(new QLabel(tr("Please select the date and time:"))); QDateTimeEdit*dte; - vl->addWidget(dte=new QDateTimeEdit(TimeStamp(oldestOrderStamp()).toDateTime())); + vl->addWidget(dte=new QDateTimeEdit()); dte->setDisplayFormat(tr("ddd MMMM d yyyy, h:mm ap","time format")); - dte->setDateTime(QDateTime::currentDateTime().addDays(-1)); + dte->setDateTime(TimeStamp(oldestOrderStamp(OldestForSince)).toDateTime()); dte->setCalendarPopup(true); vl->addSpacing(10);vl->addStretch(1); vl->addLayout(hl=new QHBoxLayout); @@ -301,7 +308,7 @@ void MOrdersTab::orderByEvent() } //request data and display resetModel(); - MTGetOrdersByEvents obe=req->queryGetOrdersByEvents(eventids,oldestOrderStamp()); + MTGetOrdersByEvents obe=req->queryGetOrdersByEvents(eventids,oldestOrderStamp(OldestForEvent)); if(obe.hasError()){ QMessageBox::warning(this,tr("Warning"),tr("There was a problem retrieving the order list: %1").arg(obe.errorString())); return; @@ -329,7 +336,7 @@ void MOrdersTab::orderByCustomer() } //request data and display resetModel(); - MTGetOrdersByCustomer obc=req->queryGetOrdersByCustomer(cst.customerid(),oldestOrderStamp()); + MTGetOrdersByCustomer obc=req->queryGetOrdersByCustomer(cst.customerid(), oldestOrderStamp(OldestForCustomer)); if(obc.hasError()){ QMessageBox::warning(this,tr("Warning"),tr("Error while retrieving order list: %1").arg(obc.errorString())); return; diff --git a/src/mwin/orderstab.h b/src/mwin/orderstab.h index 7abb55d..bb163e6 100644 --- a/src/mwin/orderstab.h +++ b/src/mwin/orderstab.h @@ -64,8 +64,16 @@ class MOrdersTab:public QWidget void addOrderToModel(const MOOrderInfo&,const QList&); /**helper function: resets the model to an empty state*/ void resetModel(); + + enum OrderTimeStampMode{ + OldestForAll, + OldestForOpen, + OldestForEvent, + OldestForCustomer, + OldestForSince, + }; /**returns timestamp for oldest order; if age is given it returns a timestamp age days in the past, if age is not given it uses the configured time*/ - qint64 oldestOrderStamp(int age=-1); + qint64 oldestOrderStamp(OrderTimeStampMode mode,int age=-1); //the profile associated with this session QString profilekey; diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index f140ad0..238ca5f 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -49,6 +49,7 @@ #include #include #include +#include MOverview::MOverview(QString pk) { @@ -423,31 +424,68 @@ void MOverview::displaySettings() //get settings int maxage=set.value("maxeventage", 0).toInt(); int maxageo=set.value("maxorderage", 0).toInt(); + int maxageoo=set.value("maxorderageopen", 0).toInt(); + int maxageoe=set.value("maxorderageevent", 0).toInt(); + int maxageoc=set.value("maxorderagecust", 0).toInt(); + int maxageos=set.value("deforderagesince", 7).toInt(); //dialog QDialog d; + QLabel*lab; + QGroupBox*gbox; d.setWindowTitle(tr("Display Settings")); QGridLayout*gl; QHBoxLayout*hl; - d.setLayout(gl=new QGridLayout); - int cl=0; - gl->addWidget(new QLabel(tr("Maximum event age (days, 0=show all):")),cl,0); + QVBoxLayout*vl; + d.setLayout(vl=new QVBoxLayout); + vl->addWidget(gbox=new QGroupBox(tr("Event settings")),0); + gbox->setLayout(gl=new QGridLayout); + int cl=-1; + gl->addWidget(new QLabel(tr("Maximum event age (days, 0=show all):")),++cl,0); QSpinBox*mage; gl->addWidget(mage=new QSpinBox,cl,1); mage->setRange(0,99999); mage->setValue(maxage); - gl->addWidget(new QLabel(tr("Maximum order list age (days, 0=show all):")),++cl,0); + + vl->addWidget(gbox=new QGroupBox(tr("Maximum order list age")),0); + gbox->setLayout(gl=new QGridLayout); + cl=-1; + gl->addWidget(new QLabel(tr("Age in days, 0=show all.")),++cl,0,1,2); + gl->addWidget(new QLabel(tr("When showing all orders:")),++cl,0); QSpinBox*oage; gl->addWidget(oage=new QSpinBox,cl,1); oage->setRange(0,99999); oage->setValue(maxageo); - gl->setRowMinimumHeight(++cl,5); + gl->addWidget(new QLabel(tr("When showing open orders:")),++cl,0); + QSpinBox*ooage; + gl->addWidget(ooage=new QSpinBox,cl,1); + ooage->setRange(0,99999); + ooage->setValue(maxageoo); + gl->addWidget(new QLabel(tr("When searching by event:")),++cl,0); + QSpinBox*oeage; + gl->addWidget(oeage=new QSpinBox,cl,1); + oeage->setRange(0,99999); + oeage->setValue(maxageoe); + gl->addWidget(new QLabel(tr("When searching by customer:")),++cl,0); + QSpinBox*ocage; + gl->addWidget(ocage=new QSpinBox,cl,1); + ocage->setRange(0,99999); + ocage->setValue(maxageoc); + gl->addWidget(new QLabel(tr("Default age when searching by date:")),++cl,0); + QSpinBox*osage; + gl->addWidget(osage=new QSpinBox,cl,1); + osage->setRange(0,99999); + osage->setValue(maxageos); + + vl->addWidget(gbox=new QGroupBox(tr("Script settings"))); + gbox->setLayout(gl=new QGridLayout); + cl=-1; QComboBox*udeb; gl->addWidget(new QLabel(tr("Show script debugger:")),++cl,0); gl->addWidget(udeb=new QComboBox,cl,1); udeb->addItems(MScriptEngine::debugModes()); udeb->setCurrentIndex(MScriptEngine::debugMode()); - gl->setRowMinimumHeight(++cl,15); - gl->addLayout(hl=new QHBoxLayout,++cl,0,1,2); + vl->addSpacing(15);vl->addStretch(1); + vl->addLayout(hl=new QHBoxLayout); hl->addStretch(10); QPushButton*p; hl->addWidget(p=new QPushButton(tr("&OK"))); @@ -458,8 +496,15 @@ void MOverview::displaySettings() //write settings maxage=mage->value(); maxageo=oage->value(); + maxageoo=ooage->value(); + maxageoe=oeage->value(); + maxageoc=ocage->value(); set.setValue("maxeventage",maxage); set.setValue("maxorderage",maxageo); + set.setValue("maxorderageopen",maxageoo); + set.setValue("maxorderageevent",maxageoe); + set.setValue("maxorderagecust",maxageoc); + set.setValue("deforderagesince",maxageos); MScriptEngine::setDebugMode(udeb->currentIndex()); } -- 1.7.2.5