Extract creation of QShortenedLabel and add context menu

Create an intermediate class used to create a QShortenedLabel. If field is scriptable, add a context menu to support copy of the Python field name to clipboard.
This commit is contained in:
Magne Sjaastad 2024-11-25 07:16:42 +01:00
parent ddefd39fc2
commit 494175d1e6
45 changed files with 264 additions and 263 deletions

View File

@ -40,8 +40,10 @@
#include "cafPdmUiCommandSystemProxy.h"
#include "cafPdmUiFieldHandle.h"
#include "cafPdmUiObjectHandle.h"
#include "cafQShortenedLabel.h"
#include <QAbstractScrollArea>
#include <QLabel>
#include <QMenu>
namespace caf

View File

@ -38,7 +38,8 @@
#include "cafClassTypeName.h"
#include "cafFactory.h"
#include "cafPdmUiEditorHandle.h"
#include "cafQShortenedLabel.h"
class QLabel;
namespace caf
{

View File

@ -36,6 +36,8 @@
#include "cafQShortenedLabel.h"
#include <QApplication>
#include <QClipboard>
#include <QMenu>
#include <QResizeEvent>
using namespace caf;
@ -142,6 +144,35 @@ void QShortenedLabel::resizeEvent( QResizeEvent* event )
QLabel::resizeEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QShortenedLabel::configureContextMenu( const QString& pythonParameterName )
{
setContextMenuPolicy( Qt::CustomContextMenu );
auto createContextMenu = [pythonParameterName]( const QPoint& pos )
{
QMenu menu;
QAction* action = menu.addAction( "Copy Python Parameter Name" );
action->setIcon( QIcon( ":/caf/duplicate.svg" ) );
connect( action,
&QAction::triggered,
[pythonParameterName]()
{
if ( QClipboard* clipboard = QApplication::clipboard() )
{
clipboard->setText( pythonParameterName );
}
} );
menu.exec( QCursor::pos() );
};
connect( this, &QLabel::customContextMenuRequested, this, createContextMenu );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -51,6 +51,8 @@ public:
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
void configureContextMenu( const QString& pythonParameterName );
protected:
void resizeEvent( QResizeEvent* event ) override;
void resizeText( QSize paintSize );

View File

@ -180,6 +180,8 @@ set(PROJECT_FILES
cafUiIconFactory.cpp
cafPdmUiSliderTools.h
cafPdmUiSliderTools.cpp
cafPdmUiFieldLabelEditorHandle.h
cafPdmUiFieldLabelEditorHandle.cpp
)
add_library(
@ -194,6 +196,8 @@ endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} cafProjectDataModel ${QT_LIBRARIES})
target_link_libraries(
${PROJECT_NAME} cafProjectDataModel cafPdmScripting ${QT_LIBRARIES}
)
source_group("" FILES ${PROJECT_FILES})

View File

@ -78,15 +78,13 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
// QWidget* createLabelWidget(QWidget * parent) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
void slotClicked( bool checked );
private:
QPointer<QPushButton> m_pushButton;
// QPointer<QShortenedLabel> m_label;
QPointer<QHBoxLayout> m_buttonLayout;
};

View File

@ -115,15 +115,6 @@ QWidget* PdmUiCheckBoxAndTextEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiCheckBoxAndTextEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QCheckBox>
#include <QLabel>
@ -50,7 +50,7 @@ namespace caf
//==================================================================================================
///
//==================================================================================================
class PdmUiCheckBoxAndTextEditor : public PdmUiFieldEditorHandle
class PdmUiCheckBoxAndTextEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -61,16 +61,14 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
void slotSetValueToField();
private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QCheckBox> m_checkBox;
QPointer<QShortenedLabel> m_label;
QPointer<QLineEdit> m_lineEdit;
QPointer<QCheckBox> m_checkBox;
};
} // end namespace caf

View File

@ -38,11 +38,11 @@
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include "cafQShortenedLabel.h"
namespace caf
{

View File

@ -2,13 +2,11 @@
#include "cafPdmUiCheckBoxTristateEditor.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include "cafTristate.h"
namespace caf
@ -56,15 +54,6 @@ QWidget* PdmUiCheckBoxTristateEditor::createEditorWidget( QWidget* parent )
return m_checkBox;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiCheckBoxTristateEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QCheckBox>
#include <QLabel>
@ -11,7 +11,7 @@
namespace caf
{
class PdmUiCheckBoxTristateEditor : public PdmUiFieldEditorHandle
class PdmUiCheckBoxTristateEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -22,15 +22,13 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
void slotClicked( bool );
private:
QPointer<QCheckBox> m_checkBox;
QPointer<QShortenedLabel> m_label;
QPointer<QCheckBox> m_checkBox;
};
} // end namespace caf

View File

@ -38,12 +38,11 @@
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include <QApplication>
#include <QColor>
#include <QColorDialog>
@ -167,15 +166,6 @@ QWidget* PdmUiColorEditor::createEditorWidget( QWidget* parent )
return placeholder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiColorEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QLabel>
#include <QLineEdit>
@ -67,7 +67,7 @@ public:
//==================================================================================================
/// See cafPdmFieldCvfColor for conversion between cvf::Color3f and QColor
//==================================================================================================
class PdmUiColorEditor : public PdmUiFieldEditorHandle
class PdmUiColorEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -80,7 +80,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
QMargins calculateLabelContentMargins() const override;
@ -93,8 +92,6 @@ private:
QColor getFontColor( const QColor& backgroundColor ) const;
private:
QPointer<QShortenedLabel> m_label;
QColor m_color;
QPointer<QLabel> m_colorTextLabel;
QPointer<QToolButton> m_colorSelectionButton;

View File

@ -399,15 +399,6 @@ QWidget* PdmUiComboBoxEditor::createEditorWidget( QWidget* parent )
return m_placeholder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiComboBoxEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QComboBox>
#include <QHBoxLayout>
@ -90,7 +90,7 @@ public:
//==================================================================================================
///
//==================================================================================================
class PdmUiComboBoxEditor : public PdmUiFieldEditorHandle
class PdmUiComboBoxEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -101,7 +101,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
QMargins calculateLabelContentMargins() const override;
@ -114,8 +113,7 @@ protected slots:
void slotApplyAutoValue();
private:
QPointer<QComboBox> m_comboBox;
QPointer<QShortenedLabel> m_label;
QPointer<QComboBox> m_comboBox;
QPointer<QToolButton> m_previousItemButton;
QPointer<QToolButton> m_nextItemButton;

View File

@ -96,15 +96,6 @@ QWidget* PdmUiDateEditor::createEditorWidget( QWidget* parent )
return m_dateEdit;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDateEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QDateTimeEdit>
#include <QLabel>
@ -61,7 +61,7 @@ public:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiDateEditor : public PdmUiFieldEditorHandle
class PdmUiDateEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -72,15 +72,13 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
void slotEditingFinished();
private:
QPointer<QDateTimeEdit> m_dateEdit;
QPointer<QShortenedLabel> m_label;
QPointer<QDateTimeEdit> m_dateEdit;
PdmUiDateEditorAttribute m_attributes;
};

View File

@ -42,6 +42,7 @@
#include <QDoubleValidator>
#include <QHBoxLayout>
#include <QLabel>
namespace caf
{
@ -123,15 +124,6 @@ QWidget* PdmUiDoubleSliderEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDoubleSliderEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include "cafPdmUiSliderTools.h"
#include <QLabel>
@ -53,7 +53,7 @@ namespace caf
//==================================================================================================
///
//==================================================================================================
class PdmUiDoubleSliderEditor : public PdmUiFieldEditorHandle
class PdmUiDoubleSliderEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -65,7 +65,6 @@ public:
protected:
void configureAndUpdateUi( const QString& uiConfigName ) override;
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
protected slots:
void slotEditingFinished();
@ -76,10 +75,9 @@ private:
void writeValueToField( double value );
private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QSlider> m_slider;
QPointer<QShortenedLabel> m_label;
double m_sliderValue;
QPointer<QLineEdit> m_lineEdit;
QPointer<QSlider> m_slider;
double m_sliderValue;
PdmUiDoubleSliderEditorAttribute m_attributes;
};

View File

