Changeset 71792 in vbox
- Timestamp:
- Apr 9, 2018 5:08:47 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121895
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp
r71693 r71792 720 720 , m_pCreateNewDirectory(0) 721 721 , m_pShowProperties(0) 722 , m_pSelectAll(0) 723 , m_pInvertSelection(0) 724 722 725 { 723 726 prepareObjects(); … … 919 922 } 920 923 924 m_pSelectAll = new QAction(this); 925 { 926 m_pSelectAll->setIcon(UIIconPool::iconSet(QString(":/session_info_32px.png"))); 927 m_pToolBar->addAction(m_pSelectAll); 928 connect(m_pSelectAll, &QAction::triggered, this, &UIGuestControlFileTable::sltSelectAll); 929 } 930 931 m_pInvertSelection = new QAction(this); 932 { 933 m_pInvertSelection->setIcon(UIIconPool::iconSet(QString(":/session_info_32px.png"))); 934 m_pToolBar->addAction(m_pInvertSelection); 935 connect(m_pInvertSelection, &QAction::triggered, this, &UIGuestControlFileTable::sltInvertSelection); 936 } 937 921 938 disableSelectionDependentActions(); 922 939 } … … 1214 1231 void UIGuestControlFileTable::sltSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected) 1215 1232 { 1216 /* Disable all the action that operate on some selection: */ 1217 if (!deselected.isEmpty() && selected.isEmpty()) 1233 if (m_pView->hasSelection()) 1234 enableSelectionDependentActions(); 1235 else 1218 1236 disableSelectionDependentActions(); 1219 1220 /* Enable all the action that operate on some selection: */1221 if (deselected.isEmpty() && !selected.isEmpty())1222 enableSelectionDependentActions();1223 1237 } 1224 1238 … … 1231 1245 QStringList pathList = comboLocation.split(UIPathOperations::delimiter, QString::SkipEmptyParts); 1232 1246 goIntoDirectory(pathList); 1247 } 1248 1249 void UIGuestControlFileTable::sltSelectAll() 1250 { 1251 if (!m_pModel || !m_pView) 1252 return; 1253 m_pView->selectAll(); 1254 deSelectUpDirectoryItem(); 1255 } 1256 1257 void UIGuestControlFileTable::sltInvertSelection() 1258 { 1259 setSelectionForAll(QItemSelectionModel::QItemSelectionModel::Toggle | QItemSelectionModel::Rows); 1260 deSelectUpDirectoryItem(); 1261 } 1262 1263 void UIGuestControlFileTable::deSelectUpDirectoryItem() 1264 { 1265 if (!m_pView) 1266 return; 1267 QItemSelectionModel *pSelectionModel = m_pView->selectionModel(); 1268 if (!pSelectionModel) 1269 return; 1270 QModelIndex currentRoot = m_pView->rootIndex(); 1271 if (!currentRoot.isValid()) 1272 return; 1273 1274 /* Make sure that "up directory item" (if exists) is deselected: */ 1275 for (int i = 0; i < m_pModel->rowCount(currentRoot); ++i) 1276 { 1277 QModelIndex index = m_pModel->index(i, 0, currentRoot); 1278 if (!index.isValid()) 1279 continue; 1280 1281 UIFileTableItem *item = static_cast<UIFileTableItem*>(index.internalPointer()); 1282 if (item && item->isUpDirectory()) 1283 { 1284 pSelectionModel->select(index, QItemSelectionModel::QItemSelectionModel::Deselect | QItemSelectionModel::Rows); 1285 } 1286 } 1287 } 1288 1289 void UIGuestControlFileTable::setSelectionForAll(QItemSelectionModel::SelectionFlags flags) 1290 { 1291 if (!m_pView) 1292 return; 1293 QItemSelectionModel *pSelectionModel = m_pView->selectionModel(); 1294 if (!pSelectionModel) 1295 return; 1296 QModelIndex currentRoot = m_pView->rootIndex(); 1297 if (!currentRoot.isValid()) 1298 return; 1299 1300 for (int i = 0; i < m_pModel->rowCount(currentRoot); ++i) 1301 { 1302 QModelIndex index = m_pModel->index(i, 0, currentRoot); 1303 if (!index.isValid()) 1304 continue; 1305 pSelectionModel->select(index, flags); 1306 } 1233 1307 } 1234 1308 … … 1312 1386 m_pShowProperties->setToolTip(UIVMInformationDialog::tr("Show the properties of the selected item(s)")); 1313 1387 m_pShowProperties->setStatusTip(UIVMInformationDialog::tr("Show the properties of the selected item(s)")); 1388 } 1389 1390 if (m_pSelectAll) 1391 { 1392 m_pSelectAll->setText(UIVMInformationDialog::tr("Select All")); 1393 m_pSelectAll->setToolTip(UIVMInformationDialog::tr("Select All")); 1394 m_pSelectAll->setStatusTip(UIVMInformationDialog::tr("Select All")); 1395 } 1396 1397 if (m_pInvertSelection) 1398 { 1399 m_pInvertSelection->setText(UIVMInformationDialog::tr("Invert Selection")); 1400 m_pInvertSelection->setToolTip(UIVMInformationDialog::tr("Invert Selection")); 1401 m_pInvertSelection->setStatusTip(UIVMInformationDialog::tr("Invert Selection")); 1314 1402 } 1315 1403 } … … 1482 1570 1483 1571 #include "UIGuestControlFileTable.moc" 1484 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h
r71693 r71792 20 20 21 21 /* Qt includes: */ 22 # include <QMutex> 22 #include <QItemSelectionModel> 23 #include <QMutex> 23 24 #include <QThread> 24 25 #include <QWidget> … … 304 305 void sltSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); 305 306 void sltLocationComboCurrentChange(const QString &strLocation); 307 void sltSelectAll(); 308 void sltInvertSelection(); 306 309 307 310 private: … … 316 319 void enableSelectionDependentActions(); 317 320 void disableSelectionDependentActions(); 321 void deSelectUpDirectoryItem(); 322 void setSelectionForAll(QItemSelectionModel::SelectionFlags flags); 318 323 QGridLayout *m_pMainLayout; 319 324 QComboBox *m_pLocationComboBox; … … 326 331 QAction *m_pCreateNewDirectory; 327 332 QAction *m_pShowProperties; 333 QAction *m_pSelectAll; 334 QAction *m_pInvertSelection; 328 335 /** The vector of action which need some selection to work on like cut, copy etc. */ 329 336 QVector<QAction*> m_selectionDependentActions; … … 335 342 336 343 #endif /* !___UIGuestControlFileTable_h___ */ 337
Note:
See TracChangeset
for help on using the changeset viewer.