X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=code%2Ffamily-shop-mgr%2FGUI%2FListManagerView.cpp;fp=code%2Ffamily-shop-mgr%2FGUI%2FListManagerView.cpp;h=8dfe6eca1b9134288637747024de663fab514429;hb=72201ddd2c26ef3575f5504d2eb07b0940f8aa80;hp=0000000000000000000000000000000000000000;hpb=6d19d55e61c6fe26d16f246c06bec58b955010ca;p=family-shop-mgr diff --git a/code/family-shop-mgr/GUI/ListManagerView.cpp b/code/family-shop-mgr/GUI/ListManagerView.cpp new file mode 100644 index 0000000..8dfe6ec --- /dev/null +++ b/code/family-shop-mgr/GUI/ListManagerView.cpp @@ -0,0 +1,80 @@ +/* + * This file is part of family-shop-mgr. + * + * family-shop-mgr is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * family-shop-mgr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with family-shop-mgr. If not, see . + * + * Author: Unai IRIGOYEN + * Date: 12/17/2009 + * + */ + +#include "ListManagerView.h" + +#include "ShoppingTreeModel.h" + +/*******************************************************************/ +ListManagerView::ListManagerView(QString xmlFileName, QWidget *parent) + :QTreeView(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); +} + +/*******************************************************************/ +ListManagerView::~ListManagerView() +{ +} + +/*******************************************************************/ +void ListManagerView::updateActions() +{ + /* + bool hasSelection = !this->selectionModel()->selection().isEmpty(); + removeRowAction->setEnabled(hasSelection); + removeColumnAction->setEnabled(hasSelection); + + bool hasCurrent = this->selectionModel()->currentIndex().isValid(); + insertRowAction->setEnabled(hasCurrent); + insertColumnAction->setEnabled(hasCurrent); + + if (hasCurrent) + { + this->closePersistentEditor(view->selectionModel()->currentIndex()); + + int row = this->selectionModel()->currentIndex().row(); + int column = this->selectionModel()->currentIndex().column(); + if (this->selectionModel()->currentIndex().parent().isValid()) + statusBar()->showMessage(tr("Position: (%1,%2)").arg(row).arg(column)); + else + statusBar()->showMessage(tr("Position: (%1,%2) in top level").arg(row).arg(column)); + } + */ +} + +bool ListManagerView::addCategory(QString name) +{ + return ((ShoppingTreeModel*) this->model())->addCategory(this->selectedIndexes().last(), name); +} + +bool ListManagerView::addItem(QString name) +{ + return ((ShoppingTreeModel*) this->model())->addItem(this->selectedIndexes().last(), name); +}