From: Konrad Rosenbaum Date: Sun, 7 Feb 2016 12:52:21 +0000 (+0100) Subject: enable table sorting and more logical config X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=dff0f29c30197936307b05f67555b26f1ce274ca;p=web%2Fkonrad%2Fsmoke.git enable table sorting and more logical config --- diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp index 01b7d14..c07d9fb 100644 --- a/src/dialogs/login.cpp +++ b/src/dialogs/login.cpp @@ -148,7 +148,7 @@ void MLogin::startLogin() pd.setLabelText(txt); } ); - mo->show(); + mo->showMaximized(); //make sure the application exits (only) after everything is cleaned up qApp->setQuitOnLastWindowClosed(false); diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index be193c4..001f959 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -206,6 +206,7 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) vl->addWidget(m_table=new MOWTableView,10); m_table->setModel(m_model=new QStandardItemModel(this)); m_table->setEditTriggers(QAbstractItemView::NoEditTriggers); + m_table->setSortingEnabled(true); updateData(); } diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index 5297175..6d87039 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -59,15 +59,17 @@ MEventsTab::MEventsTab(QString pk) eventtable->setSelectionBehavior(QAbstractItemView::SelectRows); eventtable->setEditTriggers(QAbstractItemView::NoEditTriggers); eventtable->verticalHeader()->hide(); + eventtable->setSortingEnabled(true); + eventmodel->setSortRole(SortRole); hl->addSpacing(5); hl->addLayout(vl=new QVBoxLayout,0); QPushButton*p; vl->addWidget(p=new QPushButton(tr("New Event")),0); p->setEnabled(req->hasRight(req->RCreateEvent)); - QMenu*m; - p->setMenu(m=new QMenu); - m->addAction(tr("New Event..."),this,SLOT(newEvent())); - m->addAction(tr("Clone Current Event..."),this,SLOT(cloneEvent())); + QMenu*m; + p->setMenu(m=new QMenu); + m->addAction(tr("New Event..."),this,SLOT(newEvent())); + m->addAction(tr("Clone Current Event..."),this,SLOT(cloneEvent())); vl->addWidget(p=new QPushButton(tr("Details...")),0); connect(p,SIGNAL(clicked()),this,SLOT(editEvent())); @@ -96,19 +98,21 @@ QListMEventsTab::menu() { //menu QListret; - QMenu*m=new QMenu(tr("&Event")); + QMenu*m=new QMenu(tr("&View")); ret<addAction(tr("&Update Event List"),this,SLOT(updateEvents())) ->setEnabled(req->hasRight(req->RGetAllEvents)); - m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) - ->setEnabled(req->hasRight(req->RGetEvent)); - m->addAction(tr("&New Event..."),this,SLOT(newEvent())) - ->setEnabled(req->hasRight(req->RCreateEvent)); m->addSeparator(); showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents())); showoldevents->setEnabled(req->hasRight(req->RGetAllEvents)); showoldevents->setCheckable(true); showoldevents->setChecked(QSettings().value("profiles/"+profilekey+"/showOldEvents",false).toBool()); + + m=new QMenu(tr("&Edit")); + m->addAction(tr("&Show/Edit details..."),this,SLOT(editEvent())) + ->setEnabled(req->hasRight(req->RGetEvent)); + m->addAction(tr("&New Event..."),this,SLOT(newEvent())) + ->setEnabled(req->hasRight(req->RCreateEvent)); m->addSeparator(); m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat())); @@ -148,13 +152,19 @@ void MEventsTab::updateEvents() if(!showveryold && stimeinsertRow(j); - eventmodel->setData(eventmodel->index(j,0),evl[i].id().value(),Qt::UserRole); + eventmodel->setData(eventmodel->index(j,0),evl[i].id().value(),IdRole); eventmodel->setData(eventmodel->index(j,0),evl[i].startTimeString()); + eventmodel->setData(eventmodel->index(j,0),evl[i].start().value(),SortRole); eventmodel->setData(eventmodel->index(j,1),evl[i].title().value()); + eventmodel->setData(eventmodel->index(j,1),evl[i].title().value(),SortRole); eventmodel->setData(eventmodel->index(j,2),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved()); + eventmodel->setData(eventmodel->index(j,2),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved(),SortRole); eventmodel->setData(eventmodel->index(j,3),evl[i].amountReserved().value()); + eventmodel->setData(eventmodel->index(j,3),evl[i].amountReserved().value(),SortRole); eventmodel->setData(eventmodel->index(j,4),evl[i].amountSold().value()); + eventmodel->setData(eventmodel->index(j,4),evl[i].amountSold().value(),SortRole); eventmodel->setData(eventmodel->index(j,5),evl[i].capacity().value()); + eventmodel->setData(eventmodel->index(j,5),evl[i].capacity().value(),SortRole); j++; } eventtable->resizeColumnsToContents(); @@ -180,7 +190,7 @@ void MEventsTab::cloneEvent() QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); if(ilst.size()<1)return; QModelIndex idx=eventmodel->index(ilst[0].row(),0); - id=eventmodel->data(idx,Qt::UserRole).toInt(); + id=eventmodel->data(idx,IdRole).toInt(); if(id<0)return; MEventEditor ed(this,MEventEditor::OpenMode::Create,id); ed.exec(); @@ -193,7 +203,7 @@ void MEventsTab::editEvent() QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); if(ilst.size()<1)return; QModelIndex idx=eventmodel->index(ilst[0].row(),0); - id=eventmodel->data(idx,Qt::UserRole).toInt(); + id=eventmodel->data(idx,IdRole).toInt(); if(id<0)return; MEventEditor ed(this,id); ed.exec(); @@ -206,7 +216,7 @@ void MEventsTab::eventSummary() QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); if(ilst.size()<1)return; QModelIndex idx=eventmodel->index(ilst[0].row(),0); - id=eventmodel->data(idx,Qt::UserRole).toInt(); + id=eventmodel->data(idx,IdRole).toInt(); if(id<0)return; MEventSummary ed(this,id); ed.exec(); @@ -218,7 +228,7 @@ void MEventsTab::eventCancel() QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); if(ilst.size()<1)return; QModelIndex idx=eventmodel->index(ilst[0].row(),0); - id=eventmodel->data(idx,Qt::UserRole).toInt(); + id=eventmodel->data(idx,IdRole).toInt(); if(id<0)return; MTGetEvent getev=MTGetEvent::query(id); if(!getev.hasError()){ @@ -239,7 +249,7 @@ int MEventsTab::currentEventId()const QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); if(ilst.size()<1)return -1; QModelIndex idx=eventmodel->index(ilst[0].row(),0); - return eventmodel->data(idx,Qt::UserRole).toInt(); + return eventmodel->data(idx,IdRole).toInt(); } QString MEventsTab::currentEventTitle()const @@ -303,7 +313,7 @@ void MEventsTab::selectEventIds(QList< int >& eids, bool multi) const } //get events for(int i=0;idata(eventmodel->index(ilst[i].row(),0),Qt::UserRole).toInt(); + int eid=eventmodel->data(eventmodel->index(ilst[i].row(),0),IdRole).toInt(); if(!eids.contains(eid))eids.append(eid); } } diff --git a/src/mwin/eventstab.h b/src/mwin/eventstab.h index da82521..788c05b 100644 --- a/src/mwin/eventstab.h +++ b/src/mwin/eventstab.h @@ -92,6 +92,11 @@ class MEventsTab:public QWidget QAction*showoldevents; //refresh timers QTimer rtimer; + //table role definitions + enum ExtraTableRoles{ + IdRole=Qt::UserRole, + SortRole + }; }; #endif diff --git a/src/mwin/orderstab.cpp b/src/mwin/orderstab.cpp index eda2cb6..21c54b3 100644 --- a/src/mwin/orderstab.cpp +++ b/src/mwin/orderstab.cpp @@ -85,6 +85,7 @@ MOrdersTab::MOrdersTab(QString pk) ordertable->setSelectionMode(QAbstractItemView::SingleSelection); ordertable->setSelectionBehavior(QAbstractItemView::SelectRows); ordertable->setEditTriggers(QAbstractItemView::NoEditTriggers); + ordertable->setSortingEnabled(true); connect(ordertable,SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(orderDetails())); hl->addLayout(vl=new QVBoxLayout,0); vl->addWidget(p=new QPushButton(tr("Update")),0); @@ -347,6 +348,7 @@ void MOrdersTab::orderByEvent() addOrderToModel(orders[cl],cust); } ordermode->setCurrentIndex(ordermode->count()-1); + ordertable->resizeColumnsToContents(); } void MOrdersTab::orderByCustomer() @@ -376,6 +378,7 @@ void MOrdersTab::orderByCustomer() addOrderToModel(orders[i],cust); } ordermode->setCurrentIndex(ordermode->count()-1); + ordertable->resizeColumnsToContents(); } void MOrdersTab::orderByOrder() @@ -428,6 +431,7 @@ void MOrdersTab::orderByUser() addOrderToModel(orders[i],cust); } ordermode->setCurrentIndex(ordermode->count()-1); + ordertable->resizeColumnsToContents(); } void MOrdersTab::genReport() diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 159bb0a..ceed9c7 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -139,6 +139,7 @@ MOverview::MOverview(QString pk,std::functioninitUpdate) ->setEnabled(req->hasRight(req->RBackup)); m2=m->addMenu(tr("&Configuration")); + m2->addAction(tr("&Change Language..."),this,SLOT(changeLang())); m2->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); m2->addAction(tr("&Server Access settings..."),this,SLOT(webSettings())); m2->addAction(tr("&Display settings..."),this,SLOT(displaySettings())); @@ -561,6 +562,11 @@ void MOverview::displaySettings() MScriptEngine::setDebugMode(udeb->currentIndex()); } +void MOverview::changeLang() +{ + choseLanguage(); +} + void MOverview::doBackup() { diff --git a/src/mwin/overview.h b/src/mwin/overview.h index e226436..9628d32 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -81,6 +81,8 @@ class MOverview:public MTabWin void openOfficeSettings(); ///barcode scanner settings void barcodeSettings(); + ///language settings + void changeLang(); ///\internal run init scripts void runStartupScript();