draft of seat choice dialog
authorKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Thu, 17 Mar 2016 08:49:11 +0000 (09:49 +0100)
committerKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Thu, 17 Mar 2016 08:49:11 +0000 (09:49 +0100)
src/dialogs/dialogs.pri
src/dialogs/seatchoicedlg.cpp [new file with mode: 0644]
src/dialogs/seatchoicedlg.h [new file with mode: 0644]

index 2ead568..93648e3 100644 (file)
@@ -15,7 +15,8 @@ HEADERS += \
        dialogs/orderauditdlg_p.h \
        dialogs/backupdlg.h \
        dialogs/payedit.h \
-       dialogs/editreg.h
+       dialogs/editreg.h \
+       dialogs/seatchoicedlg.h
 
 SOURCES += \
        dialogs/configdialog.cpp \
@@ -33,7 +34,8 @@ SOURCES += \
        dialogs/orderauditdlg.cpp \
        dialogs/backupdlg.cpp \
        dialogs/payedit.cpp \
-       dialogs/editreg.cpp
+       dialogs/editreg.cpp \
+       dialogs/seatchoicedlg.cpp
 
 RESOURCES += dialogs/dialogfiles.qrc
 
diff --git a/src/dialogs/seatchoicedlg.cpp b/src/dialogs/seatchoicedlg.cpp
new file mode 100644 (file)
index 0000000..e3d219a
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// 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)
+{
+
+}
diff --git a/src/dialogs/seatchoicedlg.h b/src/dialogs/seatchoicedlg.h
new file mode 100644 (file)
index 0000000..6bf3f4c
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// 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