2 * This file is part of family-shop-mgr.
4 * family-shop-mgr is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * family-shop-mgr is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with family-shop-mgr. If not, see <http://www.gnu.org/licenses/>.
17 * Author: Unai IRIGOYEN
22 #include "FamilyShoppingManagerMainWindow.h"
24 #include <QMessageBox>
26 #include "ListManagerView.h"
27 #include "GoShoppingView.h"
29 /*******************************************************************/
30 FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent)
31 : QMainWindow(parent), activityView(NULL), showCheckedItemsAction(NULL),
32 endShoppingAction(NULL), goShoppingAction(NULL), editMenu(NULL)
34 aboutAction = new QAction(tr("&About"), this);
35 connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
36 menuBar()->addAction(aboutAction);
42 /*******************************************************************/
43 FamilyShoppingManagerMainWindow::~FamilyShoppingManagerMainWindow()
48 /*******************************************************************/
49 void FamilyShoppingManagerMainWindow::showListManager()
53 delete showCheckedItemsAction;
54 delete endShoppingAction;
57 activityView = new ListManagerView("ShoppingList.xml", this);
58 setCentralWidget(activityView);
60 editMenu = new QMenu(tr("&Edit"), this);
61 editMenu->addAction(tr("Add category"));
62 editMenu->addAction(tr("Remove category"));
63 editMenu->addAction(tr("Add item"));
64 editMenu->addAction(tr("Remove item"));
65 menuBar()->addMenu(editMenu);
67 goShoppingAction = new QAction(tr("Go shopping!"), this);
68 connect(goShoppingAction, SIGNAL(triggered()),
69 this, SLOT(showGoShopping()));
70 menuBar()->addAction(goShoppingAction);
72 menuBar()->addAction(aboutAction);
76 /*******************************************************************/
77 void FamilyShoppingManagerMainWindow::showGoShopping()
81 delete goShoppingAction;
84 activityView = new GoShoppingView("ShoppingList.xml", this);
85 setCentralWidget(activityView);
87 showCheckedItemsAction = new QAction(tr("&Show checked"), this);
88 showCheckedItemsAction->setCheckable(true);
89 connect(showCheckedItemsAction, SIGNAL(toggled(bool)),
90 activityView, SLOT(showChecked(bool)));
91 menuBar()->addAction(showCheckedItemsAction);
93 endShoppingAction = new QAction(tr("&End shopping"), this);
94 connect(endShoppingAction, SIGNAL(triggered()),
95 this, SLOT(showListManager()));
96 menuBar()->addAction(endShoppingAction);
98 menuBar()->addAction(aboutAction);
102 /*******************************************************************/
103 void FamilyShoppingManagerMainWindow::showAbout()
106 text = "Application name: Family shopping manager\n";
107 text += "Author: Unai IRIGOYEN\n\n";
108 text += "Licence: GPL";
109 QMessageBox::about(this,tr("About"), text);