mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-13 12:49:58 +01:00
Improve element query widget
User can now filter each field of the query
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user