VirtualBox

Changeset 74893 in vbox


Ignore:
Timestamp:
Oct 17, 2018 6:48:46 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9230: Load selected profile details, no editing possibility yet.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/cloud
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.cpp

    r74892 r74893  
    2121
    2222/* Qt includes: */
     23# include <QHeaderView>
    2324# include <QPushButton>
    2425# include <QTableWidget>
     
    5758void UICloudProfileDetailsWidget::retranslateUi()
    5859{
     60    /// @todo add description tool-tips
     61
    5962    /* Translate table-widget: */
    6063    m_pTableWidget->setToolTip(tr("Contains cloud profile settings"));
     
    6265    /* Retranslate validation: */
    6366    retranslateValidation();
     67
     68    /* Update table tool-tips: */
     69    updateTableToolTips();
    6470}
    6571
     
    110116        if (m_pTableWidget)
    111117        {
     118            m_pTableWidget->setAlternatingRowColors(true);
     119            m_pTableWidget->horizontalHeader()->setVisible(false);
     120            m_pTableWidget->verticalHeader()->setVisible(false);
     121            m_pTableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
     122
    112123            /* Add into layout: */
    113124            pLayout->addWidget(m_pTableWidget);
     
    132143void UICloudProfileDetailsWidget::loadData()
    133144{
    134     /// @todo load profile settings table data!
     145    /* Clear table initially: */
     146    m_pTableWidget->clear();
     147
     148    /* Configure table: */
     149    m_pTableWidget->setRowCount(m_oldData.m_data.keys().size());
     150    m_pTableWidget->setColumnCount(2);
     151
     152    /* Push acquired keys/values to data fields: */
     153    for (int i = 0; i < m_pTableWidget->rowCount(); ++i)
     154    {
     155        /* Gather values: */
     156        const QString strKey = m_oldData.m_data.keys().at(i);
     157        const QString strValue = m_oldData.m_data.value(strKey).first;
     158        const QString strToolTip = m_oldData.m_data.value(strKey).second;
     159
     160        /* Create key item: */
     161        QTableWidgetItem *pItemK = new QTableWidgetItem(strKey);
     162        if (pItemK)
     163        {
     164            /* Non-editable for sure, but non-selectable? */
     165            pItemK->setFlags(pItemK->flags() & ~Qt::ItemIsEditable);
     166            /* Use non-translated description as tool-tip: */
     167            pItemK->setData(Qt::UserRole, strToolTip);
     168
     169            /* Insert into table: */
     170            m_pTableWidget->setItem(i, 0, pItemK);
     171        }
     172
     173        /* Create value item: */
     174        QTableWidgetItem *pItemV = new QTableWidgetItem(strValue);
     175        if (pItemV)
     176        {
     177            /* Use the value as tool-tip, there can be quite long values: */
     178            pItemV->setToolTip(strValue);
     179
     180            /* Insert into table: */
     181            m_pTableWidget->setItem(i, 1, pItemV);
     182        }
     183    }
     184
     185    /* Update table tooltips: */
     186    updateTableToolTips();
     187    /* Adjust table contents: */
     188    adjustTableContents();
    135189}
    136190
     
    148202
    149203    /// @todo retranslate profile settings vaidation!
     204}
     205
     206void UICloudProfileDetailsWidget::updateTableToolTips()
     207{
     208    /* Iterate through all the key items: */
     209    for (int i = 0; i < m_pTableWidget->rowCount(); ++i)
     210    {
     211        /* Acquire current key item: */
     212        QTableWidgetItem *pItemK = m_pTableWidget->item(i, 0);
     213        if (pItemK)
     214        {
     215            const QString strToolTip = pItemK->data(Qt::UserRole).toString();
     216            pItemK->setToolTip(tr(strToolTip.toUtf8().constData()));
     217        }
     218    }
     219}
     220
     221void UICloudProfileDetailsWidget::adjustTableContents()
     222{
     223    /* Disable last column stretching temporary: */
     224    m_pTableWidget->horizontalHeader()->setStretchLastSection(false);
     225
     226    /* Resize both columns to contents: */
     227    m_pTableWidget->resizeColumnsToContents();
     228    /* Then acquire full available width: */
     229    const int iFullWidth = m_pTableWidget->viewport()->width();
     230    /* First column should not be less than it's minimum size, last gets the rest: */
     231    const int iMinimumWidth0 = qMin(m_pTableWidget->horizontalHeader()->sectionSize(0), iFullWidth / 2);
     232    m_pTableWidget->horizontalHeader()->resizeSection(0, iMinimumWidth0);
     233
     234    /* Enable last column stretching again: */
     235    m_pTableWidget->horizontalHeader()->setStretchLastSection(true);
    150236}
    151237
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.h

    r74892 r74893  
    8484    /** Holds the profile name. */
    8585    QString  m_strName;
     86
     87    /** Holds the profile data. */
     88    QMap<QString, QPair<QString, QString> >  m_data;
    8689};
    8790
     
    153156        void retranslateValidation(QWidget *pWidget = 0);
    154157
     158        /** Updates table tooltips. */
     159        void updateTableToolTips();
     160        /** Adjusts table contents. */
     161        void adjustTableContents();
     162
    155163        /** Updates button states. */
    156164        void updateButtonStates();
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp

    r74888 r74893  
    499499        data.m_strName = comProfile.GetName();
    500500
     501    if (comProfile.isOk())
     502    {
     503        /* Acquire properties: */
     504        QVector<QString> keys;
     505        QVector<QString> values;
     506        QVector<QString> descriptions;
     507        values = comProfile.GetProperties(QString(), keys);
     508
     509        /* Sync sizes: */
     510        values.resize(keys.size());
     511        descriptions.resize(keys.size());
     512
     513        if (comProfile.isOk())
     514        {
     515            /* Acquire descriptions: */
     516            for (int i = 0; i < keys.size(); ++i)
     517            {
     518                descriptions[i] = comProfile.GetPropertyDescription(keys.at(i));
     519                if (!comProfile.isOk())
     520                    continue;
     521            }
     522
     523            /* Enumerate all the keys: */
     524            for (int i = 0; i < keys.size(); ++i)
     525                data.m_data[keys.at(i)] = qMakePair(values.at(i), descriptions.at(i));
     526        }
     527    }
     528
    501529    /* Show error message if necessary: */
    502530    if (!comProfile.isOk())
Note: See TracChangeset for help on using the changeset viewer.

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