@ -36,13 +36,12 @@
#include "cafPdmUiDoubleValueEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include <QDoubleValidator>
#include <QHBoxLayout>
#include <QLabel>
@ -126,15 +125,6 @@ QWidget* PdmUiDoubleValueEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDoubleValueEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QDoubleValidator>
#include <QGroupBox>
@ -90,7 +90,7 @@ public:
//==================================================================================================
///
//==================================================================================================
class PdmUiDoubleValueEditor : public PdmUiFieldEditorHandle
class PdmUiDoubleValueEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -102,7 +102,6 @@ public:
protected:
void configureAndUpdateUi( const QString& uiConfigName ) override;
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
protected slots:
void slotEditingFinished();
@ -111,8 +110,7 @@ private:
void writeValueToField();
private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QShortenedLabel> m_label;
QPointer<QLineEdit> m_lineEdit;
PdmUiDoubleValueEditorAttribute m_attributes;
};

View File

@ -0,0 +1,78 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2024 Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cafPdmUiFieldLabelEditorHandle.h"
#include "cafPdmAbstractFieldScriptingCapability.h"
#include "cafPdmPythonGenerator.h"
#include "cafPdmUiFieldHandle.h"
#include "cafQShortenedLabel.h"
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* caf::PdmUiFieldLabelEditorHandle::createLabelWidget( QWidget* parent )
{
m_label = createLabel( parent, this );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::QShortenedLabel* caf::PdmUiFieldLabelEditorHandle::createLabel( QWidget* parent,
caf::PdmUiFieldEditorHandle* uiFieldEditorHandle )
{
auto label = new caf::QShortenedLabel( parent );
if ( uiFieldEditorHandle && uiFieldEditorHandle->uiField() && uiFieldEditorHandle->uiField()->fieldHandle() )
{
if ( auto scriptingCapability =
uiFieldEditorHandle->uiField()->fieldHandle()->capability<caf::PdmAbstractFieldScriptingCapability>() )
{
auto scriptFieldName = scriptingCapability->scriptFieldName();
QString pythonParameterName = caf::PdmPythonGenerator::camelToSnakeCase( scriptFieldName );
if ( !pythonParameterName.isEmpty() )
{
label->configureContextMenu( pythonParameterName );
}
}
}
return label;
}

View File

@ -0,0 +1,62 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2024 Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
class QWidget;
class QLabel;
namespace caf
{
class QShortenedLabel;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiFieldLabelEditorHandle : public PdmUiFieldEditorHandle
{
public:
QWidget* createLabelWidget( QWidget* parent ) final;
private:
static QShortenedLabel* createLabel( QWidget* parent, caf::PdmUiFieldEditorHandle* uiFieldEditorHandle );
protected:
QPointer<QLabel> m_label;
};
} // end namespace caf

View File

@ -118,15 +118,6 @@ QWidget* PdmUiFilePathEditor::createEditorWidget( QWidget* parent )
return placeholder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiFilePathEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QLabel>
#include <QLineEdit>
@ -78,7 +78,7 @@ public:
//==================================================================================================
///
//==================================================================================================
class PdmUiFilePathEditor : public PdmUiFieldEditorHandle
class PdmUiFilePathEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -89,7 +89,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
@ -98,10 +97,9 @@ protected slots:
void copyToClipboard();
private:
QPointer<QLineEdit> m_lineEdit;
QPointer<QShortenedLabel> m_label;
QPointer<QToolButton> m_button;
QPointer<QToolButton> m_copyToClipboardButton;
QPointer<QLineEdit> m_lineEdit;
QPointer<QToolButton> m_button;
QPointer<QToolButton> m_copyToClipboardButton;
PdmUiFilePathEditorAttribute m_attributes;
};

View File

