Improve element query widget

User can now filter each field of the query
This commit is contained in:
Claveau Joshua
2020-04-05 21:48:08 +02:00
parent 035709b70f
commit 60e61a9f20
8 changed files with 248 additions and 55 deletions

View File

@@ -165,12 +165,7 @@ QVariant NomenclatureModel::data(const QModelIndex &index, int role) const
void NomenclatureModel::query(const QString &query)
{
auto rm_ = m_query != query;
if (rm_)
{
auto headers = projectDataBase::headersFromElementsInfoQuery(query);
for (auto i=0 ; i<headers.size() ; ++i) {
this->setHeaderData(i, Qt::Horizontal, headers.at(i));
}
if (rm_) {
emit beginResetModel();
}
@@ -195,6 +190,18 @@ QETProject *NomenclatureModel::project() const {
return m_project.data();
}
/**
* @brief NomenclatureModel::autoHeaders
* Try to determine the name of each columns header
*/
void NomenclatureModel::autoHeaders()
{
auto headers = projectDataBase::headersFromElementsInfoQuery(m_query);
for (auto i=0 ; i<headers.size() ; ++i) {
this->setHeaderData(i, Qt::Horizontal, headers.at(i));
}
}
/**
* @brief NomenclatureModel::dataBaseUpdated
* slot called when the project database is updated

View File

@@ -43,6 +43,7 @@ class NomenclatureModel : public QAbstractTableModel
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void query(const QString &query);
QETProject *project() const;
void autoHeaders();
private:
void dataBaseUpdated();

View File

@@ -70,8 +70,13 @@ void NomenclatureModelPropertiesWidget::on_m_edit_query_pb_clicked()
connect(button_box, &QDialogButtonBox::accepted, &d, &QDialog::accept);
connect(button_box, &QDialogButtonBox::rejected, &d, &QDialog::reject);
if (d.exec()) {
if (d.exec())
{
m_model->query(query_widget->queryStr());
auto headers = query_widget->header();
for (auto i=0 ; i<headers.size() ; ++i) {
m_model->setHeaderData(i, Qt::Horizontal, headers.at(i));
}
}
}