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 diff
     1.1 --- a/MainWindow.cs	Tue Aug 03 19:36:49 2010 +0000
     1.2 +++ b/MainWindow.cs	Wed Aug 04 19:37:23 2010 +0000
     1.3 @@ -145,7 +145,7 @@
     1.4  		}		
     1.5  
     1.6  		private void HandleWarFoundryCoreArmyChanged(Army oldValue, Army newValue)
     1.7 -		{
     1.8 +		{			
     1.9  			CommandStack.Reset();
    1.10  			loadedFilePath = null;
    1.11  			layout.actionSaveArmy.Enabled = false;
    1.12 @@ -153,7 +153,7 @@
    1.13  			SetPointsPanelText();
    1.14  			SetAppTitle();
    1.15  		}
    1.16 -
    1.17 +		
    1.18  		private void SetPointsPanelText ()
    1.19  		{
    1.20  			//TODO: implement panel and points panel
    1.21 @@ -375,9 +375,19 @@
    1.22  			if (unitObj is Unit)
    1.23  			{
    1.24  				Unit unit = (Unit)unitObj;
    1.25 +				QStandardItemModel treeModel = (QStandardItemModel)layout.armyTree.Model();
    1.26 +				List<QStandardItem> items = treeModel.FindItems(unit.Category.Name, (uint)MatchFlag.MatchExactly, 0);
    1.27 +				
    1.28 +				if (items.Count == 1)
    1.29 +				{
    1.30 +					QStandardItem item = items[0];
    1.31 +					CreateTreeSubItem(unit, item);
    1.32 +					layout.armyTree.Expand(item.Index());
    1.33 +				}
    1.34 +				//Else something odd happened and we need to handle it
    1.35 +				
    1.36  				//TODO set error panel
    1.37  				//sbErrorPanel.Text = "";
    1.38 -				//TODO add unit to tree
    1.39  			}
    1.40  		}
    1.41  
    1.42 @@ -461,7 +471,7 @@
    1.43  			FillArmyTree(newArmy);
    1.44  		}
    1.45  
    1.46 -		private void FillArmyTree (Army army)
    1.47 +		private void FillArmyTree(Army army)
    1.48  		{
    1.49  			QStandardItemModel treeModel = new QStandardItemModel();
    1.50  			List<string> headers = new List<string>();