diff --git a/UIs/BeetRoundWidgets/CMakeLists.txt b/UIs/BeetRoundWidgets/CMakeLists.txt index 8c97104..1e558a0 100644 --- a/UIs/BeetRoundWidgets/CMakeLists.txt +++ b/UIs/BeetRoundWidgets/CMakeLists.txt @@ -36,6 +36,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) views/itemdetailmapper.h views/itemdetailmapper.cpp widgets/comboboxdelegate.h widgets/comboboxdelegate.cpp widgets/spinboxdelegate.h widgets/spinboxdelegate.cpp + widgets/biddingroundcontrol.h widgets/biddingroundcontrol.cpp ) # Define target properties for Android with Qt 6 as: # set_property(TARGET ${TARGET_APP} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR diff --git a/UIs/BeetRoundWidgets/mainwindow.cpp b/UIs/BeetRoundWidgets/mainwindow.cpp index 5b3985f..d783106 100644 --- a/UIs/BeetRoundWidgets/mainwindow.cpp +++ b/UIs/BeetRoundWidgets/mainwindow.cpp @@ -17,6 +17,7 @@ #include "model/generalsortfiltermodel.h" #include "model/metadata.h" #include "model/tablemodel.h" +#include "widgets/biddingroundcontrol.h" #include "widgets/comboboxdelegate.h" #include "widgets/spinboxdelegate.h" @@ -70,6 +71,8 @@ MainWindow::MainWindow(QWidget* parent) onSelectionChanged(QItemSelection(), QItemSelection()); onCurrentChanged(QModelIndex(), QModelIndex()); + + setupEventTab(); } MainWindow::~MainWindow() { delete ui; } @@ -176,11 +179,6 @@ void MainWindow::on_actionCheck_for_update_triggered() { } } -void MainWindow::on_pushButton_clicked() { - const QString prefix("Backend provided by: "); - ui->label->setText(prefix + m_core->toString()); -} - void MainWindow::openNewItemDialog() { showStatusMessage(tr("Invoked 'Edit|New Item'")); m_newItemDialog->show(); @@ -569,3 +567,13 @@ void MainWindow::createGuiDialogs() { m_editItemDialog = make_unique(ui->tableView, this); m_editItemDialog->createContent(); } + +void MainWindow::setupEventTab() { + QWidget* containerWidget = new QWidget(); + QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget); + m_biddingRoundControl = make_unique(); + containerLayout->addWidget(m_biddingRoundControl.get()); + + + ui->tabWidget->insertTab(0, containerWidget, "Event (&1)"); +} diff --git a/UIs/BeetRoundWidgets/mainwindow.h b/UIs/BeetRoundWidgets/mainwindow.h index b8f9949..6ad35e4 100644 --- a/UIs/BeetRoundWidgets/mainwindow.h +++ b/UIs/BeetRoundWidgets/mainwindow.h @@ -19,6 +19,7 @@ class TableModel; class GeneralSortFilterModel; class NewItemDialog; class EditItemDialog; +class BiddingRoundControl; using namespace std; @@ -44,8 +45,6 @@ class MainWindow : public QMainWindow { void onAboutClicked(); void on_actionCheck_for_update_triggered(); - void on_pushButton_clicked(); - /// slots for menu actions void openNewItemDialog(); void openEditItemDialog(); @@ -78,7 +77,7 @@ class MainWindow : public QMainWindow { shared_ptr m_proxyModel; QUndoStack* m_modelUndoStack; unique_ptr m_modelUndoView; - + unique_ptr m_biddingRoundControl; /// File actions unique_ptr m_newFileAct; unique_ptr m_openAct; @@ -119,5 +118,7 @@ class MainWindow : public QMainWindow { void createToolsActions(); void createHelpMenu(); void createGuiDialogs(); + + void setupEventTab(); }; #endif // MAINWINDOW_H diff --git a/UIs/BeetRoundWidgets/mainwindow.ui b/UIs/BeetRoundWidgets/mainwindow.ui index d32d7f5..86e34b6 100644 --- a/UIs/BeetRoundWidgets/mainwindow.ui +++ b/UIs/BeetRoundWidgets/mainwindow.ui @@ -14,22 +14,22 @@ GenericQtClient - - - - - - - - Push the button! - - - - - - - Button + + + + + 0 + + + Mitglieder (&2) + + + + + + + diff --git a/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.cpp b/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.cpp new file mode 100644 index 0000000..9c4bffc --- /dev/null +++ b/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.cpp @@ -0,0 +1,57 @@ +#include "biddingroundcontrol.h" + +#include +#include +#include + +BiddingRoundControl::BiddingRoundControl(QWidget* parent) + : QWidget{parent} { + m_layout = new QHBoxLayout(this); + m_title = new QLabel("Bidding round control:"); + m_status = new QLabel("(No round started yet.)"); + + m_newRoundButton = new QPushButton("Start new round"); + m_restartRoundButton = new QPushButton("Restart last round"); + m_stopRoundButton = new QPushButton("Stop round"); + m_refreshRoundButton = new QPushButton("Refresh"); + + m_newRoundButton->setEnabled(false); + m_restartRoundButton->setEnabled(false); + m_stopRoundButton->setEnabled(false); + + m_layout->addWidget(m_title); + m_layout->addWidget(m_status); + m_layout->addWidget(m_newRoundButton); + m_layout->addWidget(m_restartRoundButton); + m_layout->addWidget(m_stopRoundButton); + m_layout->addWidget(m_refreshRoundButton); + + connect(m_newRoundButton, &QPushButton::clicked, this, + &BiddingRoundControl::triggerStartNewRound); + connect(m_restartRoundButton, &QPushButton::clicked, this, + &BiddingRoundControl::triggerRestartLastRound); + connect(m_stopRoundButton, &QPushButton::clicked, this, + &BiddingRoundControl::triggerStopCurrentRound); + connect(m_refreshRoundButton, &QPushButton::clicked, this, + &BiddingRoundControl::onRefreshCurrentRoundTriggered); +} + +void BiddingRoundControl::onRefreshCurrentRoundTriggered() { + emit sendGetRequest(GetCurrentBiddingRound); +} + +void BiddingRoundControl::onCurrentBiddingRoundChanged(int roundNumber, bool isActive) { + QString text = QString::number(roundNumber); + if (isActive) { + text.append(" (active)"); + m_newRoundButton->setEnabled(false); + m_restartRoundButton->setEnabled(false); + m_stopRoundButton->setEnabled(true); + } else { + text.append(" (stopped)"); + m_newRoundButton->setEnabled(true); + m_restartRoundButton->setEnabled(roundNumber > 0); + m_stopRoundButton->setEnabled(false); + } + m_status->setText(text); +} diff --git a/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.h b/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.h new file mode 100644 index 0000000..3b54c74 --- /dev/null +++ b/UIs/BeetRoundWidgets/widgets/biddingroundcontrol.h @@ -0,0 +1,41 @@ +#ifndef BIDDINGROUNDCONTROL_H +#define BIDDINGROUNDCONTROL_H + +#include +#include "model/metadata.h" + +class QPushButton; +class QLabel; +class QHBoxLayout; +class BiddingRoundControl : public QWidget { + Q_OBJECT + public: + explicit BiddingRoundControl(QWidget* parent = nullptr); + + signals: + void sendGetRequest(GetRequestTypes type); + + void triggerStartNewRound(); + void triggerRestartLastRound(); + void triggerStopCurrentRound(); + // void refreshCurrentRound(); + + public slots: + /// button slots + void onRefreshCurrentRoundTriggered(); + + /// event slots + void onCurrentBiddingRoundChanged(int roundNumber, bool isActive); + + private: + QHBoxLayout* m_layout = nullptr; + QLabel* m_title = nullptr; + QLabel* m_status = nullptr; + + QPushButton* m_newRoundButton = nullptr; + QPushButton* m_restartRoundButton = nullptr; + QPushButton* m_stopRoundButton = nullptr; + QPushButton* m_refreshRoundButton = nullptr; +}; + +#endif // BIDDINGROUNDCONTROL_H diff --git a/libs/BeetRoundCore/model/metadata.h b/libs/BeetRoundCore/model/metadata.h index 435511b..0e8dd84 100644 --- a/libs/BeetRoundCore/model/metadata.h +++ b/libs/BeetRoundCore/model/metadata.h @@ -82,6 +82,9 @@ static const QString ITEM_KEY_STRING = "item"; /// file naming static const QString ITEMS_FILE_NAME = ITEMS_KEY_STRING + ".json"; +/// server communication +enum GetRequestTypes { GetCurrentBiddingRound }; + /// functions static UserRoles GET_ROLE_FOR_COLUMN(const int column) { switch (column) {