Changeset 84103 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
- Timestamp:
- Apr 30, 2020 1:23:42 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r83674 r84103 20 20 21 21 /* GUI includes: */ 22 #include "UICommon.h" 22 23 #include "UIChooser.h" 23 24 #include "UIChooserModel.h" 24 25 #include "UIChooserView.h" 25 26 #include "UIVirtualBoxManagerWidget.h" 26 #include "UICommon.h"27 27 28 28 … … 30 30 : QWidget(pParent) 31 31 , m_pManagerWidget(pParent) 32 , m_pMainLayout(0)33 32 , m_pChooserModel(0) 34 33 , m_pChooserView(0) 35 34 { 36 /* Prepare: */37 35 prepare(); 38 36 } … … 40 38 UIChooser::~UIChooser() 41 39 { 42 /* Cleanup: */43 40 cleanup(); 44 41 } … … 46 43 UIActionPool *UIChooser::actionPool() const 47 44 { 45 AssertPtrReturn(managerWidget(), 0); 48 46 return managerWidget()->actionPool(); 49 47 } … … 51 49 UIVirtualMachineItem *UIChooser::currentItem() const 52 50 { 53 return m_pChooserModel->firstSelectedMachineItem(); 51 AssertPtrReturn(model(), 0); 52 return model()->firstSelectedMachineItem(); 54 53 } 55 54 56 55 QList<UIVirtualMachineItem*> UIChooser::currentItems() const 57 56 { 58 return m_pChooserModel->selectedMachineItems(); 57 AssertPtrReturn(model(), QList<UIVirtualMachineItem*>()); 58 return model()->selectedMachineItems(); 59 59 } 60 60 61 61 bool UIChooser::isGroupItemSelected() const 62 62 { 63 return m_pChooserModel->isGroupItemSelected(); 63 AssertPtrReturn(model(), false); 64 return model()->isGroupItemSelected(); 64 65 } 65 66 66 67 bool UIChooser::isGlobalItemSelected() const 67 68 { 68 return m_pChooserModel->isGlobalItemSelected(); 69 AssertPtrReturn(model(), false); 70 return model()->isGlobalItemSelected(); 69 71 } 70 72 71 73 bool UIChooser::isMachineItemSelected() const 72 74 { 73 return m_pChooserModel->isMachineItemSelected(); 75 AssertPtrReturn(model(), false); 76 return model()->isMachineItemSelected(); 74 77 } 75 78 76 79 bool UIChooser::isSingleGroupSelected() const 77 80 { 78 return m_pChooserModel->isSingleGroupSelected(); 81 AssertPtrReturn(model(), false); 82 return model()->isSingleGroupSelected(); 79 83 } 80 84 81 85 bool UIChooser::isSingleLocalGroupSelected() const 82 86 { 83 return m_pChooserModel->isSingleLocalGroupSelected(); 87 AssertPtrReturn(model(), false); 88 return model()->isSingleLocalGroupSelected(); 84 89 } 85 90 86 91 bool UIChooser::isSingleCloudProfileGroupSelected() const 87 92 { 88 return m_pChooserModel->isSingleCloudProfileGroupSelected(); 93 AssertPtrReturn(model(), false); 94 return model()->isSingleCloudProfileGroupSelected(); 89 95 } 90 96 91 97 bool UIChooser::isAllItemsOfOneGroupSelected() const 92 98 { 93 return m_pChooserModel->isAllItemsOfOneGroupSelected(); 99 AssertPtrReturn(model(), false); 100 return model()->isAllItemsOfOneGroupSelected(); 94 101 } 95 102 96 103 bool UIChooser::isGroupSavingInProgress() const 97 104 { 98 return m_pChooserModel->isGroupSavingInProgress(); 105 AssertPtrReturn(model(), false); 106 return model()->isGroupSavingInProgress(); 99 107 } 100 108 … … 102 110 { 103 111 /* Pass height to a model: */ 112 AssertPtrReturnVoid(model()); 104 113 model()->setGlobalItemHeightHint(newSize.height()); 105 114 } … … 108 117 { 109 118 /* Translate scene coordinates to global one: */ 119 AssertPtrReturnVoid(view()); 110 120 emit sigToolMenuRequested(enmClass, mapToGlobal(view()->mapFromScene(position))); 111 121 } … … 113 123 void UIChooser::prepare() 114 124 { 115 /* Prepare palette: */125 /* Prepare everything: */ 116 126 preparePalette(); 117 /* Prepare layout: */118 prepareLayout();119 /* Prepare model: */120 127 prepareModel(); 121 /* Prepare view: */ 122 prepareView(); 123 /* Prepare connections: */ 128 prepareWidgets(); 124 129 prepareConnections(); 125 130 126 /* Load settings: */127 loadSettings();131 /* Init model: */ 132 initModel(); 128 133 } 129 134 … … 138 143 } 139 144 140 void UIChooser::prepareLayout() 141 { 142 /* Create main-layout: */ 143 m_pMainLayout = new QVBoxLayout(this); 144 if (m_pMainLayout) 145 void UIChooser::prepareModel() 146 { 147 m_pChooserModel = new UIChooserModel(this); 148 } 149 150 void UIChooser::prepareWidgets() 151 { 152 /* Prepare main-layout: */ 153 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 154 if (pMainLayout) 145 155 { 146 /* Configure main-layout: */ 147 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 148 m_pMainLayout->setSpacing(0); 156 pMainLayout->setContentsMargins(0, 0, 0, 0); 157 pMainLayout->setSpacing(0); 158 159 /* Prepare chooser-view: */ 160 m_pChooserView = new UIChooserView(this); 161 if (m_pChooserView) 162 { 163 AssertPtrReturnVoid(model()); 164 m_pChooserView->setScene(model()->scene()); 165 m_pChooserView->show(); 166 setFocusProxy(m_pChooserView); 167 168 /* Add into layout: */ 169 pMainLayout->addWidget(m_pChooserView); 170 } 149 171 } 150 172 } 151 173 152 void UIChooser::prepareModel()153 {154 /* Create chooser-model: */155 m_pChooserModel = new UIChooserModel(this);156 }157 158 void UIChooser::prepareView()159 {160 /* Setup chooser-view: */161 m_pChooserView = new UIChooserView(this);162 if (m_pChooserView)163 {164 /* Configure chooser-view. */165 m_pChooserView->setScene(m_pChooserModel->scene());166 m_pChooserView->show();167 setFocusProxy(m_pChooserView);168 169 /* Add into layout: */170 m_pMainLayout->addWidget(m_pChooserView);171 }172 }173 174 174 void UIChooser::prepareConnections() 175 175 { 176 AssertPtrReturnVoid(model()); 177 AssertPtrReturnVoid(view()); 178 176 179 /* Setup chooser-model connections: */ 177 connect(m _pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged,178 m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged);179 connect(m _pChooserModel, &UIChooserModel::sigToolMenuRequested,180 connect(model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged, 181 view(), &UIChooserView::sltMinimumWidthHintChanged); 182 connect(model(), &UIChooserModel::sigToolMenuRequested, 180 183 this, &UIChooser::sltToolMenuRequested); 181 connect(m _pChooserModel, &UIChooserModel::sigCloudMachineStateChange,184 connect(model(), &UIChooserModel::sigCloudMachineStateChange, 182 185 this, &UIChooser::sigCloudMachineStateChange); 183 186 184 187 /* Setup chooser-view connections: */ 185 connect(m_pChooserView, &UIChooserView::sigResized, 186 m_pChooserModel, &UIChooserModel::sltHandleViewResized); 187 } 188 189 void UIChooser::loadSettings() 190 { 191 /* Init model: */ 192 m_pChooserModel->init(); 193 } 194 195 void UIChooser::saveSettings() 188 connect(view(), &UIChooserView::sigResized, 189 model(), &UIChooserModel::sltHandleViewResized); 190 } 191 192 void UIChooser::initModel() 193 { 194 AssertPtrReturnVoid(model()); 195 model()->init(); 196 } 197 198 void UIChooser::deinitModel() 199 { 200 AssertPtrReturnVoid(model()); 201 model()->deinit(); 202 } 203 204 void UIChooser::cleanup() 196 205 { 197 206 /* Deinit model: */ 198 m_pChooserModel->deinit(); 199 } 200 201 void UIChooser::cleanup() 202 { 203 /* Save settings: */ 204 saveSettings(); 205 } 207 deinitModel(); 208 }
Note:
See TracChangeset
for help on using the changeset viewer.