(#502) Reduce size of plot window when track is deleted

This commit is contained in:
Magne Sjaastad 2015-09-22 09:49:51 +02:00
parent 0daaba58a4
commit ef87f63b63
2 changed files with 35 additions and 8 deletions

View File

@ -76,14 +76,7 @@ void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrackPlot* trackPlot)
m_layout->insertWidget(m_layout->count() - 1, trackPlot);
m_trackPlots.append(trackPlot);
QMdiSubWindow* mdiWindow = RiuMainWindow::instance()->findMdiSubWindow(this);
if (mdiWindow)
{
QSize subWindowSize = mdiWindow->size();
subWindowSize.setWidth(subWindowSize.width() + trackPlot->width());
mdiWindow->resize(subWindowSize);
}
modifyWidthOfContainingMdiWindow(trackPlot->width());
}
//--------------------------------------------------------------------------------------------------
@ -93,6 +86,39 @@ void RiuWellLogPlot::removeTrackPlot(RiuWellLogTrackPlot* trackPlot)
{
m_layout->removeWidget(trackPlot);
m_trackPlots.removeAll(trackPlot);
modifyWidthOfContainingMdiWindow(-trackPlot->width());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::modifyWidthOfContainingMdiWindow(int widthChange)
{
QMdiSubWindow* mdiWindow = RiuMainWindow::instance()->findMdiSubWindow(this);
if (mdiWindow)
{
QSize subWindowSize = mdiWindow->size();
int newWidth = subWindowSize.width() + widthChange;
if (newWidth < 0) newWidth = 100;
subWindowSize.setWidth(newWidth);
mdiWindow->resize(subWindowSize);
if (mdiWindow->isMaximized())
{
// Set window temporarily to normal state and back to maximized
// to redo layout so the whole window canvas is filled
// Tried to activate layout, did not work as expected
// Tested code:
// m_layout->activate();
// mdiWindow->layout()->activate();
mdiWindow->showNormal();
mdiWindow->showMaximized();
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -52,6 +52,7 @@ public:
private:
void updateScrollBar(double minDepth, double maxDepth);
void modifyWidthOfContainingMdiWindow(int widthChange);
private slots:
void slotSetMinDepth(int value);