- Timestamp:
- Oct 17, 2018 6:48:46 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/cloud
- Files:
-
- 3 edited
-
UICloudProfileDetailsWidget.cpp (modified) (6 diffs)
-
UICloudProfileDetailsWidget.h (modified) (2 diffs)
-
UICloudProfileManager.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.cpp
r74892 r74893 21 21 22 22 /* Qt includes: */ 23 # include <QHeaderView> 23 24 # include <QPushButton> 24 25 # include <QTableWidget> … … 57 58 void UICloudProfileDetailsWidget::retranslateUi() 58 59 { 60 /// @todo add description tool-tips 61 59 62 /* Translate table-widget: */ 60 63 m_pTableWidget->setToolTip(tr("Contains cloud profile settings")); … … 62 65 /* Retranslate validation: */ 63 66 retranslateValidation(); 67 68 /* Update table tool-tips: */ 69 updateTableToolTips(); 64 70 } 65 71 … … 110 116 if (m_pTableWidget) 111 117 { 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 112 123 /* Add into layout: */ 113 124 pLayout->addWidget(m_pTableWidget); … … 132 143 void UICloudProfileDetailsWidget::loadData() 133 144 { 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(); 135 189 } 136 190 … … 148 202 149 203 /// @todo retranslate profile settings vaidation! 204 } 205 206 void 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 221 void 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); 150 236 } 151 237 -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.h
r74892 r74893 84 84 /** Holds the profile name. */ 85 85 QString m_strName; 86 87 /** Holds the profile data. */ 88 QMap<QString, QPair<QString, QString> > m_data; 86 89 }; 87 90 … … 153 156 void retranslateValidation(QWidget *pWidget = 0); 154 157 158 /** Updates table tooltips. */ 159 void updateTableToolTips(); 160 /** Adjusts table contents. */ 161 void adjustTableContents(); 162 155 163 /** Updates button states. */ 156 164 void updateButtonStates(); -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp
r74888 r74893 499 499 data.m_strName = comProfile.GetName(); 500 500 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 501 529 /* Show error message if necessary: */ 502 530 if (!comProfile.isOk())
Note:
See TracChangeset
for help on using the changeset viewer.

