Changeset f971906d086c560d234c81517be0ee162ec89d7f
- Timestamp:
- 04/13/09 21:13:07
(1 year ago)
- Author:
- Hans Petter Jansson <hpj@linux-rqhg.site>
- git-committer:
- Hans Petter Jansson <hpj@linux-rqhg.site> 1239671587 -0500
- git-parent:
[84a65af40abf1152485712ca2a58c6a546b5f3b8]
- git-author:
- Hans Petter Jansson <hpj@cl.no> 1239671587 -0500
- Message:
Use a TreeModelSort? instead of buggy TreeSortable?.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r8d9ed78 |
rf971906 |
|
| 25 | 25 | private TransactionModel completion_model; // Description entry completion. |
|---|
| 26 | 26 | private TransactionModel browse_model; // Transaction browsing view. |
|---|
| | 27 | private TreeModelSort browse_model_sort; |
|---|
| 27 | 28 | |
|---|
| 28 | 29 | public TransactionEditor () : base ("Sterling: Transaction Editor") |
|---|
| … | … | |
| 34 | 35 | browse_model = new TransactionModel (); |
|---|
| 35 | 36 | browse_model.SetQuery (new TransactionQuery ()); |
|---|
| | 37 | |
|---|
| | 38 | browse_model_sort = new TreeModelSort (new TreeModelAdapter (browse_model)); |
|---|
| 36 | 39 | |
|---|
| 37 | 40 | // Construct UI |
|---|
| … | … | |
| 53 | 56 | // Transaction browser |
|---|
| 54 | 57 | |
|---|
| 55 | | TreeView transaction_view = new TransactionListView (new TreeModelAdapter (browse_model)); |
|---|
| | 58 | TreeView transaction_view = new TransactionListView (browse_model_sort); |
|---|
| 56 | 59 | transaction_view.HeadersVisible = true; |
|---|
| 57 | 60 | transaction_view.ShowAll (); |
|---|
| r84a65af |
rf971906 |
|
| 20 | 20 | column.Resizable = true; |
|---|
| 21 | 21 | column.SortColumnId = (int) TransactionModel.Columns.Description; |
|---|
| 22 | | column.Clicked += new EventHandler (ColumnClicked); |
|---|
| 23 | 22 | AppendColumn (column); |
|---|
| 24 | 23 | |
|---|
| … | … | |
| 30 | 29 | column.Resizable = false; |
|---|
| 31 | 30 | column.SortColumnId = (int) TransactionModel.Columns.Amount; |
|---|
| 32 | | column.Clicked += new EventHandler (ColumnClicked); |
|---|
| 33 | 31 | AppendColumn (column); |
|---|
| 34 | 32 | |
|---|
| … | … | |
| 38 | 36 | column.Resizable = true; |
|---|
| 39 | 37 | column.SortColumnId = (int) TransactionModel.Columns.TransactionTimeStamp; |
|---|
| 40 | | column.Clicked += new EventHandler (ColumnClicked); |
|---|
| 41 | 38 | AppendColumn (column); |
|---|
| 42 | 39 | |
|---|
| … | … | |
| 46 | 43 | column.Resizable = true; |
|---|
| 47 | 44 | column.SortColumnId = (int) TransactionModel.Columns.CreationTimeStamp; |
|---|
| 48 | | column.Clicked += new EventHandler (ColumnClicked); |
|---|
| 49 | 45 | AppendColumn (column); |
|---|
| 50 | 46 | |
|---|
| … | … | |
| 54 | 50 | column.Resizable = true; |
|---|
| 55 | 51 | column.SortColumnId = (int) TransactionModel.Columns.Tags; |
|---|
| 56 | | column.Clicked += new EventHandler (ColumnClicked); |
|---|
| 57 | 52 | AppendColumn (column); |
|---|
| 58 | | } |
|---|
| 59 | | |
|---|
| 60 | | // private int col0_compare (TreeModel model, TreeIter tia, TreeIter tib) |
|---|
| 61 | | // { |
|---|
| 62 | | // return String.Compare ((string) model.GetValue (tia, 0), |
|---|
| 63 | | // (string) model.GetValue (tib, 0)); |
|---|
| 64 | | // } |
|---|
| 65 | | |
|---|
| 66 | | private void ColumnClicked (object o, EventArgs args) |
|---|
| 67 | | { |
|---|
| 68 | | TreeViewColumn column = (TreeViewColumn) o; |
|---|
| 69 | | |
|---|
| 70 | | column.SortOrder = ToggleSortOrder (column); |
|---|
| 71 | | column.SortIndicator = true; |
|---|
| 72 | | |
|---|
| 73 | | // FIXME: No way to pass model or view to this function. this == null. |
|---|
| 74 | | // my_model.SetSortColumnId (column.SortColumnId, column.SortOrder); |
|---|
| 75 | | } |
|---|
| 76 | | |
|---|
| 77 | | public SortType ToggleSortOrder (TreeViewColumn col) |
|---|
| 78 | | { |
|---|
| 79 | | if (col.SortIndicator) |
|---|
| 80 | | { |
|---|
| 81 | | if (col.SortOrder == SortType.Ascending) |
|---|
| 82 | | return SortType.Descending; |
|---|
| 83 | | else |
|---|
| 84 | | return SortType.Ascending; |
|---|
| 85 | | } |
|---|
| 86 | | else |
|---|
| 87 | | { |
|---|
| 88 | | return SortType.Ascending; |
|---|
| 89 | | } |
|---|
| 90 | 53 | } |
|---|
| 91 | 54 | } |
|---|