Changeset 76297 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 19, 2018 4:32:48 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r76211 r76297 859 859 src/guestctrl/UIFileManagerPanel.h \ 860 860 src/guestctrl/UIFileManagerSessionPanel.h \ 861 src/guestctrl/UI FileManagerModel.h \861 src/guestctrl/UICustomFileSystemModel.h \ 862 862 src/guestctrl/UIFileManagerTable.h \ 863 863 src/guestctrl/UIGuestControlInterface.h \ … … 1015 1015 src/guestctrl/UIFileManagerPanel.h \ 1016 1016 src/guestctrl/UIFileManagerSessionPanel.h \ 1017 src/guestctrl/UI FileManagerModel.h \1017 src/guestctrl/UICustomFileSystemModel.h \ 1018 1018 src/guestctrl/UIFileManagerTable.h \ 1019 1019 src/guestctrl/UIGuestControlInterface.h \ … … 1588 1588 src/guestctrl/UIFileManagerPanel.cpp \ 1589 1589 src/guestctrl/UIFileManagerSessionPanel.cpp \ 1590 src/guestctrl/UI FileManagerModel.cpp \1590 src/guestctrl/UICustomFileSystemModel.cpp \ 1591 1591 src/guestctrl/UIFileManagerTable.cpp \ 1592 1592 src/guestctrl/UIGuestControlInterface.cpp \ … … 1767 1767 src/guestctrl/UIFileManagerPanel.cpp \ 1768 1768 src/guestctrl/UIFileManagerSessionPanel.cpp \ 1769 src/guestctrl/UI FileManagerModel.cpp \1769 src/guestctrl/UICustomFileSystemModel.cpp \ 1770 1770 src/guestctrl/UIFileManagerTable.cpp \ 1771 1771 src/guestctrl/UIGuestControlInterface.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.cpp
r76296 r76297 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI FileManagerModel class implementation.3 * VBox Qt GUI - UICustomFileSystemModel class implementation. 4 4 */ 5 5 … … 26 26 /* GUI includes: */ 27 27 # include "UIErrorString.h" 28 # include "UI FileManagerModel.h"28 # include "UICustomFileSystemModel.h" 29 29 # include "UIFileManagerTable.h" 30 30 # include "UIFileManager.h" … … 33 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 34 35 const char* UI FileManagerModel::strUpDirectoryString = "..";36 37 UI GuestControlFileProxyModel::UIGuestControlFileProxyModel(QObject *parent /* = 0 */)35 const char* UICustomFileSystemModel::strUpDirectoryString = ".."; 36 37 UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */) 38 38 :QSortFilterProxyModel(parent) 39 39 , m_fListDirectoriesOnTop(false) … … 41 41 } 42 42 43 void UI GuestControlFileProxyModel::setListDirectoriesOnTop(bool fListDirectoriesOnTop)43 void UICustomFileSystemProxyModel::setListDirectoriesOnTop(bool fListDirectoriesOnTop) 44 44 { 45 45 m_fListDirectoriesOnTop = fListDirectoriesOnTop; 46 46 } 47 47 48 bool UI GuestControlFileProxyModel::listDirectoriesOnTop() const48 bool UICustomFileSystemProxyModel::listDirectoriesOnTop() const 49 49 { 50 50 return m_fListDirectoriesOnTop; 51 51 } 52 52 53 bool UI GuestControlFileProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const53 bool UICustomFileSystemProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const 54 54 { 55 55 UIFileTableItem *pLeftItem = static_cast<UIFileTableItem*>(left.internalPointer()); … … 73 73 74 74 /* If the sort column is QDateTime than handle it correctly: */ 75 if (sortColumn() == UI FileManagerModelColumn_ChangeTime)76 { 77 QVariant dataLeft = pLeftItem->data(UI FileManagerModelColumn_ChangeTime);78 QVariant dataRight = pRightItem->data(UI FileManagerModelColumn_ChangeTime);75 if (sortColumn() == UICustomFileSystemModelColumn_ChangeTime) 76 { 77 QVariant dataLeft = pLeftItem->data(UICustomFileSystemModelColumn_ChangeTime); 78 QVariant dataRight = pRightItem->data(UICustomFileSystemModelColumn_ChangeTime); 79 79 QDateTime leftDateTime = dataLeft.toDateTime(); 80 80 QDateTime rightDateTime = dataRight.toDateTime(); … … 82 82 } 83 83 /* When we show human readble sizes in size column sorting gets confused, so do it here: */ 84 else if(sortColumn() == UI FileManagerModelColumn_Size)85 { 86 qulonglong leftSize = pLeftItem->data(UI FileManagerModelColumn_Size).toULongLong();87 qulonglong rightSize = pRightItem->data(UI FileManagerModelColumn_Size).toULongLong();84 else if(sortColumn() == UICustomFileSystemModelColumn_Size) 85 { 86 qulonglong leftSize = pLeftItem->data(UICustomFileSystemModelColumn_Size).toULongLong(); 87 qulonglong rightSize = pRightItem->data(UICustomFileSystemModelColumn_Size).toULongLong(); 88 88 return (leftSize < rightSize); 89 89 … … 93 93 } 94 94 95 UI FileManagerModel::UIFileManagerModel(QObject *parent)95 UICustomFileSystemModel::UICustomFileSystemModel(QObject *parent) 96 96 : QAbstractItemModel(parent) 97 97 , m_pParent(qobject_cast<UIFileManagerTable*>(parent)) … … 100 100 } 101 101 102 UIFileTableItem* UI FileManagerModel::rootItem() const102 UIFileTableItem* UICustomFileSystemModel::rootItem() const 103 103 { 104 104 if (!m_pParent) … … 107 107 } 108 108 109 UI FileManagerModel::~UIFileManagerModel()109 UICustomFileSystemModel::~UICustomFileSystemModel() 110 110 {} 111 111 112 int UI FileManagerModel::columnCount(const QModelIndex &parent) const112 int UICustomFileSystemModel::columnCount(const QModelIndex &parent) const 113 113 { 114 114 if (parent.isValid()) … … 123 123 } 124 124 125 bool UI FileManagerModel::setData(const QModelIndex &index, const QVariant &value, int role)125 bool UICustomFileSystemModel::setData(const QModelIndex &index, const QVariant &value, int role) 126 126 { 127 127 if (index.isValid() && role == Qt::EditRole) … … 148 148 } 149 149 150 QVariant UI FileManagerModel::data(const QModelIndex &index, int role) const150 QVariant UICustomFileSystemModel::data(const QModelIndex &index, int role) const 151 151 { 152 152 if (!index.isValid()) … … 159 159 { 160 160 /* dont show anything but the name for up directories: */ 161 if (item->isUpDirectory() && index.column() != UI FileManagerModelColumn_Name)161 if (item->isUpDirectory() && index.column() != UICustomFileSystemModelColumn_Name) 162 162 return QVariant(); 163 163 /* Format date/time column: */ … … 169 169 } 170 170 /* Decide whether to show human-readable file object sizes: */ 171 if (index.column() == UI FileManagerModelColumn_Size)171 if (index.column() == UICustomFileSystemModelColumn_Size) 172 172 { 173 173 if (m_fShowHumanReadableSizes) … … 207 207 } 208 208 209 Qt::ItemFlags UI FileManagerModel::flags(const QModelIndex &index) const209 Qt::ItemFlags UICustomFileSystemModel::flags(const QModelIndex &index) const 210 210 { 211 211 if (!index.isValid()) … … 220 220 } 221 221 222 QVariant UI FileManagerModel::headerData(int section, Qt::Orientation orientation,222 QVariant UICustomFileSystemModel::headerData(int section, Qt::Orientation orientation, 223 223 int role) const 224 224 { … … 233 233 } 234 234 235 QModelIndex UI FileManagerModel::index(UIFileTableItem* item)235 QModelIndex UICustomFileSystemModel::index(UIFileTableItem* item) 236 236 { 237 237 if (!item) … … 240 240 } 241 241 242 QModelIndex UI FileManagerModel::index(int row, int column, const QModelIndex &parent)242 QModelIndex UICustomFileSystemModel::index(int row, int column, const QModelIndex &parent) 243 243 const 244 244 { … … 263 263 264 264 265 QModelIndex UI FileManagerModel::parent(const QModelIndex &index) const265 QModelIndex UICustomFileSystemModel::parent(const QModelIndex &index) const 266 266 { 267 267 if (!index.isValid()) … … 277 277 } 278 278 279 int UI FileManagerModel::rowCount(const QModelIndex &parent) const279 int UICustomFileSystemModel::rowCount(const QModelIndex &parent) const 280 280 { 281 281 if (parent.column() > 0) … … 291 291 } 292 292 293 void UI FileManagerModel::signalUpdate()293 void UICustomFileSystemModel::signalUpdate() 294 294 { 295 295 emit layoutChanged(); 296 296 } 297 297 298 QModelIndex UI FileManagerModel::rootIndex() const298 QModelIndex UICustomFileSystemModel::rootIndex() const 299 299 { 300 300 if (!rootItem()) … … 304 304 } 305 305 306 void UI FileManagerModel::beginReset()306 void UICustomFileSystemModel::beginReset() 307 307 { 308 308 beginResetModel(); 309 309 } 310 310 311 void UI FileManagerModel::endReset()311 void UICustomFileSystemModel::endReset() 312 312 { 313 313 endResetModel(); 314 314 } 315 315 316 void UI FileManagerModel::setShowHumanReadableSizes(bool fShowHumanReadableSizes)316 void UICustomFileSystemModel::setShowHumanReadableSizes(bool fShowHumanReadableSizes) 317 317 { 318 318 m_fShowHumanReadableSizes = fShowHumanReadableSizes; 319 319 } 320 320 321 bool UI FileManagerModel::showHumanReadableSizes() const321 bool UICustomFileSystemModel::showHumanReadableSizes() const 322 322 { 323 323 return m_fShowHumanReadableSizes; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.h
r76296 r76297 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI FileManagerModel class declaration.3 * VBox Qt GUI - UICustomFileSystemModel class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef ___UI FileManagerModel_h___19 #define ___UI FileManagerModel_h___18 #ifndef ___UICustomFileSystemModel_h___ 19 #define ___UICustomFileSystemModel_h___ 20 20 21 21 /* Qt includes: */ … … 30 30 class UIFileManagerTable; 31 31 32 enum UI FileManagerModelColumn32 enum UICustomFileSystemModelColumn 33 33 { 34 UI FileManagerModelColumn_Name = 0,35 UI FileManagerModelColumn_Size,36 UI FileManagerModelColumn_ChangeTime,37 UI FileManagerModelColumn_Owner,38 UI FileManagerModelColumn_Permissions,39 UI FileManagerModelColumn_Max34 UICustomFileSystemModelColumn_Name = 0, 35 UICustomFileSystemModelColumn_Size, 36 UICustomFileSystemModelColumn_ChangeTime, 37 UICustomFileSystemModelColumn_Owner, 38 UICustomFileSystemModelColumn_Permissions, 39 UICustomFileSystemModelColumn_Max 40 40 }; 41 41 42 42 /** A QSortFilterProxyModel extension used in file tables. Modifies some 43 43 * of the base class behavior like lessThan(..) */ 44 class UI GuestControlFileProxyModel : public QSortFilterProxyModel44 class UICustomFileSystemProxyModel : public QSortFilterProxyModel 45 45 { 46 46 … … 49 49 public: 50 50 51 UI GuestControlFileProxyModel(QObject *parent = 0);51 UICustomFileSystemProxyModel(QObject *parent = 0); 52 52 53 53 void setListDirectoriesOnTop(bool fListDirectoriesOnTop); … … 63 63 }; 64 64 65 /** UI FileManagerModel serves as the model for a file structure.65 /** UICustomFileSystemModel serves as the model for a file structure. 66 66 * it supports a tree level hierarchy which can be displayed with 67 67 * QTableView and/or QTreeView. Note the file structure data is not 68 68 * kept by the model but rather by the containing widget which also servers 69 69 * as the interface to functionality that this model provides.*/ 70 class UI FileManagerModel : public QAbstractItemModel70 class UICustomFileSystemModel : public QAbstractItemModel 71 71 { 72 72 … … 75 75 public: 76 76 77 explicit UI FileManagerModel(QObject *parent = 0);78 ~UI FileManagerModel();77 explicit UICustomFileSystemModel(QObject *parent = 0); 78 ~UICustomFileSystemModel(); 79 79 80 80 QVariant data(const QModelIndex &index, int role) const /* override */; … … 110 110 111 111 112 #endif /* !___UI FileManagerModel_h___ */112 #endif /* !___UICustomFileSystemModel_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r76177 r76297 29 29 # include "UIActionPool.h" 30 30 # include "UIFileManager.h" 31 # include "UI FileManagerModel.h"31 # include "UICustomFileSystemModel.h" 32 32 # include "UIFileManagerHostTable.h" 33 33 # include "UIToolBar.h" … … 105 105 const QFileInfo &entryInfo = entryList.at(i); 106 106 if (entryInfo.baseName().isEmpty() || entryInfo.baseName() == "." || 107 entryInfo.baseName() == UI FileManagerModel::strUpDirectoryString)107 entryInfo.baseName() == UICustomFileSystemModel::strUpDirectoryString) 108 108 continue; 109 109 statistics.m_totalSize += entryInfo.size(); -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r76177 r76297 26 26 27 27 /** This class scans the host file system by using the Qt API 28 and connects to the UI FileManagerModel*/28 and connects to the UICustomFileSystemModel*/ 29 29 class UIFileManagerHostTable : public UIFileManagerTable 30 30 { -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r76296 r76297 47 47 # include "UIFileManagerTable.h" 48 48 # include "UIFileManager.h" 49 # include "UI FileManagerModel.h"49 # include "UICustomFileSystemModel.h" 50 50 # include "UIToolBar.h" 51 51 … … 586 586 if (!isDirectory()) 587 587 return false; 588 if (data(0) == UI FileManagerModel::strUpDirectoryString)588 if (data(0) == UICustomFileSystemModel::strUpDirectoryString) 589 589 return true; 590 590 return false; … … 762 762 763 763 764 m_pModel = new UI FileManagerModel(this);764 m_pModel = new UICustomFileSystemModel(this); 765 765 if (!m_pModel) 766 766 return; 767 767 768 m_pProxyModel = new UI GuestControlFileProxyModel(this);768 m_pProxyModel = new UICustomFileSystemProxyModel(this); 769 769 if (!m_pProxyModel) 770 770 return; … … 863 863 const QString startPath("/"); 864 864 QVector<QVariant> headData; 865 headData.resize(UI FileManagerModelColumn_Max);865 headData.resize(UICustomFileSystemModelColumn_Max); 866 866 m_pRootItem = new UIFileTableItem(headData, 0, FileObjectType_Directory); 867 867 UIFileTableItem* startItem = new UIFileTableItem(createTreeItemData(startPath, 4096, QDateTime(), … … 910 910 if (isDirectoryMap) 911 911 { 912 if (!map.contains(UI FileManagerModel::strUpDirectoryString) && !isStartDir)912 if (!map.contains(UICustomFileSystemModel::strUpDirectoryString) && !isStartDir) 913 913 { 914 914 QVector<QVariant> data; 915 UIFileTableItem *item = new UIFileTableItem(createTreeItemData(UI FileManagerModel::strUpDirectoryString, 4096,915 UIFileTableItem *item = new UIFileTableItem(createTreeItemData(UICustomFileSystemModel::strUpDirectoryString, 4096, 916 916 QDateTime(), QString(), QString()) 917 917 , parent, FileObjectType_Directory); 918 918 item->setIsOpened(false); 919 map.insert(UI FileManagerModel::strUpDirectoryString, item);919 map.insert(UICustomFileSystemModel::strUpDirectoryString, item); 920 920 } 921 else if (map.contains(UI FileManagerModel::strUpDirectoryString) && isStartDir)921 else if (map.contains(UICustomFileSystemModel::strUpDirectoryString) && isStartDir) 922 922 { 923 map.remove(UI FileManagerModel::strUpDirectoryString);923 map.remove(UICustomFileSystemModel::strUpDirectoryString); 924 924 } 925 925 } … … 1281 1281 if (m_pRootItem) 1282 1282 { 1283 m_pRootItem->setData(UIFileManager::tr("Name"), UI FileManagerModelColumn_Name);1284 m_pRootItem->setData(UIFileManager::tr("Size"), UI FileManagerModelColumn_Size);1285 m_pRootItem->setData(UIFileManager::tr("Change Time"), UI FileManagerModelColumn_ChangeTime);1286 m_pRootItem->setData(UIFileManager::tr("Owner"), UI FileManagerModelColumn_Owner);1287 m_pRootItem->setData(UIFileManager::tr("Permissions"), UI FileManagerModelColumn_Permissions);1283 m_pRootItem->setData(UIFileManager::tr("Name"), UICustomFileSystemModelColumn_Name); 1284 m_pRootItem->setData(UIFileManager::tr("Size"), UICustomFileSystemModelColumn_Size); 1285 m_pRootItem->setData(UIFileManager::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime); 1286 m_pRootItem->setData(UIFileManager::tr("Owner"), UICustomFileSystemModelColumn_Owner); 1287 m_pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelColumn_Permissions); 1288 1288 } 1289 1289 if (m_pWarningLabel) … … 1432 1432 { 1433 1433 QVector<QVariant> data; 1434 data.resize(UI FileManagerModelColumn_Max);1435 data[UI FileManagerModelColumn_Name] = strName;1436 data[UI FileManagerModelColumn_Size] = (qulonglong)size;1437 data[UI FileManagerModelColumn_ChangeTime] = changeTime;1438 data[UI FileManagerModelColumn_Owner] = strOwner;1439 data[UI FileManagerModelColumn_Permissions] = strPermissions;1434 data.resize(UICustomFileSystemModelColumn_Max); 1435 data[UICustomFileSystemModelColumn_Name] = strName; 1436 data[UICustomFileSystemModelColumn_Size] = (qulonglong)size; 1437 data[UICustomFileSystemModelColumn_ChangeTime] = changeTime; 1438 data[UICustomFileSystemModelColumn_Owner] = strOwner; 1439 data[UICustomFileSystemModelColumn_Permissions] = strPermissions; 1440 1440 return data; 1441 1441 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r76296 r76297 47 47 class UIActionPool; 48 48 class UIFileTableItem; 49 class UI FileManagerModel;50 class UI GuestControlFileProxyModel;49 class UICustomFileSystemModel; 50 class UICustomFileSystemProxyModel; 51 51 class UIGuestControlFileView; 52 52 class UIToolBar; … … 161 161 162 162 /** A UIFileTableItem instance is a tree node representing a file object (file, directory, etc). The tree contructed 163 by these instances is the data source for the UI FileManagerModel. */163 by these instances is the data source for the UICustomFileSystemModel. */ 164 164 class UIFileTableItem 165 165 { … … 240 240 /** This class serves a base class for file table. Currently a guest version 241 241 * and a host version are derived from this base. Each of these children 242 * populates the UI FileManagerModel by scanning the file system242 * populates the UICustomFileSystemModel by scanning the file system 243 243 * differently. The file structre kept in this class as a tree. */ 244 244 class UIFileManagerTable : public QIWithRetranslateUI<QWidget> … … 342 342 CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const; 343 343 void setSelectionDependentActionsEnabled(bool fIsEnabled); 344 /** Creates a QList out of the parameters wrt. UI FileManagerModelColumn enum */344 /** Creates a QList out of the parameters wrt. UICustomFileSystemModelColumn enum */ 345 345 QVector<QVariant> createTreeItemData(const QString &strName, ULONG64 size, const QDateTime &changeTime, 346 346 const QString &strOwner, const QString &strPermissions); … … 395 395 bool checkIfDeleteOK(); 396 396 397 UI FileManagerModel *m_pModel;397 UICustomFileSystemModel *m_pModel; 398 398 UIGuestControlFileView *m_pView; 399 UI GuestControlFileProxyModel *m_pProxyModel;399 UICustomFileSystemProxyModel *m_pProxyModel; 400 400 401 401 QGridLayout *m_pMainLayout; … … 404 404 QILabel *m_pWarningLabel; 405 405 406 friend class UI FileManagerModel;406 friend class UICustomFileSystemModel; 407 407 }; 408 408
Note:
See TracChangeset
for help on using the changeset viewer.