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

Correct processing of PythonScript viewer when dock visibility changed

parent abbb3a6f
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,23 @@ QSize InfoWidget::minimumSizeHint() const
return QSize(minimum_widget_height, minimum_widget_height);
}
void InfoWidget::onDockVisibilityChange(bool is_visible)
{
qDebug() << "InfoWidget::onDockVisibilityChange(bool status)" << is_visible << isEditorVisible();
Q_ASSERT(m_pySampleWidget);
if(isEditorVisible()) {
if(!is_visible) {
m_pySampleWidget->disableEditor();
} else {
m_pySampleWidget->scheduleUpdate();
}
}
// if(status != isEditorVisible())
// m_pySampleWidget->setEditorEnabled(status);
}
void InfoWidget::onExpandButtonClicked()
{
qDebug() << "InfoWidget::onExpandButtonClicked()" << m_cached_height;
......
......@@ -41,6 +41,9 @@ public:
signals:
void widgetHeightRequest(int);
public slots:
void onDockVisibilityChange(bool is_visible);
private slots:
void onExpandButtonClicked();
......
......@@ -163,20 +163,39 @@ void PySampleWidget::disableEditor()
{
Q_ASSERT(m_sampleModel);
m_timer->stop();
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(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex)));
disconnect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor()));
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(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(onDataChanged(QModelIndex,QModelIndex)));
disconnect(m_sampleModel, SIGNAL(modelReset()),
this, SLOT(updateEditor()));
}
void PySampleWidget::enableEditor()
{
Q_ASSERT(m_sampleModel);
updateEditor();
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(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex)));
connect(m_sampleModel, SIGNAL(modelReset()), this, SLOT(updateEditor()));
connect(m_sampleModel, SIGNAL(rowsInserted(QModelIndex, int,int)),
this, SLOT(onModifiedRow(QModelIndex,int,int)), Qt::UniqueConnection);
connect(m_sampleModel, SIGNAL(rowsRemoved(QModelIndex, int,int)),
this, SLOT(onModifiedRow(QModelIndex,int,int)), Qt::UniqueConnection);
connect(m_sampleModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(onDataChanged(QModelIndex,QModelIndex)), Qt::UniqueConnection);
connect(m_sampleModel, SIGNAL(modelReset()),
this, SLOT(updateEditor()), Qt::UniqueConnection);
}
void PySampleWidget::setEditorEnabled(bool status)
{
if(status) {
qDebug() << "PySampleWidget::setEditorEnabled() -> enabling";
enableEditor();
} else {
qDebug() << "PySampleWidget::setEditorEnabled() -> disabling";
disableEditor();
}
}
//! Triggers the update of the editor
......
......@@ -46,6 +46,7 @@ public slots:
void disableEditor();
void enableEditor();
void setEditorEnabled(bool status);
private slots:
void onTimerTimeout();
......
......@@ -54,6 +54,7 @@ SampleView::SampleView(SampleModel *sampleModel, InstrumentModel *instrumentMode
//subWindow->setWindowTitle(subs[i]->windowTitle());
m_dockWidgets[i] = addDockForWidget(subWindow);
m_widget_to_dock[subWindow] = m_dockWidgets[i];
m_dock_to_widget[m_dockWidgets[i]] = subWindow;
// Since we have 1-pixel splitters, we generally want to remove
// frames around item views. So we apply this hack for now.
......@@ -240,6 +241,17 @@ void SampleView::dockToMinMaxSizes()
m_dock_info.m_dock = 0;
}
void SampleView::onDockVisibilityChangeV2(bool status)
{
QDockWidget *dock = qobject_cast<QDockWidget *>(sender());
Q_ASSERT(dock);
InfoWidget *infoWidget = dynamic_cast<InfoWidget *>(m_dock_to_widget[dock]);
Q_ASSERT(infoWidget);
infoWidget->onDockVisibilityChange(status);
}
void SampleView::connectSignals()
{
......@@ -268,6 +280,15 @@ void SampleView::connectSignals()
this, SLOT(showContextMenu(const QPoint &)));
addToolBar(m_toolBar);
for (int i = 0; i < NUMBER_OF_SUB_WINDOWS; i++) {
if(i == INFO) {
connect(m_dockWidgets[i], SIGNAL(visibilityChanged(bool)),
this, SLOT(onDockVisibilityChangeV2(bool)));
}
}
}
void SampleView::setCurrentIndex(const QModelIndex &index)
......
......@@ -62,6 +62,7 @@ protected slots:
void showContextMenu(const QPoint &pnt);
void setDirty(bool dirty=true) { setWindowModified(dirty); }
void dockToMinMaxSizes();
void onDockVisibilityChangeV2(bool status);
private:
//! Stores sizes of dock widget
......@@ -89,6 +90,7 @@ private:
QDockWidget *m_dockWidgets[NUMBER_OF_SUB_WINDOWS];
QMap<QWidget *, QDockWidget *> m_widget_to_dock;
QMap<QDockWidget *, QWidget *> m_dock_to_widget;
QSignalMapper *m_add_item_mapper;
QMap<QString, QAction *> m_add_action_map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment