git-svn-id: file:///svnroot/family-shop-mgr@30 26eb2498-383b-47a6-be48-5d6f36779e85
[family-shop-mgr] / code / family-shop-mgr / FamilyShoppingManagerMainWindow.cpp
index 393639b..6407261 100644 (file)
@@ -30,7 +30,7 @@
 
 /*******************************************************************/
 FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent)
-    : QMainWindow(parent), activityView(NULL), editMenu(NULL),
+    : QMainWindow(parent), activityView(NULL), //editMenu(NULL),
     showCheckedItemsAction(NULL), goShoppingAction(NULL), endShoppingAction(NULL)
 {
     aboutAction = new QAction(tr("&About"), this);
@@ -57,26 +57,28 @@ void FamilyShoppingManagerMainWindow::showListManager()
 
     delete activityView;
     activityView = new ListManagerView("ShoppingList.xml", this);
-    setCentralWidget(activityView);
 
-    editMenu = new QMenu(tr("&Edit"), this);
+//    editMenu = new QMenu(tr("&Edit"), this);
     addCategoryAction = new QAction(tr("Add category"), this);
     connect(addCategoryAction, SIGNAL(triggered()),
             this, SLOT(addCategory()));
-    editMenu->addAction(addCategoryAction);
-//    removeCategoryAction = new QAction(tr("Remove category"), this);
-//    connect(removeCategoryAction, SIGNAL(triggered()),
-//            this, SLOT(removeRow()));
+//    editMenu->addAction(addCategoryAction);
+    removeCategoryAction = new QAction(tr("Remove category"), this);
+    connect(removeCategoryAction, SIGNAL(triggered()),
+            this, SLOT(removeCategoryOrItem()));
 //    editMenu->addAction(removeCategoryAction);
-//    addItemAction = new QAction(tr("Add item"), this);
-//    connect(addItemAction, SIGNAL(triggered()),
-//            this, SLOT(insertRow()));
+    addItemAction = new QAction(tr("Add item"), this);
+    connect(addItemAction, SIGNAL(triggered()),
+            this, SLOT(addItem()));
 //    editMenu->addAction(addItemAction);
-//    removeItemAction = new QAction(tr("Remove item"), this);
-//    connect(removeItemAction, SIGNAL(triggered()),
-//            this, SLOT(removeRow()));
+    removeItemAction = new QAction(tr("Remove item"), this);
+    connect(removeItemAction, SIGNAL(triggered()),
+            this, SLOT(removeCategoryOrItem()));
 //    editMenu->addAction(removeItemAction);
-    menuBar()->addMenu(editMenu);
+    menuBar()->addAction(addCategoryAction);
+    activityView->addAction(removeCategoryAction);
+    activityView->addAction(addItemAction);
+    activityView->addAction(removeItemAction);
 
     goShoppingAction = new QAction(tr("Go shopping!"), this);
     connect(goShoppingAction, SIGNAL(triggered()),
@@ -84,6 +86,8 @@ void FamilyShoppingManagerMainWindow::showListManager()
     menuBar()->addAction(goShoppingAction);
 
     menuBar()->addAction(aboutAction);
+
+    setCentralWidget(activityView);
     update();
 }
 
@@ -91,7 +95,7 @@ void FamilyShoppingManagerMainWindow::showListManager()
 void FamilyShoppingManagerMainWindow::showGoShopping()
 {
     menuBar()->clear();
-    delete editMenu;
+//    delete editMenu;
     delete goShoppingAction;
 
     delete activityView;