Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
changeset 30:56771b8efdaf
Re #244: Create "New Unit" dialog in Qt# app
* Add unit to tree once it is created
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 04 Aug 2010 19:37:23 +0000 |
parents | 246237c88b9b |
children | d586244177ff |
files | MainWindow.cs |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/MainWindow.cs Tue Aug 03 19:36:49 2010 +0000 +++ b/MainWindow.cs Wed Aug 04 19:37:23 2010 +0000 @@ -145,7 +145,7 @@ } private void HandleWarFoundryCoreArmyChanged(Army oldValue, Army newValue) - { + { CommandStack.Reset(); loadedFilePath = null; layout.actionSaveArmy.Enabled = false; @@ -153,7 +153,7 @@ SetPointsPanelText(); SetAppTitle(); } - + private void SetPointsPanelText () { //TODO: implement panel and points panel @@ -375,9 +375,19 @@ if (unitObj is Unit) { Unit unit = (Unit)unitObj; + QStandardItemModel treeModel = (QStandardItemModel)layout.armyTree.Model(); + List<QStandardItem> items = treeModel.FindItems(unit.Category.Name, (uint)MatchFlag.MatchExactly, 0); + + if (items.Count == 1) + { + QStandardItem item = items[0]; + CreateTreeSubItem(unit, item); + layout.armyTree.Expand(item.Index()); + } + //Else something odd happened and we need to handle it + //TODO set error panel //sbErrorPanel.Text = ""; - //TODO add unit to tree } } @@ -461,7 +471,7 @@ FillArmyTree(newArmy); } - private void FillArmyTree (Army army) + private void FillArmyTree(Army army) { QStandardItemModel treeModel = new QStandardItemModel(); List<string> headers = new List<string>();