Initial commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#ifndef ENTITY_DELETER_WIDGET_H
|
||||
#define ENTITY_DELETER_WIDGET_H
|
||||
|
||||
#include "repository_manager.h"
|
||||
#include "schema_metadata.h"
|
||||
#include "ui_entity_deleter_widget.h"
|
||||
|
||||
// Forward declaration
|
||||
class RepositoryResult;
|
||||
|
||||
class EntityDeleterWidget : public QWidget, private Ui::EntityDeleterWidget {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QSqlRecord selectedRecord_;
|
||||
QSqlField retrievedField_;
|
||||
|
||||
public:
|
||||
explicit EntityDeleterWidget(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void setupComboBoxCurrentTable();
|
||||
void setupConnections();
|
||||
void setupEntityFinder();
|
||||
|
||||
private slots:
|
||||
void onComboBoxCurrentTableCurrentIndexChanged(int index);
|
||||
void onFieldRetrieved(const QSqlField &field);
|
||||
void onPushButtonDeleteEntityClicked();
|
||||
void onRecordRetrieved(const QSqlRecord &rowValues);
|
||||
|
||||
private:
|
||||
void refreshEntityFinder();
|
||||
|
||||
void showMessageDialog(const RepositoryResult &result,
|
||||
const QString &successMessage);
|
||||
|
||||
template <typename Repository> Repository *currentRepository();
|
||||
template <typename Repository> RepositoryResult deleteEntityById();
|
||||
};
|
||||
|
||||
template <typename Repository>
|
||||
Repository *EntityDeleterWidget::currentRepository() {
|
||||
SchemaMetadata metadata = SchemaMetadata::defaultSchema();
|
||||
|
||||
const QString &databaseTableName =
|
||||
comboBoxCurrentTable->currentData().toString();
|
||||
|
||||
return RepositoryManager::instance().getRepositoryAs<Repository>(
|
||||
metadata.repositoryTableName(databaseTableName));
|
||||
}
|
||||
|
||||
#endif // ENTITY_DELETER_WIDGET_H
|
||||
Reference in New Issue
Block a user