Make a copie of previous table model when unlink a table from her previous table.

This commit is contained in:
Claveau Joshua
2020-06-04 14:17:14 +02:00
parent 8ad876fb31
commit ae9ef3cf21
3 changed files with 18 additions and 3 deletions

View File

@@ -39,6 +39,19 @@ NomenclatureModel::NomenclatureModel(QETProject *project, QObject *parent) :
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &NomenclatureModel::dataBaseUpdated); connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &NomenclatureModel::dataBaseUpdated);
} }
/**
* @brief NomenclatureModel::NomenclatureModel
* @param other_model
*/
NomenclatureModel::NomenclatureModel(const NomenclatureModel &other_model)
{
this->setParent(other_model.parent());
m_project = other_model.m_project;
connect(m_project->dataBase(), &projectDataBase::dataBaseUpdated, this, &NomenclatureModel::dataBaseUpdated);
m_index_0_0_data = other_model.m_index_0_0_data;
query(other_model.queryString());
}
/** /**
* @brief NomenclatureModel::rowCount * @brief NomenclatureModel::rowCount
* Reimplemented for QAbstractTableModel * Reimplemented for QAbstractTableModel
@@ -346,5 +359,6 @@ void NomenclatureModel::fillValue()
++i; ++i;
} }
m_record << record_; m_record << record_;
} }
} }

View File

@@ -38,6 +38,7 @@ class NomenclatureModel : public QAbstractTableModel
public: public:
explicit NomenclatureModel(QETProject *project, QObject *parent = nullptr); explicit NomenclatureModel(QETProject *project, QObject *parent = nullptr);
explicit NomenclatureModel (const NomenclatureModel &other_model);
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;

View File

@@ -313,9 +313,9 @@ void QetGraphicsTableItem::setPreviousTable(QetGraphicsTableItem *table)
m_previous_table->setNextTable(this); m_previous_table->setNextTable(this);
setModel(m_previous_table->m_model); setModel(m_previous_table->m_model);
} }
else //Remove model else //Copie the model of old previous table
{ {
setModel(nullptr); setModel(new NomenclatureModel(*static_cast<NomenclatureModel *>(old_previous_table->model())));
} }
if (old_previous_table && if (old_previous_table &&