Merge pull request #4902 from OPM/summary-text-edit-in-toolbar

Summary text editor in toolbar
This commit is contained in:
Magne Sjaastad
2019-10-24 21:44:33 +02:00
committed by GitHub
17 changed files with 666 additions and 105 deletions

View File

@@ -29,6 +29,7 @@
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RimSummaryPlotFilterTextCurveSetEditor.h"
#include "RimViewWindow.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurveCommonDataSource.h"
@@ -202,6 +203,19 @@ void RiuPlotMainWindow::closeEvent( QCloseEvent* event )
app->closeProject();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::keyPressEvent( QKeyEvent* keyEvent )
{
if ( RiuTreeViewEventFilter::activateFeatureFromKeyEvent( keyEvent ) )
{
return;
}
RiuMainWindowBase::keyPressEvent( keyEvent );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -559,29 +573,40 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
{
std::vector<caf::PdmFieldHandle*> toolBarFields = summaryPlot->fieldsToShowInToolbar();
QString keyword;
if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) )
{
keyword = m_summaryPlotToolBarEditor->keywordForFocusWidget();
m_summaryPlotToolBarEditor->setFields( toolBarFields );
}
else if ( forceUpdateUi )
{
m_summaryPlotToolBarEditor->updateUi();
}
m_summaryPlotToolBarEditor->updateUi();
m_summaryPlotToolBarEditor->updateUi( caf::PdmUiToolBarEditor::uiEditorConfigName() );
m_summaryPlotToolBarEditor->show();
m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword( keyword );
}
else
{
m_summaryPlotToolBarEditor->clear();
m_summaryPlotToolBarEditor->hide();
}
refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setFocusToLineEditInSummaryToolBar()
{
if ( m_summaryPlotToolBarEditor )
{
m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword(
RimSummaryPlotFilterTextCurveSetEditor::curveFilterFieldKeyword() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -828,8 +853,8 @@ void RiuPlotMainWindow::customMenuRequested( const QPoint& pos )
RiaApplication* app = RiaApplication::instance();
app->project()->actionsBasedOnSelection( menu );
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
// Since we might get this signal from different treeViews, we need to map the position accordingly.
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the
// viewport(). Since we might get this signal from different treeViews, we need to map the position accordingly.
QObject* senderObj = this->sender();
QTreeView* treeView = dynamic_cast<QTreeView*>( senderObj );
if ( treeView )

View File

@@ -81,9 +81,11 @@ public:
void updateWellLogPlotToolBar();
void updateSummaryPlotToolBar( bool forceUpdateUi = false );
void setFocusToLineEditInSummaryToolBar();
protected:
void closeEvent( QCloseEvent* event ) override;
void keyPressEvent( QKeyEvent* ) override;
private:
void setPdmRoot( caf::PdmObject* pdmRoot );

View File

@@ -49,6 +49,44 @@ RiuTreeViewEventFilter::RiuTreeViewEventFilter( QObject* parent )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuTreeViewEventFilter::activateFeatureFromKeyEvent( QKeyEvent* keyEvent )
{
QKeySequence keySeq( keyEvent->modifiers() + keyEvent->key() );
auto matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut( keySeq );
bool wasFeatureActivated = activateFirstEnabledFeature( matches );
if ( wasFeatureActivated )
{
keyEvent->setAccepted( true );
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuTreeViewEventFilter::activateFirstEnabledFeature( const std::vector<caf::CmdFeature*>& features )
{
for ( caf::CmdFeature* feature : features )
{
if ( feature->canFeatureBeExecuted() )
{
feature->actionTriggered( false );
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -93,15 +131,11 @@ bool RiuTreeViewEventFilter::eventFilter( QObject* obj, QEvent* event )
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut( keySeq );
}
for ( caf::CmdFeature* feature : matches )
bool wasFeatureActivated = RiuTreeViewEventFilter::activateFirstEnabledFeature( matches );
if ( wasFeatureActivated )
{
if ( feature->canFeatureBeExecuted() )
{
feature->actionTriggered( false );
keyEvent->setAccepted( true );
return true;
}
keyEvent->setAccepted( true );
return true;
}
}

View File

@@ -21,7 +21,15 @@
#include <QObject>
#include <vector>
class QEvent;
class QKeyEvent;
namespace caf
{
class CmdFeature;
}
//--------------------------------------------------------------------------------------------------
class RiuTreeViewEventFilter : public QObject
@@ -30,6 +38,9 @@ class RiuTreeViewEventFilter : public QObject
public:
explicit RiuTreeViewEventFilter( QObject* parent );
static bool activateFeatureFromKeyEvent( QKeyEvent* keyEvent );
static bool activateFirstEnabledFeature( const std::vector<caf::CmdFeature*>& features );
protected:
bool eventFilter( QObject* obj, QEvent* event ) override;
};
};