VirtualBox

Changeset 94733 in vbox


Ignore:
Timestamp:
Apr 28, 2022 12:24:47 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151113
Message:

FE/Qt/Ds: bugref:10205: Reworking global update preferences and linked stuff to use UpdatePeriodType enum instead of VBoxUpdateData::PeriodType; Cleanup for related stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.cpp

    r94725 r94733  
    2727
    2828/* static: */
    29 VBoxUpdateDayList VBoxUpdateData::m_dayList = VBoxUpdateDayList();
     29VBoxUpdateDayList VBoxUpdateData::s_days = VBoxUpdateDayList();
    3030
    3131/* static */
     
    3333{
    3434    /* Clear list initially: */
    35     m_dayList.clear();
     35    s_days.clear();
    3636
    3737    // WORKAROUND:
     
    4040
    4141    /* Separately retranslate each day: */
    42     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 day"),  "1 d");
    43     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 days"), "2 d");
    44     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 days"), "3 d");
    45     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "4 days"), "4 d");
    46     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "5 days"), "5 d");
    47     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "6 days"), "6 d");
     42    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 day"),   "1 d");
     43    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 days"), "2 d");
     44    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 days"), "3 d");
     45    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "4 days"), "4 d");
     46    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "5 days"), "5 d");
     47    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "6 days"), "6 d");
    4848
    4949    /* Separately retranslate each week: */
    50     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 week"),  "1 w");
    51     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 weeks"), "2 w");
    52     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 weeks"), "3 w");
     50    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 week"),  "1 w");
     51    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 weeks"), "2 w");
     52    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 weeks"), "3 w");
    5353
    5454    /* Separately retranslate each month: */
    55     m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 month"), "1 m");
     55    s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 month"), "1 m");
    5656}
    5757
     
    6060{
    6161    QStringList result;
    62     for (int i = 0; i < m_dayList.size(); ++i)
    63         result << m_dayList.at(i).val;
     62    foreach (const VBoxUpdateDay &day, s_days)
     63        result << day.val;
    6464    return result;
    6565}
     
    6767VBoxUpdateData::VBoxUpdateData(const QString &strData)
    6868    : m_strData(strData)
    69     , m_enmPeriodIndex(Period1Day)
     69    , m_enmUpdatePeriod(UpdatePeriodType_1Day)
    7070    , m_enmUpdateChannel(KUpdateChannel_Stable)
    7171{
     
    7373}
    7474
    75 VBoxUpdateData::VBoxUpdateData(PeriodType enmPeriodIndex, KUpdateChannel enmUpdateChannel)
     75VBoxUpdateData::VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel)
    7676    : m_strData(QString())
    77     , m_enmPeriodIndex(enmPeriodIndex)
     77    , m_enmUpdatePeriod(enmUpdatePeriod)
    7878    , m_enmUpdateChannel(enmUpdateChannel)
    7979{
     
    8484{
    8585    /* No need to check if Period == Never: */
    86     return m_enmPeriodIndex == PeriodNever;
     86    return m_enmUpdatePeriod == UpdatePeriodType_Never;
    8787}
    8888
     
    110110}
    111111
    112 VBoxUpdateData::PeriodType VBoxUpdateData::periodIndex() const
    113 {
    114     return m_enmPeriodIndex;
     112UpdatePeriodType VBoxUpdateData::updatePeriod() const
     113{
     114    return m_enmUpdatePeriod;
    115115}
    116116
     
    145145    return    true
    146146           && (m_strData == another.data())
    147            && (m_enmPeriodIndex == another.periodIndex())
     147           && (m_enmUpdatePeriod == another.updatePeriod())
    148148           && (m_date == another.internalDate())
    149149           && (m_enmUpdateChannel == another.updateChannel())
     
    188188    /* Parse standard values: */
    189189    if (m_strData == "never")
    190         m_enmPeriodIndex = PeriodNever;
     190        m_enmUpdatePeriod = UpdatePeriodType_Never;
    191191    /* Parse other values: */
    192192    else
     
    201201        if (parser.size() > 0)
    202202        {
    203             if (m_dayList.isEmpty())
     203            if (s_days.isEmpty())
    204204                populate();
    205             PeriodType index = (PeriodType)m_dayList.indexOf(VBoxUpdateDay(QString(), parser.at(0)));
    206             m_enmPeriodIndex = index == PeriodUndefined ? Period1Day : index;
     205            const UpdatePeriodType enmUpdatePeriod = (UpdatePeriodType)s_days.indexOf(VBoxUpdateDay(QString(), parser.at(0)));
     206            m_enmUpdatePeriod = enmUpdatePeriod == UpdatePeriodType_Never ? UpdatePeriodType_1Day : enmUpdatePeriod;
    207207        }
    208208
     
    231231{
    232232    /* Encode standard values: */
    233     if (m_enmPeriodIndex == PeriodNever)
     233    if (m_enmUpdatePeriod == UpdatePeriodType_Never)
    234234        m_strData = "never";
    235235    /* Encode other values: */
     
    237237    {
    238238        /* Encode 'period' value: */
    239         if (m_dayList.isEmpty())
     239        if (s_days.isEmpty())
    240240            populate();
    241         QString remindPeriod = m_dayList[m_enmPeriodIndex].key;
     241        QString remindPeriod = s_days.at(m_enmUpdatePeriod).key;
    242242
    243243        /* Encode 'date' value: */
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.h

    r94725 r94733  
    3333
    3434
    35 /** Structure to store retranslated reminder values. */
     35/** Update period types. */
     36enum UpdatePeriodType
     37{
     38    UpdatePeriodType_Never  = -1,
     39    UpdatePeriodType_1Day   =  0,
     40    UpdatePeriodType_2Days  =  1,
     41    UpdatePeriodType_3Days  =  2,
     42    UpdatePeriodType_4Days  =  3,
     43    UpdatePeriodType_5Days  =  4,
     44    UpdatePeriodType_6Days  =  5,
     45    UpdatePeriodType_1Week  =  6,
     46    UpdatePeriodType_2Weeks =  7,
     47    UpdatePeriodType_3Weeks =  8,
     48    UpdatePeriodType_1Month =  9
     49};
     50
     51
     52/** Structure to store retranslated period type values. */
    3653struct VBoxUpdateDay
    3754{
    3855    VBoxUpdateDay(const QString &strVal, const QString &strKey)
    39         : val(strVal), key(strKey) {}
     56        : val(strVal)
     57        , key(strKey)
     58    {}
    4059
    41     bool operator==(const VBoxUpdateDay &other) const { return val == other.val || key == other.key; }
     60    bool operator==(const VBoxUpdateDay &other) const
     61    {
     62        return    val == other.val
     63               || key == other.key;
     64    }
    4265
    43     QString val;
    44     QString key;
     66    QString     val;
     67    QString     key;
    4568};
    4669typedef QList<VBoxUpdateDay> VBoxUpdateDayList;
     
    5275public:
    5376
    54     /** Period types. */
    55     enum PeriodType
    56     {
    57         PeriodNever     = -2,
    58         PeriodUndefined = -1,
    59         Period1Day      =  0,
    60         Period2Days     =  1,
    61         Period3Days     =  2,
    62         Period4Days     =  3,
    63         Period5Days     =  4,
    64         Period6Days     =  5,
    65         Period1Week     =  6,
    66         Period2Weeks    =  7,
    67         Period3Weeks    =  8,
    68         Period1Month    =  9
    69     };
    70 
    7177    /** Populates a set of update options. */
    7278    static void populate();
     
    7682    /** Constructs update description on the basis of passed @a strData. */
    7783    VBoxUpdateData(const QString &strData = QString());
    78     /** Constructs update description on the basis of passed @a enmPeriodIndex and @a enmUpdateChannel. */
    79     VBoxUpdateData(PeriodType enmPeriodIndex, KUpdateChannel enmUpdateChannel);
     84    /** Constructs update description on the basis of passed @a enmUpdatePeriod and @a enmUpdateChannel. */
     85    VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel);
    8086
    8187    /** Returns whether there is no need to check. */
     
    8389    /** Returns whether there is really need to check. */
    8490    bool isNeedToCheck() const;
     91
    8592    /** Returns update data. */
    8693    QString data() const;
    87     /** Returns period index. */
    88     PeriodType periodIndex() const;
     94
     95    /** Returns update period. */
     96    UpdatePeriodType updatePeriod() const;
    8997    /** Returns update date. */
    9098    QString date() const;
     
    121129    void encode();
    122130
    123     /** Holds the populated list of update options. */
    124     static VBoxUpdateDayList m_dayList;
     131    /** Holds the populated list of update period options. */
     132    static VBoxUpdateDayList  s_days;
    125133
    126134    /** Holds the update data. */
    127     QString         m_strData;
    128     /** Holds the update period index. */
    129     PeriodType      m_enmPeriodIndex;
     135    QString           m_strData;
     136    /** Holds the update period. */
     137    UpdatePeriodType  m_enmUpdatePeriod;
    130138    /** Holds the update date. */
    131     QDate           m_date;
     139    QDate             m_date;
    132140    /** Holds the update channel. */
    133     KUpdateChannel  m_enmUpdateChannel;
     141    KUpdateChannel    m_enmUpdateChannel;
    134142    /** Holds the update version. */
    135     UIVersion       m_version;
     143    UIVersion         m_version;
    136144};
    137145
  • trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp

    r94725 r94733  
    364364    VBoxUpdateData currentData(gEDataManager->applicationUpdateData());
    365365    /* Encode/save new update data: */
    366     VBoxUpdateData newData(currentData.periodIndex(), currentData.updateChannel());
     366    VBoxUpdateData newData(currentData.updatePeriod(), currentData.updateChannel());
    367367    gEDataManager->setApplicationUpdateData(newData.data());
    368368
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.cpp

    r94725 r94733  
    5757            {
    5858                if (m_pComboUpdatePeriod)
    59                     m_pComboUpdatePeriod->setCurrentIndex(m_guiValue.periodIndex());
     59                    m_pComboUpdatePeriod->setCurrentIndex(m_guiValue.updatePeriod());
    6060                if (m_mapRadioButtons.value(m_guiValue.updateChannel()))
    6161                    m_mapRadioButtons.value(m_guiValue.updateChannel())->setChecked(true);
     
    6969VBoxUpdateData UIUpdateSettingsEditor::value() const
    7070{
    71     return m_pCheckBox ? VBoxUpdateData(periodType(), updateChannel()) : m_guiValue;
     71    return m_pCheckBox ? VBoxUpdateData(updatePeriod(), updateChannel()) : m_guiValue;
    7272}
    7373
     
    141141{
    142142    if (m_pFieldUpdateDate)
    143         m_pFieldUpdateDate->setText(VBoxUpdateData(periodType(), updateChannel()).date());
     143        m_pFieldUpdateDate->setText(VBoxUpdateData(updatePeriod(), updateChannel()).date());
    144144}
    145145
     
    265265}
    266266
    267 VBoxUpdateData::PeriodType UIUpdateSettingsEditor::periodType() const
    268 {
    269     const VBoxUpdateData::PeriodType enmResult = m_pCheckBox && m_pCheckBox->isChecked() && m_pComboUpdatePeriod
    270                                                ? (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex()
    271                                                : VBoxUpdateData::PeriodNever;
    272     return enmResult == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : enmResult;
     267UpdatePeriodType UIUpdateSettingsEditor::updatePeriod() const
     268{
     269    return   m_pCheckBox && m_pCheckBox->isChecked() && m_pComboUpdatePeriod
     270           ? (UpdatePeriodType)m_pComboUpdatePeriod->currentIndex()
     271           : UpdatePeriodType_Never;
    273272}
    274273
     
    276275{
    277276    QAbstractButton *pCheckedButton = m_pRadioButtonGroup ? m_pRadioButtonGroup->checkedButton() : 0;
    278     return m_mapRadioButtons.key(pCheckedButton, KUpdateChannel_Stable);
    279 }
     277    return m_mapRadioButtons.key(pCheckedButton, m_guiValue.updateChannel());
     278}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.h

    r94725 r94733  
    7272    void prepareConnections();
    7373
    74     /** Returns period type. */
    75     VBoxUpdateData::PeriodType periodType() const;
     74    /** Returns update period. */
     75    UpdatePeriodType updatePeriod() const;
    7676    /** Returns update channel. */
    7777    KUpdateChannel updateChannel() const;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette