Compare commits

..

13 Commits

Author SHA1 Message Date
5e3950f6ba Bumped version to 0.3.0. 2026-02-04 11:28:11 +01:00
34a34891b4 In SettingsDialog: Disabled the email and password input edits. 2026-02-03 12:12:51 +01:00
4c4d734b1b Added a SettingsDialog with a "Server" tab to configure the server settings. 2026-02-03 11:22:55 +01:00
0eef55fc32 Don't use the SettingsHandler directly. Go through the GenericCore instead. 2026-02-03 11:21:33 +01:00
d109eb31f8 Added "Server/Delete item" menu action. 2026-02-02 16:30:59 +01:00
a9f24ac8f2 Adjusted to GenericCore::postItemsToServer and using ModelItemsValues typedef in new item dialog. 2026-02-02 16:25:17 +01:00
67d9a3914d Retrieving JSON data from the proxy model and send it via core to the server. 2026-01-29 15:11:59 +01:00
518bebcbb7 Added "Server" menu with "fetch items" and "post items" actions to trigger communication with the RESTful server. 2026-01-29 09:00:12 +01:00
8f61c6bc2f Bugfix: Save changes when closing the EditItemDialog. 2026-01-19 18:40:39 +01:00
a966b26185 Getting rid of warning, that a widget has already a layout. 2026-01-19 14:43:07 +01:00
a8bf5b4032 Displaying a QR code in the EditItemDialog containing the full data of the current item as a string. 2026-01-15 14:06:02 +01:00
c83ba2da9d Bumped version to 0.2.0. 2026-01-14 10:27:38 +01:00
232b9ceb78 Added a find items dialog to select items based on if they contain a specific text. 2026-01-12 15:02:34 +01:00
11 changed files with 275 additions and 24 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
set(TARGET_APP "GenericQtClient-Widgets") set(TARGET_APP "GenericQtClient-Widgets")
project(${TARGET_APP} VERSION 0.1.0 LANGUAGES CXX) project(${TARGET_APP} VERSION 0.3.0 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -32,6 +32,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
dialogs/abstractdialog.h dialogs/abstractdialog.cpp dialogs/abstractdialog.h dialogs/abstractdialog.cpp
dialogs/newitemdialog.h dialogs/newitemdialog.cpp dialogs/newitemdialog.h dialogs/newitemdialog.cpp
dialogs/edititemdialog.h dialogs/edititemdialog.cpp dialogs/edititemdialog.h dialogs/edititemdialog.cpp
dialogs/settingsdialog.h dialogs/settingsdialog.cpp
views/itemdetailmapper.h views/itemdetailmapper.cpp views/itemdetailmapper.h views/itemdetailmapper.cpp
) )
# Define target properties for Android with Qt 6 as: # Define target properties for Android with Qt 6 as:
@ -63,6 +64,8 @@ target_link_libraries(${TARGET_APP} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/) target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/)
target_link_libraries(${TARGET_APP} PRIVATE GenericCore) target_link_libraries(${TARGET_APP} PRIVATE GenericCore)
target_include_directories(${TARGET_APP} PRIVATE ${QR_LIB_DIR}/src)
target_link_libraries(${TARGET_APP} PRIVATE qrcode)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.

View File

