- Timestamp:
- Aug 7, 2012 12:15:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserHandlerKeyboard.cpp
r42583 r42656 61 61 return false; 62 62 63 /* Determine focus item position: */ 64 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 65 /* Determine 'previous' item: */ 66 UIGChooserItem *pPreviousItem = iPosition > 0 ? 67 model()->navigationList().at(iPosition - 1) : 0; 68 if (pPreviousItem) 69 { 70 /* Make sure 'previous' item is visible: */ 71 pPreviousItem->makeSureItsVisible(); 72 /* Move focus to 'previous' item: */ 73 model()->setFocusItem(pPreviousItem); 74 /* Was 'shift' modifier pressed? */ 75 #ifdef Q_WS_MAC 76 if (pEvent->modifiers() & Qt::ShiftModifier && 77 pEvent->modifiers() & Qt::KeypadModifier) 78 #else /* Q_WS_MAC */ 79 if (pEvent->modifiers() == Qt::ShiftModifier) 80 #endif /* !Q_WS_MAC */ 81 { 63 /* Was control modifier pressed? */ 64 #ifdef Q_WS_MAC 65 if (pEvent->modifiers() & Qt::ControlModifier && 66 pEvent->modifiers() & Qt::KeypadModifier) 67 #else /* Q_WS_MAC */ 68 if (pEvent->modifiers() == Qt::ControlModifier) 69 #endif /* !Q_WS_MAC */ 70 { 71 /* Get focus and his parent: */ 72 UIGChooserItem *pFocusItem = model()->focusItem(); 73 UIGChooserItem *pParentItem = pFocusItem->parentItem(); 74 UIGChooserItemType type = (UIGChooserItemType)pFocusItem->type(); 75 QList<UIGChooserItem*> items = pParentItem->items(type); 76 int iFocusPosition = items.indexOf(pFocusItem); 77 if (iFocusPosition > 0) 78 { 79 items.move(iFocusPosition, iFocusPosition - 1); 80 pParentItem->setItems(items, type); 81 model()->updateNavigation(); 82 model()->updateLayout(); 83 } 84 /* Filter-out this event: */ 85 return true; 86 } 87 /* Was shift modifier pressed? */ 88 #ifdef Q_WS_MAC 89 else if (pEvent->modifiers() & Qt::ShiftModifier && 90 pEvent->modifiers() & Qt::KeypadModifier) 91 #else /* Q_WS_MAC */ 92 else if (pEvent->modifiers() == Qt::ShiftModifier) 93 #endif /* !Q_WS_MAC */ 94 { 95 /* Determine focus item position: */ 96 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 97 /* Determine 'previous' item: */ 98 UIGChooserItem *pPreviousItem = iPosition > 0 ? 99 model()->navigationList().at(iPosition - 1) : 0; 100 if (pPreviousItem) 101 { 102 /* Make sure 'previous' item is visible: */ 103 pPreviousItem->makeSureItsVisible(); 104 /* Move focus to 'previous' item: */ 105 model()->setFocusItem(pPreviousItem); 82 106 /* Calculate positions: */ 83 107 UIGChooserItem *pFirstItem = model()->selectionList().first(); … … 93 117 for (int i = iFirstPosition; i >= iPreviousPosition; --i) 94 118 model()->addToSelectionList(model()->navigationList().at(i)); 95 } 96 /* There is no modifiers pressed? */ 97 #ifdef Q_WS_MAC 98 else if (pEvent->modifiers() == Qt::KeypadModifier) 99 #else /* Q_WS_MAC */ 100 else if (pEvent->modifiers() == Qt::NoModifier) 101 #endif /* !Q_WS_MAC */ 102 { 119 /* Notify selection changed: */ 120 model()->notifySelectionChanged(); 121 /* Filter-out this event: */ 122 return true; 123 } 124 } 125 /* There is no modifiers pressed? */ 126 #ifdef Q_WS_MAC 127 else if (pEvent->modifiers() == Qt::KeypadModifier) 128 #else /* Q_WS_MAC */ 129 else if (pEvent->modifiers() == Qt::NoModifier) 130 #endif /* !Q_WS_MAC */ 131 { 132 /* Determine focus item position: */ 133 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 134 /* Determine 'previous' item: */ 135 UIGChooserItem *pPreviousItem = iPosition > 0 ? 136 model()->navigationList().at(iPosition - 1) : 0; 137 if (pPreviousItem) 138 { 139 /* Make sure 'previous' item is visible: */ 140 pPreviousItem->makeSureItsVisible(); 141 /* Move focus to 'previous' item: */ 142 model()->setFocusItem(pPreviousItem); 103 143 /* Move selection to 'previous' item: */ 104 144 model()->clearSelectionList(); 105 145 model()->addToSelectionList(pPreviousItem); 106 }107 /* Notify selection changed: */108 model()->notifySelectionChanged();109 /* Filter-out this event: */110 return true;146 /* Notify selection changed: */ 147 model()->notifySelectionChanged(); 148 /* Filter-out this event: */ 149 return true; 150 } 111 151 } 112 152 /* Pass this event: */ … … 120 160 return false; 121 161 122 /* Determine focus item position: */ 123 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 124 /* Determine 'next' item: */ 125 UIGChooserItem *pNextItem = iPosition < model()->navigationList().size() - 1 ? 126 model()->navigationList().at(iPosition + 1) : 0; 127 if (pNextItem) 128 { 129 /* Make sure 'next' item is visible: */ 130 pNextItem->makeSureItsVisible(); 131 /* Move focus to 'next' item: */ 132 model()->setFocusItem(pNextItem); 133 /* Was shift modifier pressed? */ 134 #ifdef Q_WS_MAC 135 if (pEvent->modifiers() & Qt::ShiftModifier && 136 pEvent->modifiers() & Qt::KeypadModifier) 137 #else /* Q_WS_MAC */ 138 if (pEvent->modifiers() == Qt::ShiftModifier) 139 #endif /* !Q_WS_MAC */ 140 { 162 /* Was control modifier pressed? */ 163 #ifdef Q_WS_MAC 164 if (pEvent->modifiers() & Qt::ControlModifier && 165 pEvent->modifiers() & Qt::KeypadModifier) 166 #else /* Q_WS_MAC */ 167 if (pEvent->modifiers() == Qt::ControlModifier) 168 #endif /* !Q_WS_MAC */ 169 { 170 /* Get focus and his parent: */ 171 UIGChooserItem *pFocusItem = model()->focusItem(); 172 UIGChooserItem *pParentItem = pFocusItem->parentItem(); 173 UIGChooserItemType type = (UIGChooserItemType)pFocusItem->type(); 174 QList<UIGChooserItem*> items = pParentItem->items(type); 175 int iFocusPosition = items.indexOf(pFocusItem); 176 if (iFocusPosition < items.size() - 1) 177 { 178 items.move(iFocusPosition, iFocusPosition + 1); 179 pParentItem->setItems(items, type); 180 model()->updateNavigation(); 181 model()->updateLayout(); 182 } 183 /* Filter-out this event: */ 184 return true; 185 } 186 /* Was shift modifier pressed? */ 187 #ifdef Q_WS_MAC 188 else if (pEvent->modifiers() & Qt::ShiftModifier && 189 pEvent->modifiers() & Qt::KeypadModifier) 190 #else /* Q_WS_MAC */ 191 else if (pEvent->modifiers() == Qt::ShiftModifier) 192 #endif /* !Q_WS_MAC */ 193 { 194 /* Determine focus item position: */ 195 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 196 /* Determine 'next' item: */ 197 UIGChooserItem *pNextItem = iPosition < model()->navigationList().size() - 1 ? 198 model()->navigationList().at(iPosition + 1) : 0; 199 if (pNextItem) 200 { 201 /* Make sure 'next' item is visible: */ 202 pNextItem->makeSureItsVisible(); 203 /* Move focus to 'next' item: */ 204 model()->setFocusItem(pNextItem); 141 205 /* Calculate positions: */ 142 206 UIGChooserItem *pFirstItem = model()->selectionList().first(); … … 152 216 for (int i = iFirstPosition; i >= iNextPosition; --i) 153 217 model()->addToSelectionList(model()->navigationList().at(i)); 154 } 155 /* There is no modifiers pressed? */ 156 #ifdef Q_WS_MAC 157 else if (pEvent->modifiers() == Qt::KeypadModifier) 158 #else /* Q_WS_MAC */ 159 else if (pEvent->modifiers() == Qt::NoModifier) 160 #endif /* !Q_WS_MAC */ 161 { 218 /* Notify selection changed: */ 219 model()->notifySelectionChanged(); 220 /* Filter-out this event: */ 221 return true; 222 } 223 } 224 /* There is no modifiers pressed? */ 225 #ifdef Q_WS_MAC 226 else if (pEvent->modifiers() == Qt::KeypadModifier) 227 #else /* Q_WS_MAC */ 228 else if (pEvent->modifiers() == Qt::NoModifier) 229 #endif /* !Q_WS_MAC */ 230 { 231 /* Determine focus item position: */ 232 int iPosition = model()->navigationList().indexOf(model()->focusItem()); 233 /* Determine 'next' item: */ 234 UIGChooserItem *pNextItem = iPosition < model()->navigationList().size() - 1 ? 235 model()->navigationList().at(iPosition + 1) : 0; 236 if (pNextItem) 237 { 238 /* Make sure 'next' item is visible: */ 239 pNextItem->makeSureItsVisible(); 240 /* Move focus to 'next' item: */ 241 model()->setFocusItem(pNextItem); 162 242 /* Move selection to 'next' item: */ 163 243 model()->clearSelectionList(); 164 244 model()->addToSelectionList(pNextItem); 165 }166 /* Notify selection changed: */167 model()->notifySelectionChanged();168 /* Filter-out this event: */169 return true;245 /* Notify selection changed: */ 246 model()->notifySelectionChanged(); 247 /* Filter-out this event: */ 248 return true; 249 } 170 250 } 171 251 /* Pass this event: */
Note:
See TracChangeset
for help on using the changeset viewer.