mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8732 from OPM/summarymultiplot_updates2
Summary Multiplot updates
This commit is contained in:
@@ -778,6 +778,8 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
||||
const MimeDataWithIndexes* mimeData = nullptr;
|
||||
Qt::KeyboardModifiers keyModifiers;
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
if ( event->type() == QEvent::Drop )
|
||||
{
|
||||
// These drop events come from Qwt
|
||||
@@ -788,6 +790,8 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
||||
keyModifiers = dropEvent->keyboardModifiers();
|
||||
|
||||
dropEvent->acceptProposedAction();
|
||||
dropEvent->accept();
|
||||
bResult = true;
|
||||
}
|
||||
}
|
||||
else if ( event->type() == QEvent::GraphicsSceneDrop )
|
||||
@@ -799,6 +803,8 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
||||
mimeData = qobject_cast<const MimeDataWithIndexes*>( dropEvent->mimeData() );
|
||||
|
||||
dropEvent->acceptProposedAction();
|
||||
dropEvent->accept();
|
||||
bResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,8 +825,8 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
||||
if ( obj ) droppedObjects.push_back( obj );
|
||||
}
|
||||
|
||||
return true;
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,6 @@ void RiuMainWindowBase::selectAsCurrentItem( const caf::PdmObject* object, bool
|
||||
if ( dw )
|
||||
{
|
||||
dw->show();
|
||||
dw->raise();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
|
||||
, m_subTitlesVisible( true )
|
||||
, m_previewMode( true )
|
||||
, m_currentPageIndex( 0 )
|
||||
, m_goToLastPageAfterUpdate( false )
|
||||
, m_pageTimerId( -1 )
|
||||
{
|
||||
const int spacing = 8;
|
||||
|
||||
@@ -168,6 +170,7 @@ void RiuMultiPlotBook::addPlot( RiuPlotWidget* plotWidget )
|
||||
void RiuMultiPlotBook::insertPlot( RiuPlotWidget* plotWidget, size_t index )
|
||||
{
|
||||
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
|
||||
m_goToLastPageAfterUpdate = true;
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
@@ -461,6 +464,24 @@ void RiuMultiPlotBook::performUpdate()
|
||||
deleteAllPages();
|
||||
createPages();
|
||||
updateGeometry();
|
||||
// use a timer to trigger a viewer page change, if needed
|
||||
if ( m_goToLastPageAfterUpdate )
|
||||
{
|
||||
m_pageTimerId = startTimer( 100 );
|
||||
m_goToLastPageAfterUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::timerEvent( QTimerEvent* event )
|
||||
{
|
||||
if ( event->timerId() == m_pageTimerId )
|
||||
{
|
||||
killTimer( m_pageTimerId );
|
||||
goToLastPage();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -501,8 +522,8 @@ void RiuMultiPlotBook::createPages()
|
||||
{
|
||||
CAF_ASSERT( m_plotDefinition );
|
||||
|
||||
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
||||
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
|
||||
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
||||
auto [rowCount, columnCount] = this->rowAndColumnCount( plotWidgets.size() );
|
||||
|
||||
int rowsPerPage = m_plotDefinition->rowsPerPage();
|
||||
int row = 0;
|
||||
@@ -514,9 +535,9 @@ void RiuMultiPlotBook::createPages()
|
||||
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
|
||||
{
|
||||
int expectedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
|
||||
int colSpan = std::min( expectedColSpan, rowAndColumnCount.second );
|
||||
int colSpan = std::min( expectedColSpan, columnCount );
|
||||
|
||||
std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
|
||||
std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, columnCount );
|
||||
if ( row >= rowsPerPage )
|
||||
{
|
||||
page = createPage();
|
||||
@@ -609,7 +630,7 @@ void RiuMultiPlotBook::applyLook()
|
||||
void RiuMultiPlotBook::changeCurrentPage( int pageNumber )
|
||||
{
|
||||
m_currentPageIndex = pageNumber;
|
||||
if ( m_currentPageIndex >= (int)m_pages.size() ) m_currentPageIndex = (int)m_pages.size() - 1;
|
||||
if ( m_currentPageIndex >= m_pages.size() ) m_currentPageIndex = m_pages.size() - 1;
|
||||
if ( m_currentPageIndex < 0 ) m_currentPageIndex = 0;
|
||||
if ( !m_pages.isEmpty() ) m_scrollArea->ensureWidgetVisible( m_pages[m_currentPageIndex] );
|
||||
}
|
||||
|
||||
@@ -53,9 +53,6 @@ class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using ColumnCount = RiuMultiPlotPage::ColumnCount;
|
||||
|
||||
public:
|
||||
RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuMultiPlotBook() override;
|
||||
@@ -108,6 +105,8 @@ protected:
|
||||
void dragEnterEvent( QDragEnterEvent* event ) override;
|
||||
void dropEvent( QDropEvent* event ) override;
|
||||
|
||||
void timerEvent( QTimerEvent* event ) override;
|
||||
|
||||
private:
|
||||
void deleteAllPages();
|
||||
void createPages();
|
||||
@@ -136,4 +135,7 @@ protected:
|
||||
bool m_subTitlesVisible;
|
||||
bool m_previewMode;
|
||||
int m_currentPageIndex;
|
||||
|
||||
bool m_goToLastPageAfterUpdate;
|
||||
int m_pageTimerId;
|
||||
};
|
||||
|
||||
@@ -537,7 +537,7 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
|
||||
|
||||
for ( RiuPlotWidget* plotWidget : m_plotWidgets )
|
||||
{
|
||||
CAF_ASSERT( plotWidget );
|
||||
if ( !plotWidget ) continue;
|
||||
RimPlot* plot = plotWidget->plotDefinition();
|
||||
if ( !plot ) continue;
|
||||
|
||||
|
||||
@@ -53,16 +53,6 @@ class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, p
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class ColumnCount
|
||||
{
|
||||
COLUMNS_1 = 1,
|
||||
COLUMNS_2 = 2,
|
||||
COLUMNS_3 = 3,
|
||||
COLUMNS_4 = 4,
|
||||
COLUMNS_UNLIMITED = 1000,
|
||||
};
|
||||
|
||||
public:
|
||||
RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuMultiPlotPage() override;
|
||||
|
||||
@@ -1025,7 +1025,6 @@ void RiuPlotMainWindow::selectedObjectsChanged()
|
||||
// The only way to get to this code is by selection change initiated from the project tree view
|
||||
// As we are activating an MDI-window, the focus is given to this MDI-window
|
||||
// Set focus back to the tree view to be able to continue keyboard tree view navigation
|
||||
projectTree->raise();
|
||||
projectTree->treeView()->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user