Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_legend.cpp


Ignore:
Timestamp:
Mar 19, 2021, 9:15:03 AM (3 years ago)
Author:
stoecker
Message:

update to qwt verion 6.1.1 to fix build with newer Qt5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_legend.cpp

    r8127 r9383  
    5050};
    5151
    52 void QwtLegendMap::insert( const QVariant &itemInfo, 
     52void QwtLegendMap::insert( const QVariant &itemInfo,
    5353    const QList<QWidget *> &widgets )
    5454{
     
    142142{
    143143public:
    144     LegendView( QWidget *parent ):
     144    explicit LegendView( QWidget *parent ):
    145145        QScrollArea( parent )
    146146    {
     
    296296    if ( tl )
    297297        tl->setMaxColumns( numColums );
     298
     299    updateGeometry();
    298300}
    299301
     
    342344
    343345/*!
    344   The contents widget is the only child of the viewport of 
     346  The contents widget is the only child of the viewport of
    345347  the internal QScrollArea and the parent widget of all legend items.
    346348
     
    371373
    372374/*!
    373   The contents widget is the only child of the viewport of 
     375  The contents widget is the only child of the viewport of
    374376  the internal QScrollArea and the parent widget of all legend items.
    375377
     
    386388
    387389  \param itemInfo Info for an item
    388   \param data List of legend entry attributes for the item
     390  \param legendData List of legend entry attributes for the item
    389391 */
    390 void QwtLegend::updateLegend( const QVariant &itemInfo, 
    391     const QList<QwtLegendData> &data )
     392void QwtLegend::updateLegend( const QVariant &itemInfo,
     393    const QList<QwtLegendData> &legendData )
    392394{
    393395    QList<QWidget *> widgetList = legendWidgets( itemInfo );
    394396
    395     if ( widgetList.size() != data.size() )
     397    if ( widgetList.size() != legendData.size() )
    396398    {
    397399        QLayout *contentsLayout = d_data->view->contentsWidget->layout();
    398400
    399         while ( widgetList.size() > data.size() )
     401        while ( widgetList.size() > legendData.size() )
    400402        {
    401403            QWidget *w = widgetList.takeLast();
     
    410412        }
    411413
    412         for ( int i = widgetList.size(); i < data.size(); i++ )
    413         {
    414             QWidget *widget = createWidget( data[i] );
     414#if QT_VERSION >= 0x040700
     415        widgetList.reserve( legendData.size() );
     416#endif
     417
     418        for ( int i = widgetList.size(); i < legendData.size(); i++ )
     419        {
     420            QWidget *widget = createWidget( legendData[i] );
    415421
    416422            if ( contentsLayout )
     
    441447        updateTabOrder();
    442448    }
    443    
    444     for ( int i = 0; i < data.size(); i++ )
    445         updateWidget( widgetList[i], data[i] );
     449
     450    for ( int i = 0; i < legendData.size(); i++ )
     451        updateWidget( widgetList[i], legendData[i] );
    446452}
    447453
     
    451457  The default implementation returns a QwtLegendLabel.
    452458
    453   \param data Attributes of the legend entry
     459  \param legendData Attributes of the legend entry
    454460  \return Widget representing data on the legend
    455  
     461
    456462  \note updateWidget() will called soon after createWidget()
    457463        with the same attributes.
    458464 */
    459 QWidget *QwtLegend::createWidget( const QwtLegendData &data ) const
    460 {
    461     Q_UNUSED( data );
     465QWidget *QwtLegend::createWidget( const QwtLegendData &legendData ) const
     466{
     467    Q_UNUSED( legendData );
    462468
    463469    QwtLegendLabel *label = new QwtLegendLabel();
    464470    label->setItemMode( defaultItemMode() );
    465471
    466     connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) );
    467     connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) );
     472    connect( label, SIGNAL(clicked()), SLOT(itemClicked()) );
     473    connect( label, SIGNAL(checked(bool)), SLOT(itemChecked(bool)) );
    468474
    469475    return label;
     
    471477
    472478/*!
    473   \brief Update the widget 
     479  \brief Update the widget
    474480
    475481  \param widget Usually a QwtLegendLabel
    476   \param data Attributes to be displayed
     482  \param legendData Attributes to be displayed
    477483
    478484  \sa createWidget()
    479485  \note When widget is no QwtLegendLabel updateWidget() does nothing.
    480486 */
    481 void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &data )
     487void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &legendData )
    482488{
    483489    QwtLegendLabel *label = qobject_cast<QwtLegendLabel *>( widget );
    484490    if ( label )
    485491    {
    486         label->setData( data );
    487         if ( !data.value( QwtLegendData::ModeRole ).isValid() )
     492        label->setData( legendData );
     493        if ( !legendData.value( QwtLegendData::ModeRole ).isValid() )
    488494        {
    489495            // use the default mode, when there is no specific
     
    541547
    542548/*!
    543   Handle QEvent::ChildRemoved andQEvent::LayoutRequest events 
     549  Handle QEvent::ChildRemoved andQEvent::LayoutRequest events
    544550  for the contentsWidget().
    545551
     
    557563            case QEvent::ChildRemoved:
    558564            {
    559                 const QChildEvent *ce = 
     565                const QChildEvent *ce =
    560566                    static_cast<const QChildEvent *>(event);
     567
    561568                if ( ce->child()->isWidgetType() )
    562569                {
    563                     QWidget *w = static_cast< QWidget * >( ce->child() );
     570                    /*
     571                        We are called from the ~QObject and ce->child() is
     572                        no widget anymore. But all we need is the address
     573                        to remove it from the map.
     574                     */
     575                    QWidget *w = reinterpret_cast< QWidget * >( ce->child() );
    564576                    d_data->itemMap.removeWidget( w );
    565577                }
     
    585597                    QApplication::postEvent( parentWidget(),
    586598                        new QEvent( QEvent::LayoutRequest ) );
    587                 }               
     599                }
    588600                break;
    589601            }
     
    645657  \param painter Painter
    646658  \param rect Bounding rectangle
    647   \param fillBackground When true, fill rect with the widget background 
     659  \param fillBackground When true, fill rect with the widget background
    648660
    649661  \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself
    650662*/
    651 void QwtLegend::renderLegend( QPainter *painter, 
     663void QwtLegend::renderLegend( QPainter *painter,
    652664    const QRectF &rect, bool fillBackground ) const
    653665{
     
    664676    }
    665677
    666     const QwtDynGridLayout *legendLayout = 
     678    const QwtDynGridLayout *legendLayout =
    667679        qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() );
    668680    if ( legendLayout == NULL )
     
    672684    getContentsMargins( &left, &top, &right, &bottom );
    673685
    674     QRect layoutRect; 
     686    QRect layoutRect;
    675687    layoutRect.setLeft( qCeil( rect.left() ) + left );
    676688    layoutRect.setTop( qCeil( rect.top() ) + top );
     
    679691
    680692    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
    681     QList<QRect> itemRects =
     693    const QList<QRect> itemRects =
    682694        legendLayout->layoutItems( layoutRect, numCols );
    683695
     
    707719  \param widget Widget representing a legend entry
    708720  \param rect Bounding rectangle
    709   \param fillBackground When true, fill rect with the widget background 
     721  \param fillBackground When true, fill rect with the widget background
    710722
    711723  \note When widget is not derived from QwtLegendLabel renderItem
    712724        does nothing beside the background
    713725*/
    714 void QwtLegend::renderItem( QPainter *painter, 
     726void QwtLegend::renderItem( QPainter *painter,
    715727    const QWidget *widget, const QRectF &rect, bool fillBackground ) const
    716728{
     
    733745
    734746        const QRectF iconRect( rect.x() + label->margin(),
    735             rect.center().y() - 0.5 * sz.height(), 
     747            rect.center().y() - 0.5 * sz.height(),
    736748            sz.width(), sz.height() );
    737749
     
    743755        titleRect.setX( iconRect.right() + 2 * label->spacing() );
    744756
    745         painter->setFont( label->font() );
     757        QFont labelFont = label->font();
     758        labelFont.resolve( QFont::AllPropertiesResolved );
     759
     760        painter->setFont( labelFont );
    746761        painter->setPen( label->palette().color( QPalette::Text ) );
     762
    747763        const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect );
    748764    }
     
    795811    Return the extent, that is needed for the scrollbars
    796812
    797     \param orientation Orientation (
     813    \param orientation Orientation
    798814    \return The width of the vertical scrollbar for Qt::Horizontal and v.v.
    799815 */
Note: See TracChangeset for help on using the changeset viewer.