flags for events; prio for prices
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 30 Nov 2010 21:37:05 +0000 (21:37 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 30 Nov 2010 21:37:05 +0000 (21:37 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@647 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/dialogs/eventedit.cpp
src/dialogs/eventedit.h
wob/db/event.wolf
www/inc/wext/flag.php

index 22b6c50..71e50ac 100644 (file)
@@ -70,6 +70,7 @@ MEventEditor::MEventEditor(QWidget*pw,qint64 id)
        gl->addWidget(lab=new QLabel(tr("ID:")),lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
        gl->addWidget(eventid=new QLabel,lctr,1);
+       eventid->setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
        eventid->setText(event.id().isNull()?"new":QString::number(event.id()));
        
        gl->addWidget(lab=new QLabel(tr("Title:")),++lctr,0);
@@ -131,6 +132,14 @@ MEventEditor::MEventEditor(QWidget*pw,qint64 id)
        cancelreason->setText(event.cancelreason());
        connect(cancelcheck,SIGNAL(toggled(bool)),cancelreason,SLOT(setEnabled(bool)));
        
+       gl->addWidget(lab=new QLabel(tr("Flags:")),++lctr,0);
+       lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+       gl->addLayout(hl=new QHBoxLayout,lctr,1);
+       hl->addWidget(flags=new QLabel(event.flags()),1);
+       flags->setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
+       hl->addWidget(p=new QPushButton("..."),0);
+       connect(p,SIGNAL(clicked(bool)),this,SLOT(setFlags()));
+       
        tab->addTab(w=new QWidget,tr("Description"));
        w->setLayout(vl2=new QVBoxLayout);
        vl2->addWidget(new QLabel(tr("The description will be displayed on the web site, please use HTML syntax.")),0);
@@ -181,6 +190,7 @@ void MEventEditor::writeBack()
        event.setcomment(comment->toPlainText());
        event.setcapacity(capacity->value());
        event.setroom(room->text());
+       event.setflags(flags->text());
        //artist is set in other methods already
        //prices are changed by the methods reacting to the table
        //send to server
@@ -195,20 +205,28 @@ void MEventEditor::writeBack()
        }
 }
 
+void MEventEditor::setFlags()
+{
+       flags->setText(MFlagEditor::edit(this, flags->text(), tr("Edit flags of event %1:").arg(event.title())));
+}
+
+
 void MEventEditor::updatePrice()
 {
        pricemodel->clear();
        pricemodel->insertColumns(0,5);
-       pricemodel->setHorizontalHeaderLabels(QStringList()<<tr("Price Category")<<tr("Price")<<tr("Ticket Capacity")<<tr("Tickets")<<tr("Seats Blocked"));
+       pricemodel->setHorizontalHeaderLabels(QStringList()<<tr("Price Category")<<tr("Price")<<tr("Ordering")<<tr("Ticket Capacity")<<tr("Tickets")<<tr("Seats Blocked")<<tr("Flags"));
        QList<MOEventPrice> prc=event.price();
        pricemodel->insertRows(0,prc.size());
        for(int i=0;i<prc.size();i++){
-               pricemodel->setData(pricemodel->index(i,0),prc[i].pricecategory().value().name().value());
-               pricemodel->setData(pricemodel->index(i,0),prc[i].pricecategoryid().value(),Qt::UserRole);
-               pricemodel->setData(pricemodel->index(i,1),cent2str(prc[i].price().value()));
-               pricemodel->setData(pricemodel->index(i,2),prc[i].maxavailable().value());
-               pricemodel->setData(pricemodel->index(i,3),prc[i].amounttickets().value());
-               pricemodel->setData(pricemodel->index(i,4),prc[i].amountticketsblock().value());
+               pricemodel->setData(pricemodel->index(i,0), prc[i].pricecategory().value().name().value());
+               pricemodel->setData(pricemodel->index(i,0), prc[i].pricecategoryid().value(), Qt::UserRole);
+               pricemodel->setData(pricemodel->index(i,1), cent2str(prc[i].price().value()));
+               pricemodel->setData(pricemodel->index(i,2), prc[i].prio().value());
+               pricemodel->setData(pricemodel->index(i,3), prc[i].maxavailable().value());
+               pricemodel->setData(pricemodel->index(i,4), prc[i].amounttickets().value());
+               pricemodel->setData(pricemodel->index(i,5), prc[i].amountticketsblock().value());
+               pricemodel->setData(pricemodel->index(i,6), prc[i].flags().value());
        }
        pricetable->resizeColumnsToContents();
 }
@@ -226,15 +244,20 @@ MEEPriceEdit::MEEPriceEdit(QWidget*pw,MOEventPrice prc,int maxseats)
        setLayout(vl=new QVBoxLayout);
        vl->addLayout(gl=new QFormLayout,10);
        gl->addRow(tr("Price category:"),cname=new QLabel(prc.pricecategory().value().name()));
+       cname->setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
        gl->addRow(tr("Price:"),price=new MCentSpinBox(&d,prc.price()));
        price->setMinimumWidth(200);
        gl->addRow(tr("Maximum Seats:"),cap=new QSpinBox);
+       gl->addRow(tr("Ordering:"),ord=new QSpinBox);
        gl->addRow(tr("Flags:"),hl=new QHBoxLayout);
        hl->addWidget(flg=new QLabel(prc.flags()),1);
+       flg->setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
        hl->addWidget(p=new QPushButton("..."),0);
        connect(p,SIGNAL(clicked(bool)),this,SLOT(setFlags()));
        cap->setRange(prc.amountticketsblock(),maxseats);
        cap->setValue(prc.maxavailable());
+       ord->setRange(0,0x7fffffff);
+       ord->setValue(prc.prio());
        vl->addSpacing(10);
        vl->addStretch(1);
        vl->addLayout(hl=new QHBoxLayout,0);
@@ -272,6 +295,7 @@ void MEventEditor::changePrice()
        prc[lid].setprice(d.price->value());
        prc[lid].setmaxavailable(d.cap->value());
        prc[lid].setflags(d.flg->text());
+       prc[lid].setprio(d.ord->value());
        event.setprice(prc);
        updatePrice();
 }
