Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_date_scale_draw.h"
     11#include "qwt_text.h"
    1112
    1213class QwtDateScaleDraw::PrivateData
    1314{
    14 public:
    15     PrivateData( Qt::TimeSpec spec ):
    16         timeSpec( spec ),
    17         utcOffset( 0 ),
    18         week0Type( QwtDate::FirstThursday )
     15  public:
     16    explicit PrivateData( Qt::TimeSpec spec )
     17        : timeSpec( spec )
     18        , utcOffset( 0 )
     19        , week0Type( QwtDate::FirstThursday )
    1920    {
    2021        dateFormats[ QwtDate::Millisecond ] = "hh:mm:ss:zzz\nddd dd MMM yyyy";
    … …  
    3536
    3637/*!
    37   \brief Constructor
    38 
    39   The default setting is to display tick labels for the
    40   given time specification. The first week of a year is defined like
    41   for QwtDate::FirstThursday.
    42 
    43   \param timeSpec Time specification
    44 
    45   \sa setTimeSpec(), setWeek0Type()
     38   \brief Constructor
     39
     40   The default setting is to display tick labels for the
     41   given time specification. The first week of a year is defined like
     42   for QwtDate::FirstThursday.
     43
     44   \param timeSpec Time specification
     45
     46   \sa setTimeSpec(), setWeek0Type()
    4647 */
    4748QwtDateScaleDraw::QwtDateScaleDraw( Qt::TimeSpec timeSpec )
    4849{
    49     d_data = new PrivateData( timeSpec );
     50    m_data = new PrivateData( timeSpec );
    5051}
    5152
    … …  
    5354QwtDateScaleDraw::~QwtDateScaleDraw()
    5455{
    55     delete d_data;
    56 }
    57 
    58 /*!
    59   Set the time specification used for the tick labels
    60 
    61   \param timeSpec Time specification
    62   \sa timeSpec(), setUtcOffset(), toDateTime()
     56    delete m_data;
     57}
     58
     59/*!
     60   Set the time specification used for the tick labels
     61
     62   \param timeSpec Time specification
     63   \sa timeSpec(), setUtcOffset(), toDateTime()
    6364 */
    6465void QwtDateScaleDraw::setTimeSpec( Qt::TimeSpec timeSpec )
    6566{
    66     d_data->timeSpec = timeSpec;
    67 }
    68 
    69 /*!
    70   \return Time specification used for the tick labels
    71   \sa setTimeSpec(), utcOffset(), toDateTime()
     67    m_data->timeSpec = timeSpec;
     68}
     69
     70/*!
     71   \return Time specification used for the tick labels
     72   \sa setTimeSpec(), utcOffset(), toDateTime()
    7273 */
    7374Qt::TimeSpec QwtDateScaleDraw::timeSpec() const
    7475{
    75     return d_data->timeSpec;
    76 }
    77 
    78 /*!
    79   Set the offset in seconds from Coordinated Universal Time
    80 
    81   \param seconds Offset in seconds
    82 
    83   \note The offset has no effect beside for the time specification
     76    return m_data->timeSpec;
     77}
     78
     79/*!
     80   Set the offset in seconds from Coordinated Universal Time
     81
     82   \param seconds Offset in seconds
     83
     84   \note The offset has no effect beside for the time specification
    8485        Qt::OffsetFromUTC.
    8586
    86   \sa QDate::utcOffset(), setTimeSpec(), toDateTime()
     87   \sa QDate::utcOffset(), setTimeSpec(), toDateTime()
    8788 */
    8889void QwtDateScaleDraw::setUtcOffset( int seconds )
    8990{
    90     d_data->utcOffset = seconds;
    91 }
    92 
    93 /*!
    94   \return Offset in seconds from Coordinated Universal Time
    95   \note The offset has no effect beside for the time specification
     91    m_data->utcOffset = seconds;
     92}
     93
     94/*!
     95   \return Offset in seconds from Coordinated Universal Time
     96   \note The offset has no effect beside for the time specification
    9697        Qt::OffsetFromUTC.
    9798
    98   \sa QDate::setUtcOffset(), setTimeSpec(), toDateTime()
     99   \sa QDate::setUtcOffset(), setTimeSpec(), toDateTime()
    99100 */
    100101int QwtDateScaleDraw::utcOffset() const
    101102{
    102     return d_data->utcOffset;
    103 }
    104 
    105 /*!
    106   Sets how to identify the first week of a year.
    107 
    108   \param week0Type Mode how to identify the first week of a year
    109 
    110   \sa week0Type().
    111   \note week0Type has no effect beside for intervals classified as
     103    return m_data->utcOffset;
     104}
     105
     106/*!
     107   Sets how to identify the first week of a year.
     108
     109   \param week0Type Mode how to identify the first week of a year
     110
     111   \sa week0Type().
     112   \note week0Type has no effect beside for intervals classified as
    112113        QwtDate::Week.
    113114 */
    114115void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type )
    115116{
    116     d_data->week0Type = week0Type;
    117 }
    118 
    119 /*!
    120   \return Setting how to identify the first week of a year.
    121   \sa setWeek0Type()
     117    m_data->week0Type = week0Type;
     118}
     119
     120/*!
     121   \return Setting how to identify the first week of a year.
     122   \sa setWeek0Type()
    122123 */
    123124QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
    124125{
    125     return d_data->week0Type;
    126 }
    127 
    128 /*!
    129   Set the default format string for an datetime interval type
    130 
    131   \param intervalType Interval type
    132   \param format Default format string
    133 
    134   \sa dateFormat(), dateFormatOfDate(), QwtDate::toString()
     126    return m_data->week0Type;
     127}
     128
     129/*!
     130   Set the default format string for an datetime interval type
     131
     132   \param intervalType Interval type
     133   \param format Default format string
     134
     135   \sa dateFormat(), dateFormatOfDate(), QwtDate::toString()
    135136 */
    136137void QwtDateScaleDraw::setDateFormat(
    137     QwtDate::IntervalType intervalType, const QString &format )
     138    QwtDate::IntervalType intervalType, const QString& format )
    138139{
    139140    if ( intervalType >= QwtDate::Millisecond &&
    140141        intervalType <= QwtDate::Year )
    141142    {
    142         d_data->dateFormats[ intervalType ] = format;
    143     }
    144 }
    145 
    146 /*!
    147   \param intervalType Interval type
    148   \return Default format string for an datetime interval type
    149   \sa setDateFormat(), dateFormatOfDate()
     143        m_data->dateFormats[ intervalType ] = format;
     144    }
     145}
     146
     147/*!
     148   \param intervalType Interval type
     149   \return Default format string for an datetime interval type
     150   \sa setDateFormat(), dateFormatOfDate()
    150151 */
    151152QString QwtDateScaleDraw::dateFormat(
    … …  
    155156        intervalType <= QwtDate::Year )
    156157    {
    157         return d_data->dateFormats[ intervalType ];
     158        return m_data->dateFormats[ intervalType ];
    158159    }
    159160
    … …  
    162163
    163164/*!
    164   Format string for the representation of a datetime
    165 
    166   dateFormatOfDate() is intended to be overloaded for
    167   situations, where formats are individual for specific
    168   datetime values.
    169 
    170   The default setting ignores dateTime and return
    171   the default format for the interval type.
    172 
    173   \param dateTime Datetime value
    174   \param intervalType Interval type
    175   \return Format string
    176 
    177   \sa setDateFormat(), QwtDate::toString()
    178  */
    179 QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
     165   Format string for the representation of a datetime
     166
     167   dateFormatOfDate() is intended to be overloaded for
     168   situations, where formats are individual for specific
     169   datetime values.
     170
     171   The default setting ignores dateTime and return
     172   the default format for the interval type.
     173
     174   \param dateTime Datetime value
     175   \param intervalType Interval type
     176   \return Format string
     177
     178   \sa setDateFormat(), QwtDate::toString()
     179 */
     180QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime& dateTime,
    180181    QwtDate::IntervalType intervalType ) const
    181182{
    … …  
    185186        intervalType <= QwtDate::Year )
    186187    {
    187         return d_data->dateFormats[ intervalType ];
    188     }
    189 
    190     return d_data->dateFormats[ QwtDate::Second ];
    191 }
    192 
    193 /*!
    194   \brief Convert a value into its representing label
    195 
    196   The value is converted to a datetime value using toDateTime()
    197   and converted to a plain text using QwtDate::toString().
    198 
    199   \param value Value
    200   \return Label string.
    201 
    202   \sa dateFormatOfDate()
    203 */
     188        return m_data->dateFormats[ intervalType ];
     189    }
     190
     191    return m_data->dateFormats[ QwtDate::Second ];
     192}
     193
     194/*!
     195   \brief Convert a value into its representing label
     196
     197   The value is converted to a datetime value using toDateTime()
     198   and converted to a plain text using QwtDate::toString().
     199
     200   \param value Value
     201   \return Label string.
     202
     203   \sa dateFormatOfDate()
     204 */
    204205QwtText QwtDateScaleDraw::label( double value ) const
    205206{
    … …  
    208209        dt, intervalType( scaleDiv() ) );
    209210
    210     return QwtDate::toString( dt, fmt, d_data->week0Type );
    211 }
    212 
    213 /*!
    214   Find the less detailed datetime unit, where no rounding
    215   errors happen.
    216 
    217   \param scaleDiv Scale division
    218   \return Interval type
    219 
    220   \sa dateFormatOfDate()
     211    return QwtDate::toString( dt, fmt, m_data->week0Type );
     212}
     213
     214/*!
     215   Find the less detailed datetime unit, where no rounding
     216   errors happen.
     217
     218   \param scaleDiv Scale division
     219   \return Interval type
     220
     221   \sa dateFormatOfDate()
    221222 */
    222223QwtDate::IntervalType QwtDateScaleDraw::intervalType(
    223     const QwtScaleDiv &scaleDiv ) const
     224    const QwtScaleDiv& scaleDiv ) const
    224225{
    225226    int intvType = QwtDate::Year;
    … …  
    227228    bool alignedToWeeks = true;
    228229
    229     const QList<double> ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
     230    const QList< double > ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
    230231    for ( int i = 0; i < ticks.size(); i++ )
    231232    {
    … …  
    234235        {
    235236            const QDateTime dt0 = QwtDate::floor( dt,
    236                 static_cast<QwtDate::IntervalType>( j ) );
     237                static_cast< QwtDate::IntervalType >( j ) );
    237238
    238239            if ( dt0 != dt )
    … …  
    257258        intvType = QwtDate::Day;
    258259
    259     return static_cast<QwtDate::IntervalType>( intvType );
    260 }
    261 
    262 /*!
    263   Translate a double value into a QDateTime object.
    264 
    265   \return QDateTime object initialized with timeSpec() and utcOffset().
    266   \sa timeSpec(), utcOffset(), QwtDate::toDateTime()
     260    return static_cast< QwtDate::IntervalType >( intvType );
     261}
     262
     263/*!
     264   Translate a double value into a QDateTime object.
     265
     266   \return QDateTime object initialized with timeSpec() and utcOffset().
     267   \sa timeSpec(), utcOffset(), QwtDate::toDateTime()
    267268 */
    268269QDateTime QwtDateScaleDraw::toDateTime( double value ) const
    269270{
    270     QDateTime dt = QwtDate::toDateTime( value, d_data->timeSpec );
    271     if ( d_data->timeSpec == Qt::OffsetFromUTC )
    272     {
    273         dt = dt.addSecs( d_data->utcOffset );
    274         dt.setUtcOffset( d_data->utcOffset );
     271    QDateTime dt = QwtDate::toDateTime( value, m_data->timeSpec );
     272    if ( m_data->timeSpec == Qt::OffsetFromUTC )
     273    {
     274        dt = dt.addSecs( m_data->utcOffset );
     275#if QT_VERSION >= 0x050200
     276        dt.setOffsetFromUtc( m_data->utcOffset );
     277#else
     278        dt.setUtcOffset( m_data->utcOffset );
     279#endif
    275280    }
    276281
Note: See TracChangeset for help on using the changeset viewer.