From a4841c5078f818b2fc673e8953f2d3ddb25c35fc Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Tue, 9 Feb 2016 22:32:17 +0100 Subject: [PATCH] redesign event overview: - remove buttons - move all button functions to menu - add detail view --- src/dialogs/orderwin.cpp | 2 +- src/mwin/carttab.cpp | 19 ++++++- src/mwin/carttab.h | 4 +- src/mwin/eventstab.cpp | 141 +++++++++++++++++++++++++++++++++++++++++++--- src/mwin/eventstab.h | 15 ++++- src/mwin/overview.cpp | 1 + src/mwin/tabwin.cpp | 2 +- src/mwin/tabwin.h | 2 +- 8 files changed, 170 insertions(+), 16 deletions(-) diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 001f959..0567e10 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -206,7 +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); + m_table->setSortingEnabled(true); updateData(); } diff --git a/src/mwin/carttab.cpp b/src/mwin/carttab.cpp index 17a9259..60307a6 100644 --- a/src/mwin/carttab.cpp +++ b/src/mwin/carttab.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -290,7 +291,7 @@ void MCartTab::cartAddTicket() addTicketForEvent(id); } -void MCartTab::addTicketForEvent(qint64 id) +void MCartTab::addTicketForEvent(qint64 id, qint64 prcid) { //get event MTGetEvent ge=MTGetEvent::query(id); @@ -316,8 +317,13 @@ void MCartTab::addTicketForEvent(qint64 id) d.setLayout(vl=new QVBoxLayout); vl->addWidget(new QLabel(tr("Please chose a price category:"))); vl->addWidget(box=new QComboBox); - for(int i=0;iaddItem(ep[i].pricecategory().value().name().value()+": "+cent2str(ep[i].price())); + if(ep[i].pricecategoryid()==prcid) + prcidx=i; + } + if(prcidx>=0)box->setCurrentIndex(prcidx); box->setEditable(false); vl->addSpacing(10); vl->addStretch(10); @@ -355,6 +361,15 @@ void MCartTab::eventOrderTicket() addTicketForEvent(id); } +void MCartTab::eventOrderTicket(qint64 id,qint64 prcid) +{ + qDebug()<<"xxxx"; + //activate order tab + emit requestFocus(); + //insert event into table + addTicketForEvent(id,prcid); +} + void MCartTab::cartAddVoucher() { //create voucher selection dialog diff --git a/src/mwin/carttab.h b/src/mwin/carttab.h index 8601908..9a48a7d 100644 --- a/src/mwin/carttab.h +++ b/src/mwin/carttab.h @@ -72,6 +72,8 @@ class MCartTab:public QWidget public slots: /**order ticket from event tab*/ void eventOrderTicket(); + /**order ticket from event tab*/ + void eventOrderTicket(qint64,qint64); /**update shipping info*/ void updateShipping(); @@ -133,7 +135,7 @@ class MCartTab:public QWidget void verifyOrderItems(const QList&); /**helper for cartAddTicket and eventOrderTicket: choses a price category and then adds the ticket*/ - void addTicketForEvent(qint64); + void addTicketForEvent(qint64,qint64 prcid=-1); }; /**Helper class for shopping cart: allow editing amount, but nothing else*/ diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index 6d87039..4afafe8 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -30,9 +30,12 @@ #include #include #include +#include +#include #include #include #include +#include #include #include #include @@ -40,9 +43,12 @@ #include #include #include +#include #include #include -#include +#include +#include +#include MEventsTab::MEventsTab(QString pk) { @@ -52,16 +58,24 @@ MEventsTab::MEventsTab(QString pk) //Event tab QVBoxLayout*vl;QHBoxLayout*hl; - setLayout(hl=new QHBoxLayout); - hl->addWidget(eventtable=new QTableView,10); + setLayout(vl=new QVBoxLayout); + QSplitter*split; + vl->addWidget(split=new QSplitter); + split->addWidget(eventtable=new QTableView); eventtable->setModel(eventmodel=new QStandardItemModel(this)); eventtable->setSelectionMode(QAbstractItemView::SingleSelection); - eventtable->setSelectionBehavior(QAbstractItemView::SelectRows); + eventtable->setSelectionBehavior(QAbstractItemView::SelectRows); eventtable->setEditTriggers(QAbstractItemView::NoEditTriggers); eventtable->verticalHeader()->hide(); eventtable->setSortingEnabled(true); eventmodel->setSortRole(SortRole); - hl->addSpacing(5); + connect(eventtable->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(updateDetails())); + split->addWidget(eventdetail=new QTextBrowser); + eventdetail->setReadOnly(true); + connect(eventdetail,SIGNAL(anchorClicked(QUrl)),this,SLOT(eventOrderTicketUrl(QUrl))); + eventdetail->setOpenExternalLinks(false); + eventdetail->setOpenLinks(false); +/* hl->addSpacing(5); hl->addLayout(vl=new QVBoxLayout,0); QPushButton*p; vl->addWidget(p=new QPushButton(tr("New Event")),0); @@ -71,7 +85,7 @@ MEventsTab::MEventsTab(QString pk) 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); + vl->addWidget(p=new QPushButton(tr("Details...")),0); connect(p,SIGNAL(clicked()),this,SLOT(editEvent())); p->setEnabled(req->hasRight(req->RGetEvent)); vl->addSpacing(15); @@ -87,7 +101,7 @@ MEventsTab::MEventsTab(QString pk) p->setEnabled(req->hasRight(req->RCancelEvent)); connect(p,SIGNAL(clicked()),this,SLOT(eventCancel())); vl->addStretch(10); - +*/ //fill tables if(req->hasRight(req->RGetAllEvents)){ updateEvents(); @@ -101,7 +115,9 @@ QListMEventsTab::menu() QMenu*m=new QMenu(tr("&View")); ret<addAction(tr("&Update Event List"),this,SLOT(updateEvents())) - ->setEnabled(req->hasRight(req->RGetAllEvents)); + ->setEnabled(req->hasRight(req->RGetAllEvents)); + m->addAction(tr("Event &Summary..."),this,SLOT(eventSummary())) + ->setEnabled(req->hasRight(MInterface::RGetEventSummary)); m->addSeparator(); showoldevents=m->addAction(tr("Show &old Events"),this,SLOT(updateEvents())); showoldevents->setEnabled(req->hasRight(req->RGetAllEvents)); @@ -109,10 +125,15 @@ QListMEventsTab::menu() showoldevents->setChecked(QSettings().value("profiles/"+profilekey+"/showOldEvents",false).toBool()); m=new QMenu(tr("&Edit")); + ret<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->addAction(tr("&Clone Current Event..."),this,SLOT(cloneEvent())) + ->setEnabled(req->hasRight(req->RCreateEvent)); + m->addAction(tr("C&ancel Event..."),this,SLOT(eventCancel())) + ->setEnabled(req->hasRight(req->MInterface::RCancelEvent)); m->addSeparator(); m->addAction(tr("&Edit Price Categories..."),this,SLOT(editPriceCat())); @@ -143,6 +164,8 @@ void MEventsTab::updateEvents() now.addDays(-maxage); } //fill model + eventdetail->clear(); + eventdetail->clearHistory(); eventmodel->clear(); eventmodel->insertColumns(0,6); eventmodel->setHorizontalHeaderLabels(QStringList()<insertRow(j); eventmodel->setData(eventmodel->index(j,0),evl[i].id().value(),IdRole); + eventmodel->setData(eventmodel->index(j,0),QVariant::fromValue(evl[i]),ObjectRole); 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()); @@ -177,6 +201,107 @@ MEventsTab::~MEventsTab() { } +void MEventsTab::updateDetails() +{ + //clear + eventdetail->clearHistory(); + eventdetail->clear(); + //get selection + QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes(); + if(ilst.size()<1)return; + QModelIndex idx=eventmodel->index(ilst[0].row(),0); + //get event + MOEvent event=eventmodel->data(idx,ObjectRole).value(); + if(!event.isValid())return; + //generate HTML + QString detail="

"+htmlize(event.title())+"

\n"; + detail+=tr("Artist: %1").arg(htmlize(event.artist().value().name()))+"

\n"; + detail+=tr("Starttime: %1").arg(htmlize(event.startTimeString()))+"
\n"; + detail+=tr("Endtime: %1").arg(htmlize(event.startTimeString()))+"

\n"; + detail+=tr("Room: %1").arg(htmlize(event.room()))+"
\n"; + detail+=tr("Seats: %1 max. (%2 sold out; %3 reserved; %4 free)").arg(event.capacity()).arg(event.amountSold()).arg(event.amountReserved()).arg(event.amountFree())+"

\n"; + + const QString bgsold=tr("

Sold Out!
","Colored display for sold out tickets"); + const QString bgavail=tr("
","Colored display for ordering tickets"); + const QString bghide=tr("
Unable to sell.
","Colored display for tickets unavailable to this user"); + + const bool showevent=req->checkFlags(event.flags()); + if(showevent) + detail+=event.amountFree()>0?bgavail.arg(QString("order:?ev=%1").arg(event.id())):bgsold; + else + detail+=bghide; + detail+="

"+tr("Prices")+"

\n"; + detail+="" + "\n"; + QListprices=event.price(); + qSort(prices.begin(),prices.end(),[](const MOEventPrice&p1,const MOEventPrice&p2){return p1.prio()checkFlags(ctg.flags())) + detail+=""; + } + detail+="
"+tr("Category")+""+tr("Price")+""+tr("Available")+""+tr("Max. Seats")+""+tr("Order")+"
"+ + (avail>0? + bgavail.arg(QString("order:?ev=%1&pr=%2").arg(event.id()).arg(ctg.pricecategoryid())) + :bgsold); + else + detail+=""+bghide; + detail+="

\n"; + + detail+="

"+tr("Description")+"

\n"+event.description()+"

\n"; + detail+="

"+tr("Comment")+"

\n"+htmlize(event.comment()); + //set value + eventdetail->setHtml(detail); +} + +void MEventsTab::eventOrderTicketUrl(const QUrl &url) +{ + //check whether it is order URL + if(url.scheme()=="order"){ + QUrlQuery query(url); + if(query.hasQueryItem("ev")){ + bool b=false; + qint64 evid=query.queryItemValue("ev").toLongLong(&b); + if(!b || evid<0){ + qDebug()<<"ordering tickets for current event (invalid EvID)..."; + emit eventOrderTicket(); + return; + } + qint64 prid=-1; + if(query.hasQueryItem("pr")){ + prid=query.queryItemValue("pr").toLongLong(&b); + if(!b)prid=-1; + } + qDebug()<<"ordering tickets for event"<url().resolved(url); + qDebug()<<"Relative URL"<url(); + qDebug()<<" ...opening"<&eids,bool multi=true)const; - + + ///order ticket from URL click + void eventOrderTicketUrl(const QUrl&); + signals: /**order ticket from event tab*/ void eventOrderTicket(); + /**order ticket from event tab*/ + void eventOrderTicket(qint64,qint64); private: //the profile associated with this session @@ -88,6 +97,7 @@ class MEventsTab:public QWidget //widgets QTableView*eventtable; QStandardItemModel*eventmodel; + QTextBrowser*eventdetail; //event list QAction*showoldevents; //refresh timers @@ -95,7 +105,8 @@ class MEventsTab:public QWidget //table role definitions enum ExtraTableRoles{ IdRole=Qt::UserRole, - SortRole + SortRole, + ObjectRole }; }; diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index ceed9c7..41231cd 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -159,6 +159,7 @@ MOverview::MOverview(QString pk,std::functioninitUpdate) carttab=new MCartTab(pk); addTab(carttab,tr("Shopping Cart"),carttab->menu()); connect(eventtab,SIGNAL(eventOrderTicket()),carttab,SLOT(eventOrderTicket())); + connect(eventtab,SIGNAL(eventOrderTicket(qint64,qint64)),carttab,SLOT(eventOrderTicket(qint64,qint64))); connect(carttab,SIGNAL(getEventId(int&,bool&)), eventtab,SLOT(selectEventId(int&,bool&)), Qt::DirectConnection); connect(carttab,SIGNAL(currentEventId()), eventtab,SLOT(currentEventId()), Qt::DirectConnection); connect(carttab,SIGNAL(currentEventTitle()), eventtab,SLOT(currentEventTitle()), Qt::DirectConnection); diff --git a/src/mwin/tabwin.cpp b/src/mwin/tabwin.cpp index b25f14f..bb22acb 100644 --- a/src/mwin/tabwin.cpp +++ b/src/mwin/tabwin.cpp @@ -98,7 +98,7 @@ void MTabWin::addTab(QWidget* tw, QString title, QList menu) int idx=tabw->addTab(tw,title); tabmenu.insert(idx,menu); QMenuBar*mb=menuBar(); - for(int i=menu.size()-1;i>=0;i--){ + for(int i=0;iinsertMenu(helpseparator,menu[i]); } } diff --git a/src/mwin/tabwin.h b/src/mwin/tabwin.h index 9ad3590..4435e04 100644 --- a/src/mwin/tabwin.h +++ b/src/mwin/tabwin.h @@ -39,7 +39,7 @@ class MTabWin:public QMainWindow ///add a tab virtual void addTab(QWidget*tab,QString title,QListmenu=QList()); - ///add a menu to the left + ///add a menu to the left side, where it is visible for all tabs virtual QMenu* addMenu(QString); ///returns a pointer to the help menu -- 1.7.2.5