Skip to content
Snippets Groups Projects
Commit b01a3c63 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

SessionModel now gets informed onSubItemChanged

parent 4dd107ca
No related branches found
No related tags found
No related merge requests found
...@@ -468,6 +468,9 @@ ParameterizedItem *SessionModel::insertNewItem(QString model_type, ...@@ -468,6 +468,9 @@ ParameterizedItem *SessionModel::insertNewItem(QString model_type,
connect(new_item, SIGNAL(propertyChanged(const QString &)), connect(new_item, SIGNAL(propertyChanged(const QString &)),
this, SLOT(onItemPropertyChange(const QString &))); this, SLOT(onItemPropertyChange(const QString &)));
connect(new_item, SIGNAL(subItemChanged(const QString &)),
this, SLOT(onItemPropertyChange(const QString &)));
parent->insertChildItem(row, new_item); parent->insertChildItem(row, new_item);
return new_item; return new_item;
......
...@@ -32,6 +32,7 @@ PySampleWidget::PySampleWidget(QWidget *parent) ...@@ -32,6 +32,7 @@ PySampleWidget::PySampleWidget(QWidget *parent)
, m_textEdit(new QTextEdit) , m_textEdit(new QTextEdit)
, m_sampleModel(0) , m_sampleModel(0)
, m_instrumentModel(0) , m_instrumentModel(0)
, m_block_update(false)
{ {
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0);
...@@ -56,16 +57,19 @@ void PySampleWidget::setSampleModel(SampleModel *sampleModel) ...@@ -56,16 +57,19 @@ void PySampleWidget::setSampleModel(SampleModel *sampleModel)
if(m_sampleModel) { if(m_sampleModel) {
disconnect(m_sampleModel, SIGNAL(rowsInserted(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int))); disconnect(m_sampleModel, SIGNAL(rowsInserted(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int)));
disconnect(m_sampleModel, SIGNAL(rowsRemoved(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int))); disconnect(m_sampleModel, SIGNAL(rowsRemoved(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int)));
disconnect(m_sampleModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex)));
disconnect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor())); disconnect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor()));
} }
m_sampleModel = sampleModel; m_sampleModel = sampleModel;
updateEditor();
connect(m_sampleModel, SIGNAL(rowsInserted(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int))); connect(m_sampleModel, SIGNAL(rowsInserted(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int)));
connect(m_sampleModel, SIGNAL(rowsRemoved(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int))); connect(m_sampleModel, SIGNAL(rowsRemoved(QModelIndex, int,int)), this, SLOT(onModifiedRow(QModelIndex,int,int)));
connect(m_sampleModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex)));
connect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor())); connect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor()));
updateEditor();
} }
} }
...@@ -82,31 +86,34 @@ void PySampleWidget::onModifiedRow(const QModelIndex &, int, int) ...@@ -82,31 +86,34 @@ void PySampleWidget::onModifiedRow(const QModelIndex &, int, int)
updateEditor(); updateEditor();
} }
void PySampleWidget::onDataChanged(const QModelIndex &, const QModelIndex &)
{
updateEditor();
}
void PySampleWidget::updateEditor() void PySampleWidget::updateEditor()
{ {
if(m_block_update) return;
qDebug() << "PySampleWidget::updateEditor()"; qDebug() << "PySampleWidget::updateEditor()";
// QFile scriptFile("CylindersAndPrisms.py"); m_block_update = true;
// if (!scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
// return;
// }
// QTextStream fileStream(&scriptFile);
// m_textEdit->setText(fileStream.readAll());
QMap<QString, ParameterizedItem *> sampleMap = m_sampleModel->getSampleMap(); QMap<QString, ParameterizedItem *> sampleMap = m_sampleModel->getSampleMap();
if(!sampleMap.isEmpty()) {
if(sampleMap.isEmpty()) return; DomainObjectBuilder builder;
ParameterizedItem *sampleItem = sampleMap.first();
boost::scoped_ptr<MultiLayer> multilayer(builder.buildMultiLayer(*sampleItem));
multilayer->printSampleTree();
DomainObjectBuilder builder; PyGenVisitor visitor;
ParameterizedItem *sampleItem = sampleMap.first(); VisitSampleTree(*multilayer, visitor);
boost::scoped_ptr<MultiLayer> multilayer(builder.buildMultiLayer(*sampleItem));
multilayer->printSampleTree();
PyGenVisitor visitor; std::ostringstream result;
VisitSampleTree(*multilayer, visitor); result << visitor.defineGetSample();
std::ostringstream result; m_textEdit->setText(QString::fromStdString(result.str()));
result << visitor.defineGetSample(); }
m_textEdit->setText(QString::fromStdString(result.str()));
m_block_update = false;
} }
...@@ -38,12 +38,16 @@ public: ...@@ -38,12 +38,16 @@ public:
public slots: public slots:
void onModifiedRow(const QModelIndex &, int, int); void onModifiedRow(const QModelIndex &, int, int);
void onDataChanged(const QModelIndex &, const QModelIndex &);
void updateEditor(); void updateEditor();
private: private:
QTextEdit *m_textEdit; QTextEdit *m_textEdit;
SampleModel *m_sampleModel; SampleModel *m_sampleModel;
InstrumentModel *m_instrumentModel; InstrumentModel *m_instrumentModel;
bool m_block_update;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment