Added an EditItemDialog dummy, based on the NewItemDialog.
This commit is contained in:
@ -31,6 +31,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
assets/icons.qrc
|
||||
Dialogs/abstractdialog.h Dialogs/abstractdialog.cpp
|
||||
Dialogs/newitemdialog.h Dialogs/newitemdialog.cpp
|
||||
Dialogs/edititemdialog.h Dialogs/edititemdialog.cpp
|
||||
)
|
||||
# Define target properties for Android with Qt 6 as:
|
||||
# set_property(TARGET ${TARGET_APP} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
||||
|
||||
60
Dialogs/edititemdialog.cpp
Normal file
60
Dialogs/edititemdialog.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "edititemdialog.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
|
||||
EditItemDialog::EditItemDialog(QWidget* parent)
|
||||
: AbstractDialog(parent) {}
|
||||
|
||||
void EditItemDialog::createContent() {
|
||||
if (m_contentContainer) {
|
||||
delete m_contentContainer;
|
||||
}
|
||||
|
||||
setWindowTitle(tr("Edit item..."));
|
||||
|
||||
m_contentContainer = new QWidget(this);
|
||||
|
||||
// REFACTOR deduce label names and types from meta data & use a factory
|
||||
m_nameLabel = new QLabel("&Name");
|
||||
m_nameEdit = new QLineEdit();
|
||||
m_nameLabel->setBuddy(m_nameEdit);
|
||||
|
||||
m_descriptionLabel = new QLabel("&Description");
|
||||
m_descriptionEdit = new QLineEdit();
|
||||
m_descriptionLabel->setBuddy(m_descriptionEdit);
|
||||
|
||||
m_infoLabel = new QLabel("&Info");
|
||||
m_infoEdit = new QLineEdit();
|
||||
m_infoLabel->setBuddy(m_infoEdit);
|
||||
|
||||
m_amountLabel = new QLabel("&Amount");
|
||||
m_amountBox = new QSpinBox();
|
||||
m_amountBox->setMaximum(1000);
|
||||
m_amountLabel->setBuddy(m_amountBox);
|
||||
|
||||
m_factorLabel = new QLabel("&Factor");
|
||||
m_factorBox = new QDoubleSpinBox();
|
||||
m_factorBox->setMaximum(1000);
|
||||
m_factorLabel->setBuddy(m_factorBox);
|
||||
|
||||
QGridLayout* layout = new QGridLayout();
|
||||
layout->addWidget(m_nameLabel, 0, 0, 1, 1);
|
||||
layout->addWidget(m_nameEdit, 0, 1, 1, 1);
|
||||
layout->addWidget(m_descriptionLabel, 1, 0, 1, 1);
|
||||
layout->addWidget(m_descriptionEdit, 1, 1, 1, 1);
|
||||
layout->addWidget(m_infoLabel, 2, 0, 1, 1);
|
||||
layout->addWidget(m_infoEdit, 2, 1, 1, 1);
|
||||
layout->addWidget(m_amountLabel, 3, 0, 1, 1);
|
||||
layout->addWidget(m_amountBox, 3, 1, 1, 1);
|
||||
layout->addWidget(m_factorLabel, 4, 0, 1, 1);
|
||||
layout->addWidget(m_factorBox, 4, 1, 1, 1);
|
||||
|
||||
m_contentContainer->setLayout(layout);
|
||||
|
||||
m_outerLayout->insertWidget(0, m_contentContainer);
|
||||
}
|
||||
36
Dialogs/edititemdialog.h
Normal file
36
Dialogs/edititemdialog.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef EDITITEMDIALOG_H
|
||||
#define EDITITEMDIALOG_H
|
||||
|
||||
#include "abstractdialog.h"
|
||||
|
||||
class QDoubleSpinBox;
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
class QLabel;
|
||||
|
||||
class EditItemDialog : public AbstractDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EditItemDialog(QWidget* parent = nullptr);
|
||||
|
||||
/// AbstractDialog interface
|
||||
void createContent() override;
|
||||
|
||||
private:
|
||||
QLabel* m_nameLabel = nullptr;
|
||||
QLineEdit* m_nameEdit = nullptr;
|
||||
|
||||
QLabel* m_descriptionLabel = nullptr;
|
||||
QLineEdit* m_descriptionEdit = nullptr;
|
||||
|
||||
QLabel* m_infoLabel = nullptr;
|
||||
QLineEdit* m_infoEdit = nullptr;
|
||||
|
||||
QLabel* m_amountLabel = nullptr;
|
||||
QSpinBox* m_amountBox = nullptr;
|
||||
|
||||
QLabel* m_factorLabel = nullptr;
|
||||
QDoubleSpinBox* m_factorBox = nullptr;
|
||||
};
|
||||
|
||||
#endif // EDITITEMDIALOG_H
|
||||
@ -7,6 +7,7 @@ class QDoubleSpinBox;
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
class QLabel;
|
||||
|
||||
class NewItemDialog : public AbstractDialog {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <QUndoView>
|
||||
|
||||
#include "../../ApplicationConfig.h"
|
||||
#include "Dialogs/edititemdialog.h"
|
||||
#include "Dialogs/newitemdialog.h"
|
||||
#include "data/settingshandler.h"
|
||||
#include "genericcore.h"
|
||||
@ -156,6 +157,11 @@ void MainWindow::openNewItemDialog() {
|
||||
m_newItemDialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::openEditItemDialog() {
|
||||
showStatusMessage(tr("Invoked 'Edit|Edit Item'"));
|
||||
m_editItemDialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::deleteSelectedtItems() {
|
||||
showStatusMessage(tr("Invoked 'Edit|Delete Item'"));
|
||||
QItemSelection localSelection = ui->tableView->selectionModel()->selection();
|
||||
@ -336,8 +342,8 @@ void MainWindow::createEditActions() {
|
||||
m_openEditItemDialogAct = make_unique<QAction>(tr("&Edit item"), this);
|
||||
m_openEditItemDialogAct->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_E));
|
||||
m_openEditItemDialogAct->setStatusTip(tr("Opens a edit dialog for the current item"));
|
||||
// connect(m_openEditItemDialogAct, &QAction::triggered, this, &MainWindow::openEditDialog);
|
||||
m_openEditItemDialogAct->setEnabled(false);
|
||||
connect(m_openEditItemDialogAct.get(), &QAction::triggered, this,
|
||||
&MainWindow::openEditItemDialog);
|
||||
ui->menu_Edit->addAction(m_openEditItemDialogAct.get());
|
||||
|
||||
m_deleteItemAct = make_unique<QAction>(tr("&Delete item(s)"), this);
|
||||
@ -367,8 +373,12 @@ void MainWindow::createHelpMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::createGuiDialogs() {
|
||||
/// new item dialog
|
||||
m_newItemDialog = make_unique<NewItemDialog>(this);
|
||||
m_newItemDialog->createContent();
|
||||
connect(m_newItemDialog.get(), &NewItemDialog::addItems, m_tableModel.get(),
|
||||
&TableModel::appendItems);
|
||||
/// edit item dialog
|
||||
m_editItemDialog = make_unique<EditItemDialog>(this);
|
||||
m_editItemDialog->createContent();
|
||||
}
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
#include <QItemSelection>
|
||||
#include <QMainWindow>
|
||||
|
||||
class NewItemDialog;
|
||||
class TableModel;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QUndoStack;
|
||||
@ -18,6 +15,9 @@ class MainWindow;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class GenericCore;
|
||||
class TableModel;
|
||||
class NewItemDialog;
|
||||
class EditItemDialog;
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -46,6 +46,7 @@ class MainWindow : public QMainWindow {
|
||||
|
||||
/// slots for menu actions
|
||||
void openNewItemDialog();
|
||||
void openEditItemDialog();
|
||||
void deleteSelectedtItems();
|
||||
|
||||
void onCleanStateChanged(bool clean);
|
||||
@ -83,6 +84,7 @@ class MainWindow : public QMainWindow {
|
||||
|
||||
/// Dialogs
|
||||
unique_ptr<NewItemDialog> m_newItemDialog;
|
||||
unique_ptr<EditItemDialog> m_editItemDialog;
|
||||
|
||||
/// Setup functions
|
||||
void createActions();
|
||||
|
||||
Reference in New Issue
Block a user