Changeset 76301 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 19, 2018 7:24:16 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.cpp
r76297 r76301 35 35 const char* UICustomFileSystemModel::strUpDirectoryString = ".."; 36 36 37 38 /********************************************************************************************************************************* 39 * UIFileTableItem implementation. * 40 *********************************************************************************************************************************/ 41 42 UIFileTableItem::UIFileTableItem(const QVector<QVariant> &data, 43 UIFileTableItem *parent, KFsObjType type) 44 : m_itemData(data) 45 , m_parentItem(parent) 46 , m_bIsOpened(false) 47 , m_isTargetADirectory(false) 48 , m_type(type) 49 , m_isDriveItem(false) 50 { 51 } 52 53 UIFileTableItem::~UIFileTableItem() 54 { 55 qDeleteAll(m_childItems); 56 m_childItems.clear(); 57 } 58 59 void UIFileTableItem::appendChild(UIFileTableItem *item) 60 { 61 if (!item) 62 return; 63 m_childItems.append(item); 64 m_childMap.insert(item->name(), item); 65 } 66 67 UIFileTableItem *UIFileTableItem::child(int row) const 68 { 69 return m_childItems.value(row); 70 } 71 72 UIFileTableItem *UIFileTableItem::child(const QString &path) const 73 { 74 if (!m_childMap.contains(path)) 75 return 0; 76 return m_childMap.value(path); 77 } 78 79 int UIFileTableItem::childCount() const 80 { 81 return m_childItems.count(); 82 } 83 84 int UIFileTableItem::columnCount() const 85 { 86 return m_itemData.count(); 87 } 88 89 QVariant UIFileTableItem::data(int column) const 90 { 91 return m_itemData.value(column); 92 } 93 94 QString UIFileTableItem::name() const 95 { 96 if (m_itemData.isEmpty() || !m_itemData[0].canConvert(QMetaType::QString)) 97 return QString(); 98 return m_itemData[0].toString(); 99 } 100 101 void UIFileTableItem::setData(const QVariant &data, int index) 102 { 103 if (index >= m_itemData.length()) 104 return; 105 m_itemData[index] = data; 106 } 107 108 UIFileTableItem *UIFileTableItem::parentItem() 109 { 110 return m_parentItem; 111 } 112 113 int UIFileTableItem::row() const 114 { 115 if (m_parentItem) 116 return m_parentItem->m_childItems.indexOf(const_cast<UIFileTableItem*>(this)); 117 return 0; 118 } 119 120 bool UIFileTableItem::isDirectory() const 121 { 122 return m_type == KFsObjType_Directory; 123 } 124 125 bool UIFileTableItem::isSymLink() const 126 { 127 return m_type == KFsObjType_Symlink; 128 } 129 130 bool UIFileTableItem::isFile() const 131 { 132 return m_type == KFsObjType_File; 133 } 134 135 void UIFileTableItem::clearChildren() 136 { 137 qDeleteAll(m_childItems); 138 m_childItems.clear(); 139 m_childMap.clear(); 140 } 141 142 bool UIFileTableItem::isOpened() const 143 { 144 return m_bIsOpened; 145 } 146 147 void UIFileTableItem::setIsOpened(bool flag) 148 { 149 m_bIsOpened = flag; 150 } 151 152 const QString &UIFileTableItem::path() const 153 { 154 return m_strPath; 155 } 156 157 void UIFileTableItem::setPath(const QString &path) 158 { 159 if (path.isNull() || path.isEmpty()) 160 return; 161 m_strPath = path; 162 UIPathOperations::removeTrailingDelimiters(m_strPath); 163 } 164 165 bool UIFileTableItem::isUpDirectory() const 166 { 167 if (!isDirectory()) 168 return false; 169 if (data(0) == UICustomFileSystemModel::strUpDirectoryString) 170 return true; 171 return false; 172 } 173 174 KFsObjType UIFileTableItem::type() const 175 { 176 return m_type; 177 } 178 179 const QString &UIFileTableItem::targetPath() const 180 { 181 return m_strTargetPath; 182 } 183 184 void UIFileTableItem::setTargetPath(const QString &path) 185 { 186 m_strTargetPath = path; 187 } 188 189 bool UIFileTableItem::isSymLinkToADirectory() const 190 { 191 return m_isTargetADirectory; 192 } 193 194 void UIFileTableItem::setIsSymLinkToADirectory(bool flag) 195 { 196 m_isTargetADirectory = flag; 197 } 198 199 bool UIFileTableItem::isSymLinkToAFile() const 200 { 201 return isSymLink() && !m_isTargetADirectory; 202 } 203 204 void UIFileTableItem::setIsDriveItem(bool flag) 205 { 206 m_isDriveItem = flag; 207 } 208 209 bool UIFileTableItem::isDriveItem() const 210 { 211 return m_isDriveItem; 212 } 213 37 214 UICustomFileSystemProxyModel::UICustomFileSystemProxyModel(QObject *parent /* = 0 */) 38 215 :QSortFilterProxyModel(parent) … … 45 222 m_fListDirectoriesOnTop = fListDirectoriesOnTop; 46 223 } 224 225 /********************************************************************************************************************************* 226 * UICustomFileSystemProxyModel implementation. * 227 *********************************************************************************************************************************/ 47 228 48 229 bool UICustomFileSystemProxyModel::listDirectoriesOnTop() const -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UICustomFileSystemModel.h
r76297 r76301 23 23 #include <QSortFilterProxyModel> 24 24 25 /* COM includes: */ 26 #include "COMEnums.h" 27 25 28 /* GUI includes: */ 26 29 #include "QITableView.h" … … 38 41 UICustomFileSystemModelColumn_Permissions, 39 42 UICustomFileSystemModelColumn_Max 43 }; 44 45 /** A UIFileTableItem instance is a tree node representing a file object (file, directory, etc). The tree contructed 46 by these instances is the data source for the UICustomFileSystemModel. */ 47 class UIFileTableItem 48 { 49 public: 50 51 /** @p data contains values to be shown in table view's colums. data[0] is assumed to be 52 * the name of the file object which is the file name including extension or name of the 53 * directory */ 54 explicit UIFileTableItem(const QVector<QVariant> &data, 55 UIFileTableItem *parentItem, KFsObjType type); 56 ~UIFileTableItem(); 57 58 void appendChild(UIFileTableItem *child); 59 60 UIFileTableItem *child(int row) const; 61 /** Searches for the child by path and returns it if found. */ 62 UIFileTableItem *child(const QString &path) const; 63 int childCount() const; 64 int columnCount() const; 65 QVariant data(int column) const; 66 void setData(const QVariant &data, int index); 67 int row() const; 68 UIFileTableItem *parentItem(); 69 70 bool isDirectory() const; 71 bool isSymLink() const; 72 bool isFile() const; 73 74 bool isOpened() const; 75 void setIsOpened(bool flag); 76 77 const QString &path() const; 78 void setPath(const QString &path); 79 80 /** Returns true if this is directory and name is ".." */ 81 bool isUpDirectory() const; 82 void clearChildren(); 83 84 KFsObjType type() const; 85 86 const QString &targetPath() const; 87 void setTargetPath(const QString &path); 88 89 bool isSymLinkToADirectory() const; 90 void setIsSymLinkToADirectory(bool flag); 91 92 bool isSymLinkToAFile() const; 93 94 const QString &owner() const; 95 void setOwner(const QString &owner); 96 97 QString name() const; 98 99 void setIsDriveItem(bool flag); 100 bool isDriveItem() const; 101 102 private: 103 104 QList<UIFileTableItem*> m_childItems; 105 /** Used to find children by name */ 106 QMap<QString, UIFileTableItem*> m_childMap; 107 /** It is required that m_itemData[0] is name (QString) of the file object */ 108 QVector<QVariant> m_itemData; 109 UIFileTableItem *m_parentItem; 110 bool m_bIsOpened; 111 /** Full absolute path of the item. Without the trailing '/' */ 112 QString m_strPath; 113 /** If this is a symlink m_targetPath keeps the absolute path of the target */ 114 QString m_strTargetPath; 115 /** True if this is a symlink and the target is a directory */ 116 bool m_isTargetADirectory; 117 KFsObjType m_type; 118 /** True if only this item represents a DOS style drive letter item */ 119 bool m_isDriveItem; 40 120 }; 41 121 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r76300 r76301 29 29 # include "UIActionPool.h" 30 30 # include "UIErrorString.h" 31 # include "UICustomFileSystemModel.h" 31 32 # include "UIFileManager.h" 32 33 # include "UIFileManagerGuestTable.h" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r76300 r76301 452 452 , m_uSymlinkCount(0) 453 453 { 454 }455 456 457 /*********************************************************************************************************************************458 * UIFileTableItem implementation. *459 *********************************************************************************************************************************/460 461 UIFileTableItem::UIFileTableItem(const QVector<QVariant> &data,462 UIFileTableItem *parent, KFsObjType type)463 : m_itemData(data)464 , m_parentItem(parent)465 , m_bIsOpened(false)466 , m_isTargetADirectory(false)467 , m_type(type)468 , m_isDriveItem(false)469 {470 }471 472 UIFileTableItem::~UIFileTableItem()473 {474 qDeleteAll(m_childItems);475 m_childItems.clear();476 }477 478 void UIFileTableItem::appendChild(UIFileTableItem *item)479 {480 if (!item)481 return;482 m_childItems.append(item);483 m_childMap.insert(item->name(), item);484 }485 486 UIFileTableItem *UIFileTableItem::child(int row) const487 {488 return m_childItems.value(row);489 }490 491 UIFileTableItem *UIFileTableItem::child(const QString &path) const492 {493 if (!m_childMap.contains(path))494 return 0;495 return m_childMap.value(path);496 }497 498 int UIFileTableItem::childCount() const499 {500 return m_childItems.count();501 }502 503 int UIFileTableItem::columnCount() const504 {505 return m_itemData.count();506 }507 508 QVariant UIFileTableItem::data(int column) const509 {510 return m_itemData.value(column);511 }512 513 QString UIFileTableItem::name() const514 {515 if (m_itemData.isEmpty() || !m_itemData[0].canConvert(QMetaType::QString))516 return QString();517 return m_itemData[0].toString();518 }519 520 void UIFileTableItem::setData(const QVariant &data, int index)521 {522 if (index >= m_itemData.length())523 return;524 m_itemData[index] = data;525 }526 527 UIFileTableItem *UIFileTableItem::parentItem()528 {529 return m_parentItem;530 }531 532 int UIFileTableItem::row() const533 {534 if (m_parentItem)535 return m_parentItem->m_childItems.indexOf(const_cast<UIFileTableItem*>(this));536 return 0;537 }538 539 bool UIFileTableItem::isDirectory() const540 {541 return m_type == KFsObjType_Directory;542 }543 544 bool UIFileTableItem::isSymLink() const545 {546 return m_type == KFsObjType_Symlink;547 }548 549 bool UIFileTableItem::isFile() const550 {551 return m_type == KFsObjType_File;552 }553 554 void UIFileTableItem::clearChildren()555 {556 qDeleteAll(m_childItems);557 m_childItems.clear();558 m_childMap.clear();559 }560 561 bool UIFileTableItem::isOpened() const562 {563 return m_bIsOpened;564 }565 566 void UIFileTableItem::setIsOpened(bool flag)567 {568 m_bIsOpened = flag;569 }570 571 const QString &UIFileTableItem::path() const572 {573 return m_strPath;574 }575 576 void UIFileTableItem::setPath(const QString &path)577 {578 if (path.isNull() || path.isEmpty())579 return;580 m_strPath = path;581 UIPathOperations::removeTrailingDelimiters(m_strPath);582 }583 584 bool UIFileTableItem::isUpDirectory() const585 {586 if (!isDirectory())587 return false;588 if (data(0) == UICustomFileSystemModel::strUpDirectoryString)589 return true;590 return false;591 }592 593 KFsObjType UIFileTableItem::type() const594 {595 return m_type;596 }597 598 const QString &UIFileTableItem::targetPath() const599 {600 return m_strTargetPath;601 }602 603 void UIFileTableItem::setTargetPath(const QString &path)604 {605 m_strTargetPath = path;606 }607 608 bool UIFileTableItem::isSymLinkToADirectory() const609 {610 return m_isTargetADirectory;611 }612 613 void UIFileTableItem::setIsSymLinkToADirectory(bool flag)614 {615 m_isTargetADirectory = flag;616 }617 618 bool UIFileTableItem::isSymLinkToAFile() const619 {620 return isSymLink() && !m_isTargetADirectory;621 }622 623 void UIFileTableItem::setIsDriveItem(bool flag)624 {625 m_isDriveItem = flag;626 }627 628 bool UIFileTableItem::isDriveItem() const629 {630 return m_isDriveItem;631 454 } 632 455 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r76300 r76301 148 148 149 149 }; 150 151 /** A UIFileTableItem instance is a tree node representing a file object (file, directory, etc). The tree contructed152 by these instances is the data source for the UICustomFileSystemModel. */153 class UIFileTableItem154 {155 public:156 157 /** @p data contains values to be shown in table view's colums. data[0] is assumed to be158 * the name of the file object which is the file name including extension or name of the159 * directory */160 explicit UIFileTableItem(const QVector<QVariant> &data,161 UIFileTableItem *parentItem, KFsObjType type);162 ~UIFileTableItem();163 164 void appendChild(UIFileTableItem *child);165 166 UIFileTableItem *child(int row) const;167 /** Searches for the child by path and returns it if found. */168 UIFileTableItem *child(const QString &path) const;169 int childCount() const;170 int columnCount() const;171 QVariant data(int column) const;172 void setData(const QVariant &data, int index);173 int row() const;174 UIFileTableItem *parentItem();175 176 bool isDirectory() const;177 bool isSymLink() const;178 bool isFile() const;179 180 bool isOpened() const;181 void setIsOpened(bool flag);182 183 const QString &path() const;184 void setPath(const QString &path);185 186 /** Returns true if this is directory and name is ".." */187 bool isUpDirectory() const;188 void clearChildren();189 190 KFsObjType type() const;191 192 const QString &targetPath() const;193 void setTargetPath(const QString &path);194 195 bool isSymLinkToADirectory() const;196 void setIsSymLinkToADirectory(bool flag);197 198 bool isSymLinkToAFile() const;199 200 const QString &owner() const;201 void setOwner(const QString &owner);202 203 QString name() const;204 205 void setIsDriveItem(bool flag);206 bool isDriveItem() const;207 208 private:209 210 QList<UIFileTableItem*> m_childItems;211 /** Used to find children by name */212 QMap<QString, UIFileTableItem*> m_childMap;213 /** It is required that m_itemData[0] is name (QString) of the file object */214 QVector<QVariant> m_itemData;215 UIFileTableItem *m_parentItem;216 bool m_bIsOpened;217 /** Full absolute path of the item. Without the trailing '/' */218 QString m_strPath;219 /** If this is a symlink m_targetPath keeps the absolute path of the target */220 QString m_strTargetPath;221 /** True if this is a symlink and the target is a directory */222 bool m_isTargetADirectory;223 KFsObjType m_type;224 /** True if only this item represents a DOS style drive letter item */225 bool m_isDriveItem;226 };227 228 150 229 151 /** This class serves a base class for file table. Currently a guest version
Note:
See TracChangeset
for help on using the changeset viewer.