Created
March 21, 2012 09:07
-
-
Save ianunruh/2145726 to your computer and use it in GitHub Desktop.
Revisions
-
ianunruh revised this gist
Mar 21, 2012 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,10 @@ public class RecursiveSortFilterProxyModel extends QSortFilterProxyModel { protected boolean filterAcceptsRow(int row, QModelIndex parent) { if(super.filterAcceptsRow(row, parent)) { return true; } QStandardItemModel model = (QStandardItemModel)sourceModel(); QStandardItem item; @@ -12,9 +16,7 @@ protected boolean filterAcceptsRow(int row, QModelIndex parent) { item = model.itemFromIndex(parent).child(row); } if(item.hasChildren()) { QModelIndex index = item.index(); int rowCount = item.rowCount(); for(int i = 0; i < rowCount; i++) { -
ianunruh created this gist
Mar 21, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import com.trolltech.qt.core.QModelIndex; import com.trolltech.qt.gui.*; public class RecursiveSortFilterProxyModel extends QSortFilterProxyModel { protected boolean filterAcceptsRow(int row, QModelIndex parent) { QStandardItemModel model = (QStandardItemModel)sourceModel(); QStandardItem item; if(parent == null) { item = model.item(row); } else { item = model.itemFromIndex(parent).child(row); } if(super.filterAcceptsRow(row, parent)) { return true; } else if(item.hasChildren()) { QModelIndex index = item.index(); int rowCount = item.rowCount(); for(int i = 0; i < rowCount; i++) { if(filterAcceptsRow(i, index)) { return true; } } } return false; } }