@ -39,6 +39,7 @@
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldHandle.h"
#include "cafPdmUiObjectHandle.h"
#include "cafQShortenedLabel.h"
namespace caf
{

View File

@ -37,7 +37,6 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafQShortenedLabel.h"
#include <QLabel>
#include <QPointer>

View File

@ -115,15 +115,6 @@ QWidget* PdmUiLineEditor::createEditorWidget( QWidget* parent )
return m_lineEdit;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiLineEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QHBoxLayout>
#include <QLabel>
@ -115,7 +115,7 @@ private:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiLineEditor : public PdmUiFieldEditorHandle
class PdmUiLineEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -131,7 +131,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
QMargins calculateLabelContentMargins() const override;
@ -146,8 +145,7 @@ private:
bool isMultipleFieldsWithSameKeywordSelected( PdmFieldHandle* editorField ) const;
protected:
QPointer<PdmUiLineEdit> m_lineEdit;
QPointer<QShortenedLabel> m_label;
QPointer<PdmUiLineEdit> m_lineEdit;
QPointer<QToolButton> m_autoValueToolButton;

View File

@ -288,15 +288,6 @@ QWidget* PdmUiListEditor::createEditorWidget( QWidget* parent )
return m_listView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiListEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -523,4 +514,16 @@ bool PdmUiListEditor::isMultiRowEditor() const
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiListEditorAttribute::PdmUiListEditorAttribute()
: heightHint( 2000 )
, allowHorizontalScrollBar( true )
{
QPalette myPalette;
baseColor = myPalette.color( QPalette::Active, QPalette::Base );
}
} // end namespace caf

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QStringListModel>
@ -53,14 +53,7 @@ namespace caf
class PdmUiListEditorAttribute : public PdmUiEditorAttribute
{
public:
PdmUiListEditorAttribute()
: heightHint( 2000 )
, allowHorizontalScrollBar( true )
{
QPalette myPalette;
baseColor = myPalette.color( QPalette::Active, QPalette::Base );
}
PdmUiListEditorAttribute();
public:
QColor baseColor;
@ -72,7 +65,7 @@ public:
//==================================================================================================
///
//==================================================================================================
class PdmUiListEditor : public PdmUiFieldEditorHandle
class PdmUiListEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -83,7 +76,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
bool eventFilter( QObject* listView, QEvent* event ) override; // To catch delete key press in list view.
bool isMultiRowEditor() const override;
@ -101,7 +93,6 @@ private:
private:
QPointer<QListViewHeightHint> m_listView;
QPointer<QShortenedLabel> m_label;
QPointer<QStringListModel> m_model;
bool m_isEditOperationsAvailable;

View File

@ -36,14 +36,12 @@
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include <QBoxLayout>
#include <cmath>
@ -171,15 +169,6 @@ QWidget* PdmUiPushButtonEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiPushButtonEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QLabel>
#include <QPointer>
@ -60,7 +60,7 @@ public:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiPushButtonEditor : public PdmUiFieldEditorHandle
class PdmUiPushButtonEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -74,16 +74,14 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
void slotClicked( bool checked );
private:
QPointer<QPushButton> m_pushButton;
QPointer<QShortenedLabel> m_label;
QPointer<QHBoxLayout> m_buttonLayout;
QPointer<QPushButton> m_pushButton;
QPointer<QHBoxLayout> m_buttonLayout;
};
} // end namespace caf

View File

@ -36,13 +36,12 @@
#include "cafPdmUiSliderEditor.h"
#include "cafFactory.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDefaultObjectEditor.h"
#include "cafPdmUiFieldEditorHandle.h"
#include "cafFactory.h"
#include <QHBoxLayout>
#include <QIntValidator>
#include <QLabel>
@ -120,15 +119,6 @@ QWidget* PdmUiSliderEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiSliderEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QGroupBox>
#include <QLabel>
@ -69,7 +69,7 @@ public:
int m_step;
};
class PdmUiSliderEditor : public PdmUiFieldEditorHandle
class PdmUiSliderEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -81,7 +81,6 @@ public:
protected:
void configureAndUpdateUi( const QString& uiConfigName ) override;
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
protected slots:
void slotSliderValueChanged( int position );
@ -92,9 +91,8 @@ private:
void writeValueToField();
private:
QPointer<QSpinBox> m_spinBox;
QPointer<QSlider> m_slider;
QPointer<QShortenedLabel> m_label;
QPointer<QSpinBox> m_spinBox;
QPointer<QSlider> m_slider;
PdmUiSliderEditorAttribute m_attributes;
};

View File

@ -42,6 +42,7 @@
#include "cafPdmUiEditorHandle.h"
#include "cafPdmUiTableViewDelegate.h"
#include "cafPdmUiTableViewQModel.h"
#include "cafQShortenedLabel.h"
#include "cafSelectionManager.h"
#include <QApplication>

View File

@ -163,8 +163,8 @@ private slots:
private:
friend class FocusEventHandler;
QPointer<QShortenedLabel> m_tableHeading;
QPointer<QLabel> m_tableHeadingIcon;
QPointer<QLabel> m_tableHeading;
QPointer<QLabel> m_tableHeadingIcon;
TableView* m_tableView;
PdmUiTableViewQModel* m_tableModelPdm;

