comparison MainWindow.cs @ 33:be876c03054f

Re #245: Create unit tab implementation * Add stub widget * Record which unit tabs are open * Remove two default tabs
author IBBoard <dev@ibboard.co.uk>
date Sat, 07 Aug 2010 15:40:37 +0000
parents e405b43a405b
children
comparison
equal deleted inserted replaced
32:e405b43a405b 33:be876c03054f
14 using IBBoard.WarFoundry.API.Factories; 14 using IBBoard.WarFoundry.API.Factories;
15 using IBBoard.WarFoundry.API.Objects; 15 using IBBoard.WarFoundry.API.Objects;
16 using IBBoard.WarFoundry.API.Savers; 16 using IBBoard.WarFoundry.API.Savers;
17 using IBBoard.WarFoundry.GUI.QtSharp.Handler; 17 using IBBoard.WarFoundry.GUI.QtSharp.Handler;
18 using IBBoard.WarFoundry.API.Commands; 18 using IBBoard.WarFoundry.API.Commands;
19 using IBBoard.WarFoundry.GUI.QtSharp.Widgets;
19 20
20 namespace IBBoard.WarFoundry.GUI.QtSharp 21 namespace IBBoard.WarFoundry.GUI.QtSharp
21 { 22 {
22 public class MainWindow : QMainWindow 23 public class MainWindow : QMainWindow
23 { 24 {
30 private QFileDialog saveArmyDialog; 31 private QFileDialog saveArmyDialog;
31 private QFileDialog openArmyDialog; 32 private QFileDialog openArmyDialog;
32 private Preferences preferences; 33 private Preferences preferences;
33 private QAction[] categoryActions; 34 private QAction[] categoryActions;
34 private Dictionary<string, QStandardItem> treeNodes; 35 private Dictionary<string, QStandardItem> treeNodes;
36 private Dictionary<Unit, UnitWidget> openUnitWidgets;
37
35 38
36 public MainWindow () 39 public MainWindow ()
37 { 40 {
38 layout = new Ui_MainWindowLayout(); 41 layout = new Ui_MainWindowLayout();
39 layout.SetupUi(this); 42 layout.SetupUi(this);
40 WindowIcon = new QIcon("icons/App.png"); 43 WindowIcon = new QIcon("icons/App.png");
41 Preferences = new Preferences("WarFoundryQt"); 44 Preferences = new Preferences("WarFoundryQt");
42 treeNodes = new Dictionary<string, QStandardItem>(); 45 treeNodes = new Dictionary<string, QStandardItem>();
46 openUnitWidgets = new Dictionary<Unit, UnitWidget>();
43 47
44 try 48 try
45 { 49 {
46 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); 50 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString());
47 } 51 }
551 } 555 }
552 } 556 }
553 557
554 private void OpenUnitDialog(Unit unit) 558 private void OpenUnitDialog(Unit unit)
555 { 559 {
556 560 UnitWidget currentWidget = DictionaryUtils.GetValue(openUnitWidgets, unit);
561
562 if (currentWidget != null)
563 {
564 layout.unitTabs.SetCurrentWidget(currentWidget);
565 }
566 else
567 {
568 UnitWidget unitWidget = new UnitWidget(unit);
569 openUnitWidgets.Add(unit, unitWidget);
570 layout.unitTabs.AddTab(unitWidget, unit.Name);
571 }
557 } 572 }
558 573
559 void EnableCategoryButtons () 574 void EnableCategoryButtons ()
560 { 575 {
561 //TODO enable category buttons 576 //TODO enable category buttons