enable table sorting and more logical config
authorKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Sun, 7 Feb 2016 12:52:21 +0000 (13:52 +0100)
committerKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Sun, 7 Feb 2016 12:52:52 +0000 (13:52 +0100)
src/dialogs/login.cpp
src/dialogs/orderwin.cpp
src/mwin/eventstab.cpp
src/mwin/eventstab.h
src/mwin/orderstab.cpp
src/mwin/overview.cpp
src/mwin/overview.h

index 01b7d14..c07d9fb 100644 (file)
@@ -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);
index be193c4..001f959 100644 (file)
@@ -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();
 }
 
index 5297175..6d87039 100644 (file)
@@ -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 @@ QList<QMenu*>MEventsTab::menu()
 {
        //menu
        QList<QMenu*>ret;
-       QMenu*m=new QMenu(tr("&Event"));
+       QMenu*m=new QMenu(tr("&View"));
        ret<<m;
        m->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 && stime<now)continue;
                //show
                eventmodel->insertRow(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;i<ilst.size();i++){
-               int eid=eventmodel->data(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);
        }
 }
index da82521..788c05b 100644 (file)
@@ -92,6 +92,11 @@ class MEventsTab:public QWidget
                QAction*showoldevents;
                //refresh timers
                QTimer rtimer;
+               //table role definitions
+               enum ExtraTableRoles{
+                       IdRole=Qt::UserRole,
+                       SortRole
+               };
 };
 
 #endif
index eda2cb6..21c54b3 100644 (file)
@@ -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()
index 159bb0a..ceed9c7 100644 (file)
@@ -139,6 +139,7 @@ MOverview::MOverview(QString pk,std::function<void(int,QString)>initUpdate)
         ->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()
 {
index e226436..9628d32 100644 (file)
@@ -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();