index 2455134..8ecc03a 100644 (file)
@@ -61,6 +61,9 @@ class MEventEditor:public QDialog
                void addPrice();
                /**removes a price*/
                void removePrice();
+               
+               ///change flags
+               void setFlags();
        private:
                MOEvent event;
                QDateTimeEdit*starttime,*endtime;
@@ -68,7 +71,7 @@ class MEventEditor:public QDialog
                QTextEdit*description,*comment;
                QCheckBox*cancelcheck;
                QSpinBox*capacity;
-               QLabel*eventid;
+               QLabel*eventid,*flags;
                QTableView*pricetable;
                QStandardItemModel*pricemodel;
 };
@@ -83,7 +86,7 @@ class MEEPriceEdit:public QDialog
        protected:
                friend class MEventEditor;
                MCentSpinBox*price;
-               QSpinBox*cap;
+               QSpinBox*cap,*ord;
                QLabel*flg,*cname;
                MEEPriceEdit(QWidget*,MOEventPrice,int);
        private slots:
index 6efbe2e..7086178 100644 (file)
@@ -79,7 +79,7 @@
                <Column name="pricecategoryid" type="int32" primarykey="yes" foreignkey="pricecategory:pricecategoryid"/>
                <Column name="maxavailable" type="int32" notnull="yes"/>
                <Column name="price" type="int32" notnull="yes"/>
-               <Column name="prio" type="int32" notnull="yes" default="10">order in which prices are listet, lowest prio first</Column>
+               <Column name="prio" type="int32" notnull="yes" default="10">order in which prices are listet, lowest number of prio first</Column>
                <Column name="flags" type="string">filter: who can sell tickets in this category for this event</Column>
                <Column name="tags" type="string">internal tags: can be used by macros and printer routines to change behavior or output</Column>
        </Table>
index 5170eaf..01935be 100644 (file)
@@ -40,7 +40,7 @@ class WOFlag extends WOFlagAbstract
                global $db;
                $f=$trans->getflag();
                //check flag name
-               if(!ereg("^[a-zA-Z0-9]+$",$f->getflag())){
+               if(!preg_match("/^[a-zA-Z0-9]+$/",$f->getflag())){
                        $trans->abortWithError("Invalid flag name.");
                        return;
                }
@@ -53,7 +53,7 @@ class WOFlag extends WOFlagAbstract
                global $db;
                $f=$trans->getflag();
                //check flag name
-               if(!ereg("^[a-zA-Z0-9]+$",$f)){
+               if(!preg_match("/^[a-zA-Z0-9]+$/",$f)){
                        $trans->abortWithError("Invalid flag name or attempt to delete special flag.");
                        return;
                }