don't use QSortFilterProxyModel in TabDeckStorage and TabReplays unnecessarily

This commit is contained in:
Max-Wilhelm Bruker 2012-03-31 13:28:04 +02:00
parent 13b992cf12
commit ff632911f2
4 changed files with 11 additions and 25 deletions

View file

@ -1,6 +1,5 @@
#include <QTreeView>
#include <QFileSystemModel>
#include <QSortFilterProxyModel>
#include <QToolBar>
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -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 {

View file

@ -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;

View file

@ -1,6 +1,5 @@
#include <QTreeView>
#include <QFileSystemModel>
#include <QSortFilterProxyModel>
#include <QToolBar>
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -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 {

View file

@ -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;