Changeset 1281 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 6, 2007 11:24:52 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 19233
- Location:
- trunk/src/VBox/Frontends/VirtualBox/ui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r1215 r1281 1146 1146 <cstring>unnamed</cstring> 1147 1147 </property> 1148 <widget class="QTable">1149 <property name="name">1150 <cstring>tblBootOrder</cstring>1151 </property>1152 <property name="sizePolicy">1153 <sizepolicy>1154 <hsizetype>7</hsizetype>1155 <vsizetype>7</vsizetype>1156 <horstretch>1</horstretch>1157 <verstretch>0</verstretch>1158 </sizepolicy>1159 </property>1160 <property name="numRows">1161 <number>0</number>1162 </property>1163 <property name="numCols">1164 <number>0</number>1165 </property>1166 <property name="showGrid">1167 <bool>false</bool>1168 </property>1169 <property name="selectionMode">1170 <enum>NoSelection</enum>1171 </property>1172 <property name="focusStyle">1173 <enum>FollowStyle</enum>1174 </property>1175 <property name="whatsThis" stdset="0">1176 <string>Defines the boot device order. Click1177 on the entry and select a desired boot device from the drop-down list.</string>1178 </property>1179 </widget>1180 1148 </vbox> 1181 1149 </widget> … … 2598 2566 <slot>tbUSBFilterDown_clicked()</slot> 2599 2567 </connection> 2600 <connection>2601 <sender>tblBootOrder</sender>2602 <signal>clicked(int,int,int,const QPoint&)</signal>2603 <receiver>VBoxVMSettingsDlg</receiver>2604 <slot>bootItemActivate(int,int,int,const QPoint&)</slot>2605 </connection>2606 2568 </connections> 2607 2569 <tabstops> … … 2614 2576 <tabstop>slVRAM</tabstop> 2615 2577 <tabstop>leVRAM</tabstop> 2616 <tabstop>tblBootOrder</tabstop>2617 2578 <tabstop>chbEnableACPI</tabstop> 2618 2579 <tabstop>chbEnableIOAPIC</tabstop> … … 2664 2625 <include location="global" impldecl="in implementation">qtimer.h</include> 2665 2626 <include location="global" impldecl="in implementation">qpopupmenu.h</include> 2627 <include location="global" impldecl="in implementation">qtable.h</include> 2666 2628 <include location="local" impldecl="in declaration">COMDefs.h</include> 2667 2629 <include location="local" impldecl="in declaration">QIWidgetValidator.h</include> … … 2681 2643 <forward>class VBoxSharedFoldersSettings</forward> 2682 2644 <forward>class QIRichLabel</forward> 2645 <forward>class BootItemsTable</forward> 2683 2646 </forwards> 2684 2647 <variables> … … 2714 2677 <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable> 2715 2678 <variable access="private">QIRichLabel *whatsThisLabel;</variable> 2679 <variable access="private">BootItemsTable *tblBootOrder;</variable> 2716 2680 </variables> 2717 2681 <slots> … … 2743 2707 <slot>tbUSBFilterUp_clicked()</slot> 2744 2708 <slot>tbUSBFilterDown_clicked()</slot> 2745 <slot>bootItemActivate(int row, int col, int button, const QPoint & mousePos)</slot>2746 2709 <slot>hdaMediaChanged()</slot> 2747 2710 <slot>hdbMediaChanged()</slot> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r1243 r1281 51 51 } 52 52 53 53 54 /** 55 * Class: BootItemsTable. 56 * QTable class reimplementation to use as boot items table. 57 * It handles "focus-in" situation creating combo-box for focused item. 58 * It also presents wrappers for some hidden functionality. 59 */ 60 class BootItemsTable : public QTable 61 { 62 Q_OBJECT 63 64 public: 65 66 BootItemsTable (QWidget *aParent, const char *aName) 67 : QTable (aParent, aName) {} 68 ~BootItemsTable() {} 69 70 void endEdit (int aRow, int aCol) 71 { 72 QTable::endEdit (aRow, aCol, true, false); 73 } 74 75 protected: 76 77 void focusInEvent (QFocusEvent *) 78 { 79 int row = currentRow() >= 0 ? currentRow() : 0; 80 setCurrentCell (row, 0); 81 editCell (row, 0); 82 } 83 }; 84 85 86 /** 87 * Class: BootComboBox. 88 * QComboBox class reimplementation to use as boot item's editor. 89 * This class handles tab/backtab keypress events for boot item re-focusing. 90 * It also handles "focus-lost" situation for combo-box control destroying 91 * it after focus leaving from the combo-box. 92 */ 93 class BootComboBox : public QComboBox 94 { 95 public: 96 97 BootComboBox (QWidget *aParent, QTable *aTable) 98 : QComboBox (aParent), mParent (0) 99 { 100 Assert (aTable->inherits ("BootItemsTable")); 101 mParent = static_cast<BootItemsTable*> (aTable); 102 } 103 ~BootComboBox() {} 104 105 protected: 106 107 void focusOutEvent (QFocusEvent *) 108 { 109 if (!listBox()->hasFocus()) 110 { 111 mParent->endEdit (mParent->currentRow(), mParent->currentColumn()); 112 mParent->clearFocus(); 113 } 114 } 115 116 bool event (QEvent *aEvent) 117 { 118 if (aEvent->type() == QEvent::KeyPress) 119 { 120 QKeyEvent *event = static_cast<QKeyEvent*> (aEvent); 121 switch (event->key()) 122 { 123 case Qt::Key_Backtab: 124 focusData()->home(); 125 focusData()->prev()->setFocus(); 126 return false; 127 break; 128 case Qt::Key_Tab: 129 focusData()->home(); 130 focusData()->next()->setFocus(); 131 return false; 132 break; 133 default: 134 return QComboBox::event (aEvent); 135 } 136 } 137 else 138 return QComboBox::event (aEvent); 139 } 140 141 BootItemsTable *mParent; 142 }; 143 144 145 /** 146 * Class: ComboTableItem. 54 147 * Simple QTableItem subclass to use QComboBox as the cell editor. 55 148 * This subclass (as opposed to QComboTableItem) allows to specify the … … 67 160 public: 68 161 162 enum { BootItemType = 1001 }; 163 69 164 ComboTableItem (QTable *aTable, EditType aEditType, 70 165 const QStringList &aList, const QStringList &aUnique, … … 76 171 } 77 172 78 // reimplemented QTableItem members79 173 QWidget *createEditor() const 80 174 { 81 mComboBoxSelector = new QComboBox (table()->viewport());175 mComboBoxSelector = (QComboBox*) new BootComboBox (table()->viewport(), table()); 82 176 QStringList list = mList; 83 177 if (mUniqueInUse) … … 93 187 mComboBoxSelector->insertStringList (list); 94 188 mComboBoxSelector->setCurrentText (text()); 95 QObject::connect (mComboBoxSelector, SIGNAL (highlighted (const QString &)), 96 this, SLOT (doValueChanged (const QString &))); 97 QObject::connect (mComboBoxSelector, SIGNAL (activated (const QString &)), 98 this, SLOT (focusClearing ())); 189 QObject::connect (table(), SIGNAL (clicked (int, int, int, const QPoint&)), 190 this, SLOT (processClicked (int, int, int, const QPoint&))); 99 191 100 192 return mComboBoxSelector; … … 111 203 QTableItem::setContentFromEditor (aWidget); 112 204 } 205 113 206 void setText (const QString &aText) 114 207 { … … 130 223 /* 131 224 * Function: rtti() 132 * Target: required for runtime information about ComboTableItem class133 * 225 * Required for runtime information about ComboTableItem class 226 * used for static_cast from QTableItem 134 227 */ 135 int rtti() const { return 1001; }228 int rtti() const { return BootItemType; } 136 229 137 230 /* 138 231 * Function: getEditor() 139 * Target: returns pointer to stored combo-box232 * Returns pointer to stored combo-box 140 233 */ 141 234 QComboBox* getEditor() { return mComboBoxSelector; } … … 144 237 145 238 /* 146 * QTable doesn't call endEdit() when item's EditType is WhenCurrent and147 * the table widget loses focus or gets destroyed (assuming the user will148 * hit Enter if he wants to keep the value), so we need to do it ourselves239 * Slot: processClicked(...) 240 * Ensures item's combo-box popup in case of it was force-closed 241 * with using of endEdit() last time 149 242 */ 150 void doValueChanged (const QString &text) { setText (text); } 151 152 /* 153 * Function: focusClearing() 154 * Target: required for removing focus from combo-box 155 */ 156 void focusClearing() { mComboBoxSelector->clearFocus(); } 243 void processClicked (int aRow, int aCol, int, const QPoint &) 244 { 245 if (aRow == row() && aCol == col()) 246 mComboBoxSelector->popup(); 247 } 157 248 158 249 private: … … 552 643 slVRAM_valueChanged (slVRAM->value()); 553 644 645 646 tblBootOrder = new BootItemsTable ( groupBox12, "tblBootOrder" ); 647 QWhatsThis::add (tblBootOrder, 648 tr ("Defines the boot device order. Click on the entry and " 649 "select a desired boot device from the drop-down list.")); 650 setTabOrder (leVRAM, tblBootOrder); 651 setTabOrder (tblBootOrder, chbEnableACPI); 652 tblBootOrder->setSizePolicy (QSizePolicy ((QSizePolicy::SizeType)7, 653 (QSizePolicy::SizeType)7, 1, 0, 654 tblBootOrder->sizePolicy().hasHeightForWidth())); 655 tblBootOrder->setNumRows (0); 656 tblBootOrder->setNumCols (0); 657 tblBootOrder->setShowGrid (FALSE); 658 tblBootOrder->setSelectionMode (QTable::NoSelection); 659 tblBootOrder->setFocusStyle (QTable::FollowStyle); 660 groupBox12Layout->addWidget (tblBootOrder); 661 554 662 tblBootOrder->horizontalHeader()->hide(); 555 663 tblBootOrder->setTopMargin (0); … … 569 677 { 570 678 ComboTableItem *item = new ComboTableItem ( 571 tblBootOrder, QTableItem:: OnTyping,679 tblBootOrder, QTableItem::WhenCurrent, 572 680 list, unique, &bootDevicesInUse); 573 681 tblBootOrder->setItem (i, 0, item); 574 682 } 575 683 } 576 connect (tblBootOrder, SIGNAL (clicked(int, int, int, const QPoint&)),577 this, SLOT (bootItemActivate(int, int, int, const QPoint&)));578 684 579 685 tblBootOrder->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred); … … 686 792 } 687 793 688 void VBoxVMSettingsDlg::bootItemActivate (int row, int col, int /* button */,689 const QPoint &/* mousePos */)690 {691 tblBootOrder->editCell(row, col);692 QTableItem* tableItem = tblBootOrder->item(row, col);693 if (tableItem->rtti() == 1001)694 (static_cast<ComboTableItem*>(tableItem))->getEditor()->popup();695 }696 794 697 795 void VBoxVMSettingsDlg::updateShortcuts()
Note:
See TracChangeset
for help on using the changeset viewer.