git-svn-id: file:///svnroot/family-shop-mgr@20 26eb2498-383b-47a6-be48-5d6f36779e85
[family-shop-mgr] / code / family-shop-mgr / FamilyShoppingManagerMainWindow.cpp
index bb4a8c9..e962014 100644 (file)
 #include "GoShoppingView.h"
 
 FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent)
-    : QMainWindow(parent), activityView(NULL)
+    : QMainWindow(parent), activityView(NULL), showCheckedItemsAction(NULL),
+    endShoppingAction(NULL), goShoppingAction(NULL), editMenu(NULL)
 {
-    showListManager();
-
-    editMenu = new QMenu(tr("&Edit"), this);
-    editMenu->addAction(tr("Add category"));
-    editMenu->addAction(tr("Remove category"));
-    editMenu->addAction(tr("Add item"));
-    editMenu->addAction(tr("Remove item"));
-    menuBar()->addMenu(editMenu);
-
-    goShoppingAction = new QAction(tr("Go shopping!"), this);
-    connect(goShoppingAction, SIGNAL(triggered()),
-            this, SLOT(showGoShopping()));
-    menuBar()->addAction(goShoppingAction);
-
     aboutAction = new QAction(tr("&About"), this);
     connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
     menuBar()->addAction(aboutAction);
 
-    setCentralWidget(activityView);
-    update();
+
+    showListManager();
 }
 
 FamilyShoppingManagerMainWindow::~FamilyShoppingManagerMainWindow()
@@ -59,11 +46,13 @@ FamilyShoppingManagerMainWindow::~FamilyShoppingManagerMainWindow()
 void FamilyShoppingManagerMainWindow::showListManager()
 {
     menuBar()->clear();
-    (showCheckedItemsAction) ? delete showCheckedItemsAction:;
-    (endShoppingAction) ? delete endShoppingAction:;
+
+    delete showCheckedItemsAction;
+    delete endShoppingAction;
 
     delete activityView;
     activityView = new ListManagerView("ShoppingList.xml", this);
+    setCentralWidget(activityView);
 
     editMenu = new QMenu(tr("&Edit"), this);
     editMenu->addAction(tr("Add category"));
@@ -78,6 +67,7 @@ void FamilyShoppingManagerMainWindow::showListManager()
     menuBar()->addAction(goShoppingAction);
 
     menuBar()->addAction(aboutAction);
+    update();
 }
 
 void FamilyShoppingManagerMainWindow::showGoShopping()
@@ -88,6 +78,7 @@ void FamilyShoppingManagerMainWindow::showGoShopping()
 
     delete activityView;
     activityView = new GoShoppingView("ShoppingList.xml", this);
+    setCentralWidget(activityView);
 
     showCheckedItemsAction = new QAction(tr("&Show checked"), this);
     showCheckedItemsAction->setCheckable(true);
@@ -101,6 +92,7 @@ void FamilyShoppingManagerMainWindow::showGoShopping()
     menuBar()->addAction(endShoppingAction);
 
     menuBar()->addAction(aboutAction);
+    update();
 }
 
 void FamilyShoppingManagerMainWindow::showAbout()