Added an "Event" tab with a BiddingRoundControl class in it. No connections of signals and slots yet.

This commit is contained in:
2026-02-13 16:12:03 +01:00
parent bea89a2a16
commit a4d2815947
7 changed files with 134 additions and 23 deletions

View File

@ -36,6 +36,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
views/itemdetailmapper.h views/itemdetailmapper.cpp views/itemdetailmapper.h views/itemdetailmapper.cpp
widgets/comboboxdelegate.h widgets/comboboxdelegate.cpp widgets/comboboxdelegate.h widgets/comboboxdelegate.cpp
widgets/spinboxdelegate.h widgets/spinboxdelegate.cpp widgets/spinboxdelegate.h widgets/spinboxdelegate.cpp
widgets/biddingroundcontrol.h widgets/biddingroundcontrol.cpp
) )
# Define target properties for Android with Qt 6 as: # Define target properties for Android with Qt 6 as:
# set_property(TARGET ${TARGET_APP} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # set_property(TARGET ${TARGET_APP} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR

View File

@ -17,6 +17,7 @@
#include "model/generalsortfiltermodel.h" #include "model/generalsortfiltermodel.h"
#include "model/metadata.h" #include "model/metadata.h"
#include "model/tablemodel.h" #include "model/tablemodel.h"
#include "widgets/biddingroundcontrol.h"
#include "widgets/comboboxdelegate.h" #include "widgets/comboboxdelegate.h"
#include "widgets/spinboxdelegate.h" #include "widgets/spinboxdelegate.h"
@ -70,6 +71,8 @@ MainWindow::MainWindow(QWidget* parent)
onSelectionChanged(QItemSelection(), QItemSelection()); onSelectionChanged(QItemSelection(), QItemSelection());
onCurrentChanged(QModelIndex(), QModelIndex()); onCurrentChanged(QModelIndex(), QModelIndex());
setupEventTab();
} }
MainWindow::~MainWindow() { delete ui; } 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() { void MainWindow::openNewItemDialog() {
showStatusMessage(tr("Invoked 'Edit|New Item'")); showStatusMessage(tr("Invoked 'Edit|New Item'"));
m_newItemDialog->show(); m_newItemDialog->show();
@ -569,3 +567,13 @@ void MainWindow::createGuiDialogs() {
m_editItemDialog = make_unique<EditItemDialog>(ui->tableView, this); m_editItemDialog = make_unique<EditItemDialog>(ui->tableView, this);
m_editItemDialog->createContent(); m_editItemDialog->createContent();
} }
void MainWindow::setupEventTab() {
QWidget* containerWidget = new QWidget();
QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget);
m_biddingRoundControl = make_unique<BiddingRoundControl>();
containerLayout->addWidget(m_biddingRoundControl.get());
ui->tabWidget->insertTab(0, containerWidget, "Event (&1)");
}

View File

@ -19,6 +19,7 @@ class TableModel;
class GeneralSortFilterModel; class GeneralSortFilterModel;
class NewItemDialog; class NewItemDialog;
class EditItemDialog; class EditItemDialog;
class BiddingRoundControl;
using namespace std; using namespace std;
@ -44,8 +45,6 @@ class MainWindow : public QMainWindow {
void onAboutClicked(); void onAboutClicked();
void on_actionCheck_for_update_triggered(); void on_actionCheck_for_update_triggered();
void on_pushButton_clicked();
/// slots for menu actions /// slots for menu actions
void openNewItemDialog(); void openNewItemDialog();
void openEditItemDialog(); void openEditItemDialog();
@ -78,7 +77,7 @@ class MainWindow : public QMainWindow {
shared_ptr<GeneralSortFilterModel> m_proxyModel; shared_ptr<GeneralSortFilterModel> m_proxyModel;
QUndoStack* m_modelUndoStack; QUndoStack* m_modelUndoStack;
unique_ptr<QUndoView> m_modelUndoView; unique_ptr<QUndoView> m_modelUndoView;
unique_ptr<BiddingRoundControl> m_biddingRoundControl;
/// File actions /// File actions
unique_ptr<QAction> m_newFileAct; unique_ptr<QAction> m_newFileAct;
unique_ptr<QAction> m_openAct; unique_ptr<QAction> m_openAct;
@ -119,5 +118,7 @@ class MainWindow : public QMainWindow {
void createToolsActions(); void createToolsActions();
void createHelpMenu(); void createHelpMenu();
void createGuiDialogs(); void createGuiDialogs();
void setupEventTab();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -14,22 +14,22 @@
<string>GenericQtClient</string> <string>GenericQtClient</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QGridLayout" name="gridLayout_2">
<item> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_user">
<attribute name="title">
<string>Mitglieder (&amp;2)</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableView" name="tableView"/> <widget class="QTableView" name="tableView"/>
</item> </item>
<item> </layout>
<widget class="QLabel" name="label">
<property name="text">
<string>Push the button!</string>
</property>
</widget> </widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Button</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -0,0 +1,57 @@
#include "biddingroundcontrol.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
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);
}

View File

@ -0,0 +1,41 @@
#ifndef BIDDINGROUNDCONTROL_H
#define BIDDINGROUNDCONTROL_H
#include <QWidget>
#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

View File

@ -82,6 +82,9 @@ static const QString ITEM_KEY_STRING = "item";
/// file naming /// file naming
static const QString ITEMS_FILE_NAME = ITEMS_KEY_STRING + ".json"; static const QString ITEMS_FILE_NAME = ITEMS_KEY_STRING + ".json";
/// server communication
enum GetRequestTypes { GetCurrentBiddingRound };
/// functions /// functions
static UserRoles GET_ROLE_FOR_COLUMN(const int column) { static UserRoles GET_ROLE_FOR_COLUMN(const int column) {
switch (column) { switch (column) {