--- /dev/null
+//
+// C++ Interface: chosing a seat for a ticket
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include "seatchoicedlg.h"
+
+#include <QDebug>
+#include <QPainter>
+
+MSeatButton::MSeatButton(QString text, MSeatButton::Mode mode, MSeatButton::ArrowType button)
+ : QWidget(), mArrowType(button), mMode(mode), mText(text)
+{
+
+}
+
+MSeatButton::MSeatButton(QString text, int row, int column, MSeatButton::ArrowType button)
+ : QWidget(), mArrowType(button), mRow(row), mColumn(column), mText(text)
+{
+
+}
+
+MSeatButton* MSeatButton::addPrice(int priceid, int pricecents)
+{
+ for(auto prc:mPrices)if(prc.first==priceid)return this;
+ mPrices.append({priceid,pricecents});
+ return this;
+}
+
+void MSeatButton::addSubSeat(MSeatButton*b)
+{
+ if(b)
+ mSubButtons.append(b);
+}
+
+void MSeatButton::setBaseColor(QColor c)
+{
+ mBaseColor=c;
+}
+
+void MSeatButton::setRemoveEnabled(bool)
+{
+ qWarning()<<"setRemoveEnabled not implemented";
+}
+
+void MSeatButton::setSeatNumber(int row, int column)
+{
+ mRow=row;
+ mColumn=column;
+}
+
+void MSeatButton::setArrowType(MSeatButton::ArrowType at)
+{
+ mArrowType=at;
+}
+
+void MSeatButton::setMode(MSeatButton::Mode m)
+{
+ mMode=m;
+ if(m!=Mode::Selectable)
+ mState=State::Neutral;
+}
+
+void MSeatButton::setSelectable(bool selectable)
+{
+
+}
+
+void MSeatButton::setSelected(bool selected)
+{
+
+}
+
+void MSeatButton::setUnselected()
+{
+ setSelected(false);
+}
+
+void MSeatButton::setText(QString text)
+{
+ mText=text;
+}
+
+void MSeatButton::paintEvent(QPaintEvent*e)
+{
+ QWidget::paintEvent(e);
+}
+
+
+MSeatChoiceDialog::MSeatChoiceDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f)
+{
+
+}
--- /dev/null
+//
+// C++ Interface: chosing a seat for a ticket
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_SEATCHOICE_H
+#define MAGICSMOKE_SEATCHOICE_H
+
+#include <QDialog>
+#include <QPointer>
+
+class MSeatButton:public QWidget
+{
+ Q_OBJECT
+public:
+ enum class ArrowType{None,Left,Right,Up,Down};
+ enum class Mode{Unavailable,Blocked,Selectable};
+ enum class State{Neutral,Selected,Unselected};
+ explicit MSeatButton(QString text,int row=-1,int column=-1,ArrowType button=ArrowType::None);
+ MSeatButton(QString text,Mode mode,ArrowType button=ArrowType::None);
+
+ State state()const{return mState;}
+ bool isSelectable()const{return mIsSelectable;}
+ bool isSelected()const{return mState==State::Selected;}
+ QColor baseColor()const{return mBaseColor;}
+ ArrowType arrowType()const{return mArrowType;}
+ Mode mode()const{return mMode;}
+ int row()const{return mRow;}
+ int column()const{return mColumn;}
+ QString text()const{return mText;}
+
+public slots:
+ MSeatButton* addPrice(int priceid,int pricecents=-1);
+ void setSeatNumber(int row,int column=-1);
+ void setBaseColor(QColor);
+ void setRemoveEnabled(bool);
+ void addSubSeat(MSeatButton*);
+ void setSelected(bool selected=true);
+ void setUnselected();
+ void setSelectable(bool selectable);
+ void setText(QString);
+ void setMode(Mode);
+ void setArrowType(ArrowType);
+
+signals:
+ void seatSelected(int priceid,int row,int column);
+ void seatUnselected(int row,int column);
+
+protected:
+ virtual void paintEvent(QPaintEvent*)override;
+
+private:
+ QList<QPair<int,int>>mPrices;
+ QColor mBaseColor=Qt::gray;
+ ArrowType mArrowType=ArrowType::None;
+ Mode mMode=Mode::Selectable;
+ int mRow=-1,mColumn=-1;
+ bool mIsSelectable=true;
+ State mState=State::Neutral;
+ QString mText;
+ QList<QPointer<MSeatButton>>mSubButtons;
+};
+
+class MSeatPlanWidget:public QWidget
+{
+ Q_OBJECT
+};
+
+class MSeatChoiceDialog:public QDialog
+{
+ Q_OBJECT
+public:
+ explicit MSeatChoiceDialog ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
+
+public slots:
+
+};
+
+
+#endif