Changeset 75728 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 26, 2018 8:49:55 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.cpp
r75610 r75728 24 24 # include <QHeaderView> 25 25 # include <QLabel> 26 # include <QMenu> 26 27 # include <QProgressBar> 27 28 # include <QTableWidget> … … 54 55 UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent = 0); 55 56 ~UIFileOperationProgressWidget(); 57 bool isCompleted() const; 58 bool isCanceled() const; 56 59 57 60 signals: … … 104 107 } 105 108 109 bool UIFileOperationProgressWidget::isCompleted() const 110 { 111 if (m_comProgress.isNull()) 112 return true; 113 return m_comProgress.GetCompleted(); 114 } 115 116 bool UIFileOperationProgressWidget::isCanceled() const 117 { 118 if (m_comProgress.isNull()) 119 return true; 120 return m_comProgress.GetCanceled(); 121 } 122 106 123 void UIFileOperationProgressWidget::retranslateUi() 107 124 { … … 231 248 if (m_pTableWidget) 232 249 { 250 m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 233 251 m_pTableWidget->setColumnCount(TableColumn_Max); 234 252 m_pTableWidget->verticalHeader()->hide(); … … 249 267 { 250 268 UIGuestControlFileManagerPanel::retranslateUi(); 251 269 } 270 271 void UIGuestControlFileManagerOperationsPanel::contextMenuEvent(QContextMenuEvent *pEvent) 272 { 273 QMenu *menu = new QMenu(this); 274 275 QAction *pCleanFinished = menu->addAction(UIGuestControlFileManager::tr("Clean Finished")); 276 QAction *pCleanAll = menu->addAction(UIGuestControlFileManager::tr("Clean All")); 277 278 connect(pCleanFinished, &QAction::triggered, 279 this, &UIGuestControlFileManagerOperationsPanel::sltCleanFinished); 280 connect(pCleanAll, &QAction::triggered, 281 this, &UIGuestControlFileManagerOperationsPanel::sltCleanAll); 282 283 menu->exec(pEvent->globalPos()); 284 delete menu; 285 } 286 287 void UIGuestControlFileManagerOperationsPanel::sltCleanFinished() 288 { 289 QList<int> listOfRowsToRemove; 290 for (int i = 0; i < m_pTableWidget->rowCount(); ++i) 291 { 292 UIFileOperationProgressWidget* pProgressWidget = 293 qobject_cast<UIFileOperationProgressWidget*>(m_pTableWidget->cellWidget(i, TableColumn_Progress)); 294 if (pProgressWidget) 295 { 296 if (pProgressWidget->isCanceled() || pProgressWidget->isCompleted()) 297 listOfRowsToRemove << i; 298 } 299 } 300 foreach (int row, listOfRowsToRemove) 301 { 302 /* This will delete the progress widget as well: */ 303 m_pTableWidget->removeRow(row); 304 } 305 } 306 307 void UIGuestControlFileManagerOperationsPanel::sltCleanAll() 308 { 309 m_pTableWidget->clearContents(); 310 m_pTableWidget->setRowCount(0); 252 311 } 253 312 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h
r75610 r75728 58 58 59 59 /** Handles the translation event. */ 60 void retranslateUi(); 60 virtual void retranslateUi() /* override */; 61 virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */; 61 62 62 63 private slots: 63 64 65 void sltCleanFinished(); 66 void sltCleanAll(); 64 67 65 68 private:
Note:
See TracChangeset
for help on using the changeset viewer.