Janitor : Remove obsolete code related to Qt 4

This commit is contained in:
Magne Sjaastad
2021-02-22 08:29:15 +01:00
parent 9077031535
commit 3c07989c51
10 changed files with 5 additions and 138 deletions

View File

@@ -117,11 +117,7 @@ bool PdmUiTableViewDelegate::isEditorOpen() const
//--------------------------------------------------------------------------------------------------
void PdmUiTableViewDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
#if QT_VERSION_MAJOR > 4
QStyleOptionViewItem viewItemOption( option );
#else
QStyleOptionViewItemV4 viewItemOption( option );
#endif
QVariant fgText = index.data( Qt::ForegroundRole );

View File

@@ -235,11 +235,7 @@ void PdmUiTableViewEditor::configureAndUpdateUi( const QString& uiConfigName )
}
else if ( editorAttrib.resizePolicy == PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER )
{
#if QT_VERSION >= 0x050000
m_tableView->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
#else
m_tableView->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
#endif
}
}

View File

@@ -134,85 +134,6 @@ protected:
}
};
//--------------------------------------------------------------------------------------------------
/// Ported parts of placeholder text painting from Qt 4.7
/// setPlaceholderText() was introduced in Qt 4.7,
/// and this class is intended to be removed when Qt is upgraded
//--------------------------------------------------------------------------------------------------
class PlaceholderLineEdit : public QLineEdit
{
public:
explicit PlaceholderLineEdit( const QString& placeholderText, QWidget* parent = nullptr )
: QLineEdit( parent )
, m_placeholderText( placeholderText )
{
}
private:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void paintEvent( QPaintEvent* paintEvent ) override
{
QPainter p( this );
QRect r = rect();
QPalette pal = palette();
#if QT_VERSION_MAJOR > 4
QStyleOptionFrame panel;
#else
QStyleOptionFrameV2 panel;
#endif
initStyleOption( &panel );
style()->drawPrimitive( QStyle::PE_PanelLineEdit, &panel, &p, this );
r = style()->subElementRect( QStyle::SE_LineEditContents, &panel, this );
int left = 0;
int top = 0;
int right = 0;
int bottom = 0;
getTextMargins( &left, &top, &right, &bottom );
r.setX( r.x() + left );
r.setY( r.y() + top );
r.setRight( r.right() - right );
r.setBottom( r.bottom() - bottom );
p.setClipRect( r );
QFontMetrics fm = fontMetrics();
const int horizontalMargin = 2;
const int vscroll = r.y() + ( r.height() - fm.height() + 1 ) / 2;
QRect lineRect( r.x() + horizontalMargin, vscroll, r.width() - 2 * horizontalMargin, fm.height() );
int minLB = qMax( 0, -fm.minLeftBearing() );
if ( text().isEmpty() )
{
if ( !hasFocus() && !m_placeholderText.isEmpty() )
{
QColor col = pal.text().color();
col.setAlpha( 128 );
QPen oldpen = p.pen();
p.setPen( col );
lineRect.adjust( minLB, 0, 0, 0 );
QString elidedText = fm.elidedText( m_placeholderText, Qt::ElideRight, lineRect.width() );
p.drawText( lineRect, Qt::AlignLeft | Qt::TextWordWrap, elidedText );
p.setPen( oldpen );
return;
}
}
return QLineEdit::paintEvent( paintEvent );
}
private:
QString m_placeholderText;
};
namespace caf
{
//--------------------------------------------------------------------------------------------------
@@ -393,10 +314,8 @@ QWidget* PdmUiTreeSelectionEditor::createEditorWidget( QWidget* parent )
connect( m_toggleAllCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( slotToggleAll() ) );
m_textFilterLineEdit = new PlaceholderLineEdit( "Click to add filter" );
// TODO: setPlaceholderText() was introduced in Qt 4.7
// Use QLineEdit instead of PlaceholderLineEdit when Qt is upgraded
// m_textFilterLineEdit->setPlaceholderText("Click to add filter");
m_textFilterLineEdit = new QLineEdit();
m_textFilterLineEdit->setPlaceholderText( "Click to add filter" );
headerLayout->addWidget( m_textFilterLineEdit );

View File

@@ -334,9 +334,7 @@ void caf::RotationSensitivityCalculator::init( QMouseEvent* eventAtRotationStart
m_lastPosX = eventAtRotationStart->x();
m_lastPosY = eventAtRotationStart->y();
#if QT_VERSION >= 0x050000
m_lastTime = eventAtRotationStart->timestamp();
#endif
}
//--------------------------------------------------------------------------------------------------
@@ -350,7 +348,6 @@ double caf::RotationSensitivityCalculator::calculateSensitivity( QMouseEvent* ev
{
if ( m_fixedSensitivity == std::numeric_limits<double>::infinity() )
{
#if QT_VERSION >= 0x050000
auto presentTime = eventWhenRotating->timestamp();
unsigned long timeSinceLast = presentTime - m_lastTime;
if ( timeSinceLast == 0 ) timeSinceLast = 1; // one millisecond
@@ -373,11 +370,6 @@ double caf::RotationSensitivityCalculator::calculateSensitivity( QMouseEvent* ev
m_lastPosY = eventWhenRotating->y();
m_lastTime = eventWhenRotating->timestamp();
m_lastMouseVelocityLenght = 0.8 * mouseVelocityLength + 0.2 * m_lastMouseVelocityLenght;
// openDebugWindow();
// std::cout << sensitivity << " Speed: Raw: " << mouseVelocityLength << " Smooth: " << mouseVelocityLengthCorr << "
// \tDelta " << deltaX << ", " << deltaY << " "<< timeSinceLast << std::endl;
#endif
}
else
{

View File

@@ -115,14 +115,8 @@ cvf::ref<cvf::OpenGLContextGroup> caf::Viewer::sm_openGLContextGroup;
///
//--------------------------------------------------------------------------------------------------
caf::Viewer::Viewer( const QGLFormat& format, QWidget* parent )
#if QT_VERSION >= 0x050000
: caf::OpenGLWidget( contextGroup(), format, nullptr, sharedWidget() )
,
#else
: caf::OpenGLWidget( contextGroup(), format, new QWidget( parent ), sharedWidget() )
,
#endif
m_navigationPolicy( nullptr )
, m_navigationPolicy( nullptr )
, m_navigationPolicyEnabled( true )
, m_defaultPerspectiveNearPlaneDistance( 0.05 )
, m_maxClipPlaneDistance( cvf::UNDEFINED_DOUBLE )
@@ -139,11 +133,7 @@ caf::Viewer::Viewer( const QGLFormat& format, QWidget* parent )
, m_isComparisonFollowingAnimation( true )
, m_isComparisonViewActiveFlag( false )
{
#if QT_VERSION >= 0x050000
m_layoutWidget = new QWidget( parent );
#else
m_layoutWidget = parentWidget();
#endif
QHBoxLayout* layout = new QHBoxLayout( m_layoutWidget );
@@ -598,7 +588,6 @@ bool caf::Viewer::calculateNearFarPlanes( const cvf::Rendering* rendering,
//--------------------------------------------------------------------------------------------------
bool caf::Viewer::event( QEvent* e )
{
#if QT_VERSION >= 0x050000
// The most reliable way we have found of detecting when an OpenGL context is about to be destroyed is
// hooking into the QEvent::PlatformSurface event and checking for the SurfaceAboutToBeDestroyed event type.
// From the Qt doc:
@@ -613,7 +602,6 @@ bool caf::Viewer::event( QEvent* e )
cvfShutdownOpenGLContext();
}
}
#endif
if ( e && m_navigationPolicy.notNull() && m_navigationPolicyEnabled )
{
@@ -857,10 +845,7 @@ void caf::Viewer::paintEvent( QPaintEvent* event )
m_overlayImage->setPixelSize( cvf::Vec2ui( this->width(), this->height() ) );
}
#if QT_VERSION >= 0x040600
// Qt 4.6
painter.beginNativePainting();
#endif
if ( isShadersSupported() )
{
@@ -897,10 +882,7 @@ void caf::Viewer::paintEvent( QPaintEvent* event )
cvfqt::OpenGLContext::restoreOpenGLState( myOglContext.p() );
}
#if QT_VERSION >= 0x040600
// Qt 4.6
painter.endNativePainting();
#endif
}
//--------------------------------------------------------------------------------------------------

View File

@@ -42,15 +42,10 @@
#include <QtCore/QVariant>
#include <QtCore/QString>
#if QT_VERSION >= 0x050000
#include <QVBoxLayout>
#include <QLabel>
#include <QPushButton>
#else
#include <QtGui/QVBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#endif
namespace cvfqt {

View File

@@ -38,11 +38,7 @@
#pragma once
#include <QtCore/QString>
#if QT_VERSION >= 0x050000
#include <QDialog>
#else
#include <QtGui/QDialog>
#endif
class QGridLayout;

View File

@@ -67,13 +67,11 @@ OpenGLContext::OpenGLContext(cvf::OpenGLContextGroup* contextGroup, QGLContext*
{
m_qtGLContext = backingQGLContext;
#if QT_VERSION >= 0x040700
CVF_ASSERT(m_qtGLContext);
QGLFormat glFormat = m_qtGLContext->format();
m_majorVersion = glFormat.majorVersion();
m_minorVersion = glFormat.minorVersion();
m_isCoreOpenGLProfile = (glFormat.profile() == QGLFormat::CoreProfile) ? true : false;
#endif
}

View File

@@ -43,11 +43,8 @@
#include "cvfOpenGLResourceManager.h"
#include <QtCore/QString>
#if QT_VERSION >= 0x050000
#include <QPainter>
#else
#include <QtGui/QPainter>
#endif
#include <vector>
namespace cvfqt {

View File

@@ -41,11 +41,7 @@
#include "cvfTextureImage.h"
#include <QtCore/QString>
#if QT_VERSION >= 0x050000
#include <QImage>
#else
#include <QtGui/QImage>
#endif
namespace cvfqt {