Changeset 100565 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 13, 2023 1:32:04 PM (20 months ago)
- svn:sync-xref-src-repo-rev:
- 158391
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp
r100559 r100565 44 44 45 45 46 class SHARED_LIBRARY_STUFF UIHostBrowserProxyModel : public QSortFilterProxyModel47 {48 49 Q_OBJECT;50 51 public:52 53 UIHostBrowserProxyModel(QObject *pParent = 0)54 : QSortFilterProxyModel(pParent)55 {56 }57 58 // void setListDirectoriesOnTop(bool fListDirectoriesOnTop);59 // bool listDirectoriesOnTop() const;60 61 // void setShowHiddenObjects(bool fShowHiddenObjects);62 // bool showHiddenObjects() const;63 64 protected:65 66 // virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const RT_OVERRIDE;67 // /** Currently filters out hidden objects if options is set to "not showing them". */68 // virtual bool filterAcceptsRow(int iSourceRow, const QModelIndex &sourceParent) const RT_OVERRIDE;69 70 private:71 72 // bool m_fListDirectoriesOnTop;73 // bool m_fShowHiddenObjects;74 };75 76 46 77 47 /********************************************************************************************************************************* … … 115 85 private: 116 86 87 }; 88 89 /********************************************************************************************************************************* 90 * UIHostBrowserProxyModel definition. * 91 *********************************************************************************************************************************/ 92 93 class SHARED_LIBRARY_STUFF UIHostBrowserProxyModel : public QSortFilterProxyModel 94 { 95 96 Q_OBJECT; 97 98 public: 99 100 UIHostBrowserProxyModel(QObject *pParent = 0) 101 : QSortFilterProxyModel(pParent) 102 { 103 } 104 105 protected: 106 107 virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const RT_OVERRIDE; 108 109 private: 117 110 }; 118 111 … … 185 178 } 186 179 180 181 /********************************************************************************************************************************* 182 * UIHostBrowserProxyModel implementation. * 183 *********************************************************************************************************************************/ 184 185 bool UIHostBrowserProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const 186 { 187 UIVisoHostBrowserModel *pModel = qobject_cast<UIVisoHostBrowserModel*>(sourceModel()); 188 AssertReturn(pModel, true); 189 190 if (pModel->filePath(left).contains("..")) 191 return (sortOrder() == Qt::AscendingOrder); 192 193 if (pModel->filePath(right).contains("..")) 194 return (sortOrder() == Qt::DescendingOrder); 195 196 QFileInfo leftInfo(pModel->fileInfo(left)); 197 QFileInfo rightInfo(pModel->fileInfo(right)); 198 199 if (leftInfo.isDir() && !rightInfo.isDir()) 200 return (sortOrder() == Qt::AscendingOrder); 201 202 if (!leftInfo.isDir() && rightInfo.isDir()) 203 return (sortOrder() == Qt::DescendingOrder); 204 205 return QSortFilterProxyModel::lessThan(left, right); 206 } 207 208 187 209 /********************************************************************************************************************************* 188 210 * UIVisoHostBrowser implementation. * … … 224 246 AssertReturnVoid(m_pProxyModel); 225 247 m_pProxyModel->setSourceModel(m_pModel); 248 m_pProxyModel->setDynamicSortFilter(true); 249 226 250 227 251 m_pTableView = new QTableView; … … 248 272 249 273 m_pTableView->setModel(m_pProxyModel); 274 m_pTableView->setSortingEnabled(true); 275 m_pTableView->sortByColumn(0, Qt::AscendingOrder); 250 276 251 277 /* Hide the "type" column: */ … … 377 403 return; 378 404 if (QString::compare(fileInfo.fileName(), "..") == 0) 379 setTableRootIndex(m_p Model->parent(m_pTableView->rootIndex()));405 setTableRootIndex(m_pProxyModel->parent(m_pTableView->rootIndex())); 380 406 else 381 407 setTableRootIndex(index); … … 442 468 void UIVisoHostBrowser::setTableRootIndex(QModelIndex index /* = QModelIndex */) 443 469 { 444 if (!m_pTableView || !m_pModel) 445 return; 470 AssertReturnVoid(m_pTableView); 471 AssertReturnVoid(m_pModel); 472 AssertReturnVoid(m_pProxyModel); 473 446 474 m_pTableView->setRootIndex(index); 447 475 m_pTableView->clearSelection(); … … 450 478 if (m_pGoUp) 451 479 m_pGoUp->setEnabled(!isRoot()); 480 481 m_pTableView->sortByColumn(m_pProxyModel->sortColumn(), m_pProxyModel->sortOrder()); 452 482 } 453 483
Note:
See TracChangeset
for help on using the changeset viewer.