git-svn-id: file:///svnroot/family-shop-mgr@31 26eb2498-383b-47a6-be48-5d6f36779e85
authoronil <u.irigoyen@gmail.com>
Wed, 7 Apr 2010 20:18:05 +0000 (20:18 +0000)
committeronil <u.irigoyen@gmail.com>
Wed, 7 Apr 2010 20:18:05 +0000 (20:18 +0000)
code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp
code/family-shop-mgr/FamilyShoppingManagerMainWindow.h
code/family-shop-mgr/GoShoppingView.cpp
code/family-shop-mgr/ListManagerView.cpp
code/family-shop-mgr/ShoppingTreeModel.cpp
code/family-shop-mgr/ShoppingTreeModel.h
code/family-shop-mgr/family-shop-mgr.pro.user

index 6407261..269c3fe 100644 (file)
@@ -34,6 +34,7 @@ FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent
     showCheckedItemsAction(NULL), goShoppingAction(NULL), endShoppingAction(NULL)
 {
     aboutAction = new QAction(tr("&About"), this);
+    aboutAction->setSoftKeyRole(QAction::PositiveSoftKey);
     connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
     menuBar()->addAction(aboutAction);
 
@@ -58,29 +59,29 @@ void FamilyShoppingManagerMainWindow::showListManager()
     delete activityView;
     activityView = new ListManagerView("ShoppingList.xml", this);
 
-//    editMenu = new QMenu(tr("&Edit"), this);
     addCategoryAction = new QAction(tr("Add category"), this);
+    addCategoryAction->setSoftKeyRole(QAction::PositiveSoftKey);
     connect(addCategoryAction, SIGNAL(triggered()),
             this, SLOT(addCategory()));
-//    editMenu->addAction(addCategoryAction);
+    menuBar()->addAction(addCategoryAction);
     removeCategoryAction = new QAction(tr("Remove category"), this);
+    removeCategoryAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(removeCategoryAction, SIGNAL(triggered()),
             this, SLOT(removeCategoryOrItem()));
-//    editMenu->addAction(removeCategoryAction);
+    menuBar()->addAction(removeCategoryAction);
     addItemAction = new QAction(tr("Add item"), this);
+    addItemAction->setSoftKeyRole(QAction::PositiveSoftKey);
     connect(addItemAction, SIGNAL(triggered()),
             this, SLOT(addItem()));
-//    editMenu->addAction(addItemAction);
+    menuBar()->addAction(addItemAction);
     removeItemAction = new QAction(tr("Remove item"), this);
+    removeItemAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(removeItemAction, SIGNAL(triggered()),
             this, SLOT(removeCategoryOrItem()));
-//    editMenu->addAction(removeItemAction);
-    menuBar()->addAction(addCategoryAction);
-    activityView->addAction(removeCategoryAction);
-    activityView->addAction(addItemAction);
-    activityView->addAction(removeItemAction);
+    menuBar()->addAction(removeItemAction);
 
     goShoppingAction = new QAction(tr("Go shopping!"), this);
+    goShoppingAction->setSoftKeyRole(QAction::PositiveSoftKey);
     connect(goShoppingAction, SIGNAL(triggered()),
             this, SLOT(showGoShopping()));
     menuBar()->addAction(goShoppingAction);
@@ -95,7 +96,11 @@ void FamilyShoppingManagerMainWindow::showListManager()
 void FamilyShoppingManagerMainWindow::showGoShopping()
 {
     menuBar()->clear();
-//    delete editMenu;
+
+    delete addCategoryAction;
+    delete addItemAction;
+    delete removeCategoryAction;
+    delete removeItemAction;
     delete goShoppingAction;
 
     delete activityView;
@@ -104,11 +109,13 @@ void FamilyShoppingManagerMainWindow::showGoShopping()
 
     showCheckedItemsAction = new QAction(tr("&Show checked"), this);
     showCheckedItemsAction->setCheckable(true);
+    showCheckedItemsAction->setSoftKeyRole(QAction::PositiveSoftKey);
     connect(showCheckedItemsAction, SIGNAL(toggled(bool)),
             activityView, SLOT(showChecked(bool)));
     menuBar()->addAction(showCheckedItemsAction);
 
     endShoppingAction = new QAction(tr("&End shopping"), this);
+    endShoppingAction->setSoftKeyRole(QAction::NegativeSoftKey);
     connect(endShoppingAction, SIGNAL(triggered()),
             this, SLOT(showListManager()));
     menuBar()->addAction(endShoppingAction);
@@ -121,45 +128,18 @@ void FamilyShoppingManagerMainWindow::showGoShopping()
 void FamilyShoppingManagerMainWindow::showAbout()
 {
     QString text;
-    text = "Application name: Family shopping manager\n";
-    text += "Author: Unai IRIGOYEN\n\n";
-    text += "Licence: GPL";
+    text = tr("Application name:") + " Family shopping manager\n\n";
+    text += tr("Project maintainer:") + "\n";
+    text += "\tUnai IRIGOYEN";
+    text += "\n\n";
+    text += tr("Developers:") + "\n";
+    text += "\tUnai IRIGOYEN";
+    text += "\n\n";
+    text += tr("Licence:") + " GPLv3";
     QMessageBox::about(this,tr("About"), text);
 }
 
 /*******************************************************************/
-/*
-void FamilyShoppingManagerMainWindow::insertChild()
-{
-     QModelIndex index = ((ListManagerView*) activityView)->
-                         selectionModel()->currentIndex();
-     QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
-
-     if (model->columnCount(index) == 0) {
-         if (!model->insertColumn(0, index))
-             return;
-     }
-
-     if (!model->insertRow(0, index))
-         return;
-
-     for (int column = 0; column < model->columnCount(index); ++column)
-     {
-         QModelIndex child = model->index(0, column, index);
-         model->setData(child, QVariant("[No data]"), Qt::EditRole);
-         if (!model->headerData(column, Qt::Horizontal).isValid())
-             model->setHeaderData(column, Qt::Horizontal,
-                                  QVariant("[No header]"), Qt::EditRole);
-     }
-
-     ((ListManagerView*) activityView)->selectionModel()->
-             setCurrentIndex(model->index(0, 0, index),
-                             QItemSelectionModel::ClearAndSelect);
-     ((ListManagerView*) activityView)->updateActions();
- }
- */
-
-/*******************************************************************/
 void FamilyShoppingManagerMainWindow::addCategory()
 {
     ShoppingTreeModel *model = (ShoppingTreeModel*)
index fe55da6..3187ca5 100644 (file)
@@ -47,7 +47,6 @@ private slots:
 private:
     QWidget *activityView;
 
-//    QMenu *editMenu;
     QAction *showCheckedItemsAction;
     QAction *goShoppingAction;
     QAction *endShoppingAction;
index 0f08744..37275e4 100644 (file)
@@ -29,6 +29,11 @@ GoShoppingView::GoShoppingView(QString xmlFileName, QWidget *parent)
 {\r
     ShoppingTreeModel *model = new ShoppingTreeModel(xmlFileName, this);\r
     this->setModel(model);\r
+    this->setAnimated(true);\r
+    this->setAutoExpandDelay(1);\r
+    this->setAutoScroll(true);\r
+    this->setExpandsOnDoubleClick(true);\r
+    this->setSortingEnabled(true);\r
     for(int column = 0; column < model->columnCount(); column++)\r
         this->resizeColumnToContents(column);\r
 }\r
index 11a8f52..99816fb 100644 (file)
@@ -29,6 +29,11 @@ ListManagerView::ListManagerView(QString xmlFileName, QWidget *parent)
 {\r
     ShoppingTreeModel *model = new ShoppingTreeModel(xmlFileName, this);\r
     this->setModel(model);\r
+    this->setAnimated(true);\r
+    this->setAutoExpandDelay(1);\r
+    this->setAutoScroll(true);\r
+    this->setExpandsOnDoubleClick(true);\r
+    this->setSortingEnabled(true);\r
     for(int column = 0; column < model->columnCount(); column++)\r
         this->resizeColumnToContents(column);\r
 }\r
index a9289fe..28dd5d0 100644 (file)
@@ -571,3 +571,10 @@ void ShoppingTreeModel::updateXmlFile() const
     xmlFile.write(m_document.toByteArray(4));\r
     xmlFile.close();\r
 }\r
+\r
+/*******************************************************************/\r
+void ShoppingTreeModel::sort(int column, Qt::SortOrder order)\r
+{\r
+    // TODO: implement sorting\r
+    ;\r
+}\r
index 66829bf..8535e62 100644 (file)
@@ -61,6 +61,7 @@ public:
                  int role = Qt::EditRole);\r
     bool setHeaderData(int section, Qt::Orientation orientation,\r
                        const QVariant &value, int role = Qt::EditRole);\r
+    void sort(int column, Qt::SortOrder order);\r
 \r
 private:\r
     bool insertColumns(int position, int columns,\r
index b211d51..eab2836 100644 (file)
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
    <valuelist key="abstractProcess.Environment" type="QVariantList">
-    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0wQ6AlJh5H,guid=16ecdce81ddd2a3efe739bea4bb4f643</value>
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YZNnnsfbiV,guid=cb79688c9fb6e8c85ff790f94bb8fbb8</value>
     <value type="QString">DESKTOP_SESSION=default</value>
     <value type="QString">DISPLAY=:0.0</value>
     <value type="QString">DM_CONTROL=/var/run/xdmctl</value>
-    <value type="QString">GPG_AGENT_INFO=/tmp/gpg-wgd2ui/S.gpg-agent:1917:1</value>
+    <value type="QString">GPG_AGENT_INFO=/tmp/gpg-27YKzu/S.gpg-agent:1914:1</value>
     <value type="QString">GS_LIB=/home/onil/.fonts</value>
     <value type="QString">GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/onil/.gtkrc-2.0:/home/onil/.gtkrc-2.0-kde4:/home/onil/.kde/share/config/gtkrc-2.0</value>
     <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc</value>
     <value type="QString">PWD=/home/onil/Documents</value>
     <value type="QString">QTDIR=/usr/share/qt4</value>
     <value type="QString">QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value>
-    <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2008,unix/onil-netbook:/tmp/.ICE-unix/2008</value>
+    <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2004,unix/onil-netbook:/tmp/.ICE-unix/2004</value>
     <value type="QString">SHELL=/bin/bash</value>
     <value type="QString">SHLVL=0</value>
-    <value type="QString">SSH_AGENT_PID=1916</value>
-    <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-Jujezi1871/agent.1871</value>
+    <value type="QString">SSH_AGENT_PID=1913</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-HoJAfw1868/agent.1868</value>
     <value type="QString">USER=onil</value>
     <value type="QString">WINDOWPATH=7</value>
     <value type="QString">XCURSOR_THEME=oxy-white</value>
     <value type="QString">XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share</value>
-    <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270150721.823040-135122461</value>
+    <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270414262.693559-1541288722</value>
     <value type="QString">XDM_MANAGED=method=classic</value>
    </valuelist>
    <valuelist key="abstractProcess.arguments" type="QVariantList">
   <valuemap type="QVariantMap">
    <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
    <valuelist key="abstractProcess.Environment" type="QVariantList">
-    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0wQ6AlJh5H,guid=16ecdce81ddd2a3efe739bea4bb4f643</value>
+    <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YZNnnsfbiV,guid=cb79688c9fb6e8c85ff790f94bb8fbb8</value>
     <value type="QString">DESKTOP_SESSION=default</value>
     <value type="QString">DISPLAY=:0.0</value>
     <value type="QString">DM_CONTROL=/var/run/xdmctl</value>
-    <value type="QString">GPG_AGENT_INFO=/tmp/gpg-wgd2ui/S.gpg-agent:1917:1</value>
+    <value type="QString">GPG_AGENT_INFO=/tmp/gpg-27YKzu/S.gpg-agent:1914:1</value>
     <value type="QString">GS_LIB=/home/onil/.fonts</value>
     <value type="QString">GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/onil/.gtkrc-2.0:/home/onil/.gtkrc-2.0-kde4:/home/onil/.kde/share/config/gtkrc-2.0</value>
     <value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc</value>
     <value type="QString">PWD=/home/onil/Documents</value>
     <value type="QString">QTDIR=/usr/share/qt4</value>
     <value type="QString">QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value>
-    <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2008,unix/onil-netbook:/tmp/.ICE-unix/2008</value>
+    <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2004,unix/onil-netbook:/tmp/.ICE-unix/2004</value>
     <value type="QString">SHELL=/bin/bash</value>
     <value type="QString">SHLVL=0</value>
-    <value type="QString">SSH_AGENT_PID=1916</value>
-    <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-Jujezi1871/agent.1871</value>
+    <value type="QString">SSH_AGENT_PID=1913</value>
+    <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-HoJAfw1868/agent.1868</value>
     <value type="QString">USER=onil</value>
     <value type="QString">WINDOWPATH=7</value>
     <value type="QString">XCURSOR_THEME=oxy-white</value>
     <value type="QString">XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share</value>
-    <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270150721.823040-135122461</value>
+    <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270414262.693559-1541288722</value>
     <value type="QString">XDM_MANAGED=method=classic</value>
    </valuelist>
    <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>