mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4775 Summary : Improve event handling and add shorcut
This commit is contained in:
parent
1671fe44b2
commit
28ef4166ea
@ -41,6 +41,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingSummaryCurveFeature.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -85,6 +86,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingSummaryCurveFeature.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingSummaryCurveFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicClearSourceSteppingEnsembleCurveSetFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicSetSourceSteppingEnsembleCurveSetFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicActivateCurveFilterInToolbarFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019- Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicActivateCurveFilterInToolbarFeature.h"
|
||||||
|
|
||||||
|
#include "RiaGuiApplication.h"
|
||||||
|
#include "RiuPlotMainWindow.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT( RicActivateCurveFilterInToolbarFeature, "RicActivateCurveFilterInToolbarFeature" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicActivateCurveFilterInToolbarFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicActivateCurveFilterInToolbarFeature::onActionTriggered( bool isChecked )
|
||||||
|
{
|
||||||
|
if ( RiaGuiApplication::isRunning() )
|
||||||
|
{
|
||||||
|
auto plotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||||
|
if ( plotWindow )
|
||||||
|
{
|
||||||
|
plotWindow->setFocusToLineEditInSummaryToolBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicActivateCurveFilterInToolbarFeature::setupActionLook( QAction* actionToSetup )
|
||||||
|
{
|
||||||
|
actionToSetup->setText( "Activate Summary Curve Filter Editor" );
|
||||||
|
actionToSetup->setShortcut( QKeySequence( tr( "Ctrl+F" ) ) );
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019- Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicActivateCurveFilterInToolbarFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool isCommandEnabled() override;
|
||||||
|
void onActionTriggered( bool isChecked ) override;
|
||||||
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
};
|
@ -47,11 +47,13 @@
|
|||||||
|
|
||||||
#include "RiuPlotMainWindowTools.h"
|
#include "RiuPlotMainWindowTools.h"
|
||||||
#include "RiuSummaryQwtPlot.h"
|
#include "RiuSummaryQwtPlot.h"
|
||||||
|
#include "RiuTreeViewEventFilter.h"
|
||||||
|
|
||||||
#include "cvfColor3.h"
|
#include "cvfColor3.h"
|
||||||
|
|
||||||
#include "cafPdmUiCheckBoxEditor.h"
|
#include "cafPdmUiCheckBoxEditor.h"
|
||||||
#include "cafPdmUiTreeOrdering.h"
|
#include "cafPdmUiTreeOrdering.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
#include "qwt_abstract_legend.h"
|
#include "qwt_abstract_legend.h"
|
||||||
#include "qwt_legend.h"
|
#include "qwt_legend.h"
|
||||||
@ -67,7 +69,6 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "cafSelectionManager.h"
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -1948,6 +1949,11 @@ void RimSummaryPlot::handleKeyPressEvent( QKeyEvent* keyEvent )
|
|||||||
{
|
{
|
||||||
if ( !keyEvent ) return;
|
if ( !keyEvent ) return;
|
||||||
|
|
||||||
|
if ( RiuTreeViewEventFilter::activateFeatureFromKeyEvent( keyEvent ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RimSummaryPlotSourceStepping* sourceStepping = sourceSteppingObjectForKeyEventHandling();
|
RimSummaryPlotSourceStepping* sourceStepping = sourceSteppingObjectForKeyEventHandling();
|
||||||
if ( !sourceStepping ) return;
|
if ( !sourceStepping ) return;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include "cafPdmUiLabelEditor.h"
|
#include "cafPdmUiLabelEditor.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
|
#include "cafPdmUiToolBarEditor.h"
|
||||||
#include "cafPdmUiTreeSelectionEditor.h"
|
#include "cafPdmUiTreeSelectionEditor.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@ -69,22 +70,29 @@ RimSummaryPlotFilterTextCurveSetEditor::RimSummaryPlotFilterTextCurveSetEditor()
|
|||||||
CAF_PDM_InitObject( "Curve Set Filter Text", "", "", "" );
|
CAF_PDM_InitObject( "Curve Set Filter Text", "", "", "" );
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
QString filterTextHeading = "Text to Create Summary Vectors";
|
||||||
|
QString filterTextShortcut = " (Ctrl + F)";
|
||||||
|
|
||||||
QString filterTextToolTip =
|
QString filterTextToolTip =
|
||||||
"A space separated list of vector addresses in the syntax: <vectorshortname>[:<item>[:<subitem>[:i,j,k]]]\n"
|
"A list of vector addresses separated by spaces using the syntax: <vectorshortname>[:<item>[:<subitem>[:i,j,k]]]\n"
|
||||||
"Wildcards can also be used. Examples:\n"
|
"Wildcards can also be used. Examples:\n"
|
||||||
" \"WOPT:*\" One total oil production curve for each well.\n"
|
" \"WOPT:*\" One total oil production curve for each well.\n"
|
||||||
" \"FOPT FWPT\" Two curves with oil and water total production.\n"
|
" \"FOPT FWPT\" Two curves with oil and water total production.\n"
|
||||||
" \"BPR:15,28,*\" (no space) Oil phase pressure for all blocks along k as separate curves.\n";
|
" \"BPR:15,28,*\" (no space) Oil phase pressure for all blocks along k as separate curves.\n";
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
QString toolTipPropertyEditor = filterTextHeading + "\n\n" + filterTextToolTip;
|
||||||
|
QString toolTipToolbar = filterTextHeading + filterTextShortcut + "\n\n" + filterTextToolTip;
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_curveFilterLabelText, "Summary", "Summary", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_curveFilterLabelText, "Summary", "Summary", "", "", "" );
|
||||||
m_curveFilterLabelText.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
|
m_curveFilterLabelText.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
|
||||||
m_curveFilterLabelText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
|
||||||
m_curveFilterLabelText.xmlCapability()->disableIO();
|
m_curveFilterLabelText.xmlCapability()->disableIO();
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_curveFilterText, "CurveFilterText", "Curve Filter Text", "", filterTextToolTip, "" );
|
CAF_PDM_InitFieldNoDefault( &m_curveFilterText, "CurveFilterText", "Curve Filter Text", "", toolTipPropertyEditor, "" );
|
||||||
m_curveFilterText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
m_curveFilterText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||||
// m_curveFilterText.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
|
|
||||||
|
// Special tool tip for toolbar
|
||||||
|
m_curveFilterText.uiCapability()->setUiToolTip( toolTipToolbar, caf::PdmUiToolBarEditor::uiEditorConfigName() );
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Sources", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_selectedSources, "SummaryCases", "Sources", "", "", "" );
|
||||||
m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false );
|
m_selectedSources.uiCapability()->setAutoAddingOptionFromValue( false );
|
||||||
@ -112,7 +120,10 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotFilterTextCurveSetEditor::fields
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryPlotFilterTextCurveSetEditor::updateCurveFilterText() {}
|
QString RimSummaryPlotFilterTextCurveSetEditor::curveFilterFieldKeyword()
|
||||||
|
{
|
||||||
|
return "CurveFilterText";
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -402,12 +413,15 @@ void RimSummaryPlotFilterTextCurveSetEditor::defineEditorAttribute( const caf::P
|
|||||||
QString uiConfigName,
|
QString uiConfigName,
|
||||||
caf::PdmUiEditorAttribute* attribute )
|
caf::PdmUiEditorAttribute* attribute )
|
||||||
{
|
{
|
||||||
if ( field == &m_curveFilterText )
|
if ( field == &m_curveFilterText && uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() )
|
||||||
{
|
{
|
||||||
|
// Special config for toolbar
|
||||||
|
|
||||||
auto attr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
|
auto attr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
|
||||||
if ( attr )
|
if ( attr )
|
||||||
{
|
{
|
||||||
attr->maximumWidth = 150;
|
attr->maximumWidth = 150;
|
||||||
|
attr->selectAllOnFocusEvent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
|
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
|
||||||
|
|
||||||
void updateCurveFilterText();
|
static QString curveFilterFieldKeyword();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "RimSummaryCurveCollection.h"
|
#include "RimSummaryCurveCollection.h"
|
||||||
#include "RimSummaryPlot.h"
|
#include "RimSummaryPlot.h"
|
||||||
#include "RimSummaryPlotCollection.h"
|
#include "RimSummaryPlotCollection.h"
|
||||||
|
#include "RimSummaryPlotFilterTextCurveSetEditor.h"
|
||||||
#include "RimViewWindow.h"
|
#include "RimViewWindow.h"
|
||||||
#include "RimWellAllocationPlot.h"
|
#include "RimWellAllocationPlot.h"
|
||||||
#include "RimWellLogCurveCommonDataSource.h"
|
#include "RimWellLogCurveCommonDataSource.h"
|
||||||
@ -202,6 +203,19 @@ void RiuPlotMainWindow::closeEvent( QCloseEvent* event )
|
|||||||
app->closeProject();
|
app->closeProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuPlotMainWindow::keyPressEvent( QKeyEvent* keyEvent )
|
||||||
|
{
|
||||||
|
if ( RiuTreeViewEventFilter::activateFeatureFromKeyEvent( keyEvent ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RiuMainWindowBase::keyPressEvent( keyEvent );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -562,14 +576,14 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
|
|||||||
|
|
||||||
if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) )
|
if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) )
|
||||||
{
|
{
|
||||||
keyword = m_summaryPlotToolBarEditor->keywordForWidgetWithFocus();
|
keyword = m_summaryPlotToolBarEditor->keywordForFocusWidget();
|
||||||
|
|
||||||
m_summaryPlotToolBarEditor->setFields( toolBarFields );
|
m_summaryPlotToolBarEditor->setFields( toolBarFields );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_summaryPlotToolBarEditor->updateUi();
|
m_summaryPlotToolBarEditor->updateUi( caf::PdmUiToolBarEditor::uiEditorConfigName() );
|
||||||
m_summaryPlotToolBarEditor->show();
|
m_summaryPlotToolBarEditor->show();
|
||||||
m_summaryPlotToolBarEditor->setKeyboardFocusFromKeyword( keyword );
|
m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword( keyword );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -580,6 +594,18 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
|
|||||||
refreshToolbars();
|
refreshToolbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuPlotMainWindow::setFocusToLineEditInSummaryToolBar()
|
||||||
|
{
|
||||||
|
if ( m_summaryPlotToolBarEditor )
|
||||||
|
{
|
||||||
|
m_summaryPlotToolBarEditor->setFocusWidgetFromKeyword(
|
||||||
|
RimSummaryPlotFilterTextCurveSetEditor::curveFilterFieldKeyword() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -807,8 +833,8 @@ void RiuPlotMainWindow::customMenuRequested( const QPoint& pos )
|
|||||||
RiaApplication* app = RiaApplication::instance();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
app->project()->actionsBasedOnSelection( menu );
|
app->project()->actionsBasedOnSelection( menu );
|
||||||
|
|
||||||
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the
|
||||||
// Since we might get this signal from different treeViews, we need to map the position accordingly.
|
// viewport(). Since we might get this signal from different treeViews, we need to map the position accordingly.
|
||||||
QObject* senderObj = this->sender();
|
QObject* senderObj = this->sender();
|
||||||
QTreeView* treeView = dynamic_cast<QTreeView*>( senderObj );
|
QTreeView* treeView = dynamic_cast<QTreeView*>( senderObj );
|
||||||
if ( treeView )
|
if ( treeView )
|
||||||
|
@ -81,9 +81,11 @@ public:
|
|||||||
|
|
||||||
void updateWellLogPlotToolBar();
|
void updateWellLogPlotToolBar();
|
||||||
void updateSummaryPlotToolBar( bool forceUpdateUi = false );
|
void updateSummaryPlotToolBar( bool forceUpdateUi = false );
|
||||||
|
void setFocusToLineEditInSummaryToolBar();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent( QCloseEvent* event ) override;
|
void closeEvent( QCloseEvent* event ) override;
|
||||||
|
void keyPressEvent( QKeyEvent* ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPdmRoot( caf::PdmObject* pdmRoot );
|
void setPdmRoot( caf::PdmObject* pdmRoot );
|
||||||
|
@ -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 );
|
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingKeyboardShortcut( keySeq );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( caf::CmdFeature* feature : matches )
|
bool wasFeatureActivated = RiuTreeViewEventFilter::activateFirstEnabledFeature( matches );
|
||||||
|
if ( wasFeatureActivated )
|
||||||
{
|
{
|
||||||
if ( feature->canFeatureBeExecuted() )
|
keyEvent->setAccepted( true );
|
||||||
{
|
return true;
|
||||||
feature->actionTriggered( false );
|
|
||||||
|
|
||||||
keyEvent->setAccepted( true );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,15 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class QEvent;
|
class QEvent;
|
||||||
|
class QKeyEvent;
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
class CmdFeature;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
class RiuTreeViewEventFilter : public QObject
|
class RiuTreeViewEventFilter : public QObject
|
||||||
@ -30,6 +38,9 @@ class RiuTreeViewEventFilter : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit RiuTreeViewEventFilter( QObject* parent );
|
explicit RiuTreeViewEventFilter( QObject* parent );
|
||||||
|
|
||||||
|
static bool activateFeatureFromKeyEvent( QKeyEvent* keyEvent );
|
||||||
|
static bool activateFirstEnabledFeature( const std::vector<caf::CmdFeature*>& features );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter( QObject* obj, QEvent* event ) override;
|
bool eventFilter( QObject* obj, QEvent* event ) override;
|
||||||
};
|
};
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
completerCaseSensitivity = Qt::CaseInsensitive;
|
completerCaseSensitivity = Qt::CaseInsensitive;
|
||||||
completerFilterMode = Qt::MatchContains;
|
completerFilterMode = Qt::MatchContains;
|
||||||
maximumWidth = -1;
|
maximumWidth = -1;
|
||||||
|
selectAllOnFocusEvent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -75,6 +76,7 @@ public:
|
|||||||
Qt::CaseSensitivity completerCaseSensitivity;
|
Qt::CaseSensitivity completerCaseSensitivity;
|
||||||
Qt::MatchFlags completerFilterMode;
|
Qt::MatchFlags completerFilterMode;
|
||||||
int maximumWidth;
|
int maximumWidth;
|
||||||
|
bool selectAllOnFocusEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -42,12 +42,14 @@
|
|||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
#include "cafPdmUiFieldEditorHelper.h"
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
#include "cafPdmUiFieldHandle.h"
|
#include "cafPdmUiFieldHandle.h"
|
||||||
|
#include "cafPdmUiLineEditor.h"
|
||||||
#include "cafPdmUiObjectHandle.h"
|
#include "cafPdmUiObjectHandle.h"
|
||||||
#include "cafPdmUiOrdering.h"
|
#include "cafPdmUiOrdering.h"
|
||||||
#include "cafPdmUiPushButtonEditor.h"
|
#include "cafPdmUiPushButtonEditor.h"
|
||||||
#include "cafPdmUiToolButtonEditor.h"
|
#include "cafPdmUiToolButtonEditor.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
@ -235,15 +237,40 @@ void PdmUiToolBarEditor::clear()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void PdmUiToolBarEditor::setKeyboardFocusFromKeyword(const QString& fieldKeyword)
|
void PdmUiToolBarEditor::setFocusWidgetFromKeyword(const QString& fieldKeyword)
|
||||||
{
|
{
|
||||||
auto fieldView = m_fieldViews[fieldKeyword];
|
if (!m_toolbar->isVisible()) return;
|
||||||
if (fieldView)
|
|
||||||
|
auto fieldView = m_fieldViews.find(fieldKeyword);
|
||||||
|
if (fieldView != m_fieldViews.end() && fieldView->second)
|
||||||
{
|
{
|
||||||
auto editorWidget = fieldView->editorWidget();
|
auto editorWidget = fieldView->second->editorWidget();
|
||||||
if (editorWidget)
|
if (editorWidget)
|
||||||
{
|
{
|
||||||
editorWidget->setFocus(Qt::ActiveWindowFocusReason);
|
editorWidget->setFocus(Qt::ActiveWindowFocusReason);
|
||||||
|
|
||||||
|
PdmUiLineEditorAttribute attributes;
|
||||||
|
|
||||||
|
for (auto field : m_fields)
|
||||||
|
{
|
||||||
|
if (field->keyword() == fieldKeyword)
|
||||||
|
{
|
||||||
|
caf::PdmUiObjectHandle* uiObject = uiObj(field->ownerObject());
|
||||||
|
if (uiObject)
|
||||||
|
{
|
||||||
|
uiObject->editorAttribute(field, uiEditorConfigName(), &attributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributes.selectAllOnFocusEvent)
|
||||||
|
{
|
||||||
|
auto lineEdit = dynamic_cast<QLineEdit*>(editorWidget);
|
||||||
|
if (lineEdit )
|
||||||
|
{
|
||||||
|
lineEdit->selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,10 +297,18 @@ void PdmUiToolBarEditor::hide()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Special config name used to configure toolbar UI (tooltip etc.)
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString PdmUiToolBarEditor::uiEditorConfigName()
|
||||||
|
{
|
||||||
|
return "ToolbarConfigName";
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString PdmUiToolBarEditor::keywordForWidgetWithFocus()
|
QString PdmUiToolBarEditor::keywordForFocusWidget()
|
||||||
{
|
{
|
||||||
QString keyword;
|
QString keyword;
|
||||||
|
|
||||||
|
@ -65,12 +65,13 @@ public:
|
|||||||
void setFields(std::vector<caf::PdmFieldHandle*>& fields);
|
void setFields(std::vector<caf::PdmFieldHandle*>& fields);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void setKeyboardFocusFromKeyword(const QString& fieldKeyword);
|
void setFocusWidgetFromKeyword(const QString& fieldKeyword);
|
||||||
QString keywordForWidgetWithFocus();
|
QString keywordForFocusWidget();
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
|
static QString uiEditorConfigName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user