86 lines
2.2 KiB
C++
86 lines
2.2 KiB
C++
#ifndef ENTITY_FINDER_WIDGET_H
|
|
#define ENTITY_FINDER_WIDGET_H
|
|
|
|
#include "ui_entity_finder_widget.h"
|
|
#include <QSqlField>
|
|
#include <QSqlRecord>
|
|
|
|
// Forward declaration
|
|
class SearchDialog;
|
|
|
|
class EntityFinderWidget : public QWidget, private Ui::EntityFinderWidget {
|
|
Q_OBJECT
|
|
|
|
private:
|
|
QString fieldName_;
|
|
QString modelTableName_;
|
|
int originalFrameStyle_;
|
|
|
|
public:
|
|
EntityFinderWidget(QWidget *parent = nullptr);
|
|
EntityFinderWidget(const QString &modelTableName, const QString &fieldName,
|
|
QWidget *parent = nullptr);
|
|
|
|
private:
|
|
void setupConnections();
|
|
void setupFrameStyle();
|
|
|
|
public:
|
|
void setHiddenFrame(bool hidden);
|
|
|
|
void refreshLineEditText(const QSqlRecord &fieldValue);
|
|
void setDefaultRelation(const QString &databaseRelationName);
|
|
|
|
inline void resetLineEditText();
|
|
inline void setLabelText(const QString &text);
|
|
inline void setLineEditPlaceholder(const QString &placeholder);
|
|
|
|
inline QString fieldName() const;
|
|
inline QString modelTableName() const;
|
|
|
|
signals:
|
|
void rowSelected(int rowIndex);
|
|
void recordRetrieved(QSqlRecord rowValues);
|
|
void fieldRetrieved(QSqlField fieldValue);
|
|
void reseted();
|
|
|
|
public slots:
|
|
void resetToDefault();
|
|
|
|
private slots:
|
|
void onPushButtonFindEntityClicked();
|
|
void onRowSelected(int rowIndex);
|
|
void onRecordRetrieved(const QSqlRecord &rowValues);
|
|
void onFieldRetrieved(const QSqlField &field);
|
|
|
|
private:
|
|
inline void setFieldName(const QString &fieldName);
|
|
inline void setModelTableName(const QString &modelTableName);
|
|
};
|
|
|
|
void EntityFinderWidget::resetLineEditText() {
|
|
lineEditEntityInformation->clear();
|
|
}
|
|
|
|
void EntityFinderWidget::setModelTableName(const QString &modelTableName) {
|
|
modelTableName_ = modelTableName;
|
|
}
|
|
|
|
void EntityFinderWidget::setFieldName(const QString &fieldName) {
|
|
fieldName_ = fieldName;
|
|
}
|
|
|
|
void EntityFinderWidget::setLabelText(const QString &text) {
|
|
labelEntityInformation->setText(text + ":");
|
|
}
|
|
|
|
void EntityFinderWidget::setLineEditPlaceholder(const QString &placeholder) {
|
|
lineEditEntityInformation->setPlaceholderText(placeholder);
|
|
}
|
|
|
|
QString EntityFinderWidget::fieldName() const { return fieldName_; }
|
|
|
|
QString EntityFinderWidget::modelTableName() const { return modelTableName_; }
|
|
|
|
#endif // ENTITY_FINDER_WIDGET_H
|