From 7f60114eb5e7979742782f8e0d82a3637cd4c800 Mon Sep 17 00:00:00 2001 From: onil Date: Sat, 13 Feb 2010 11:21:41 +0000 Subject: [PATCH] git-svn-id: file:///svnroot/family-shop-mgr@21 26eb2498-383b-47a6-be48-5d6f36779e85 --- .../FamilyShoppingManagerMainWindow.cpp | 5 ++++ code/family-shop-mgr/GoShoppingView.cpp | 2 ++ code/family-shop-mgr/ListManagerView.cpp | 3 +++ code/family-shop-mgr/ShoppingTreeItem.cpp | 16 +++++++++++++ code/family-shop-mgr/ShoppingTreeModel.cpp | 25 +++++++++++++++++++- code/family-shop-mgr/main.cpp | 1 + 6 files changed, 51 insertions(+), 1 deletion(-) diff --git a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp index e962014..fe8187c 100644 --- a/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp +++ b/code/family-shop-mgr/FamilyShoppingManagerMainWindow.cpp @@ -26,6 +26,7 @@ #include "ListManagerView.h" #include "GoShoppingView.h" +/*******************************************************************/ FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent) : QMainWindow(parent), activityView(NULL), showCheckedItemsAction(NULL), endShoppingAction(NULL), goShoppingAction(NULL), editMenu(NULL) @@ -38,11 +39,13 @@ FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent showListManager(); } +/*******************************************************************/ FamilyShoppingManagerMainWindow::~FamilyShoppingManagerMainWindow() { delete activityView; } +/*******************************************************************/ void FamilyShoppingManagerMainWindow::showListManager() { menuBar()->clear(); @@ -70,6 +73,7 @@ void FamilyShoppingManagerMainWindow::showListManager() update(); } +/*******************************************************************/ void FamilyShoppingManagerMainWindow::showGoShopping() { menuBar()->clear(); @@ -95,6 +99,7 @@ void FamilyShoppingManagerMainWindow::showGoShopping() update(); } +/*******************************************************************/ void FamilyShoppingManagerMainWindow::showAbout() { QString text; diff --git a/code/family-shop-mgr/GoShoppingView.cpp b/code/family-shop-mgr/GoShoppingView.cpp index 0421948..0f08744 100644 --- a/code/family-shop-mgr/GoShoppingView.cpp +++ b/code/family-shop-mgr/GoShoppingView.cpp @@ -23,6 +23,7 @@ #include "ShoppingTreeModel.h" +/*******************************************************************/ GoShoppingView::GoShoppingView(QString xmlFileName, QWidget *parent) :QTreeView(parent) { @@ -32,6 +33,7 @@ GoShoppingView::GoShoppingView(QString xmlFileName, QWidget *parent) this->resizeColumnToContents(column); } +/*******************************************************************/ GoShoppingView::~GoShoppingView() { } diff --git a/code/family-shop-mgr/ListManagerView.cpp b/code/family-shop-mgr/ListManagerView.cpp index 535444e..c9050a7 100644 --- a/code/family-shop-mgr/ListManagerView.cpp +++ b/code/family-shop-mgr/ListManagerView.cpp @@ -23,6 +23,7 @@ #include "ShoppingTreeModel.h" +/*******************************************************************/ ListManagerView::ListManagerView(QString xmlFileName, QWidget *parent) :QTreeView(parent) { @@ -32,10 +33,12 @@ ListManagerView::ListManagerView(QString xmlFileName, QWidget *parent) this->resizeColumnToContents(column); } +/*******************************************************************/ ListManagerView::~ListManagerView() { } +/*******************************************************************/ void ListManagerView::updateActions() { bool hasSelection = !this->selectionModel()->selection().isEmpty(); diff --git a/code/family-shop-mgr/ShoppingTreeItem.cpp b/code/family-shop-mgr/ShoppingTreeItem.cpp index 5f8faa1..6407767 100644 --- a/code/family-shop-mgr/ShoppingTreeItem.cpp +++ b/code/family-shop-mgr/ShoppingTreeItem.cpp @@ -21,6 +21,7 @@ #include "ShoppingTreeItem.h" +/*******************************************************************/ ShoppingTreeItem::ShoppingTreeItem(const QVector &data, ShoppingTreeItem *parent) : m_itemType(NotDefined) { @@ -28,21 +29,25 @@ ShoppingTreeItem::ShoppingTreeItem(const QVector &data, itemData = data; } +/*******************************************************************/ ShoppingTreeItem::~ShoppingTreeItem() { qDeleteAll(childItems); } +/*******************************************************************/ ShoppingTreeItem *ShoppingTreeItem::child(int number) { return childItems.value(number); } +/*******************************************************************/ int ShoppingTreeItem::childCount() const { return childItems.count(); } +/*******************************************************************/ int ShoppingTreeItem::childNumber() const { if (parentItem) @@ -51,16 +56,19 @@ int ShoppingTreeItem::childNumber() const return 0; } +/*******************************************************************/ int ShoppingTreeItem::columnCount() const { return itemData.count(); } +/*******************************************************************/ QVariant ShoppingTreeItem::data(int column) const { return itemData.value(column); } +/*******************************************************************/ bool ShoppingTreeItem::insertChildren(int position, int count, int columns) { if (position < 0 || position > childItems.size()) @@ -76,6 +84,7 @@ bool ShoppingTreeItem::insertChildren(int position, int count, int columns) return true; } +/*******************************************************************/ bool ShoppingTreeItem::insertColumns(int position, int columns) { if (position < 0 || position > itemData.size()) @@ -90,11 +99,13 @@ bool ShoppingTreeItem::insertColumns(int position, int columns) return true; } +/*******************************************************************/ ShoppingTreeItem *ShoppingTreeItem::parent() { return parentItem; } +/*******************************************************************/ bool ShoppingTreeItem::removeChildren(int position, int count) { if (position < 0 || position + count > childItems.size()) @@ -110,6 +121,7 @@ bool ShoppingTreeItem::removeChildren(int position, int count) return true; } +/*******************************************************************/ bool ShoppingTreeItem::removeColumns(int position, int columns) { if (position < 0 || position + columns > itemData.size()) @@ -124,6 +136,7 @@ bool ShoppingTreeItem::removeColumns(int position, int columns) return true; } +/*******************************************************************/ bool ShoppingTreeItem::setData(int column, const QVariant &value) { if (column < 0 || column >= itemData.size()) @@ -137,6 +150,7 @@ bool ShoppingTreeItem::setData(int column, const QVariant &value) return true; } +/*******************************************************************/ bool ShoppingTreeItem::setItemType(ItemType type) { if(type == NotDefined) @@ -150,11 +164,13 @@ bool ShoppingTreeItem::setItemType(ItemType type) return (m_itemType == type) ? true : false; } +/*******************************************************************/ ShoppingTreeItem::ItemType ShoppingTreeItem::getItemType() const { return m_itemType; } +/*******************************************************************/ void ShoppingTreeItem::waitItemTypeDefinition() { m_typeSemaphore.acquire(); diff --git a/code/family-shop-mgr/ShoppingTreeModel.cpp b/code/family-shop-mgr/ShoppingTreeModel.cpp index 0a65d9d..5f2985f 100644 --- a/code/family-shop-mgr/ShoppingTreeModel.cpp +++ b/code/family-shop-mgr/ShoppingTreeModel.cpp @@ -26,6 +26,7 @@ #include #include +/*******************************************************************/ ShoppingTreeModel::ShoppingTreeModel(const QString &xmlFileName, QObject *parent) : QAbstractItemModel(parent), m_document("ShoppingList") @@ -107,11 +108,13 @@ QAbstractItemModel(parent), m_document("ShoppingList") } } +/*******************************************************************/ ShoppingTreeModel::~ShoppingTreeModel() { delete rootItem; } +/*******************************************************************/ QVariant ShoppingTreeModel::data(const QModelIndex &index, int role) const { if(!index.isValid()) @@ -124,6 +127,7 @@ QVariant ShoppingTreeModel::data(const QModelIndex &index, int role) const return item->data(index.column()); } +/*******************************************************************/ Qt::ItemFlags ShoppingTreeModel::flags(const QModelIndex &index) const { if(!index.isValid()) @@ -132,6 +136,7 @@ Qt::ItemFlags ShoppingTreeModel::flags(const QModelIndex &index) const return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; } +/*******************************************************************/ ShoppingTreeItem *ShoppingTreeModel::getItem(const QModelIndex &index) const { if(index.isValid()){ @@ -142,6 +147,7 @@ ShoppingTreeItem *ShoppingTreeModel::getItem(const QModelIndex &index) const return rootItem; } +/*******************************************************************/ QVariant ShoppingTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -151,6 +157,7 @@ QVariant ShoppingTreeModel::headerData(int section, Qt::Orientation orientation, return QVariant(); } +/*******************************************************************/ QModelIndex ShoppingTreeModel::index(int row, int column, const QModelIndex &parent) const { if(parent.isValid() && parent.column() != 0) @@ -165,6 +172,7 @@ QModelIndex ShoppingTreeModel::index(int row, int column, const QModelIndex &par return QModelIndex(); } +/*******************************************************************/ bool ShoppingTreeModel::insertColumns(int position, int columns, const QModelIndex &parent) { bool success; @@ -176,6 +184,7 @@ bool ShoppingTreeModel::insertColumns(int position, int columns, const QModelInd return success; } +/*******************************************************************/ bool ShoppingTreeModel::insertRows(int position, int rows, const QModelIndex &parent) { ShoppingTreeItem *parentItem = getItem(parent); @@ -188,6 +197,7 @@ bool ShoppingTreeModel::insertRows(int position, int rows, const QModelIndex &pa return success; } +/*******************************************************************/ QModelIndex ShoppingTreeModel::parent(const QModelIndex &index) const { if(!index.isValid()) @@ -202,6 +212,7 @@ QModelIndex ShoppingTreeModel::parent(const QModelIndex &index) const return createIndex(parentItem->childNumber(), 0, parentItem); } +/*******************************************************************/ bool ShoppingTreeModel::removeColumns(int position, int columns, const QModelIndex &parent) { bool success; @@ -216,6 +227,7 @@ bool ShoppingTreeModel::removeColumns(int position, int columns, const QModelInd return success; } +/*******************************************************************/ bool ShoppingTreeModel::removeRows(int position, int rows, const QModelIndex &parent) { ShoppingTreeItem *parentItem = getItem(parent); @@ -228,6 +240,7 @@ bool ShoppingTreeModel::removeRows(int position, int rows, const QModelIndex &pa return success; } +/*******************************************************************/ int ShoppingTreeModel::rowCount(const QModelIndex &parent) const { ShoppingTreeItem *parentItem = getItem(parent); @@ -235,10 +248,13 @@ int ShoppingTreeModel::rowCount(const QModelIndex &parent) const return parentItem->childCount(); } +/*******************************************************************/ int ShoppingTreeModel::columnCount(const QModelIndex &parent) const { return rootItem->columnCount(); } + +/*******************************************************************/ bool ShoppingTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) { if(role != Qt::EditRole) @@ -260,6 +276,7 @@ bool ShoppingTreeModel::setData(const QModelIndex &index, const QVariant &value, return result; } +/*******************************************************************/ bool ShoppingTreeModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { @@ -274,6 +291,7 @@ bool ShoppingTreeModel::setHeaderData(int section, Qt::Orientation orientation, return result; } +/*******************************************************************/ void ShoppingTreeModel::registerInsertedChild(ShoppingTreeItem *item) { // wait until item type is defined @@ -297,6 +315,7 @@ void ShoppingTreeModel::registerInsertedChild(ShoppingTreeItem *item) SLOT(deleteRemovedChild(ShoppingTreeItem*))); } +/*******************************************************************/ void ShoppingTreeModel::deleteRemovedChild(ShoppingTreeItem *item) { QDomElement element = m_domElementForItem.value(item); @@ -306,6 +325,7 @@ void ShoppingTreeModel::deleteRemovedChild(ShoppingTreeItem *item) m_domElementForItem.remove(item); } +/*******************************************************************/ void ShoppingTreeModel::parseCategoryElement(const QDomElement &element, ShoppingTreeItem *parentItem) { @@ -367,6 +387,7 @@ void ShoppingTreeModel::parseCategoryElement(const QDomElement &element, } } +/*******************************************************************/ QVector ShoppingTreeModel::getColumnsFromItemElement(const QDomElement &element) { QVector data; @@ -383,6 +404,7 @@ QVector ShoppingTreeModel::getColumnsFromItemElement(const QDomElement return data; } +/*******************************************************************/ bool ShoppingTreeModel::updateDomElement(ShoppingTreeItem *item, int column) { QDomElement element = m_domElementForItem.value(item); @@ -391,7 +413,7 @@ bool ShoppingTreeModel::updateDomElement(ShoppingTreeItem *item, int column) return false; bool success; - switch(column) + switch(column)/*******************************************************************/ { case 0: { @@ -438,6 +460,7 @@ bool ShoppingTreeModel::updateDomElement(ShoppingTreeItem *item, int column) return success; } +/*******************************************************************/ void ShoppingTreeModel::updateXmlFile() const { QFile xmlFile(m_xmlFileName); diff --git a/code/family-shop-mgr/main.cpp b/code/family-shop-mgr/main.cpp index 670e43f..a602825 100644 --- a/code/family-shop-mgr/main.cpp +++ b/code/family-shop-mgr/main.cpp @@ -22,6 +22,7 @@ #include #include "FamilyShoppingManagerMainWindow.h" +/*******************************************************************/ int main(int argc, char *argv[]) { QApplication a(argc, argv); -- 1.7.9.5