View File

@ -208,15 +208,6 @@ QWidget* PdmUiTextEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiTextEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QLabel>
#include <QPointer>
@ -112,7 +112,7 @@ private:
//==================================================================================================
/// An editor to show (and possibly edit?) formatted larger portions of text
//==================================================================================================
class PdmUiTextEditor : public PdmUiFieldEditorHandle
class PdmUiTextEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -123,7 +123,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
bool isMultiRowEditor() const override;
@ -134,9 +133,8 @@ private:
QTextOption::WrapMode toQTextOptionWrapMode( PdmUiTextEditorAttribute::WrapMode wrapMode );
private:
QPointer<TextEdit> m_textEdit;
QPointer<QPushButton> m_saveButton;
QPointer<QShortenedLabel> m_label;
QPointer<TextEdit> m_textEdit;
QPointer<QPushButton> m_saveButton;
PdmUiTextEditorAttribute::TextMode m_textMode;
};

View File

@ -94,15 +94,6 @@ QWidget* PdmUiTimeEditor::createEditorWidget( QWidget* parent )
return m_timeEdit;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiTimeEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QPointer>
#include <QString>
@ -60,7 +60,7 @@ public:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiTimeEditor : public PdmUiFieldEditorHandle
class PdmUiTimeEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -71,7 +71,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
protected slots:
@ -79,8 +78,7 @@ protected slots:
void slotTimeChanged( const QTime& time );
private:
QPointer<QTimeEdit> m_timeEdit;
QPointer<QShortenedLabel> m_label;
QPointer<QTimeEdit> m_timeEdit;
PdmUiTimeEditorAttribute m_attributes;
};

View File

@ -382,15 +382,6 @@ QWidget* PdmUiTreeSelectionEditor::createEditorWidget( QWidget* parent )
return frame;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiTreeSelectionEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -35,7 +35,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include <QAbstractItemModel>
@ -92,7 +92,7 @@ public:
//==================================================================================================
///
//==================================================================================================
class PdmUiTreeSelectionEditor : public PdmUiFieldEditorHandle
class PdmUiTreeSelectionEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -104,7 +104,6 @@ public:
protected:
void configureAndUpdateUi( const QString& uiConfigName ) override;
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
QMargins calculateLabelContentMargins() const override;
bool isMultiRowEditor() const override;
@ -142,7 +141,6 @@ private:
private:
QPointer<QTreeViewHeightHint> m_treeView;
QPointer<QShortenedLabel> m_label;
QPointer<QCheckBox> m_toggleAllCheckBox;
QPointer<QLineEdit> m_textFilterLineEdit;

View File

@ -287,13 +287,4 @@ QWidget* PdmUiValueRangeEditor::createEditorWidget( QWidget* parent )
return containerWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiValueRangeEditor::createLabelWidget( QWidget* parent )
{
m_label = new QShortenedLabel( parent );
return m_label;
}
} // end namespace caf

View File

@ -36,7 +36,7 @@
#pragma once
#include "cafPdmUiFieldEditorHandle.h"
#include "cafPdmUiFieldLabelEditorHandle.h"
#include "cafPdmUiSliderTools.h"
class QLineEdit;
@ -46,7 +46,7 @@ namespace caf
//==================================================================================================
///
//==================================================================================================
class PdmUiValueRangeEditor : public PdmUiFieldEditorHandle
class PdmUiValueRangeEditor : public PdmUiFieldLabelEditorHandle
{
Q_OBJECT
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
@ -57,7 +57,6 @@ public:
protected:
QWidget* createEditorWidget( QWidget* parent ) override;
QWidget* createLabelWidget( QWidget* parent ) override;
void configureAndUpdateUi( const QString& uiConfigName ) override;
private slots:
@ -78,9 +77,8 @@ private:
QPointer<QLineEdit> m_lineEditMax;
QPointer<QSlider> m_sliderMax;
QPointer<QShortenedLabel> m_label;
double m_sliderValueMin;
double m_sliderValueMax;
double m_sliderValueMin;
double m_sliderValueMax;
PdmUiDoubleSliderEditorAttribute m_attributes;
};