Changeset 78130 in vbox for trunk/src/VBox
- Timestamp:
- Apr 15, 2019 7:14:54 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.cpp
r78129 r78130 83 83 KFormValueType valueType() const { return m_enmValueType; } 84 84 85 /** Returns the row name as string. */ 86 QString nameToString() const; 87 /** Returns the row value as string. */ 88 QString valueToString() const; 89 85 90 protected: 86 91 … … 200 205 { 201 206 cleanup(); 207 } 208 209 QString UIFormEditorRow::nameToString() const 210 { 211 return m_cells.at(UIFormEditorDataType_Name)->text(); 212 } 213 214 QString UIFormEditorRow::valueToString() const 215 { 216 return m_cells.at(UIFormEditorDataType_Value)->text(); 202 217 } 203 218 … … 307 322 if (!index.isValid()) 308 323 return Qt::NoItemFlags; 309 /* Return wrong value: */ 310 return Qt::NoItemFlags; 324 /* Switch for different columns: */ 325 switch (index.column()) 326 { 327 case UIFormEditorDataType_Name: 328 return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 329 case UIFormEditorDataType_Value: 330 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; 331 default: 332 return Qt::NoItemFlags; 333 } 311 334 } 312 335 … … 323 346 QVariant UIFormEditorModel::headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const 324 347 { 325 Q_UNUSED(iSection); 326 Q_UNUSED(enmOrientation); 327 Q_UNUSED(iRole); 328 329 /* Return wrong value: */ 330 return QVariant(); 348 /* Check argument validness: */ 349 if (iRole != Qt::DisplayRole || enmOrientation != Qt::Horizontal) 350 return QVariant(); 351 /* Switch for different columns: */ 352 switch (iSection) 353 { 354 case UIFormEditorDataType_Name: 355 return UIFormEditorWidget::tr("Name"); 356 case UIFormEditorDataType_Value: 357 return UIFormEditorWidget::tr("Value"); 358 default: 359 return QVariant(); 360 } 331 361 } 332 362 … … 344 374 QVariant UIFormEditorModel::data(const QModelIndex &index, int iRole) const 345 375 { 346 Q_UNUSED(iRole);347 348 376 /* Check index validness: */ 349 377 if (!index.isValid()) 350 378 return QVariant(); 351 /* Return wrong value: */ 352 return QVariant(); 379 /* Switch for different roles: */ 380 switch (iRole) 381 { 382 /* Display role: */ 383 case Qt::DisplayRole: 384 { 385 /* Switch for different columns: */ 386 switch (index.column()) 387 { 388 case UIFormEditorDataType_Name: 389 return m_dataList[index.row()]->nameToString(); 390 case UIFormEditorDataType_Value: 391 return m_dataList[index.row()]->valueType() != KFormValueType_Boolean 392 ? m_dataList[index.row()]->valueToString() 393 : QVariant(); 394 default: 395 return QVariant(); 396 } 397 } 398 /* Alignment role: */ 399 case Qt::TextAlignmentRole: 400 { 401 /* Switch for different columns: */ 402 switch (index.column()) 403 { 404 case UIFormEditorDataType_Name: 405 return (int)(Qt::AlignLeft | Qt::AlignVCenter); 406 case UIFormEditorDataType_Value: 407 return m_dataList[index.row()]->valueType() != KFormValueType_Boolean 408 ? (int)(Qt::AlignLeft | Qt::AlignVCenter) 409 : (int)(Qt::AlignCenter); 410 default: 411 return QVariant(); 412 } 413 } 414 default: 415 return QVariant(); 416 } 353 417 } 354 418
Note:
See TracChangeset
for help on using the changeset viewer.