From f1ecd585f7e35faf5618ada92d04e23986f9d742 Mon Sep 17 00:00:00 2001 From: onil Date: Wed, 7 Apr 2010 20:18:05 +0000 Subject: [PATCH] git-svn-id: file:///svnroot/family-shop-mgr@31 26eb2498-383b-47a6-be48-5d6f36779e85 --- .../FamilyShoppingManagerMainWindow.cpp | 70 +++++++------------- .../FamilyShoppingManagerMainWindow.h | 1 - code/family-shop-mgr/GoShoppingView.cpp | 5 ++ code/family-shop-mgr/ListManagerView.cpp | 5 ++ code/family-shop-mgr/ShoppingTreeModel.cpp | 7 ++ code/family-shop-mgr/ShoppingTreeModel.h | 1 + code/family-shop-mgr/family-shop-mgr.pro.user | 24 +++---- 7 files changed, 55 insertions(+), 58 deletions(-) diff --git a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp index 6407261..269c3fe 100644 --- a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp +++ b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp @@ -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*) diff --git a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.h b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.h index fe55da6..3187ca5 100644 --- a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.h +++ b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.h @@ -47,7 +47,6 @@ private slots: private: QWidget *activityView; -// QMenu *editMenu; QAction *showCheckedItemsAction; QAction *goShoppingAction; QAction *endShoppingAction; diff --git a/code/family-shop-mgr/GoShoppingView.cpp b/code/family-shop-mgr/GoShoppingView.cpp index 0f08744..37275e4 100644 --- a/code/family-shop-mgr/GoShoppingView.cpp +++ b/code/family-shop-mgr/GoShoppingView.cpp @@ -29,6 +29,11 @@ GoShoppingView::GoShoppingView(QString xmlFileName, QWidget *parent) { ShoppingTreeModel *model = new ShoppingTreeModel(xmlFileName, this); this->setModel(model); + this->setAnimated(true); + this->setAutoExpandDelay(1); + this->setAutoScroll(true); + this->setExpandsOnDoubleClick(true); + this->setSortingEnabled(true); for(int column = 0; column < model->columnCount(); column++) this->resizeColumnToContents(column); } diff --git a/code/family-shop-mgr/ListManagerView.cpp b/code/family-shop-mgr/ListManagerView.cpp index 11a8f52..99816fb 100644 --- a/code/family-shop-mgr/ListManagerView.cpp +++ b/code/family-shop-mgr/ListManagerView.cpp @@ -29,6 +29,11 @@ ListManagerView::ListManagerView(QString xmlFileName, QWidget *parent) { ShoppingTreeModel *model = new ShoppingTreeModel(xmlFileName, this); this->setModel(model); + this->setAnimated(true); + this->setAutoExpandDelay(1); + this->setAutoScroll(true); + this->setExpandsOnDoubleClick(true); + this->setSortingEnabled(true); for(int column = 0; column < model->columnCount(); column++) this->resizeColumnToContents(column); } diff --git a/code/family-shop-mgr/ShoppingTreeModel.cpp b/code/family-shop-mgr/ShoppingTreeModel.cpp index a9289fe..28dd5d0 100644 --- a/code/family-shop-mgr/ShoppingTreeModel.cpp +++ b/code/family-shop-mgr/ShoppingTreeModel.cpp @@ -571,3 +571,10 @@ void ShoppingTreeModel::updateXmlFile() const xmlFile.write(m_document.toByteArray(4)); xmlFile.close(); } + +/*******************************************************************/ +void ShoppingTreeModel::sort(int column, Qt::SortOrder order) +{ + // TODO: implement sorting + ; +} diff --git a/code/family-shop-mgr/ShoppingTreeModel.h b/code/family-shop-mgr/ShoppingTreeModel.h index 66829bf..8535e62 100644 --- a/code/family-shop-mgr/ShoppingTreeModel.h +++ b/code/family-shop-mgr/ShoppingTreeModel.h @@ -61,6 +61,7 @@ public: int role = Qt::EditRole); bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); + void sort(int column, Qt::SortOrder order); private: bool insertColumns(int position, int columns, diff --git a/code/family-shop-mgr/family-shop-mgr.pro.user b/code/family-shop-mgr/family-shop-mgr.pro.user index b211d51..eab2836 100644 --- a/code/family-shop-mgr/family-shop-mgr.pro.user +++ b/code/family-shop-mgr/family-shop-mgr.pro.user @@ -97,11 +97,11 @@ Debug - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0wQ6AlJh5H,guid=16ecdce81ddd2a3efe739bea4bb4f643 + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YZNnnsfbiV,guid=cb79688c9fb6e8c85ff790f94bb8fbb8 DESKTOP_SESSION=default DISPLAY=:0.0 DM_CONTROL=/var/run/xdmctl - GPG_AGENT_INFO=/tmp/gpg-wgd2ui/S.gpg-agent:1917:1 + GPG_AGENT_INFO=/tmp/gpg-27YKzu/S.gpg-agent:1914:1 GS_LIB=/home/onil/.fonts 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 GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc @@ -117,16 +117,16 @@ PWD=/home/onil/Documents QTDIR=/usr/share/qt4 QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/ - SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2008,unix/onil-netbook:/tmp/.ICE-unix/2008 + SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2004,unix/onil-netbook:/tmp/.ICE-unix/2004 SHELL=/bin/bash SHLVL=0 - SSH_AGENT_PID=1916 - SSH_AUTH_SOCK=/tmp/ssh-Jujezi1871/agent.1871 + SSH_AGENT_PID=1913 + SSH_AUTH_SOCK=/tmp/ssh-HoJAfw1868/agent.1868 USER=onil WINDOWPATH=7 XCURSOR_THEME=oxy-white XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share - XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270150721.823040-135122461 + XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270414262.693559-1541288722 XDM_MANAGED=method=classic @@ -147,11 +147,11 @@ Debug - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0wQ6AlJh5H,guid=16ecdce81ddd2a3efe739bea4bb4f643 + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YZNnnsfbiV,guid=cb79688c9fb6e8c85ff790f94bb8fbb8 DESKTOP_SESSION=default DISPLAY=:0.0 DM_CONTROL=/var/run/xdmctl - GPG_AGENT_INFO=/tmp/gpg-wgd2ui/S.gpg-agent:1917:1 + GPG_AGENT_INFO=/tmp/gpg-27YKzu/S.gpg-agent:1914:1 GS_LIB=/home/onil/.fonts 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 GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc @@ -167,16 +167,16 @@ PWD=/home/onil/Documents QTDIR=/usr/share/qt4 QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/ - SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2008,unix/onil-netbook:/tmp/.ICE-unix/2008 + SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2004,unix/onil-netbook:/tmp/.ICE-unix/2004 SHELL=/bin/bash SHLVL=0 - SSH_AGENT_PID=1916 - SSH_AUTH_SOCK=/tmp/ssh-Jujezi1871/agent.1871 + SSH_AGENT_PID=1913 + SSH_AUTH_SOCK=/tmp/ssh-HoJAfw1868/agent.1868 USER=onil WINDOWPATH=7 XCURSOR_THEME=oxy-white XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share - XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270150721.823040-135122461 + XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1270414262.693559-1541288722 XDM_MANAGED=method=classic false -- 1.7.9.5