From ff632911f260f24212edc3cc9e011d5fb4c5947a Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Sat, 31 Mar 2012 13:28:04 +0200 Subject: [PATCH] don't use QSortFilterProxyModel in TabDeckStorage and TabReplays unnecessarily --- cockatrice/src/tab_deck_storage.cpp | 17 ++++++----------- cockatrice/src/tab_deck_storage.h | 2 -- cockatrice/src/tab_replays.cpp | 15 +++++---------- cockatrice/src/tab_replays.h | 2 -- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/cockatrice/src/tab_deck_storage.cpp b/cockatrice/src/tab_deck_storage.cpp index b256d618..0b66f83e 100644 --- a/cockatrice/src/tab_deck_storage.cpp +++ b/cockatrice/src/tab_deck_storage.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -31,18 +30,14 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c { localDirModel = new QFileSystemModel(this); localDirModel->setRootPath(settingsCache->getDeckPath()); - - sortFilter = new QSortFilterProxyModel(this); - sortFilter->setSourceModel(localDirModel); - sortFilter->setDynamicSortFilter(true); + localDirModel->sort(0, Qt::AscendingOrder); localDirView = new QTreeView; - localDirView->setModel(sortFilter); + localDirView->setModel(localDirModel); localDirView->setColumnHidden(1, true); - localDirView->setRootIndex(sortFilter->mapFromSource(localDirModel->index(localDirModel->rootPath(), 0))); + localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0)); localDirView->setSortingEnabled(true); localDirView->header()->setResizeMode(QHeaderView::ResizeToContents); - sortFilter->sort(0, Qt::AscendingOrder); localDirView->header()->setSortIndicator(0, Qt::AscendingOrder); leftToolBar = new QToolBar; @@ -124,7 +119,7 @@ void TabDeckStorage::retranslateUi() void TabDeckStorage::actOpenLocalDeck() { - QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex()); + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (localDirModel->isDir(curLeft)) return; QString filePath = localDirModel->filePath(curLeft); @@ -139,7 +134,7 @@ void TabDeckStorage::actOpenLocalDeck() void TabDeckStorage::actUpload() { - QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex()); + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (localDirModel->isDir(curLeft)) return; QString filePath = localDirModel->filePath(curLeft); @@ -209,7 +204,7 @@ void TabDeckStorage::openRemoteDeckFinished(const Response &r) void TabDeckStorage::actDownload() { QString filePath; - QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex()); + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (!curLeft.isValid()) filePath = localDirModel->rootPath(); else { diff --git a/cockatrice/src/tab_deck_storage.h b/cockatrice/src/tab_deck_storage.h index 51344208..19c66d77 100644 --- a/cockatrice/src/tab_deck_storage.h +++ b/cockatrice/src/tab_deck_storage.h @@ -6,7 +6,6 @@ class AbstractClient; class QTreeView; class QFileSystemModel; -class QSortFilterProxyModel; class QToolBar; class QTreeWidget; class QTreeWidgetItem; @@ -21,7 +20,6 @@ private: AbstractClient *client; QTreeView *localDirView; QFileSystemModel *localDirModel; - QSortFilterProxyModel *sortFilter; QToolBar *leftToolBar, *rightToolBar; RemoteDeckList_TreeWidget *serverDirView; QGroupBox *leftGroupBox, *rightGroupBox; diff --git a/cockatrice/src/tab_replays.cpp b/cockatrice/src/tab_replays.cpp index 2b734d24..58b0af3d 100644 --- a/cockatrice/src/tab_replays.cpp +++ b/cockatrice/src/tab_replays.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -28,18 +27,14 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) { localDirModel = new QFileSystemModel(this); localDirModel->setRootPath(settingsCache->getReplaysPath()); - - sortFilter = new QSortFilterProxyModel(this); - sortFilter->setSourceModel(localDirModel); - sortFilter->setDynamicSortFilter(true); + localDirModel->sort(0, Qt::AscendingOrder); localDirView = new QTreeView; - localDirView->setModel(sortFilter); + localDirView->setModel(localDirModel); localDirView->setColumnHidden(1, true); - localDirView->setRootIndex(sortFilter->mapFromSource(localDirModel->index(localDirModel->rootPath(), 0))); + localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0)); localDirView->setSortingEnabled(true); localDirView->header()->setResizeMode(QHeaderView::ResizeToContents); - sortFilter->sort(0, Qt::AscendingOrder); localDirView->header()->setSortIndicator(0, Qt::AscendingOrder); leftToolBar = new QToolBar; @@ -113,7 +108,7 @@ void TabReplays::retranslateUi() void TabReplays::actOpenLocalReplay() { - QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex()); + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (localDirModel->isDir(curLeft)) return; QString filePath = localDirModel->filePath(curLeft); @@ -156,7 +151,7 @@ void TabReplays::openRemoteReplayFinished(const Response &r) void TabReplays::actDownload() { QString filePath; - QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex()); + QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (!curLeft.isValid()) filePath = localDirModel->rootPath(); else { diff --git a/cockatrice/src/tab_replays.h b/cockatrice/src/tab_replays.h index 4badc292..6ea0c667 100644 --- a/cockatrice/src/tab_replays.h +++ b/cockatrice/src/tab_replays.h @@ -7,7 +7,6 @@ class Response; class AbstractClient; class QTreeView; class QFileSystemModel; -class QSortFilterProxyModel; class QToolBar; class QGroupBox; class RemoteReplayList_TreeWidget; @@ -21,7 +20,6 @@ private: AbstractClient *client; QTreeView *localDirView; QFileSystemModel *localDirModel; - QSortFilterProxyModel *sortFilter; QToolBar *leftToolBar, *rightToolBar; RemoteReplayList_TreeWidget *serverDirView; QGroupBox *leftGroupBox, *rightGroupBox;