(#466) Made sure that selecting plots and plot tracks both work

Both widgets accept focus events and select the corresponding items in
the project tree view. Focus is cleared immediately in the focus event
handlers, so that plot tracks won't steal focus from the plots in
subsequent selections of plots.
This commit is contained in:
Pål Hagen 2015-09-17 12:02:37 +02:00
parent 71b4ce9221
commit 08adcd5df7
3 changed files with 22 additions and 0 deletions

View File

@ -20,14 +20,17 @@
#include "RiuWellLogPlot.h"
#include "RiuWellLogTracePlot.h"
#include "RiuMainWindow.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"
#include "cafPdmUiTreeView.h"
#include "cvfAssert.h"
#include <QHBoxLayout>
#include <QScrollBar>
#include <QFocusEvent>
#include <math.h>
@ -50,6 +53,8 @@ RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent)
m_layout->addWidget(m_scrollBar);
connect(m_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotSetMinDepth(int)));
setFocusPolicy(Qt::ClickFocus);
}
//--------------------------------------------------------------------------------------------------
@ -126,3 +131,15 @@ RimWellLogPlot* RiuWellLogPlot::ownerPlotDefinition()
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::focusInEvent(QFocusEvent* event)
{
if (m_plotDefinition)
{
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(m_plotDefinition);
clearFocus();
}
}

View File

@ -28,6 +28,7 @@ class RiuWellLogTracePlot;
class QHBoxLayout;
class QScrollBar;
class QFocusEvent;
//==================================================================================================
//
@ -48,6 +49,9 @@ public:
void setDepthRangeAndReplot(double minDepth, double maxDepth);
protected:
virtual void focusInEvent(QFocusEvent* event);
private:
void updateScrollBar(double minDepth, double maxDepth);

View File

@ -219,6 +219,7 @@ void RiuWellLogTracePlot::focusInEvent(QFocusEvent* event)
if (m_plotTraceDefinition)
{
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(m_plotTraceDefinition);
clearFocus();
}
}