@ -1,13 +1,15 @@
#include "edititemdialog.h" #include "edititemdialog.h"
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QLabel>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "../views/itemdetailmapper.h" #include "../views/itemdetailmapper.h"
EditItemDialog::EditItemDialog(QTableView* tableView, QWidget* parent) EditItemDialog::EditItemDialog(QTableView* tableView, QWidget* parent)
: AbstractDialog(QDialogButtonBox::Close, parent) : AbstractDialog(QDialogButtonBox::Ok, parent)
, m_tableView(tableView) {} , m_tableView(tableView)
, m_qrCodeDisplay(new QLabel("QR Code")) {}
void EditItemDialog::createContent() { void EditItemDialog::createContent() {
if (m_contentContainer) { if (m_contentContainer) {
@ -16,9 +18,17 @@ void EditItemDialog::createContent() {
setWindowTitle(tr("Edit item...")); setWindowTitle(tr("Edit item..."));
m_contentContainer = new QWidget(this);
QHBoxLayout* innerLayout = new QHBoxLayout();
m_contentContainer->setLayout(innerLayout);
m_detailMapper = new ItemDetailMapper(this); m_detailMapper = new ItemDetailMapper(this);
m_detailMapper->setModelMappings(m_tableView); m_detailMapper->setModelMappings(m_tableView);
m_contentContainer = m_detailMapper; innerLayout->addWidget(m_detailMapper);
updateQRCode();
connect(m_detailMapper, &ItemDetailMapper::contentChanged, this, &EditItemDialog::updateQRCode);
innerLayout->addWidget(m_qrCodeDisplay);
m_outerLayout->insertWidget(0, m_contentContainer); m_outerLayout->insertWidget(0, m_contentContainer);
} }
@ -32,3 +42,16 @@ void EditItemDialog::reject() {
m_detailMapper->revert(); m_detailMapper->revert();
QDialog::reject(); QDialog::reject();
} }
void EditItemDialog::updateQRCode(const QString text) {
QImage unscaledImage;
if (text.isEmpty()) {
unscaledImage = QImage("://no-picture-taking.png");
} else {
unscaledImage = m_generator.generateQr(text);
}
QImage image = unscaledImage.scaled(250, 250);
m_qrCodeDisplay->setPixmap(QPixmap::fromImage(image));
m_qrCodeDisplay->setToolTip(text);
}

View File

@ -1,6 +1,7 @@
#ifndef EDITITEMDIALOG_H #ifndef EDITITEMDIALOG_H
#define EDITITEMDIALOG_H #define EDITITEMDIALOG_H
#include "QrCodeGenerator.h"
#include "abstractdialog.h" #include "abstractdialog.h"
class QDoubleSpinBox; class QDoubleSpinBox;
@ -23,6 +24,9 @@ class EditItemDialog : public AbstractDialog {
void accept() override; void accept() override;
void reject() override; void reject() override;
private slots:
void updateQRCode(const QString text = "");
private: private:
QTableView* m_tableView = nullptr; QTableView* m_tableView = nullptr;
ItemDetailMapper* m_detailMapper; ItemDetailMapper* m_detailMapper;
@ -41,6 +45,9 @@ class EditItemDialog : public AbstractDialog {
QLabel* m_factorLabel = nullptr; QLabel* m_factorLabel = nullptr;
QDoubleSpinBox* m_factorBox = nullptr; QDoubleSpinBox* m_factorBox = nullptr;
QLabel* m_qrCodeDisplay = nullptr;
QrCodeGenerator m_generator;
}; };
#endif // EDITITEMDIALOG_H #endif // EDITITEMDIALOG_H

View File

@ -64,7 +64,7 @@ void NewItemDialog::createContent() {
} }
void NewItemDialog::accept() { void NewItemDialog::accept() {
QHash<int, QVariant> itemValues; ModelItemValues itemValues;
// TODO (after refactoring data structure for input widgets) use iteration through the relevant // TODO (after refactoring data structure for input widgets) use iteration through the relevant
// roles and their input widgets // roles and their input widgets
itemValues.insert(NameRole, m_nameEdit->text()); itemValues.insert(NameRole, m_nameEdit->text());
@ -73,7 +73,7 @@ void NewItemDialog::accept() {
itemValues.insert(AmountRole, m_amountBox->value()); itemValues.insert(AmountRole, m_amountBox->value());
itemValues.insert(FactorRole, m_factorBox->value()); itemValues.insert(FactorRole, m_factorBox->value());
const QByteArray jsonDoc = JsonParser::itemValuesListToJson({itemValues}, ITEM_KEY_STRING); const QByteArray jsonDoc = JsonParser::itemValuesListToJson({itemValues}, ITEMS_KEY_STRING);
emit addItems(jsonDoc); emit addItems(jsonDoc);
// resetContent(); // resetContent();

View File

@ -0,0 +1,63 @@
#include "settingsdialog.h"
#include <QCoreApplication>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QTabWidget>
SettingsDialog::SettingsDialog(QWidget* parent)
: AbstractDialog(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent) {}
void SettingsDialog::createContent() {
if (m_contentContainer) {
delete m_contentContainer;
}
const QString dialogTitle = tr("Settings - ");
const QString applicationName = QCoreApplication::applicationName();
setWindowTitle(dialogTitle + applicationName);
setModal(true);
setGeometry(0, 0, 350, 250);
QGridLayout* serverLayout = new QGridLayout();
QLabel* urlLabel = new QLabel("Server URL:");
m_urlEdit = new QLineEdit();
serverLayout->addWidget(urlLabel, 0, 0);
serverLayout->addWidget(m_urlEdit, 0, 1);
QLabel* emailLabel = new QLabel("Email:");
m_emailEdit = new QLineEdit();
m_emailEdit->setEnabled(false);
serverLayout->addWidget(emailLabel, 1, 0);
serverLayout->addWidget(m_emailEdit, 1, 1);
QLabel* passwordLabel = new QLabel("Password:");
m_passwordEdit = new QLineEdit();
m_passwordEdit->setEnabled(false);
m_passwordEdit->setEchoMode(QLineEdit::Password);
serverLayout->addWidget(passwordLabel, 2, 0);
serverLayout->addWidget(m_passwordEdit, 2, 1);
QWidget* serverTab = new QWidget();
serverTab->setLayout(serverLayout);
QTabWidget* widget = new QTabWidget();
widget->addTab(serverTab, "Server");
m_contentContainer = widget;
m_outerLayout->insertWidget(0, m_contentContainer);
}
void SettingsDialog::fillContent(const QVariantMap& settings) {
m_urlEdit->setText(settings.value("url").toString());
m_emailEdit->setText(settings.value("email").toString());
m_passwordEdit->setText(settings.value("password").toString());
}
QVariantMap SettingsDialog::getSettings() const {
QVariantMap result;
result.insert("url", m_urlEdit->text());
result.insert("email", m_emailEdit->text());
result.insert("password", m_passwordEdit->text());
return result;
}

23
dialogs/settingsdialog.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "abstractdialog.h"
class QLineEdit;
class SettingsDialog : public AbstractDialog {
Q_OBJECT
public:
SettingsDialog(QWidget* parent = nullptr);
void createContent() override;
void fillContent(const QVariantMap& settings);
QVariantMap getSettings() const;
private:
QLineEdit* m_urlEdit = nullptr;
QLineEdit* m_emailEdit = nullptr;
QLineEdit* m_passwordEdit = nullptr;
};
#endif // SETTINGSDIALOG_H

View File

@ -3,15 +3,16 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QStandardPaths> #include <QStandardPaths>
#include <QUndoStack> #include <QUndoStack>
#include <QUndoView> #include <QUndoView>
#include "../../ApplicationConfig.h" #include "../../ApplicationConfig.h"
#include "data/settingshandler.h"
#include "dialogs/edititemdialog.h" #include "dialogs/edititemdialog.h"
#include "dialogs/newitemdialog.h" #include "dialogs/newitemdialog.h"
#include "dialogs/settingsdialog.h"
#include "genericcore.h" #include "genericcore.h"
#include "model/generalsortfiltermodel.h" #include "model/generalsortfiltermodel.h"
#include "model/tablemodel.h" #include "model/tablemodel.h"
@ -41,14 +42,14 @@ MainWindow::MainWindow(QWidget* parent)
setWindowIcon(QIcon(iconString)); setWindowIcon(QIcon(iconString));
#endif #endif
const QVariantMap settings = SettingsHandler::getSettings("GUI"); const QVariantMap settings = m_core->getSettings("GUI");
restoreGeometry(settings.value("geometry").toByteArray()); restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray()); restoreState(settings.value("windowState").toByteArray());
m_tableModel = m_core->getModel(); // m_tableModel = m_core->getModel();
// ui->tableView->setModel(m_tableModel.get()); // ui->tableView->setModel(m_tableModel.get());
m_sortModel = m_core->getSortFilterModel(); m_proxyModel = m_core->getSortFilterModel();
ui->tableView->setModel((QAbstractItemModel*)m_sortModel.get()); ui->tableView->setModel((QAbstractItemModel*)m_proxyModel.get());
ui->tableView->setSortingEnabled(true); ui->tableView->setSortingEnabled(true);
createActions(); createActions();
@ -105,8 +106,7 @@ void MainWindow::closeEvent(QCloseEvent* event) {
if (event->isAccepted()) { if (event->isAccepted()) {
qInfo() << "Saving GUI settings..."; qInfo() << "Saving GUI settings...";
SettingsHandler::saveSettings({{"geometry", saveGeometry()}, {"windowState", saveState()}}, m_core->applySettings({{"geometry", saveGeometry()}, {"windowState", saveState()}}, "GUI");
"GUI");
} }
} }
@ -194,7 +194,7 @@ void MainWindow::deleteCurrentItem() {
if (currentIndex == QModelIndex()) { if (currentIndex == QModelIndex()) {
qDebug() << "No current item. Nothing to remove."; qDebug() << "No current item. Nothing to remove.";
} else { } else {
m_sortModel->removeRows(currentIndex.row(), 1); m_proxyModel->removeRows(currentIndex.row(), 1);
} }
} }
@ -212,7 +212,7 @@ void MainWindow::deleteSelectedtItems() {
const int topRow = iter->top(); const int topRow = iter->top();
const int bottomRow = iter->bottom(); const int bottomRow = iter->bottom();
const int nRows = bottomRow - topRow + 1; const int nRows = bottomRow - topRow + 1;
m_sortModel->removeRows(topRow, nRows); m_proxyModel->removeRows(topRow, nRows);
} }
} }
} }
@ -278,11 +278,75 @@ void MainWindow::exportCSV() {
} }
} }
void MainWindow::findItems() {
showStatusMessage(tr("Invoked 'Edit|Find items'"));
bool ok;
QString text = QInputDialog::getText(this, tr("Find items"), tr("Enter the text to search for:"),
QLineEdit::Normal, "", &ok);
if (ok && !text.isEmpty()) {
const QItemSelection itemsToSelect = m_proxyModel->findItems(text);
if (itemsToSelect.empty()) {
ui->tableView->setCurrentIndex(QModelIndex());
ui->tableView->selectionModel()->select(QModelIndex(), QItemSelectionModel::ClearAndSelect);
} else {
ui->tableView->setCurrentIndex(itemsToSelect.first().topLeft());
ui->tableView->selectionModel()->select(itemsToSelect, QItemSelectionModel::ClearAndSelect);
}
}
}
void MainWindow::fetchItems() {
showStatusMessage(tr("Invoked 'Server|Fetch items'"));
emit m_core->fetchItemsFromServer();
}
void MainWindow::postItems() {
showStatusMessage(tr("Invoked 'Server|Post items'"));
const QModelIndex currentIndex = ui->tableView->currentIndex();
const QByteArray jsonData = m_proxyModel->jsonDataForServer(currentIndex);
emit m_core->postItemToServer(jsonData);
}
void MainWindow::deleteItem() {
showStatusMessage(tr("Invoked 'Server|Delete items'"));
const QModelIndex currentIndex = ui->tableView->currentIndex();
// const QByteArray jsonData = m_proxyModel->jsonDataForServer(currentIndex);
const QString currentId = m_proxyModel->getUuid(currentIndex);
emit m_core->deleteItemFromServer(currentId);
}
void MainWindow::execSettingsDialog() {
showStatusMessage(tr("Invoked 'Tools|Settings'"));
QVariantMap oldSettings = m_core->getSettings("Server");
// SettingsDialog* settingsDialog = new SettingsDialog(settingMap, this);
SettingsDialog* settingsDialog = new SettingsDialog(this);
settingsDialog->createContent();
settingsDialog->fillContent(oldSettings);
int returnCode = settingsDialog->exec();
if (returnCode == QDialog::Accepted) {
qDebug() << "Settings dialog accepted, writing settings...";
const QVariantMap settings = settingsDialog->getSettings();
m_core->applySettings(settings, "Server");
// TODO use signal-slot connection Core::syncServerSetupChanged(bool enabled) ->
// MainWindow::onSyncServerSetupChanged(bool enabled)
// enableDisableServerActions();
} else {
qDebug() << "Settings dialog rejected";
}
delete settingsDialog;
}
void MainWindow::createActions() { void MainWindow::createActions() {
// TODO add generic menu actions (file/new, edit/cut, ...) // TODO add generic menu actions (file/new, edit/cut, ...)
createFileActions(); createFileActions();
createUndoActions(); createUndoActions();
createEditActions(); createEditActions();
createServerActions();
createToolsActions();
} }
void MainWindow::createFileActions() { void MainWindow::createFileActions() {
@ -414,7 +478,7 @@ void MainWindow::createEditActions() {
ui->menu_Edit->addAction(m_openEditItemDialogAct.get()); ui->menu_Edit->addAction(m_openEditItemDialogAct.get());
m_deleteItemAct = make_unique<QAction>(tr("&Delete item(s)"), this); m_deleteItemAct = make_unique<QAction>(tr("&Delete item(s)"), this);
m_deleteItemAct->setShortcuts(QKeySequence::Delete); m_deleteItemAct->setShortcut(QKeySequence::Delete);
m_deleteItemAct->setStatusTip(tr("Delete currently selected item(s)")); m_deleteItemAct->setStatusTip(tr("Delete currently selected item(s)"));
// connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteSelectedtItems); // connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteSelectedtItems);
connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteCurrentItem); connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteCurrentItem);
@ -425,11 +489,38 @@ void MainWindow::createEditActions() {
m_findItemAct = make_unique<QAction>(tr("&Find item(s)"), this); m_findItemAct = make_unique<QAction>(tr("&Find item(s)"), this);
m_findItemAct->setShortcuts(QKeySequence::Find); m_findItemAct->setShortcuts(QKeySequence::Find);
m_findItemAct->setStatusTip(tr("Opens a dialog to find item(s) by containing text")); m_findItemAct->setStatusTip(tr("Opens a dialog to find item(s) by containing text"));
// connect(m_findItemAct, &QAction::triggered, this, &MainWindow::findItems); connect(m_findItemAct.get(), &QAction::triggered, this, &MainWindow::findItems);
m_findItemAct->setEnabled(false);
ui->menu_Edit->addAction(m_findItemAct.get()); ui->menu_Edit->addAction(m_findItemAct.get());
} }
void MainWindow::createServerActions() {
m_fetchItemsAct = make_unique<QAction>(tr("&Fetch item(s)"), this);
m_fetchItemsAct->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Down));
m_fetchItemsAct->setStatusTip(tr("Fetches all item on configured server"));
connect(m_fetchItemsAct.get(), &QAction::triggered, this, &MainWindow::fetchItems);
ui->menu_Server->addAction(m_fetchItemsAct.get());
m_postItemsAct = make_unique<QAction>(tr("&Post item(s)"), this);
m_postItemsAct->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Up));
// m_postItemsAct->setStatusTip(tr("Posts the selected items on configured server"));
m_postItemsAct->setStatusTip(tr("Posts the current item on configured server"));
connect(m_postItemsAct.get(), &QAction::triggered, this, &MainWindow::postItems);
ui->menu_Server->addAction(m_postItemsAct.get());
m_deleteItemsAct = make_unique<QAction>(tr("&Delete item"), this);
m_deleteItemsAct->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Backspace));
// m_deleteItemsAct->setStatusTip(tr("Deletes the selected items on configured server"));
m_deleteItemsAct->setStatusTip(tr("Deletes the current item on configured server"));
connect(m_deleteItemsAct.get(), &QAction::triggered, this, &MainWindow::deleteItem);
ui->menu_Server->addAction(m_deleteItemsAct.get());
}
void MainWindow::createToolsActions() {
QMenu* menu = ui->menu_Tools;
QAction* settingsAct = menu->addAction(tr("&Settings"), this, &MainWindow::execSettingsDialog);
settingsAct->setStatusTip(tr("Opens a dialog to configure applications settings."));
}
void MainWindow::createHelpMenu() { void MainWindow::createHelpMenu() {
QMenu* helpMenu = ui->menu_Help; QMenu* helpMenu = ui->menu_Help;
helpMenu->addSeparator(); helpMenu->addSeparator();
@ -444,7 +535,7 @@ void MainWindow::createGuiDialogs() {
/// new item dialog /// new item dialog
m_newItemDialog = make_unique<NewItemDialog>(this); m_newItemDialog = make_unique<NewItemDialog>(this);
m_newItemDialog->createContent(); m_newItemDialog->createContent();
connect(m_newItemDialog.get(), &NewItemDialog::addItems, m_sortModel.get(), connect(m_newItemDialog.get(), &NewItemDialog::addItems, m_proxyModel.get(),
&GeneralSortFilterModel::appendItems); &GeneralSortFilterModel::appendItems);
/// edit item dialog /// edit item dialog
m_editItemDialog = make_unique<EditItemDialog>(ui->tableView, this); m_editItemDialog = make_unique<EditItemDialog>(ui->tableView, this);

View File

@ -60,13 +60,22 @@ class MainWindow : public QMainWindow {
void importCSV(); void importCSV();
void exportCSV(); void exportCSV();
/// 'Edit' slots
void findItems();
/// 'Server' slots
void fetchItems();
void postItems();
void deleteItem();
/// 'Tools' slots
void execSettingsDialog();
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
// GenericCore* m_core;
unique_ptr<GenericCore> m_core; unique_ptr<GenericCore> m_core;
shared_ptr<TableModel> m_tableModel; shared_ptr<GeneralSortFilterModel> m_proxyModel;
shared_ptr<GeneralSortFilterModel> m_sortModel;
QUndoStack* m_modelUndoStack; QUndoStack* m_modelUndoStack;
unique_ptr<QUndoView> m_modelUndoView; unique_ptr<QUndoView> m_modelUndoView;
@ -88,6 +97,11 @@ class MainWindow : public QMainWindow {
unique_ptr<QAction> m_openEditItemDialogAct; unique_ptr<QAction> m_openEditItemDialogAct;
unique_ptr<QAction> m_deleteItemAct; unique_ptr<QAction> m_deleteItemAct;
unique_ptr<QAction> m_findItemAct; unique_ptr<QAction> m_findItemAct;
/// Server actions
unique_ptr<QAction> m_fetchItemsAct;
unique_ptr<QAction> m_postItemsAct;
unique_ptr<QAction> m_deleteItemsAct;
/// View actions /// View actions
unique_ptr<QAction> m_showModelUndoViewAct; unique_ptr<QAction> m_showModelUndoViewAct;
@ -100,6 +114,8 @@ class MainWindow : public QMainWindow {
void createFileActions(); void createFileActions();
void createUndoActions(); void createUndoActions();
void createEditActions(); void createEditActions();
void createServerActions();
void createToolsActions();
void createHelpMenu(); void createHelpMenu();
void createGuiDialogs(); void createGuiDialogs();
}; };

View File

@ -40,7 +40,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>25</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menu_File"> <widget class="QMenu" name="menu_File">
@ -64,9 +64,21 @@
</property> </property>
<addaction name="actionCheck_for_update"/> <addaction name="actionCheck_for_update"/>
</widget> </widget>
<widget class="QMenu" name="menu_Server">
<property name="title">
<string>&amp;Server</string>
</property>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>&amp;Tools</string>
</property>
</widget>
<addaction name="menu_File"/> <addaction name="menu_File"/>
<addaction name="menu_Edit"/> <addaction name="menu_Edit"/>
<addaction name="menu_View"/> <addaction name="menu_View"/>
<addaction name="menu_Server"/>
<addaction name="menu_Tools"/>
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>

View File

@ -10,6 +10,7 @@
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QTableView> #include <QTableView>
#include "model/metadata.h"
ItemDetailMapper::ItemDetailMapper(QWidget* parent) ItemDetailMapper::ItemDetailMapper(QWidget* parent)
: QWidget{parent} { : QWidget{parent} {
@ -101,12 +102,13 @@ bool ItemDetailMapper::submit() { return m_mapper->submit(); }
void ItemDetailMapper::revert() { m_mapper->revert(); } void ItemDetailMapper::revert() { m_mapper->revert(); }
void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current, void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
const QModelIndex& previous) { const QModelIndex& /*previous*/) {
if (!isEnabled()) { if (!isEnabled()) {
setEnabled(true); setEnabled(true);
} }
m_mapper->setCurrentModelIndex(current); m_mapper->setCurrentModelIndex(current);
updateButtons(current.row()); updateButtons(current.row());
emitContentChanged(current);
} }
void ItemDetailMapper::rowsInserted(const QModelIndex& parent, int start, int end) { void ItemDetailMapper::rowsInserted(const QModelIndex& parent, int start, int end) {
@ -147,3 +149,12 @@ void ItemDetailMapper::updateButtons(int row) {
m_previousButton->setEnabled(row > 0); m_previousButton->setEnabled(row > 0);
m_nextButton->setEnabled(row < m_model->rowCount() - 1); m_nextButton->setEnabled(row < m_model->rowCount() - 1);
} }
void ItemDetailMapper::emitContentChanged(const QModelIndex& currentIndex) {
// BUG QR-Code isn't updated after changes through the ItemDetailMapper #18
QString toStringText = "";
if (currentIndex.isValid()) {
toStringText = currentIndex.data(ToStringRole).toString();
}
emit contentChanged(toStringText);
}

View File

@ -24,6 +24,7 @@ class ItemDetailMapper : public QWidget {
void revert(); void revert();
signals: signals:
void contentChanged(const QString text);
private slots: private slots:
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous); void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
@ -32,6 +33,7 @@ class ItemDetailMapper : public QWidget {
void toPrevious(); void toPrevious();
void toNext(); void toNext();
void updateButtons(int row); void updateButtons(int row);
void emitContentChanged(const QModelIndex& currentIndex);
private: private:
/// *** members *** /// *** members ***