don't use QSortFilterProxyModel in TabDeckStorage and TabReplays unnecessarily
This commit is contained in:
parent
13b992cf12
commit
ff632911f2
4 changed files with 11 additions and 25 deletions
|
@ -1,6 +1,5 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -31,18 +30,14 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c
|
||||||
{
|
{
|
||||||
localDirModel = new QFileSystemModel(this);
|
localDirModel = new QFileSystemModel(this);
|
||||||
localDirModel->setRootPath(settingsCache->getDeckPath());
|
localDirModel->setRootPath(settingsCache->getDeckPath());
|
||||||
|
localDirModel->sort(0, Qt::AscendingOrder);
|
||||||
sortFilter = new QSortFilterProxyModel(this);
|
|
||||||
sortFilter->setSourceModel(localDirModel);
|
|
||||||
sortFilter->setDynamicSortFilter(true);
|
|
||||||
|
|
||||||
localDirView = new QTreeView;
|
localDirView = new QTreeView;
|
||||||
localDirView->setModel(sortFilter);
|
localDirView->setModel(localDirModel);
|
||||||
localDirView->setColumnHidden(1, true);
|
localDirView->setColumnHidden(1, true);
|
||||||
localDirView->setRootIndex(sortFilter->mapFromSource(localDirModel->index(localDirModel->rootPath(), 0)));
|
localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0));
|
||||||
localDirView->setSortingEnabled(true);
|
localDirView->setSortingEnabled(true);
|
||||||
localDirView->header()->setResizeMode(QHeaderView::ResizeToContents);
|
localDirView->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
sortFilter->sort(0, Qt::AscendingOrder);
|
|
||||||
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
leftToolBar = new QToolBar;
|
leftToolBar = new QToolBar;
|
||||||
|
@ -124,7 +119,7 @@ void TabDeckStorage::retranslateUi()
|
||||||
|
|
||||||
void TabDeckStorage::actOpenLocalDeck()
|
void TabDeckStorage::actOpenLocalDeck()
|
||||||
{
|
{
|
||||||
QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex());
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (localDirModel->isDir(curLeft))
|
if (localDirModel->isDir(curLeft))
|
||||||
return;
|
return;
|
||||||
QString filePath = localDirModel->filePath(curLeft);
|
QString filePath = localDirModel->filePath(curLeft);
|
||||||
|
@ -139,7 +134,7 @@ void TabDeckStorage::actOpenLocalDeck()
|
||||||
|
|
||||||
void TabDeckStorage::actUpload()
|
void TabDeckStorage::actUpload()
|
||||||
{
|
{
|
||||||
QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex());
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (localDirModel->isDir(curLeft))
|
if (localDirModel->isDir(curLeft))
|
||||||
return;
|
return;
|
||||||
QString filePath = localDirModel->filePath(curLeft);
|
QString filePath = localDirModel->filePath(curLeft);
|
||||||
|
@ -209,7 +204,7 @@ void TabDeckStorage::openRemoteDeckFinished(const Response &r)
|
||||||
void TabDeckStorage::actDownload()
|
void TabDeckStorage::actDownload()
|
||||||
{
|
{
|
||||||
QString filePath;
|
QString filePath;
|
||||||
QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex());
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (!curLeft.isValid())
|
if (!curLeft.isValid())
|
||||||
filePath = localDirModel->rootPath();
|
filePath = localDirModel->rootPath();
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
class QSortFilterProxyModel;
|
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
@ -21,7 +20,6 @@ private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
QTreeView *localDirView;
|
QTreeView *localDirView;
|
||||||
QFileSystemModel *localDirModel;
|
QFileSystemModel *localDirModel;
|
||||||
QSortFilterProxyModel *sortFilter;
|
|
||||||
QToolBar *leftToolBar, *rightToolBar;
|
QToolBar *leftToolBar, *rightToolBar;
|
||||||
RemoteDeckList_TreeWidget *serverDirView;
|
RemoteDeckList_TreeWidget *serverDirView;
|
||||||
QGroupBox *leftGroupBox, *rightGroupBox;
|
QGroupBox *leftGroupBox, *rightGroupBox;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -28,18 +27,14 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client)
|
||||||
{
|
{
|
||||||
localDirModel = new QFileSystemModel(this);
|
localDirModel = new QFileSystemModel(this);
|
||||||
localDirModel->setRootPath(settingsCache->getReplaysPath());
|
localDirModel->setRootPath(settingsCache->getReplaysPath());
|
||||||
|
localDirModel->sort(0, Qt::AscendingOrder);
|
||||||
sortFilter = new QSortFilterProxyModel(this);
|
|
||||||
sortFilter->setSourceModel(localDirModel);
|
|
||||||
sortFilter->setDynamicSortFilter(true);
|
|
||||||
|
|
||||||
localDirView = new QTreeView;
|
localDirView = new QTreeView;
|
||||||
localDirView->setModel(sortFilter);
|
localDirView->setModel(localDirModel);
|
||||||
localDirView->setColumnHidden(1, true);
|
localDirView->setColumnHidden(1, true);
|
||||||
localDirView->setRootIndex(sortFilter->mapFromSource(localDirModel->index(localDirModel->rootPath(), 0)));
|
localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0));
|
||||||
localDirView->setSortingEnabled(true);
|
localDirView->setSortingEnabled(true);
|
||||||
localDirView->header()->setResizeMode(QHeaderView::ResizeToContents);
|
localDirView->header()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
sortFilter->sort(0, Qt::AscendingOrder);
|
|
||||||
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
leftToolBar = new QToolBar;
|
leftToolBar = new QToolBar;
|
||||||
|
@ -113,7 +108,7 @@ void TabReplays::retranslateUi()
|
||||||
|
|
||||||
void TabReplays::actOpenLocalReplay()
|
void TabReplays::actOpenLocalReplay()
|
||||||
{
|
{
|
||||||
QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex());
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (localDirModel->isDir(curLeft))
|
if (localDirModel->isDir(curLeft))
|
||||||
return;
|
return;
|
||||||
QString filePath = localDirModel->filePath(curLeft);
|
QString filePath = localDirModel->filePath(curLeft);
|
||||||
|
@ -156,7 +151,7 @@ void TabReplays::openRemoteReplayFinished(const Response &r)
|
||||||
void TabReplays::actDownload()
|
void TabReplays::actDownload()
|
||||||
{
|
{
|
||||||
QString filePath;
|
QString filePath;
|
||||||
QModelIndex curLeft = sortFilter->mapToSource(localDirView->selectionModel()->currentIndex());
|
QModelIndex curLeft = localDirView->selectionModel()->currentIndex();
|
||||||
if (!curLeft.isValid())
|
if (!curLeft.isValid())
|
||||||
filePath = localDirModel->rootPath();
|
filePath = localDirModel->rootPath();
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -7,7 +7,6 @@ class Response;
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
class QSortFilterProxyModel;
|
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class RemoteReplayList_TreeWidget;
|
class RemoteReplayList_TreeWidget;
|
||||||
|
@ -21,7 +20,6 @@ private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
QTreeView *localDirView;
|
QTreeView *localDirView;
|
||||||
QFileSystemModel *localDirModel;
|
QFileSystemModel *localDirModel;
|
||||||
QSortFilterProxyModel *sortFilter;
|
|
||||||
QToolBar *leftToolBar, *rightToolBar;
|
QToolBar *leftToolBar, *rightToolBar;
|
||||||
RemoteReplayList_TreeWidget *serverDirView;
|
RemoteReplayList_TreeWidget *serverDirView;
|
||||||
QGroupBox *leftGroupBox, *rightGroupBox;
|
QGroupBox *leftGroupBox, *rightGroupBox;
|
||||||
|
|
Loading…
Reference in a new issue