Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
ff632911
Commit
ff632911
authored
Mar 31, 2012
by
Max-Wilhelm Bruker
Browse files
don't use QSortFilterProxyModel in TabDeckStorage and TabReplays unnecessarily
parent
13b992cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/tab_deck_storage.cpp
View file @
ff632911
#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
{
...
...
cockatrice/src/tab_deck_storage.h
View file @
ff632911
...
...
@@ -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
;
...
...
cockatrice/src/tab_replays.cpp
View file @
ff632911
#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
{
...
...
cockatrice/src/tab_replays.h
View file @
ff632911
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment