git-svn-id: file:///svnroot/family-shop-mgr@24 26eb2498-383b-47a6-be48-5d6f36779e85
authoronil <u.irigoyen@gmail.com>
Wed, 10 Mar 2010 13:01:39 +0000 (13:01 +0000)
committeronil <u.irigoyen@gmail.com>
Wed, 10 Mar 2010 13:01:39 +0000 (13:01 +0000)
code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp

index 4b821f7..393639b 100644 (file)
@@ -22,6 +22,7 @@
 #include "FamilyShoppingManagerMainWindow.h"
 #include <QMenuBar>
 #include <QMessageBox>
+#include <QInputDialog>
 
 #include "ListManagerView.h"
 #include "GoShoppingView.h"
@@ -160,8 +161,16 @@ void FamilyShoppingManagerMainWindow::addCategory()
     ShoppingTreeModel *model = (ShoppingTreeModel*)
                                ((ListManagerView*) activityView)->model();
 
-    if(model->addCategory("New category"))
+    bool* ok = new bool(false);
+    QString name = QInputDialog::getText(this, tr("Enter category name"),
+                                         tr("Category name:"),
+                                         QLineEdit::Normal, QString(), ok);
+    if(!ok)
+        return;
+
+    if(model->addCategory(name))
         ((ListManagerView*) activityView)->updateActions();
+    delete ok;
 }
 
 /*******************************************************************/
@@ -172,8 +181,17 @@ void FamilyShoppingManagerMainWindow::addSubCategory()
     ShoppingTreeModel *model = (ShoppingTreeModel*)
                                ((ListManagerView*) activityView)->model();
 
-    if(model->addSubCategory("New sub-category", index.row()+1, index))
+    bool* ok = new bool(false);
+    QString name = QInputDialog::getText(this, tr("Enter category name"),
+                                         tr("Category name:"),
+                                         QLineEdit::Normal, QString(), ok);
+    if(!ok)
+        return;
+
+    if(model->addSubCategory(name, index.row()+1, index))
         ((ListManagerView*) activityView)->updateActions();
+
+    delete ok;
 }
 
 /*******************************************************************/
@@ -184,8 +202,17 @@ void FamilyShoppingManagerMainWindow::addItem()
     ShoppingTreeModel *model = (ShoppingTreeModel*)
                                ((ListManagerView*) activityView)->model();
 
-    if(model->addItem("New item", index.row()+1, index))
+    bool* ok = new bool(false);
+    QString name = QInputDialog::getText(this, tr("Enter item name"),
+                                         tr("Item name:"),
+                                         QLineEdit::Normal, QString(), ok);
+    if(!ok)
+        return;
+
+    if(model->addItem(name, index.row()+1, index))
         ((ListManagerView*) activityView)->updateActions();
+
+    delete ok;
 }
 
 /*******************************************************************/