From 7ee067db16f56775bde37a83bccccc12f8fbd184 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Thu, 17 Mar 2016 09:49:11 +0100 Subject: [PATCH] draft of seat choice dialog --- src/dialogs/dialogs.pri | 6 ++- src/dialogs/seatchoicedlg.cpp | 100 +++++++++++++++++++++++++++++++++++++++++ src/dialogs/seatchoicedlg.h | 87 +++++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 src/dialogs/seatchoicedlg.cpp create mode 100644 src/dialogs/seatchoicedlg.h diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index 2ead568..93648e3 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -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 index 0000000..e3d219a --- /dev/null +++ b/src/dialogs/seatchoicedlg.cpp @@ -0,0 +1,100 @@ +// +// C++ Interface: chosing a seat for a ticket +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#include "seatchoicedlg.h" + +#include +#include + +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 index 0000000..6bf3f4c --- /dev/null +++ b/src/dialogs/seatchoicedlg.h @@ -0,0 +1,87 @@ +// +// C++ Interface: chosing a seat for a ticket +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2016 +// +// Copyright: See README/COPYING.GPL files that come with this distribution +// +// + +#ifndef MAGICSMOKE_SEATCHOICE_H +#define MAGICSMOKE_SEATCHOICE_H + +#include +#include + +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>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>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 -- 1.7.2.5