[gtest-runner-qt] r34 committed - Created a new 'MetaModel' and meta data concept which is used to displ...

10 views
Skip to first unread message

gtest-r...@googlecode.com

unread,
Oct 17, 2010, 11:25:06 AM10/17/10
to gtest-r...@googlegroups.com
Revision: 34
Author: sandychapman
Date: Sun Oct 17 08:22:22 2010
Log: Created a new 'MetaModel' and meta data concept which is used to
display the test results into a second treeview.
Made quite a few small changes here and there as improvements.

http://code.google.com/p/gtest-runner-qt/source/detail?r=34

Added:
/trunk/include/MetaItem.h
/trunk/include/MetaModel.h
/trunk/include/TreeItem.h
/trunk/include/TreeModel.h
/trunk/src/MetaItem.cpp
/trunk/src/MetaModel.cpp
/trunk/src/TreeItem.cpp
/trunk/src/TreeModel.cpp
Modified:
/trunk/GTestRunner.pro
/trunk/Makefile
/trunk/Makefile.Debug
/trunk/Makefile.Release
/trunk/include/GTestResults.h
/trunk/include/GTestRunner.h
/trunk/include/TestTreeModel.h
/trunk/resources/gtestrunner.ui
/trunk/src/GTestParser.cpp
/trunk/src/GTestResults.cpp
/trunk/src/GTestRunner.cpp
/trunk/src/TestTreeItem.cpp
/trunk/src/TestTreeModel.cpp

=======================================
--- /dev/null
+++ /trunk/include/MetaItem.h Sun Oct 17 08:22:22 2010
@@ -0,0 +1,40 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-26 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef METAITEM_H
+#define METAITEM_H
+
+#include "TreeItem.h"
+
+#include <QAbstractItemModel>
+#include <QList>
+#include <QSharedPointer>
+#include <QVariant>
+
+class MetaItem : public TreeItem {
+
+private:
+ QAbstractItemModel* sourceModel;
+
+public:
+ MetaItem(QList<QMap<int, QVariant> >& data, MetaItem* parent = 0);
+ virtual ~MetaItem();
+
+};
+
+Q_DECLARE_METATYPE(MetaItem*);
+
+#endif // METAITEM_H
=======================================
--- /dev/null
+++ /trunk/include/MetaModel.h Sun Oct 17 08:22:22 2010
@@ -0,0 +1,57 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-25 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef TESTRESULTSMODEL_H
+#define TESTRESULTSMODEL_H
+
+#include "MetaItem.h"
+#include "TreeModel.h"
+
+#include <QHash>
+#include <QItemSelection>
+#include <QItemSelectionModel>
+
+class MetaModel : public TreeModel {
+
+ Q_OBJECT;
+
+private:
+ QItemSelectionModel* selectionModel; //!< The selection model to
determine which elements are shown.
+ QItemSelection currentlySelected; //!< The currently selected model
indices.
+ QAbstractItemModel* itemModel; //!< The item model whose meta data
we show
+
+public slots:
+ void updateModel(QItemSelection selected, QItemSelection deselected);
+ void removeItem(const QModelIndex& index);
+ void insertItem(const QModelIndex& index);
+
+public:
+
+ MetaModel();
+ virtual ~MetaModel();
+
+ void setSelectionModel(QItemSelectionModel* model);
+ void setItemModel(TreeModel* model);
+};
+
+//! We fugde some Qt namespace stuff to make it look like
+//! meta data is a Qt defined role. Not sure if this is a
+//! good practice, but whatever.
+namespace Qt {
+ const int MetaDataRole = Qt::UserRole + 100;
+}
+
+#endif // TESTRESULTSMODEL_H
=======================================
--- /dev/null
+++ /trunk/include/TreeItem.h Sun Oct 17 08:22:22 2010
@@ -0,0 +1,176 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TreeItem.h - Created on 2010-08-28
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef TREEITEM_H_
+#define TREEITEM_H_
+
+#include <QList>
+#include <QMap>
+#include <QQueue>
+#include <QSharedPointer>
+#include <QVariant>
+
+/*! \brief A constituent item of the TreeModel.
+ *
+ * TreeItems make up the body of the TreeModel. They are what hold the data
+ * and the relations between them. Together, the items form a tree which
reflects
+ * the relations between an executable to a suite to a case.
+ * \todo Should I just make this a full blown private subclass of QList?
+ */
+class TreeItem {
+
+public:
+ TreeItem();
+ TreeItem(QList<QMap<int, QVariant> >& data, TreeItem* parent = 0);
+ virtual ~TreeItem();
+
+ void appendChild(TreeItem* child);
+ TreeItem* child(int row) const;
+ int childCount() const;
+ QList<TreeItem* > children() const;
+ int column() const;
+ int columnCount() const;
+ QVariant data(int column, int role) const;
+ QList<QMap<int, QVariant> > data() const;
+ TreeItem* findChild(const QVariant& value, int role) const;
+ bool insertChild(int row, TreeItem* child);
+ bool insertChildren(int row, QList<TreeItem* > children);
+ TreeItem* parent();
+ void removeAllChildren();
+ bool removeChild(TreeItem* child);
+ void removeChildAt(int index);
+ int row() const;
+ bool setData(const QVariant& value, int column, int role);
+ bool setData(const QList<QMap<int, QVariant> >& data);
+
+
+private:
+ QList<TreeItem* > childItems; //!< The children of the TreeItem
+ //!< The data for this item, first indexed by column, then by role.
+ QList<QMap<int, QVariant> > itemData;
+ TreeItem* parentItem; //!< The parent of this item.
+
+ void setParent(TreeItem* parent);
+};
+
+Q_DECLARE_METATYPE(TreeItem*);
+
+/*! \brief Removes all children from this tree item.
+ *
+ * This removes all the children from the tree item. The caller should
+ * be careful as this does not delete the children. Thus, if the only
+ * reference to these children are held in this item, then they should
+ * be sure to call delete on the children.
+ */
+inline void TreeItem::removeAllChildren() { childItems.clear(); }
+
+/*! \brief Removes the child specified at the index given.
+ *
+ * If the index given is larger than the number of children, or less
+ * than 0, this function does nothing.
+ * \param index The index of the child to remove.
+ */
+inline void TreeItem::removeChildAt(int index) {
childItems.removeAt(index); }
+
+/*! \brief Removes the child given from this tree item.
+ *
+ * \param child The child to remove.
+ * \return true if the child is removed, false otherwise.
+ */
+inline bool TreeItem::removeChild(TreeItem* child) { return
childItems.removeOne(child); }
+
+/*! \brief Retrieves a pointer to the child in row 'row'.
+ *
+ * If the row is invalid (less than 0 or greater or equal to the number
+ * of children, a null pointer is returned.
+ * \param row The index of the child.
+ * \return null if row is invalid, a pointer to the child in row 'row
otherwise.
+ */
+inline TreeItem* TreeItem::child(int row) const { return
childItems.value(row); }
+
+/*! \brief Retrieves a list of all the children held by this item.
+ *
+ * \return A list of the children held by this item.
+ */
+inline QList<TreeItem* > TreeItem::children() const { return childItems; }
+
+/*! \brief Retrieves the number of children held by this object.
+ *
+ * \return The number of children.
+ */
+inline int TreeItem::childCount() const { return childItems.count(); }
+
+/*! \brief Retrieves the number of columns this index has.
+ *
+ * Currently, this is fixed at one, but this may be changed in the future.
+ * \return The number of columns (one).
+ */
+inline int TreeItem::columnCount() const { return 1; }
+
+/*! \brief Inserts a child in this item before the item indexed at row.
+ *
+ * The row parameter will become the index of this child when inserted.
+ * If the index is greater than the number of children, or less than 0,
+ * this function does nothing and returns false.
+ * \param row The row to insert this item before.
+ * \param child The child to insert into this item.
+ * \return true if the child was successfully inserted, false otherwise.
+ */
+inline bool TreeItem::insertChild(int row, TreeItem* child) {
+ if(row < 0 || row > childItems.size() || !child)
+ return false;
+ if(child->parent())
+ child->parent()->removeChild(child);
+ child->setParent(this);
+ if(!childItems.contains(child))
+ childItems.insert(row, child);
+ return true;
+}
+
+/*! \brief Inserts the list of children given at the index 'row'.
+ *
+ * The row parameter will become the index of the first item in
+ * the list. If the row parameter is greater than the number of children
+ * or less than 0, this function does nothing and returns false.
+ * \param row The row to insert this item before.
+ * \param children The list of children to insert into this item.
+ * \return true if the children were successfully inserted, false
otherwise.
+ */
+inline bool TreeItem::insertChildren(int row, QList<TreeItem* > children) {
+ if(row < 0 || row > childItems.size())
+ return false;
+ TreeItem* child;
+ foreach(child, children)
+ childItems.insert(row++, child);
+ return true;
+}
+
+/*! \brief Retrieves the column this item is in.
+ *
+ * Currently, we only support a single column, so this is always 0.
+ * \return The column this item is in (zero).
+ */
+inline int TreeItem::column() const { return 0; }
+
+/*! \brief Sets the parent of the current tree item.
+ *
+ * This function should only be used by the call insertChild
+ * so as to maintain consistency in parent-child relations.
+ * \param parent The new parent item.
+ */
+inline void TreeItem::setParent(TreeItem *parent) { this->parentItem =
parent; }
+
+#endif /* TREEITEM_H_ */
=======================================
--- /dev/null
+++ /trunk/include/TreeModel.h Sun Oct 17 08:22:22 2010
@@ -0,0 +1,50 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-26 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#ifndef TREEMODEL_H
+#define TREEMODEL_H
+
+#include <QAbstractItemModel>
+
+#include "TreeItem.h"
+
+class TreeModel : public QAbstractItemModel {
+
+ Q_OBJECT;
+
+signals:
+ void metaDataAboutToBeChanged(const QModelIndex& index);
+
+protected:
+ TreeItem rootItem; //<! The root of the data model. It's data is shown in
the header.
+
+public:
+ TreeModel(QObject* parent = 0);
+ virtual ~TreeModel();
+
+ virtual QVariant data(const QModelIndex& index, int role =
Qt::DisplayRole) const;
+ virtual Qt::ItemFlags flags(const QModelIndex& index) const;
+ virtual QVariant headerData(int secton, Qt::Orientation orientation, int
role = Qt::DisplayRole) const;
+ virtual QModelIndex index(int row, int column, const QModelIndex& parent
= QModelIndex()) const;
+ virtual bool insertItem(TreeItem* item, int row, TreeItem* parent);
+ virtual bool insertItems(const QList<TreeItem* > items, int row,
TreeItem* parent);
+ virtual QModelIndex parent(const QModelIndex& index) const;
+ virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual bool setData(const QModelIndex& index, const QVariant& value, int
role = Qt::EditRole);
+};
+
+#endif // TREEMODEL_H
=======================================
--- /dev/null
+++ /trunk/src/MetaItem.cpp Sun Oct 17 08:22:22 2010
@@ -0,0 +1,26 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-26 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include <QMap>
+
+#include "MetaItem.h"
+
+MetaItem::MetaItem(QList<QMap<int, QVariant> >& data, MetaItem* parent)
+ : TreeItem(data, parent)
+{}
+
+MetaItem::~MetaItem()
+{}
=======================================
--- /dev/null
+++ /trunk/src/MetaModel.cpp Sun Oct 17 08:22:22 2010
@@ -0,0 +1,226 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-26 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include <QSharedPointer>
+#include <QStack>
+
+#include "MetaModel.h"
+
+/*! \brief Constructor
+ *
+ */
+MetaModel::MetaModel()
+ : selectionModel(0), itemModel(0)
+{}
+
+/*! \brief Destructor
+ *
+ */
+MetaModel::~MetaModel() {
+
+}
+
+/*! \brief Sets the selection model to use for the meta model.
+ *
+ * \param model The selection model this should use as the metamodel.
+ */
+void MetaModel::setSelectionModel(QItemSelectionModel *model) {
+ if(this->selectionModel)
+ this->disconnect(this, SLOT(updateModel(QItemSelection,
QItemSelection)));
+ this->selectionModel = model;
+ if(model == 0)
+ return;
+ QObject::connect(this->selectionModel,
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(updateModel(QItemSelection, QItemSelection)));
+ //other signals to perhaps connect:
+ //void currentChanged (const QModelIndex& current, const QModelIndex&
previous)
+ //void currentColumnChanged (const QModelIndex& current, const
QModelIndex& previous)
+ //void currentRowChanged (const QModelIndex& current, const QModelIndex&
previous)
+}
+
+/*! \brief Sets the item model whose meta data this model shows.
+ *
+ * This function handles connecting the signal/slot relations to the
+ * underlying model.
+ * \param model The model to set as the base for the meta model.
+ */
+void MetaModel::setItemModel(TreeModel* model) {
+ if(this->itemModel)
+ QObject::disconnect(this->itemModel,
SIGNAL(metaDataAboutToBeChanged(const QModelIndex&)),
+ this, SLOT(removeItem(const QModelIndex&)));
+ this->itemModel = model;
+ QObject::connect(model, SIGNAL(metaDataAboutToBeChanged(const
QModelIndex&)),
+ this, SLOT(removeItem(const QModelIndex&)));
+}
+
+/*! \brief This function updates the model when the current selection has
changed.
+ *
+ * \code
+ * Algorithm:
+ * for each item in deselected
+ * remove item from model (removes children)
+ * for each child of item
+ * if child was in selectedIndices
+ * re-add child and its children to model
+ * for each item in selected
+ * add item to model
+ * for each child index of item, child
+ * add child as child of item in model
+ * remove child from selected
+ * update selectedIndices
+ * \endcode
+ * This function is a slot that gets hooked up to \see
QSelectionModel::selectionChanged().
+ * \param selected The newly selected elements.
+ * \param deselected The newly deselected elements.
+ */
+void MetaModel::updateModel(QItemSelection selected, QItemSelection
deselected) {
+
+ QModelIndexList indices = deselected.indexes();
+ QModelIndexList::iterator it = indices.begin();
+ while(it != indices.end()) {
+ this->removeItem(*it);
+ ++it;
+ }
+
+ indices = selected.indexes();
+ it = indices.begin();
+ while(it != indices.end()) {
+ this->insertItem(*it);
+ ++it;
+ }
+ emit layoutChanged();
+
+ this->currentlySelected.merge(selected, QItemSelectionModel::Select);
+ this->currentlySelected.merge(deselected, QItemSelectionModel::Deselect);
+
+}
+
+/*! \brief Removes an item from the meta model.
+ *
+ * It is the job of this function to remove items from the model.
+ * This involves removing the item and ensuring that items (such
+ * as children of the removed item) that are still selected, still
+ * appear in the model.
+ * \param index The index of the itemModel to remove from the meta model.
+ */
+void MetaModel::removeItem(const QModelIndex& index) {
+ //Remove the item from our list of selected indices
+ if(this->currentlySelected.contains(index))
+ this->currentlySelected.merge(QItemSelection (index, index),
QItemSelectionModel::Deselect);
+
+ //Remove the item from the model
+ MetaItem* metaItem = itemModel->data(index,
Qt::MetaDataRole).value<MetaItem*>();
+ if(metaItem) {
+ this->beginRemoveRows(createIndex(0, 0, &rootItem), metaItem->row(),
metaItem->row());
+ if(!rootItem.removeChild(metaItem)) {
+ //metaItem exists, and it is not a rootItem (pointers are probably
different now)
+ //For now, we just assume that all indices are children of the rootItem.
+ TreeItem* item = rootItem.findChild(QVariant(metaItem->data(0,
Qt::DisplayRole)), Qt::DisplayRole);
+ if(item) {
+ rootItem.removeChild(item);
+ //! \todo Use QSharedPointer's for the metaitems.
+ }
+ }
+ this->endRemoveRows();
+ }
+
+ //we're going to recursively search the children of *it
+ //to see if we should keep them selected
+ QStack<QModelIndex> searchStack;
+ searchStack.push(index.child(0, 0));
+ while(!searchStack.isEmpty()) {
+ QModelIndex currentIndex = searchStack.pop();
+
+ //add the valid children to the stack
+ QModelIndex child = currentIndex.child(0, 0);
+ while(child.isValid()) {
+ searchStack.push(child);
+ child = child.sibling(child.row()+1, 0);
+ }
+
+ //add the sibling to the stack if valid (next in traversal)
+ QModelIndex sibling = currentIndex.sibling(currentIndex.row()+1, 0);
+ if(sibling.isValid())
+ searchStack.push(sibling);
+
+ //re-add to the model if selected
+ if(this->currentlySelected.contains(currentIndex))
+ this->insertItem(currentIndex);
+ }
+}
+
+/*! \brief Inserts an element specified by index into the meta model.
+ *
+ * This function manages the insertion of elements. Its job is to maintain
+ * a consistent layout for the displaying of the model. This means that if
+ * a parent element is shown, its children must be shown as well. Best way
+ * to learn how it works, is to actually run the app and play with the
+ * meta model selection.
+ * \param index The index of the itemModel whose metadata we want to add.
+ */
+void MetaModel::insertItem(const QModelIndex& index) {
+
+ //Add the index to our selected list
+ if(this->currentlySelected.contains(index))
+ this->currentlySelected.merge(QItemSelection (index, index),
QItemSelectionModel::Select);
+
+ //first, check if parent is selected, if so, we do nothing.
+ QModelIndex parent = index.parent();
+ while(parent.isValid()) {
+ if(this->currentlySelected.contains(parent))
+ return;
+ parent = parent.parent();
+ }
+
+ //next, insert the item and its children
+
+ //insert the item
+ MetaItem* metaItem = itemModel->data(index,
Qt::MetaDataRole).value<MetaItem*>();
+ if(metaItem) {
+ TreeModel::insertItem(metaItem, rootItem.childCount(), &rootItem);
+
+ //we're going to recursively iterate over the children
+ //and add them (or move them if they're already there) to the model.
+ QStack<QModelIndex> stack;
+ MetaItem* currentMetaItem;
+ MetaItem* childMetaItem;
+ stack.push(index);
+ while(!stack.isEmpty()) {
+ QModelIndex currentIndex = stack.pop();
+ currentMetaItem = itemModel->data(currentIndex,
Qt::MetaDataRole).value<MetaItem*>();
+ //currentMetaItem->removeAllChildren();
+
+ //add the valid children to the stack
+ QModelIndex child = currentIndex.child(0, 0);
+ while(child.isValid()) {
+ stack.push(child);
+ childMetaItem = itemModel->data(child,
Qt::MetaDataRole).value<MetaItem*>();
+ TreeModel::insertItem(childMetaItem, currentMetaItem->childCount(),
currentMetaItem);
+ child = child.sibling(child.row()+1, 0);
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
=======================================
--- /dev/null
+++ /trunk/src/TreeItem.cpp Sun Oct 17 08:22:22 2010
@@ -0,0 +1,127 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * TreeItem.cpp - Created on 2010-08-29
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include "TreeItem.h"
+
+/*! \brief Constructor
+ *
+ */
+TreeItem::TreeItem()
+ : childItems(), itemData(), parentItem(0)
+{}
+
+/*! \brief Constructor
+ *
+ * \param data The list of data to assign to this item. The QMap should map
+ * between a Qt::ItemDataRole and the QVariant with the data.
+ * \param parent The parent of this item.
+ */
+TreeItem::TreeItem(QList<QMap<int, QVariant> >& data, TreeItem* parent)
+: childItems(), itemData(data), parentItem(parent)
+{}
+
+/*! \brief Destructor
+ *
+ */
+TreeItem::~TreeItem()
+{}
+
+/*! \brief Appends the child to the end of this item.
+ *
+ * \param child A pointer to the child to append.
+ */
+void TreeItem::appendChild(TreeItem* child) {
+ childItems.append(child);
+}
+
+/*! \brief Retrieves the data item specified by the role (a
Qt::ItemDataRole).
+ *
+ * \param role A value from Qt::ItemDataRole specifying a model role.
+ * \return A variant holding the data.
+ */
+QVariant TreeItem::data(int column, int role) const {
+ if(column >= itemData.length())
+ return QVariant();
+ return itemData.at(column).value(role);
+}
+
+/*! \brief Retrieves a pointer to the parent of this item.
+ *
+ * \return A pointer to the parent of this item.
+ */
+TreeItem* TreeItem::parent() {
+ return parentItem;
+}
+
+/*! \brief Retrieves the row that this item is in.
+ *
+ * The row is relative to the parent. The row this item is in,
+ * is the index of the item in the children of its parent.
+ * \return The row this item is in, or if it has no parent (the rootItem.
0.
+ */
+int TreeItem::row() const {
+ if(parentItem) {
+ TreeItem* item(const_cast<TreeItem*>(this));
+ int row = parentItem->childItems.indexOf(item);
+ return row;
+ }
+ return 0;
+}
+
+/*! \brief Sets the data for the given role to the variant 'value'.
+ *
+ * \param value The value to set for the given role.
+ * \param role The role specified from Qt::ItemDataRole.
+ * \return true if the data was set, false otherwise.
+ */
+bool TreeItem::setData(const QVariant& value, int col, int role) {
+ while(col >= itemData.length())
+ itemData.append(QMap<int, QVariant>());
+ itemData[col].insert(role, value);
+ return true;
+}
+
+/*! \brief Sets the data for the given role to the variant 'value'.
+ *
+ * \param value The value to set for the given role.
+ * \param role The role specified from Qt::ItemDataRole.
+ * \return true if the data was set, false otherwise.
+ */
+bool TreeItem::setData(const QList<QMap<int, QVariant> >& data) {
+ itemData = data;
+ return true;
+}
+
+/*! \brief Finds the child who has the value 'value' contained in the
role 'role'.
+ *
+ * If no child item is found who has the value given for the role given,
then null
+ * is returned.
+ * \param value The value to match.
+ * \param role The role to match (one of Qt::ItemDataRole).
+ * \return The child the holds the value for the given role, or null if
not found.
+ */
+TreeItem* TreeItem::findChild(const QVariant& value, int role) const {
+ QList<TreeItem* >::const_iterator it = childItems.begin();
+ while(it != childItems.end()) {
+ if((*it)->data(0, role) == value)
+ return *it;
+ ++it;
+ }
+ return 0;
+}
+
+
+
=======================================
--- /dev/null
+++ /trunk/src/TreeModel.cpp Sun Oct 17 08:22:22 2010
@@ -0,0 +1,219 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * *
+ * Created on 2010-09-26 2010
+ *
+ * Copyright (C) 2010 Sandy Chapman
+ *
+ * This library is free software; you can redistribute it and/or modify it
under the
+ * terms of the GNU Lesser General Public License as published by the Free
Software
+ * Foundation; either version 2.1 of the License, or (at your option) any
later version.
+ * This library 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 Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public
License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */
+
+#include "TreeModel.h"
+
+/*! \brief Constructor
+ *
+ */
+TreeModel::TreeModel(QObject* parent)
+: QAbstractItemModel(parent)
+{}
+
+/*! \brief Destructor
+ *
+ */
+TreeModel::~TreeModel() {}
+
+
+/*! \brief Gives a count of the number of columns contained by the
index 'parent'.
+ *
+ * If the index is invalid the number of columns contained by the
rootItem.are
+ * returned.
+ * \return The number of columns given by the index 'parent' or the number
of
+ * columns in the rootItem.is 'parent' is invalid.
+ */
+int TreeModel::columnCount(const QModelIndex& parent) const {
+ if (parent.isValid())
+ return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
+ else
+ return rootItem.columnCount();
+}
+
+/*! \brief Accesses data contained within the model.
+ *
+ * The data contained in the index 'index' for the given 'role' are
returned
+ * within a QVariant. If the index is invalid, or if the item specified by
+ * the index does not contain data for the role 'role', an empty QVariant
+ * is returned.
+ * \return The data specified by the index 'index' and the role 'role'.
+ */
+QVariant TreeModel::data(const QModelIndex& index, int role) const {
+ if (!index.isValid())
+ return QVariant();
+
+ switch(role) {
+ //list supported data accesses here.
+ case Qt::BackgroundColorRole:
+ case Qt::CheckStateRole:
+ case Qt::DisplayRole: {
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+ if(item)
+ return item->data(0, role);
+ return QVariant();
+ }
+ default:
+ return QVariant();
+ }
+}
+
+/*! \brief Returns the flags for the item specified by the given index.
+ *
+ * If the index is invalid, this function returns 0. Otherwise, items
within
+ * the TreeModel are enabled, selectable, checkable, and if they have
children,
+ * are tristate checkable.
+ * \see TreeModel::setCheckState() for more information on check states.
+ */
+Qt::ItemFlags TreeModel::flags(const QModelIndex& index) const {
+ if (!index.isValid())
+ return 0;
+
+ Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable |
Qt::ItemIsUserCheckable;
+
+ if(static_cast<TreeItem*>(index.internalPointer())->childCount() > 0)
+ flags |= Qt::ItemIsTristate;
+
+ return flags;
+}
+
+/*! \brief Retrieves the header information for the model.
+ *
+ * Section and orientation are ignored for this model. We only provide
data in
+ * one dimension so there are unnecessary. The data for the given role is
provided.
+ * \return The data for the given role.
+ */
+QVariant TreeModel::headerData(int /*section*/, Qt::Orientation
/*orientation*/, int role) const {
+ return rootItem.data(0, role);
+}
+
+/*! \brief Retrieves a model index at the specified (row, columns) from
the given parent.
+ *
+ * Retrieves a model index for the model. If parent is not specified, or
is a default
+ * constructed index, an index to a top level item is returned.
+ * \return A model index for the given row and column with the
parent 'parent'.
+ */
+QModelIndex TreeModel::index(int row, int column, const QModelIndex&
parent) const {
+ if(!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ const TreeItem* parentItem;
+ TreeItem* childItem;
+
+ if(parent.isValid())
+ parentItem = static_cast<TreeItem* >(parent.internalPointer());
+ else
+ parentItem = &rootItem;
+
+ childItem = parentItem->child(row);
+ if(childItem)
+ return createIndex(row, column, childItem);
+ return QModelIndex();
+}
+
+/*! \brief Retrieves the parent of the index provided.
+ *
+ * If the index is invalid or is a top level item, an invalid index is
returned.
+ * \return The parent of the index if it exists. An invalid index
otherwise.
+ */
+QModelIndex TreeModel::parent(const QModelIndex &index) const {
+ if (!index.isValid())
+ return QModelIndex();
+
+ TreeItem* childItem = static_cast<TreeItem* >(index.internalPointer());
+ if(!childItem || childItem == &rootItem)
+ return QModelIndex();
+
+ TreeItem* parentItem = childItem->parent();
+
+ if (!parentItem || parentItem == &rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+/*! \brief Retrieves the number of rows provided by the parent 'parent'.
+ *
+ * \return If the index is valid, the number of children held by 'parent'
is returned.
+ * Else, the number of top level items is returned.
+ */
+int TreeModel::rowCount(const QModelIndex& parent) const {
+ const TreeItem* parentItem;
+ if (parent.column() > 0)
+ return 0;
+
+ if (!parent.isValid())
+ parentItem = &rootItem;
+ else
+ parentItem = static_cast<TreeItem* >(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+
+/*! \brief Sets data on the model.
+ *
+ * It is trusted that the user of this function respects the information
provided by
+ * \see TreeModel::flags(). This function will set the data contained in
var
+ * on the item specified by index for the given role. If data in the model
is changed,
+ * the TreeModel::dataChanged() signal is emitted.
+ */
+bool TreeModel::setData(const QModelIndex& index, const QVariant& var, int
role) {
+ if(!index.isValid())
+ return false;
+ TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
+ if(!item)
+ return false;
+
+ if(!item->setData(var, 0, role))
+ return false;
+ emit dataChanged(index, index);
+ return true;
+}
+
+
+/*! \brief Inserts a single item into the model before row 'row' on the
parent given.
+ *
+ * If the parent, or the item is null, this function does nothing and
returns false.
+ * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the child
+ * is inserted into the model.
+ * \return true if the item was inserted successfully, false otherwise.
+ */
+bool TreeModel::insertItem(TreeItem* item, int row, TreeItem* parent) {
+ if(!item || !parent)
+ return false;
+ beginInsertRows(createIndex(parent->row(), 0, parent), row, row+1);
+ parent->insertChild(row, item);
+ endInsertRows();
+ return true;
+}
+
+/*! \brief Inserts a list of items into the model before row 'row' on the
parent given.
+ *
+ * If the parent, or the item is null, this function does nothing and
returns false.
+ * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the children
+ * are inserted into the model.
+ * \param items A list of items to be inserted.
+ * \param row The position to insert the items.
+ * \param parent The parent to add the items to as child rows.
+ * \return true if the items were inserted successfully, false otherwise.
+ */
+bool TreeModel::insertItems(QList<TreeItem* > items, int row, TreeItem*
parent) {
+ if(items.count() == 0 || parent == 0)
+ return false;
+ beginInsertRows(createIndex(parent->row(), 0, parent), row,
row+items.count());
+ parent->insertChildren(row, items);
+ endInsertRows();
+ return true;
+}
=======================================
--- /trunk/GTestRunner.pro Sat Sep 25 09:25:39 2010
+++ /trunk/GTestRunner.pro Sun Oct 17 08:22:22 2010
@@ -19,7 +19,10 @@
include/GTestParser.h \
include/GTestRunner.h \
include/TestTreeModel.h \
- include/TestTreeItem.h
+ include/MetaModel.h \
+ include/MetaItem.h \
+ include/TreeModel.h \
+ include/TreeItem.h
SOURCES += src/GTestResults.cpp \
src/GTestSuiteResults.cpp \
src/GTestSuite.cpp \
@@ -30,7 +33,10 @@
src/GTestParser.cpp \
src/GTestRunner.cpp \
src/TestTreeModel.cpp \
- src/TestTreeItem.cpp
+ src/MetaModel.cpp \
+ src/MetaItem.cpp \
+ src/TreeModel.cpp \
+ src/TreeItem.cpp
FORMS += resources/gtestrunner.ui
UI_HEADERS_DIR = include
UI_SOURCES_DIR = src
=======================================
--- /trunk/Makefile Sat Sep 25 09:25:39 2010
+++ /trunk/Makefile Sun Oct 17 08:22:22 2010
@@ -1,16 +1,16 @@

#############################################################################
-# Makefile for building: gtestrunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
+# Makefile for building: gtestrunner-debug
+# Generated by qmake (2.01a) (Qt 4.7.0) on: Sun Oct 17 12:15:44 2010
# Project: GTestRunner.pro
# Template: app
-# Command: /usr/bin/qmake -unix -o Makefile GTestRunner.pro
+# Command: /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/qmake -spec
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64 CONFIG+=debug -o
Makefile GTestRunner.pro

#############################################################################

-first: release
-install: release-install
-uninstall: release-uninstall
+first: debug
+install: debug-install
+uninstall: debug-uninstall
MAKEFILE = Makefile
-QMAKE = /usr/bin/qmake
+QMAKE = /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/qmake
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
@@ -27,25 +27,9 @@
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
SUBTARGETS = \
- release \
- debug
-
-release: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release
-release-make_default: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release
-release-make_first: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release first
-release-all: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release all
-release-clean: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release clean
-release-distclean: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release distclean
-release-install: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release install
-release-uninstall: $(MAKEFILE).Release FORCE
- $(MAKE) -f $(MAKEFILE).Release uninstall
+ debug \
+ release
+
debug: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug
debug-make_default: $(MAKEFILE).Debug FORCE
@@ -62,78 +46,98 @@
$(MAKE) -f $(MAKEFILE).Debug install
debug-uninstall: $(MAKEFILE).Debug FORCE
$(MAKE) -f $(MAKEFILE).Debug uninstall
-
-Makefile: GTestRunner.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf
/usr/share/qt4/mkspecs/common/g++.conf \
- /usr/share/qt4/mkspecs/common/unix.conf \
- /usr/share/qt4/mkspecs/common/linux.conf \
- /usr/share/qt4/mkspecs/qconfig.pri \
- /usr/share/qt4/mkspecs/features/qt_functions.prf \
- /usr/share/qt4/mkspecs/features/qt_config.prf \
- /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
- /usr/share/qt4/mkspecs/features/default_pre.prf \
- /usr/share/qt4/mkspecs/features/release.prf \
- /usr/share/qt4/mkspecs/features/debug_and_release.prf \
- /usr/share/qt4/mkspecs/features/default_post.prf \
- /usr/share/qt4/mkspecs/features/warn_on.prf \
- /usr/share/qt4/mkspecs/features/qt.prf \
- /usr/share/qt4/mkspecs/features/unix/thread.prf \
- /usr/share/qt4/mkspecs/features/moc.prf \
- /usr/share/qt4/mkspecs/features/resources.prf \
- /usr/share/qt4/mkspecs/features/uic.prf \
- /usr/share/qt4/mkspecs/features/yacc.prf \
- /usr/share/qt4/mkspecs/features/lex.prf \
- /usr/share/qt4/mkspecs/features/include_source_dir.prf \
- /usr/lib/libQtXml.prl \
- /usr/lib/libQtGui.prl \
- /usr/lib/libQtCore.prl
- $(QMAKE) -unix -o Makefile GTestRunner.pro
-/usr/share/qt4/mkspecs/common/g++.conf:
-/usr/share/qt4/mkspecs/common/unix.conf:
-/usr/share/qt4/mkspecs/common/linux.conf:
-/usr/share/qt4/mkspecs/qconfig.pri:
-/usr/share/qt4/mkspecs/features/qt_functions.prf:
-/usr/share/qt4/mkspecs/features/qt_config.prf:
-/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
-/usr/share/qt4/mkspecs/features/default_pre.prf:
-/usr/share/qt4/mkspecs/features/release.prf:
-/usr/share/qt4/mkspecs/features/debug_and_release.prf:
-/usr/share/qt4/mkspecs/features/default_post.prf:
-/usr/share/qt4/mkspecs/features/warn_on.prf:
-/usr/share/qt4/mkspecs/features/qt.prf:
-/usr/share/qt4/mkspecs/features/unix/thread.prf:
-/usr/share/qt4/mkspecs/features/moc.prf:
-/usr/share/qt4/mkspecs/features/resources.prf:
-/usr/share/qt4/mkspecs/features/uic.prf:
-/usr/share/qt4/mkspecs/features/yacc.prf:
-/usr/share/qt4/mkspecs/features/lex.prf:
-/usr/share/qt4/mkspecs/features/include_source_dir.prf:
-/usr/lib/libQtXml.prl:
-/usr/lib/libQtGui.prl:
-/usr/lib/libQtCore.prl:
+release: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release
+release-make_default: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release
+release-make_first: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release first
+release-all: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release all
+release-clean: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release clean
+release-distclean: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release distclean
+release-install: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release install
+release-uninstall: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release uninstall
+
+Makefile: GTestRunner.pro
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64/qmake.conf
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/g++.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/unix.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/linux.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/qconfig.pri \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_functions.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_config.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/exclusive_builds.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_pre.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug_and_release.prf
\
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_post.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/warn_on.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/unix/thread.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/moc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/resources.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/uic.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/yacc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/lex.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/include_source_dir.prf
\
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtXml.prl \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtCore.prl \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtGui.prl
+ $(QMAKE) -spec /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64
CONFIG+=debug -o Makefile GTestRunner.pro
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/g++.conf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/unix.conf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/linux.conf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/qconfig.pri:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/modules/qt_webkit_version.pri:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_functions.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_config.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/exclusive_builds.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_pre.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug_and_release.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_post.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/warn_on.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/unix/thread.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/moc.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/resources.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/uic.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/yacc.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/lex.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/include_source_dir.prf:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtXml.prl:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtCore.prl:
+/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib/libQtGui.prl:
qmake: qmake_all FORCE
- @$(QMAKE) -unix -o Makefile GTestRunner.pro
+ @$(QMAKE) -spec /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64
CONFIG+=debug -o Makefile GTestRunner.pro

qmake_all: FORCE

-make_default: release-make_default debug-make_default FORCE
-make_first: release-make_first debug-make_first FORCE
-all: release-all debug-all FORCE
-clean: release-clean debug-clean FORCE
-distclean: release-distclean debug-distclean FORCE
+make_default: debug-make_default release-make_default FORCE
+make_first: debug-make_first release-make_first FORCE
+all: debug-all release-all FORCE
+clean: debug-clean release-clean FORCE
+distclean: debug-distclean release-distclean FORCE
-$(DEL_FILE) Makefile

-release-mocclean: $(MAKEFILE).Release
- $(MAKE) -f $(MAKEFILE).Release mocclean
+check: first
+
debug-mocclean: $(MAKEFILE).Debug
$(MAKE) -f $(MAKEFILE).Debug mocclean
-mocclean: release-mocclean debug-mocclean
-
-release-mocables: $(MAKEFILE).Release
- $(MAKE) -f $(MAKEFILE).Release mocables
+release-mocclean: $(MAKEFILE).Release
+ $(MAKE) -f $(MAKEFILE).Release mocclean
+mocclean: debug-mocclean release-mocclean
+
debug-mocables: $(MAKEFILE).Debug
$(MAKE) -f $(MAKEFILE).Debug mocables
-mocables: release-mocables debug-mocables
+release-mocables: $(MAKEFILE).Release
+ $(MAKE) -f $(MAKEFILE).Release mocables
+mocables: debug-mocables release-mocables
FORCE:

-$(MAKEFILE).Release: Makefile
$(MAKEFILE).Debug: Makefile
+$(MAKEFILE).Release: Makefile
=======================================
--- /trunk/Makefile.Debug Sat Sep 25 09:25:39 2010
+++ /trunk/Makefile.Debug Sun Oct 17 08:22:22 2010
@@ -1,6 +1,6 @@

#############################################################################
# Makefile for building: gtestrunner-debug
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
+# Generated by qmake (2.01a) (Qt 4.7.0) on: Sun Oct 17 12:15:44 2010
# Project: GTestRunner.pro
# Template: app

#############################################################################
@@ -10,15 +10,15 @@
CC = gcc
CXX = g++
DEFINES = -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I.
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml
-I/usr/include/qt4 -Iinclude -Idebug -Iinclude
+CFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -m64 -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH =
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64 -I.
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtCore
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtGui
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtXml
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include -Iinclude -Idebug -Iinclude
LINK = g++
-LFLAGS =
-LIBS = $(SUBLIBS) -L/usr/lib -lQtXml -lQtGui -lQtCore -lpthread
+LFLAGS = -m64 -Wl,-rpath,/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib
+LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib
-lQtXml -L/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib -lQtGui
-L/usr/X11R6/lib64 -lQtCore -lpthread
AR = ar cqs
RANLIB =
-QMAKE = /usr/bin/qmake
+QMAKE = /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
@@ -52,11 +52,16 @@
src/GTestParser.cpp \
src/GTestRunner.cpp \
src/TestTreeModel.cpp \
- src/TestTreeItem.cpp debug/moc_GTestSuite.cpp \
+ src/MetaModel.cpp \
+ src/MetaItem.cpp \
+ src/TreeModel.cpp \
+ src/TreeItem.cpp debug/moc_GTestSuite.cpp \
debug/moc_GTest.cpp \
debug/moc_GTestExecutable.cpp \
debug/moc_GTestRunner.cpp \
debug/moc_TestTreeModel.cpp \
+ debug/moc_MetaModel.cpp \
+ debug/moc_TreeModel.cpp \
debug/qrc_gtestrunner.cpp
OBJECTS = debug/GTestResults.o \
debug/GTestSuiteResults.o \
@@ -68,34 +73,40 @@
debug/GTestParser.o \
debug/GTestRunner.o \
debug/TestTreeModel.o \
- debug/TestTreeItem.o \
+ debug/MetaModel.o \
+ debug/MetaItem.o \
+ debug/TreeModel.o \
+ debug/TreeItem.o \
debug/moc_GTestSuite.o \
debug/moc_GTest.o \
debug/moc_GTestExecutable.o \
debug/moc_GTestRunner.o \
debug/moc_TestTreeModel.o \
+ debug/moc_MetaModel.o \
+ debug/moc_TreeModel.o \
debug/qrc_gtestrunner.o
-DIST = /usr/share/qt4/mkspecs/common/g++.conf \
- /usr/share/qt4/mkspecs/common/unix.conf \
- /usr/share/qt4/mkspecs/common/linux.conf \
- /usr/share/qt4/mkspecs/qconfig.pri \
- /usr/share/qt4/mkspecs/features/qt_functions.prf \
- /usr/share/qt4/mkspecs/features/qt_config.prf \
- /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
- /usr/share/qt4/mkspecs/features/default_pre.prf \
- /usr/share/qt4/mkspecs/features/debug.prf \
- /usr/share/qt4/mkspecs/features/debug_and_release.prf \
- /usr/share/qt4/mkspecs/features/default_post.prf \
- /usr/share/qt4/mkspecs/features/build_pass.prf \
- /usr/share/qt4/mkspecs/features/warn_on.prf \
- /usr/share/qt4/mkspecs/features/qt.prf \
- /usr/share/qt4/mkspecs/features/unix/thread.prf \
- /usr/share/qt4/mkspecs/features/moc.prf \
- /usr/share/qt4/mkspecs/features/resources.prf \
- /usr/share/qt4/mkspecs/features/uic.prf \
- /usr/share/qt4/mkspecs/features/yacc.prf \
- /usr/share/qt4/mkspecs/features/lex.prf \
- /usr/share/qt4/mkspecs/features/include_source_dir.prf \
+DIST =
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/g++.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/unix.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/linux.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/qconfig.pri \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_functions.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_config.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/exclusive_builds.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_pre.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug_and_release.prf
\
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_post.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/build_pass.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/warn_on.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/unix/thread.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/moc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/resources.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/uic.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/yacc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/lex.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/include_source_dir.prf
\
GTestRunner.pro
QMAKE_TARGET = gtestrunner-debug
DESTDIR =
@@ -129,11 +140,11 @@
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

qmake: FORCE
- @$(QMAKE) -unix -o Makefile.Debug GTestRunner.pro
+ @$(QMAKE) -spec /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64
CONFIG+=debug -o Makefile.Debug GTestRunner.pro

dist:
@$(CHK_DIR_EXISTS) debug/gtestrunner-debug1.0.0 || $(MKDIR)
debug/gtestrunner-debug1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/gtestrunner-debug1.0.0/
&& $(COPY_FILE) --parents include/GTestSuiteResults.h
include/GTestResults.h include/GTestSuite.h include/Defines.h
include/GTestExecutableResults.h include/GTest.h include/GTestExecutable.h
include/GTestParser.h include/GTestRunner.h include/TestTreeModel.h
include/TestTreeItem.h debug/gtestrunner-debug1.0.0/ && $(COPY_FILE)
--parents resources/gtestrunner.qrc debug/gtestrunner-debug1.0.0/ &&
$(COPY_FILE) --parents src/GTestResults.cpp src/GTestSuiteResults.cpp
src/GTestSuite.cpp src/GTestExecutableResults.cpp src/GTest.cpp
src/GTestExecutable.cpp src/main.cpp src/GTestParser.cpp
src/GTestRunner.cpp src/TestTreeModel.cpp src/TestTreeItem.cpp
debug/gtestrunner-debug1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui debug/gtestrunner-debug1.0.0/ && (cd `dirname
debug/gtestrunner-debug1.0.0` && $(TAR) gtestrunner-debug1.0.0.tar
gtestrunner-debug1.0.0 && $(COMPRESS) gtestrunner-debug1.0.0.tar) &&
$(MOVE) `dirname
debug/gtestrunner-debug1.0.0`/gtestrunner-debug1.0.0.tar.gz . &&
$(DEL_FILE) -r debug/gtestrunner-debug1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) debug/gtestrunner-debug1.0.0/
&& $(COPY_FILE) --parents include/GTestSuiteResults.h
include/GTestResults.h include/GTestSuite.h include/Defines.h
include/GTestExecutableResults.h include/GTest.h include/GTestExecutable.h
include/GTestParser.h include/GTestRunner.h include/TestTreeModel.h
include/MetaModel.h include/MetaItem.h include/TreeModel.h
include/TreeItem.h debug/gtestrunner-debug1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.qrc debug/gtestrunner-debug1.0.0/ && $(COPY_FILE)
--parents src/GTestResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
src/main.cpp src/GTestParser.cpp src/GTestRunner.cpp src/TestTreeModel.cpp
src/MetaModel.cpp src/MetaItem.cpp src/TreeModel.cpp src/TreeItem.cpp
debug/gtestrunner-debug1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui debug/gtestrunner-debug1.0.0/ && (cd `dirname
debug/gtestrunner-debug1.0.0` && $(TAR) gtestrunner-debug1.0.0.tar
gtestrunner-debug1.0.0 && $(COMPRESS) gtestrunner-debug1.0.0.tar) &&
$(MOVE) `dirname
debug/gtestrunner-debug1.0.0`/gtestrunner-debug1.0.0.tar.gz . &&
$(DEL_FILE) -r debug/gtestrunner-debug1.0.0


clean:compiler_clean
@@ -148,30 +159,36 @@
-$(DEL_FILE) Makefile.Debug


+check: first
+
mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

-compiler_moc_header_make_all: debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp
+compiler_moc_header_make_all: debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp debug/moc_MetaModel.cpp debug/moc_TreeModel.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp
+ -$(DEL_FILE) debug/moc_GTestSuite.cpp debug/moc_GTest.cpp
debug/moc_GTestExecutable.cpp debug/moc_GTestRunner.cpp
debug/moc_TestTreeModel.cpp debug/moc_MetaModel.cpp debug/moc_TreeModel.cpp
debug/moc_GTestSuite.cpp: include/GTest.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestSuite.h -o
debug/moc_GTestSuite.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestSuite.h -o debug/moc_GTestSuite.cpp

debug/moc_GTest.cpp: include/GTest.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTest.h -o
debug/moc_GTest.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o debug/moc_GTest.cpp

debug/moc_GTestExecutable.cpp: include/GTestExecutableResults.h \
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h \
include/GTest.h \
include/GTestExecutable.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestExecutable.h -o
debug/moc_GTestExecutable.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o debug/moc_GTestExecutable.cpp

debug/moc_GTestRunner.cpp: include/ui_gtestrunner.h \
include/GTestExecutable.h \
@@ -179,13 +196,27 @@
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h \
include/GTest.h \
include/GTestRunner.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestRunner.h -o
debug/moc_GTestRunner.cpp
-
-debug/moc_TestTreeModel.cpp: include/TestTreeModel.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/TestTreeModel.h -o
debug/moc_TestTreeModel.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o debug/moc_GTestRunner.cpp
+
+debug/moc_TestTreeModel.cpp: include/TreeModel.h \
+ include/TreeItem.h \
+ include/TestTreeModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeModel.h -o debug/moc_TestTreeModel.cpp
+
+debug/moc_MetaModel.cpp: include/MetaItem.h \
+ include/TreeItem.h \
+ include/TreeModel.h \
+ include/MetaModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/MetaModel.h -o debug/moc_MetaModel.cpp
+
+debug/moc_TreeModel.cpp: include/TreeItem.h \
+ include/TreeModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/TreeModel.h -o debug/moc_TreeModel.cpp

compiler_rcc_make_all: debug/qrc_gtestrunner.cpp
compiler_rcc_clean:
@@ -203,7 +234,7 @@
resources/qt.png \
resources/newfile.svg \
resources/savefile.svg
- /usr/bin/rcc -name gtestrunner resources/gtestrunner.qrc -o
debug/qrc_gtestrunner.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/rcc -name gtestrunner
resources/gtestrunner.qrc -o debug/qrc_gtestrunner.cpp

compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
@@ -214,7 +245,7 @@
compiler_uic_clean:
-$(DEL_FILE) include/ui_gtestrunner.h
include/ui_gtestrunner.h: resources/gtestrunner.ui
- /usr/bin/uic-qt4 resources/gtestrunner.ui -o include/ui_gtestrunner.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/uic resources/gtestrunner.ui -o
include/ui_gtestrunner.h

compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
@@ -256,8 +287,17 @@
debug/TestTreeModel.o: src/TestTreeModel.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeModel.o
src/TestTreeModel.cpp

-debug/TestTreeItem.o: src/TestTreeItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TestTreeItem.o
src/TestTreeItem.cpp
+debug/MetaModel.o: src/MetaModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/MetaModel.o src/MetaModel.cpp
+
+debug/MetaItem.o: src/MetaItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/MetaItem.o src/MetaItem.cpp
+
+debug/TreeModel.o: src/TreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TreeModel.o src/TreeModel.cpp
+
+debug/TreeItem.o: src/TreeItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/TreeItem.o src/TreeItem.cpp

debug/moc_GTestSuite.o: debug/moc_GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_GTestSuite.o
debug/moc_GTestSuite.cpp
@@ -274,6 +314,12 @@
debug/moc_TestTreeModel.o: debug/moc_TestTreeModel.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_TestTreeModel.o
debug/moc_TestTreeModel.cpp

+debug/moc_MetaModel.o: debug/moc_MetaModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_MetaModel.o
debug/moc_MetaModel.cpp
+
+debug/moc_TreeModel.o: debug/moc_TreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/moc_TreeModel.o
debug/moc_TreeModel.cpp
+
debug/qrc_gtestrunner.o: debug/qrc_gtestrunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug/qrc_gtestrunner.o
debug/qrc_gtestrunner.cpp

=======================================
--- /trunk/Makefile.Release Sat Sep 25 09:25:39 2010
+++ /trunk/Makefile.Release Sun Oct 17 08:22:22 2010
@@ -1,6 +1,6 @@

#############################################################################
# Makefile for building: gtestrunner
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Sep 25 13:21:13 2010
+# Generated by qmake (2.01a) (Qt 4.7.0) on: Sun Oct 17 12:15:44 2010
# Project: GTestRunner.pro
# Template: app

#############################################################################
@@ -10,15 +10,15 @@
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_SHARED
-CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I.
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml
-I/usr/include/qt4 -Iinclude -Irelease -Iinclude
+CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH =
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64 -I.
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtCore
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtGui
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include/QtXml
-I/usr/local/Trolltech/Qt-3.7.0-sdk/qt/include -Iinclude -Irelease -Iinclude
LINK = g++
-LFLAGS = -Wl,-O1
-LIBS = $(SUBLIBS) -L/usr/lib -lQtXml -lQtGui -lQtCore -lpthread
+LFLAGS = -m64 -Wl,-O1
-Wl,-rpath,/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib
+LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib
-lQtXml -L/usr/local/Trolltech/Qt-3.7.0-sdk/qt/lib -lQtGui
-L/usr/X11R6/lib64 -lQtCore -lpthread
AR = ar cqs
RANLIB =
-QMAKE = /usr/bin/qmake
+QMAKE = /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
@@ -52,11 +52,16 @@
src/GTestParser.cpp \
src/GTestRunner.cpp \
src/TestTreeModel.cpp \
- src/TestTreeItem.cpp release/moc_GTestSuite.cpp \
+ src/MetaModel.cpp \
+ src/MetaItem.cpp \
+ src/TreeModel.cpp \
+ src/TreeItem.cpp release/moc_GTestSuite.cpp \
release/moc_GTest.cpp \
release/moc_GTestExecutable.cpp \
release/moc_GTestRunner.cpp \
release/moc_TestTreeModel.cpp \
+ release/moc_MetaModel.cpp \
+ release/moc_TreeModel.cpp \
release/qrc_gtestrunner.cpp
OBJECTS = release/GTestResults.o \
release/GTestSuiteResults.o \
@@ -68,34 +73,40 @@
release/GTestParser.o \
release/GTestRunner.o \
release/TestTreeModel.o \
- release/TestTreeItem.o \
+ release/MetaModel.o \
+ release/MetaItem.o \
+ release/TreeModel.o \
+ release/TreeItem.o \
release/moc_GTestSuite.o \
release/moc_GTest.o \
release/moc_GTestExecutable.o \
release/moc_GTestRunner.o \
release/moc_TestTreeModel.o \
+ release/moc_MetaModel.o \
+ release/moc_TreeModel.o \
release/qrc_gtestrunner.o
-DIST = /usr/share/qt4/mkspecs/common/g++.conf \
- /usr/share/qt4/mkspecs/common/unix.conf \
- /usr/share/qt4/mkspecs/common/linux.conf \
- /usr/share/qt4/mkspecs/qconfig.pri \
- /usr/share/qt4/mkspecs/features/qt_functions.prf \
- /usr/share/qt4/mkspecs/features/qt_config.prf \
- /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
- /usr/share/qt4/mkspecs/features/default_pre.prf \
- /usr/share/qt4/mkspecs/features/release.prf \
- /usr/share/qt4/mkspecs/features/debug_and_release.prf \
- /usr/share/qt4/mkspecs/features/default_post.prf \
- /usr/share/qt4/mkspecs/features/build_pass.prf \
- /usr/share/qt4/mkspecs/features/warn_on.prf \
- /usr/share/qt4/mkspecs/features/qt.prf \
- /usr/share/qt4/mkspecs/features/unix/thread.prf \
- /usr/share/qt4/mkspecs/features/moc.prf \
- /usr/share/qt4/mkspecs/features/resources.prf \
- /usr/share/qt4/mkspecs/features/uic.prf \
- /usr/share/qt4/mkspecs/features/yacc.prf \
- /usr/share/qt4/mkspecs/features/lex.prf \
- /usr/share/qt4/mkspecs/features/include_source_dir.prf \
+DIST =
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/g++.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/unix.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/common/linux.conf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/qconfig.pri \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_functions.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt_config.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/exclusive_builds.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_pre.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/release.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/debug_and_release.prf
\
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/default_post.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/build_pass.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/warn_on.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/qt.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/unix/thread.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/moc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/resources.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/uic.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/yacc.prf \
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/lex.prf \
+
/usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/features/include_source_dir.prf
\
GTestRunner.pro
QMAKE_TARGET = gtestrunner
DESTDIR =
@@ -129,11 +140,11 @@
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

qmake: FORCE
- @$(QMAKE) -unix -o Makefile.Release GTestRunner.pro
+ @$(QMAKE) -spec /usr/local/Trolltech/Qt-3.7.0-sdk/qt/mkspecs/linux-g++-64
CONFIG+=debug -o Makefile.Release GTestRunner.pro

dist:
@$(CHK_DIR_EXISTS) release/gtestrunner1.0.0 || $(MKDIR)
release/gtestrunner1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) release/gtestrunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestSuiteResults.h include/GTestResults.h
include/GTestSuite.h include/Defines.h include/GTestExecutableResults.h
include/GTest.h include/GTestExecutable.h include/GTestParser.h
include/GTestRunner.h include/TestTreeModel.h include/TestTreeItem.h
release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.qrc release/gtestrunner1.0.0/ && $(COPY_FILE)
--parents src/GTestResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
src/main.cpp src/GTestParser.cpp src/GTestRunner.cpp src/TestTreeModel.cpp
src/TestTreeItem.cpp release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui release/gtestrunner1.0.0/ && (cd `dirname
release/gtestrunner1.0.0` && $(TAR) gtestrunner1.0.0.tar gtestrunner1.0.0
&& $(COMPRESS) gtestrunner1.0.0.tar) && $(MOVE) `dirname
release/gtestrunner1.0.0`/gtestrunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/gtestrunner1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) release/gtestrunner1.0.0/ &&
$(COPY_FILE) --parents include/GTestSuiteResults.h include/GTestResults.h
include/GTestSuite.h include/Defines.h include/GTestExecutableResults.h
include/GTest.h include/GTestExecutable.h include/GTestParser.h
include/GTestRunner.h include/TestTreeModel.h include/MetaModel.h
include/MetaItem.h include/TreeModel.h include/TreeItem.h
release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.qrc release/gtestrunner1.0.0/ && $(COPY_FILE)
--parents src/GTestResults.cpp src/GTestSuiteResults.cpp src/GTestSuite.cpp
src/GTestExecutableResults.cpp src/GTest.cpp src/GTestExecutable.cpp
src/main.cpp src/GTestParser.cpp src/GTestRunner.cpp src/TestTreeModel.cpp
src/MetaModel.cpp src/MetaItem.cpp src/TreeModel.cpp src/TreeItem.cpp
release/gtestrunner1.0.0/ && $(COPY_FILE) --parents
resources/gtestrunner.ui release/gtestrunner1.0.0/ && (cd `dirname
release/gtestrunner1.0.0` && $(TAR) gtestrunner1.0.0.tar gtestrunner1.0.0
&& $(COMPRESS) gtestrunner1.0.0.tar) && $(MOVE) `dirname
release/gtestrunner1.0.0`/gtestrunner1.0.0.tar.gz . && $(DEL_FILE) -r
release/gtestrunner1.0.0


clean:compiler_clean
@@ -148,30 +159,36 @@
-$(DEL_FILE) Makefile.Release


+check: first
+
mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

-compiler_moc_header_make_all: release/moc_GTestSuite.cpp
release/moc_GTest.cpp release/moc_GTestExecutable.cpp
release/moc_GTestRunner.cpp release/moc_TestTreeModel.cpp
+compiler_moc_header_make_all: release/moc_GTestSuite.cpp
release/moc_GTest.cpp release/moc_GTestExecutable.cpp
release/moc_GTestRunner.cpp release/moc_TestTreeModel.cpp
release/moc_MetaModel.cpp release/moc_TreeModel.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) release/moc_GTestSuite.cpp release/moc_GTest.cpp
release/moc_GTestExecutable.cpp release/moc_GTestRunner.cpp
release/moc_TestTreeModel.cpp
+ -$(DEL_FILE) release/moc_GTestSuite.cpp release/moc_GTest.cpp
release/moc_GTestExecutable.cpp release/moc_GTestRunner.cpp
release/moc_TestTreeModel.cpp release/moc_MetaModel.cpp
release/moc_TreeModel.cpp
release/moc_GTestSuite.cpp: include/GTest.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestSuite.h -o
release/moc_GTestSuite.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestSuite.h -o release/moc_GTestSuite.cpp

release/moc_GTest.cpp: include/GTest.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTest.h -o
release/moc_GTest.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTest.h -o release/moc_GTest.cpp

release/moc_GTestExecutable.cpp: include/GTestExecutableResults.h \
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h \
include/GTest.h \
include/GTestExecutable.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestExecutable.h -o
release/moc_GTestExecutable.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestExecutable.h -o release/moc_GTestExecutable.cpp

release/moc_GTestRunner.cpp: include/ui_gtestrunner.h \
include/GTestExecutable.h \
@@ -179,13 +196,27 @@
include/Defines.h \
include/GTestSuiteResults.h \
include/GTestResults.h \
+ include/MetaItem.h \
+ include/TreeItem.h \
include/GTestSuite.h \
include/GTest.h \
include/GTestRunner.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/GTestRunner.h -o
release/moc_GTestRunner.cpp
-
-release/moc_TestTreeModel.cpp: include/TestTreeModel.h
- /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) include/TestTreeModel.h -o
release/moc_TestTreeModel.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/GTestRunner.h -o release/moc_GTestRunner.cpp
+
+release/moc_TestTreeModel.cpp: include/TreeModel.h \
+ include/TreeItem.h \
+ include/TestTreeModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/TestTreeModel.h -o release/moc_TestTreeModel.cpp
+
+release/moc_MetaModel.cpp: include/MetaItem.h \
+ include/TreeItem.h \
+ include/TreeModel.h \
+ include/MetaModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/MetaModel.h -o release/moc_MetaModel.cpp
+
+release/moc_TreeModel.cpp: include/TreeItem.h \
+ include/TreeModel.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/moc $(DEFINES) $(INCPATH)
include/TreeModel.h -o release/moc_TreeModel.cpp

compiler_rcc_make_all: release/qrc_gtestrunner.cpp
compiler_rcc_clean:
@@ -203,7 +234,7 @@
resources/qt.png \
resources/newfile.svg \
resources/savefile.svg
- /usr/bin/rcc -name gtestrunner resources/gtestrunner.qrc -o
release/qrc_gtestrunner.cpp
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/rcc -name gtestrunner
resources/gtestrunner.qrc -o release/qrc_gtestrunner.cpp

compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
@@ -214,7 +245,7 @@
compiler_uic_clean:
-$(DEL_FILE) include/ui_gtestrunner.h
include/ui_gtestrunner.h: resources/gtestrunner.ui
- /usr/bin/uic-qt4 resources/gtestrunner.ui -o include/ui_gtestrunner.h
+ /usr/local/Trolltech/Qt-3.7.0-sdk/qt/bin/uic resources/gtestrunner.ui -o
include/ui_gtestrunner.h

compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
@@ -256,8 +287,17 @@
release/TestTreeModel.o: src/TestTreeModel.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeModel.o
src/TestTreeModel.cpp

-release/TestTreeItem.o: src/TestTreeItem.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TestTreeItem.o
src/TestTreeItem.cpp
+release/MetaModel.o: src/MetaModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/MetaModel.o src/MetaModel.cpp
+
+release/MetaItem.o: src/MetaItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/MetaItem.o src/MetaItem.cpp
+
+release/TreeModel.o: src/TreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TreeModel.o src/TreeModel.cpp
+
+release/TreeItem.o: src/TreeItem.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/TreeItem.o src/TreeItem.cpp

release/moc_GTestSuite.o: release/moc_GTestSuite.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_GTestSuite.o
release/moc_GTestSuite.cpp
@@ -274,6 +314,12 @@
release/moc_TestTreeModel.o: release/moc_TestTreeModel.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_TestTreeModel.o
release/moc_TestTreeModel.cpp

+release/moc_MetaModel.o: release/moc_MetaModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_MetaModel.o
release/moc_MetaModel.cpp
+
+release/moc_TreeModel.o: release/moc_TreeModel.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/moc_TreeModel.o
release/moc_TreeModel.cpp
+
release/qrc_gtestrunner.o: release/qrc_gtestrunner.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/qrc_gtestrunner.o
release/qrc_gtestrunner.cpp

=======================================
--- /trunk/include/GTestResults.h Tue Aug 17 16:53:58 2010
+++ /trunk/include/GTestResults.h Sun Oct 17 08:22:22 2010
@@ -17,8 +17,11 @@
#ifndef GTESTRESULTS_H_
#define GTESTRESULTS_H_

+#include <QSharedPointer>
#include <QStringList>

+#include "MetaItem.h"
+
/* \brief This class logically represents the results of running a unit
test.
*
* The class is the analogue to a gtest unit test result. It consists of
the name of
@@ -66,6 +69,7 @@
QStringList getFailureMessages() const;

virtual GTestResults* getTestResults(QString name);
+ virtual MetaItem* createMetaItem() const;

};

=======================================
--- /trunk/include/GTestRunner.h Sat Sep 25 09:25:39 2010
+++ /trunk/include/GTestRunner.h Sun Oct 17 08:22:22 2010
@@ -35,6 +35,7 @@
#include "GTestExecutable.h"

class TestTreeModel;
+class MetaModel;

/*! \brief The is the main application window class.
*
@@ -63,6 +64,7 @@
void invokeListingRetrieval(QSharedPointer<GTestExecutable> gtest);

TestTreeModel* testModel;
+ MetaModel* metaModel;

};

=======================================
--- /trunk/include/TestTreeModel.h Sat Sep 25 09:25:39 2010
+++ /trunk/include/TestTreeModel.h Sun Oct 17 08:22:22 2010
@@ -23,7 +23,9 @@
#include <QSharedPointer>
#include <QVariant>

-class TestTreeItem;
+#include "TreeModel.h"
+
+class TreeItem;
class GTest;
class GTestExecutable;

@@ -33,7 +35,7 @@
* are each held as branches of an invisible root node (which conveniently
* holds the model's header data).
*/
-class TestTreeModel : public QAbstractItemModel {
+class TestTreeModel : public TreeModel {

Q_OBJECT;

@@ -50,16 +52,11 @@
};

QHash<QString, QSharedPointer<GTestExecutable> > testExeHash; //!< A hash
of all loaded gtest executables.
- QHash<GTest*, TestTreeItem*> itemTestHash; //!< A hash that relates unit
tests to tree items
+ QHash<GTest*, TreeItem* > itemTestHash; //!< A hash that relates unit
tests to tree items

template <class T, class U>
- TestTreeItem* createNewTreeItem(T* parent, U* test);
- bool setCheckState(TestTreeItem* item, Qt::CheckState state, int
recursionDirection = (TO_PARENT | TO_CHILDREN));
-
-signals:
- void aboutToRunTests();
- void runningTests();
- void resettingRunStates();
+ TreeItem* createNewTreeItem(T parent, U* test);
+ bool setCheckState(TreeItem* item, Qt::CheckState state, int
recursionDirection = (TO_PARENT | TO_CHILDREN));

private slots:
void updateListing(GTestExecutable* gtest);
@@ -68,6 +65,11 @@
void removeSenderItem();
void runTests();

+signals:
+ void aboutToRunTests();
+ void runningTests();
+ void resettingRunStates();
+
public:

enum ERROR {
@@ -79,21 +81,9 @@

TestTreeModel(QObject* parent = 0);
~TestTreeModel();
-
- int columnCount(const QModelIndex& parent = QModelIndex()) const;
- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
- Qt::ItemFlags flags(const QModelIndex& index) const;
- QVariant headerData(int secton, Qt::Orientation orientation, int role =
Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex& parent =
QModelIndex()) const;
- bool insertItem(TestTreeItem* item, int row, TestTreeItem* parent);
- bool insertItems(const QList<TestTreeItem*> items, int row, TestTreeItem*
parent);
- QModelIndex parent(const QModelIndex& index) const;
- int rowCount(const QModelIndex& parent = QModelIndex()) const;
- bool setData(const QModelIndex& index, const QVariant& value, int role =
Qt::EditRole);
ERROR addDataSource(const QString filepath);
-
-private:
- TestTreeItem* rootItem; //!< This is the root of the data model.
+ virtual QVariant data(const QModelIndex& index, int role =
Qt::DisplayRole) const;
+ virtual bool setData(const QModelIndex& index, const QVariant& value, int
role = Qt::EditRole);

};

=======================================
--- /trunk/resources/gtestrunner.ui Sat Sep 25 09:33:04 2010
+++ /trunk/resources/gtestrunner.ui Sun Oct 17 08:22:22 2010
@@ -14,15 +14,21 @@
<string>GTestRunner</string>
</property>
<widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QTreeView" name="testTree">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>1</horstretch>
- <verstretch>1</verstretch>
- </sizepolicy>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
+ <widget class="QTreeView" name="testTree">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QTreeView" name="resultsTree"/>
</widget>
</item>
</layout>
@@ -146,7 +152,7 @@
<string>Import Test Executable</string>
</property>
<property name="shortcut">
- <string>Ctrl+A</string>
+ <string>Ctrl+I</string>
</property>
<property name="iconVisibleInMenu">
<bool>true</bool>
=======================================
--- /trunk/src/GTestParser.cpp Tue Aug 17 16:53:58 2010
+++ /trunk/src/GTestParser.cpp Sun Oct 17 08:22:22 2010
@@ -67,15 +67,19 @@
GTestResults* testResults;
//! \bug \todo Fix the bug in here causing "premature end-of-file" error.
while(!xmlStream.atEnd()) {
- while(!xmlStream.readNextStartElement() && !xmlStream.hasError()
&& !xmlStream.atEnd()) {}
+ while(!xmlStream.readNextStartElement() && !xmlStream.hasError()
&& !xmlStream.atEnd()) { qDebug() << xmlStream.name(); }
attributes = xmlStream.attributes();
if(xmlStream.name() == "testcase") {
testResults = new GTestResults(attributes.value("name").toString());

testResults->setRunningTime(attributes.value("time").toString().toUInt());
testResults->setStatus(attributes.value("status").toString());
- while((xmlStream.readNext(), xmlStream.name()) == "failure") {
- attributes = xmlStream.attributes();
- testResults->addFailureMessage(attributes.value("message").toString());
+ xmlStream.readNext();
+ qDebug() << xmlStream.name();
+ while(xmlStream.name() != "testcase") { //no closing </testcase> yet
+ if(xmlStream.isCDATA())
+ testResults->addFailureMessage(xmlStream.text().toString());
+ xmlStream.readNext();
+ qDebug() << xmlStream.name();
}
testSuiteResults->addTestResults(testResults);
}
=======================================
--- /trunk/src/GTestResults.cpp Thu Aug 12 16:12:42 2010
+++ /trunk/src/GTestResults.cpp Sun Oct 17 08:22:22 2010
@@ -30,4 +30,53 @@
GTestResults::~GTestResults()
{}

-
+/*! \brief This function creates a meta item that can be given to
+ * a TreeModel to store as metadata.
+ *
+ * It is up to the TreeModel to decide how to handle the item. It's
+ * given as a sharedpointer as the meta item can be held by two different
+ * models, and responsibility is shared between them. The item could
+ * exist solely in the metamodel (as an out-dated selection), or in
+ * the datamodel as a piece of unread metadata, or in both.
+ * \return A MetaItem that holds the information contained in this test
result.
+ */
+MetaItem* GTestResults::createMetaItem() const {
+ //Set up the data object to insert intsudoo our metaitem.
+ QList<QMap<int, QVariant> > metaData; //for multiple columns
+ QMap<int, QVariant> metaDatum; //for a single column
+ //insert the name into the first column as the display role.
+ //For now, that's the only piece of data we give for the top level.
+ metaDatum.insert(Qt::DisplayRole, QVariant(QString(this->getName())));
+ metaData.append(metaDatum);
+ MetaItem* item(new MetaItem(metaData));
+
+ //We're going to insert child rows that hold the failure messages
+ //so we prepare those structures as well.
+ MetaItem* child;
+ QList<QMap<int, QVariant> > childData;
+ QMap<int, QVariant> childDatum;
+
+ QList<QString> messages = this->getFailureMessages();
+ if(!messages.isEmpty()) {
+ //if there are messages, iterate over the messages and insert them as
child rows.
+ QList<QString>::iterator it = messages.begin();
+ while(it != messages.end()) {
+ childDatum.insert(Qt::DisplayRole, QVariant(*it));
+ childData.append(childDatum);
+ child = new MetaItem(childData, item);
+ item->appendChild(child);
+ childDatum.clear();
+ childData.clear();
+ ++it;
+ }
+ }
+// else {
+// //There are no messages, so insert a row saying the tests have passed.
+// childDatum.insert(Qt::DisplayRole, QVariant(QString("All tests
passed!")));
+// childData.append(childDatum);
+// child = new MetaItem(childData, item);
+// item->appendChild(child);
+// }
+ return item;
+}
+
=======================================
--- /trunk/src/GTestRunner.cpp Sat Sep 25 09:25:39 2010
+++ /trunk/src/GTestRunner.cpp Sun Oct 17 08:22:22 2010
@@ -15,6 +15,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * */

#include "GTestRunner.h"
+#include "MetaModel.h"
#include "TestTreeModel.h"

#include <QAction>
@@ -57,6 +58,13 @@
void GTestRunner::setup() {
testModel = new TestTreeModel();
testTree->setModel(testModel);
+ testTree->setSelectionBehavior(QAbstractItemView::SelectRows);
+ testTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ metaModel = new MetaModel();
+ metaModel->setSelectionModel(testTree->selectionModel());
+ metaModel->setItemModel(testModel);
+ resultsTree->setModel(metaModel);
+

QObject::connect(aboutQtAction, SIGNAL(triggered()),
qApp, SLOT(aboutQt()));
=======================================
--- /trunk/src/TestTreeItem.cpp Sat Sep 25 09:25:39 2010
+++ /trunk/src/TestTreeItem.cpp Sun Oct 17 08:22:22 2010
@@ -22,7 +22,7 @@
* between a Qt::ItemDataRole and the QVariant with the data.
* \param parent The parent of this item.
*/
-TestTreeItem::TestTreeItem(QMap<int, QVariant>& data, TestTreeItem* parent)
+TestTreeItem::TestTreeItem(QList<QMap<int, QVariant> >& data,
TestTreeItem* parent)
: childItems(), itemData(data), parentItem(parent)
{}

@@ -47,8 +47,10 @@
* \param role A value from Qt::ItemDataRole specifying a model role.
* \return A variant holding the data.
*/
-QVariant TestTreeItem::data(int role) const {
- return itemData.value(role);
+QVariant TestTreeItem::data(int column, int role) const {
+ if(column >= itemData.length())
+ return QVariant();
+ return itemData.at(column).value(role);
}

/*! \brief Retrieves a pointer to the parent of this item.
@@ -77,8 +79,10 @@
* \param role The role specified from Qt::ItemDataRole.
* \return true if the data was set, false otherwise.
*/
-bool TestTreeItem::setData(const QVariant& value, int role) {
- itemData.insert(role, value);
+bool TestTreeItem::setData(const QVariant& value, int col, int role) {
+ while(col >= itemData.length())
+ itemData.append(QMap<int, QVariant>());
+ itemData[col].insert(role, value);
return true;
}

@@ -93,7 +97,7 @@
TestTreeItem* TestTreeItem::findChild(const QVariant& value, int role)
const {
QList<TestTreeItem*>::const_iterator it = childItems.begin();
while(it != childItems.end()) {
- if((*it)->data(role) == value)
+ if((*it)->data(0, role) == value)
return *it;
++it;
}
=======================================
--- /trunk/src/TestTreeModel.cpp Sat Sep 25 09:25:39 2010
+++ /trunk/src/TestTreeModel.cpp Sun Oct 17 08:22:22 2010
@@ -21,247 +21,28 @@
#include <QSharedPointer>
#include <QStack>

+#include "MetaModel.h"
#include "TestTreeModel.h"
-#include "TestTreeItem.h"
+#include "TreeItem.h"
#include "GTestExecutable.h"

/*! \brief Constructor
*
*/
TestTreeModel::TestTreeModel(QObject* parent)
-: QAbstractItemModel(parent)
-{
- QMap<int, QVariant> data;
- data.insert(0,"Test Name");
- rootItem = new TestTreeItem(data, 0);
+: TreeModel(parent)
+{
+ QList<QMap<int, QVariant> > data;
+ QMap<int, QVariant> datum;
+ datum.insert(0, "Test Name");
+ data.append(datum);
+ rootItem.setData(data);
}

/*! \brief Destructor
*
*/
-TestTreeModel::~TestTreeModel() {
- delete rootItem;
-}
-
-/*! \brief Gives a count of the number of columns contained by the
index 'parent'.
- *
- * If the index is invalid the number of columns contained by the rootItem
are
- * returned.
- * \return The number of columns given by the index 'parent' or the number
of
- * columns in the rootItem is 'parent' is invalid.
- */
-int TestTreeModel::columnCount(const QModelIndex& parent) const {
- if (parent.isValid())
- return
static_cast<TestTreeItem*>(parent.internalPointer())->columnCount();
- else
- return rootItem->columnCount();
-}
-
-/*! \brief Accesses data contained within the model.
- *
- * The data contained in the index 'index' for the given 'role' are
returned
- * within a QVariant. If the index is invalid, or if the item specified by
- * the index does not contain data for the role 'role', an empty QVariant
- * is returned.
- * \return The data specified by the index 'index' and the role 'role'.
- */
-QVariant TestTreeModel::data(const QModelIndex& index, int role) const {
- if (!index.isValid())
- return QVariant();
-
- switch(role) {
- //list supported data accesses here.
- case Qt::BackgroundColorRole:
- case Qt::CheckStateRole:
- case Qt::DisplayRole: {
- TestTreeItem *item =
static_cast<TestTreeItem*>(index.internalPointer());
- if(item)
- return item->data(role);
- return QVariant();
- }
- default:
- return QVariant();
- }
-}
-
-/*! \brief Returns the flags for the item specified by the given index.
- *
- * If the index is invalid, this function returns 0. Otherwise, items
within
- * the TestTreeModel are enabled, selectable, checkable, and if they have
children,
- * are tristate checkable.
- * \see TestTreeModel::setCheckState() for more information on check
states.
- */
-Qt::ItemFlags TestTreeModel::flags(const QModelIndex& index) const {
- if (!index.isValid())
- return 0;
-
- Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable |
Qt::ItemIsUserCheckable;
-
- if(static_cast<TestTreeItem*>(index.internalPointer())->childCount() > 0)
- flags |= Qt::ItemIsTristate;
-
- return flags;
-}
-
-/*! \brief Retrieves the header information for the model.
- *
- * Section and orientation are ignored for this model. We only provide
data in
- * one dimension so there are unnecessary. The data for the given role is
provided.
- * \return The data for the given role.
- */
-QVariant TestTreeModel::headerData(int /*section*/, Qt::Orientation
/*orientation*/, int role) const {
- if(rootItem)
- return rootItem->data(role);
- return QVariant();
-}
-
-/*! \brief Retrieves a model index at the specified (row, columns) from
the given parent.
- *
- * Retrieves a model index for the model. If parent is not specified, or
is a default
- * constructed index, an index to a top level item is returned.
- * \return A model index for the given row and column with the
parent 'parent'.
- */
-QModelIndex TestTreeModel::index(int row, int column, const QModelIndex&
parent) const {
- if(!hasIndex(row, column, parent))
- return QModelIndex();
-
- TestTreeItem* parentItem;
- TestTreeItem* childItem;
-
- if(parent.isValid())
- parentItem = static_cast<TestTreeItem*>(parent.internalPointer());
- else
- parentItem = rootItem;
-
- childItem = parentItem->child(row);
- if(childItem)
- return createIndex(row, column, childItem);
- return QModelIndex();
-}
-
-/*! \brief Retrieves the parent of the index provided.
- *
- * If the index is invalid or is a top level item, an invalid index is
returned.
- * \return The parent of the index if it exists. An invalid index
otherwise.
- */
-QModelIndex TestTreeModel::parent(const QModelIndex &index) const {
- if (!index.isValid())
- return QModelIndex();
-
- TestTreeItem *childItem =
static_cast<TestTreeItem*>(index.internalPointer());
- TestTreeItem *parentItem = childItem->parent();
-
- if (parentItem == rootItem || !parentItem)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
-}
-
-/*! \brief Retrieves the number of rows provided by the parent 'parent'.
- *
- * \return If the index is valid, the number of children held by 'parent'
is returned.
- * Else, the number of top level items is returned.
- */
-int TestTreeModel::rowCount(const QModelIndex& parent) const {
- TestTreeItem *parentItem;
- if (parent.column() > 0)
- return 0;
-
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<TestTreeItem*>(parent.internalPointer());
-
- return parentItem->childCount();
-}
-
-/*! \brief Sets data on the model.
- *
- * It is trusted that the user of this function respects the information
provided by
- * \see TestTreeModel::flags(). This function will set the data contained
in var
- * on the item specified by index for the given role. If data in the model
is changed,
- * the TestTreeModel::dataChanged() signal is emitted.
- */
-bool TestTreeModel::setData(const QModelIndex& index, const QVariant& var,
int role) {
- if(!index.isValid())
- return false;
- TestTreeItem* item = static_cast<TestTreeItem*>(index.internalPointer());
- if(!item)
- return false;
-
- bool dataModified;
- if(role == Qt::CheckStateRole)
- dataModified = this->setCheckState(item,
static_cast<Qt::CheckState>(var.value<int>()));
- else {
- dataModified = item->setData(var, role);
- if(dataModified)
- emit dataChanged(index, index);
- }
- return dataModified;
-}
-
-/*! \brief Sets the checkstate on the given item.
- *
- * This function is recursive. The recursion is only allowed to propagate
- * away from the original item that has been checked. This function
maintains
- * the consistency of the check states of items contained in the model.
The rules
- * are described as follows:
- * \li An item that is a leaf (i.e. has no children) cannot be partially
checked.
- * \li An item must be set to partially checked if it contains both
checked and unchecked
- * or partially checked child items.
- * \li If a partially checked item is changed to checked, all its children
will be checked.
- * \li If a checked item is set to unchecked, all its children will be
unchecked.
- * \return true of the checking was successful, false otherwise.
- */
-bool TestTreeModel::setCheckState(TestTreeItem* item, Qt::CheckState
newState, int recursionDirection) {
- if(!item)
- return false;
- bool retval;
- if(newState == Qt::Checked || newState == Qt::Unchecked) {
- if(recursionDirection & TO_CHILDREN)
- for(int i=0,j=item->childCount();i<j;i++)
- setCheckState(item->child(i), newState, TO_CHILDREN);
-
- retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
- if(recursionDirection & TO_PARENT) {
- setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
- }
- }
- else /*newState == Qt::PartiallyChecked*/ {
- bool checked = false;
- bool unchecked = false;
- Qt::CheckState childState;
- for(int i=0,j=item->childCount();i<j&&(!checked||!unchecked);i++) {
- childState =
static_cast<Qt::CheckState>(item->child(i)->data(Qt::CheckStateRole).value<int>());
- if(childState == Qt::Checked)
- checked = true;
- else if(childState == Qt::Unchecked)
- unchecked = true;
- }
- if(recursionDirection == (TO_PARENT | TO_CHILDREN)) {
- if(checked && !unchecked)
- newState = Qt::Unchecked;
- else if(!checked && unchecked)
- newState = Qt::Checked;
- for(int i=0,j=item->childCount();i<j;i++)
- setCheckState(item->child(i), newState, TO_CHILDREN);
- retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
- }
- else {
- if(checked && !unchecked)
- newState = Qt::Checked; //only checked children
- else if(!checked && unchecked)
- newState = Qt::Unchecked; //only unchecked children
- retval = item->setData(QVariant(static_cast<int>(newState)),
Qt::CheckStateRole);
- }
- if(recursionDirection & TO_PARENT) {
- setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
- }
- }
- QModelIndex index(createIndex(item->row(),0,item));
- emit dataChanged(index, index);
- return retval;
-}
+TestTreeModel::~TestTreeModel() {}

/*! \brief This function adds a data source for this model.
*
@@ -271,7 +52,7 @@
* \todo Set this function to take a QFile instead of a string.
*/
TestTreeModel::ERROR TestTreeModel::addDataSource(const QString filepath) {
- QSharedPointer<GTestExecutable> newTest =
QSharedPointer<GTestExecutable>(new GTestExecutable(this));
+ QSharedPointer<GTestExecutable> newTest(new GTestExecutable(this));
newTest->setExecutablePath(filepath);
switch(newTest->getState()) {
case GTestExecutable::VALID:
@@ -292,7 +73,7 @@
}
}

-/* \brief Creates a tree item and sets up some slot/signals.
+/*! \brief Creates a tree item and sets up some slot/signals.
*
* This function is a help to the updateListing method which enables
* simplified creation of new tree items. It is templated as I didn't
@@ -302,19 +83,20 @@
* test item.
*/
template <class T, class U>
-TestTreeItem* TestTreeModel::createNewTreeItem(T* parent, U* test) {
+TreeItem* TestTreeModel::createNewTreeItem(T parent, U* test) {
QVariant var;
- QMap<int, QVariant> data;
+ QList<QMap<int, QVariant> > data;
+ QMap<int, QVariant> datum;
var.setValue<QString>(test->objectName());
- data.insert(Qt::DisplayRole, var);
+ datum.insert(Qt::DisplayRole, var);
var.setValue<GTest*>(test);
- data.insert(Qt::UserRole, var);
+ datum.insert(Qt::UserRole, var);
var.setValue(static_cast<int>(Qt::Unchecked));
- data.insert(Qt::CheckStateRole, var);
- TestTreeItem* newTreeItem = new TestTreeItem(data, parent);
-
+ datum.insert(Qt::CheckStateRole, var);
+ data.append(datum);
+
+ TreeItem* newTreeItem(new TreeItem(data, parent));
itemTestHash.insert(test, newTreeItem);
-
QObject::connect(test, SIGNAL(destroyed()),
this, SLOT(removeSenderItem()));
QObject::connect(test, SIGNAL(testResultsReady()),
@@ -340,25 +122,26 @@
return;
}

- TestTreeItem* suiteTreeItem = 0;
- TestTreeItem* testTreeItem = 0;
- TestTreeItem* exeTreeItem = rootItem->findChild(gtest->objectName(),
Qt::DisplayRole);
+ TreeItem* suiteTreeItem;
+ TreeItem* treeItem;
+ TreeItem* exeTreeItem = rootItem.findChild(gtest->objectName(),
Qt::DisplayRole);

if(!exeTreeItem) {
//If we haven't added the test yet, make one now.
- exeTreeItem =
createNewTreeItem<TestTreeItem,GTestExecutable>(rootItem,gtest);
- insertItem(exeTreeItem, rootItem->childCount(), rootItem);
+ exeTreeItem = createNewTreeItem<TreeItem*,GTestExecutable>(&rootItem,
gtest);
+ this->insertItem(exeTreeItem, rootItem.childCount(), &rootItem);

QObject::connect(this, SIGNAL(runningTests()),
gtest, SLOT(runTest()));
QObject::connect(this, SIGNAL(resettingRunStates()),
gtest, SLOT(resetRunState()));
}
-
//Get which of the tests are new. This should be all of them the first
//time through for this test.
QSet<QString> newTests = gtest->getListing() - gtest->getOldListing();

+ //! \todo Remove old tests that are no longer present.
+
//Iterate through all the suites.
QList<GTestSuite*> suiteList = gtest->findChildren<GTestSuite*>();
QList<GTestSuite*>::iterator suiteIter = suiteList.begin();
@@ -369,8 +152,8 @@
}

//Create a new GTestSuite tree item.
- suiteTreeItem = createNewTreeItem<TestTreeItem,GTestSuite>(exeTreeItem,
*suiteIter);
- insertItem(suiteTreeItem, exeTreeItem->childCount(), exeTreeItem);
+ suiteTreeItem = createNewTreeItem<TreeItem*,GTestSuite>(exeTreeItem,
*suiteIter);
+ this->insertItem(suiteTreeItem, exeTreeItem->childCount(), exeTreeItem);

//Iterate through all the tests of this suite.
QList<GTest*> testList = (*suiteIter)->findChildren<GTest*>();
@@ -382,8 +165,8 @@
}

//Create a new GTest tree item.
- testTreeItem = createNewTreeItem<TestTreeItem, GTest>(suiteTreeItem,
*testIter);
- insertItem(testTreeItem, suiteTreeItem->childCount(), suiteTreeItem);
+ treeItem = createNewTreeItem<TreeItem*, GTest>(suiteTreeItem,
*testIter);
+ this->insertItem(treeItem, suiteTreeItem->childCount(), suiteTreeItem);
++testIter;
}
++suiteIter;
@@ -404,11 +187,11 @@
GTest* test = static_cast<GTest*>(sender());
if(test == 0)
return; //! \todo exception management stuff here
- TestTreeItem* treeItem = itemTestHash.value(test);
+ TreeItem* treeItem = itemTestHash.value(test);
if(treeItem == 0)
return; //! \todo exception management stuff here

- QVariant var = treeItem->data(Qt::UserRole);
+ QVariant var = treeItem->data(0, Qt::UserRole);
GTest* testItem = var.value<GTest*>();
if(testItem == 0) {
testItem = var.value<GTestSuite*>();
@@ -428,6 +211,17 @@
setData(index, QVariant(QBrush(QColor(0xAB,0xFF,0xBB,0xFF))),
Qt::BackgroundRole);
else
setData(index, QVariant(QBrush(QColor(0xFF,0x88,0x88,0xFF))),
Qt::BackgroundRole);
+
+ //clean up the old meta item
+ emit metaDataAboutToBeChanged(index);
+ var = treeItem->data(0, Qt::MetaDataRole);
+ MetaItem* oldMetaItem = var.value<MetaItem*>();
+ if(oldMetaItem)
+ delete oldMetaItem;
+
+ //create a new meta item and insert it into the tree item.
+ var.setValue<MetaItem* >(testResults->createMetaItem());
+ treeItem->setData(var, 0, Qt::MetaDataRole);
}

/*! \brief A slot that removes the signal's sender from the data model.
@@ -439,45 +233,6 @@
GTest* test = static_cast<GTest*>(sender());
if(!test)
return; //! \todo exception management stuff here
- TestTreeItem* item = itemTestHash.value(test);
- item->parent()->removeChild(item);
- itemTestHash.remove(test);
- delete item; //! \todo use QSharedPointers for items
-}
-
-/*! \brief Inserts a single item into the model before row 'row' on the
parent given.
- *
- * If the parent, or the item is null, this function does nothing and
returns false.
- * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the child
- * is inserted into the model.
- * \return true if the item was inserted successfully, false otherwise.
- */
-bool TestTreeModel::insertItem(TestTreeItem* item, int row, TestTreeItem*
parent) {
- if(item == 0 || parent == 0)
- return false;
- beginInsertRows(createIndex(parent->row(), 0, parent), row, row);
- parent->insertChild(row, item);
- endInsertRows();
- return true;
-}
-
-/*! \brief Inserts a list of items into the model before row 'row' on the
parent given.
- *
- * If the parent, or the item is null, this function does nothing and
returns false.
- * Otherwise, the appropriate QAbstractItemModel signals are emitted and
the children
- * are inserted into the model.
- * \param items A list of items to be inserted.
- * \param row The position to insert the items.
- * \param parent The parent to add the items to as child rows.
- * \return true if the items were inserted successfully, false otherwise.
- */
-bool TestTreeModel::insertItems(QList<TestTreeItem*> items, int row,
TestTreeItem* parent) {
- if(items.count() == 0 || parent == 0)
- return false;
- beginInsertRows(createIndex(parent->row(), 0, parent), row,
row+items.count());
- parent->insertChildren(row, items);
- endInsertRows();
- return true;
}

/*! \brief Runs all tests that are checked.
@@ -490,19 +245,19 @@
void TestTreeModel::runTests() {
emit aboutToRunTests();

- QStack<TestTreeItem*> stack;
- QList<TestTreeItem*> children;
- TestTreeItem* item;
- stack.push(rootItem);
+ QStack<TreeItem* > stack;
+ QList<TreeItem* > children;
+ TreeItem* item;
+ stack.push(&rootItem);

while(!stack.isEmpty()) {
item = stack.pop();
- GTest* test = item->data(Qt::UserRole).value<GTest*>();
- if(test && (item->data(Qt::CheckStateRole).value<int>() == Qt::Checked))
+ GTest* test = item->data(0, Qt::UserRole).value<GTest*>();
+ if(test && (item->data(0, Qt::CheckStateRole).value<int>() ==
Qt::Checked))
test->run();
else {
children = item->children();
- QList<TestTreeItem*>::iterator it = children.begin();
+ QList<TreeItem* >::iterator it = children.begin();
while(it != children.end()) {
stack.push(*it);
++it;
@@ -512,6 +267,7 @@

emit runningTests();
}
+

/*! \brief Updates all the listings for every GTestExecutable.
*
@@ -526,5 +282,110 @@
}
}

+/*! \brief Retrieves the data specified by the given index and role.
+ *
+ * This function only gives metadata specific data, specified by the
+ * Qt::MetaDataRole. Other data is requested from the parent class.
+ * \see TreeModel::data()
+ * \param index A model index to this tree model.
+ * \param role The role to retrieve data from.
+ * \return A QVariant of the data.
+ */
+QVariant TestTreeModel::data(const QModelIndex& index, int role) const {
+ if(role != Qt::MetaDataRole)
+ return TreeModel::data(index, role);
+
+ TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+ if(item)
+ return item->data(0, role);
+ return QVariant();
+}
+
+/*! \brief Sets the data of the given index and role to the variant var.
+ *
+ * This function only handles the Qt::CheckStateRole role to manage
appropriate
+ * checking of check boxes (e.g. when a parent item is checked, so are its
children.
+ * \see TestTreeModel::setCheckState() for more details. All other data is
passed
+ * to the parent class to handle.
+ * \param index The index to set data on.
+ * \param var The value to set the index and role to.
+ * \param role The role to set the value to.
+ * \return true if successfully set, false otherwise.
+ */
+bool TestTreeModel::setData(const QModelIndex& index, const QVariant& var,
int role) {
+ if(role != Qt::CheckStateRole)
+ return TreeModel::setData(index, var, role);
+
+ if(!index.isValid())
+ return false;
+ TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
+ if(!item)
+ return false;
+
+ return this->setCheckState(item,
static_cast<Qt::CheckState>(var.value<int>()));
+}
+
+/*! \brief Sets the checkstate on the given item.
+ *
+ * This function is recursive. The recursion is only allowed to propagate
+ * away from the original item that has been checked. This function
maintains
+ * the consistency of the check states of items contained in the model.
The rules
+ * are described as follows:
+ * \li An item that is a leaf (i.e. has no children) cannot be partially
checked.
+ * \li An item must be set to partially checked if it contains both
checked and unchecked
+ * or partially checked child items.
+ * \li If a partially checked item is changed to checked, all its children
will be checked.
+ * \li If a checked item is set to unchecked, all its children will be
unchecked.
+ * \return true of the checking was successful, false otherwise.
+ */
+bool TestTreeModel::setCheckState(TreeItem* item, Qt::CheckState newState,
int recursionDirection) {
+ if(!item)
+ return false;
+ bool retval;
+ if(newState == Qt::Checked || newState == Qt::Unchecked) {
+ if(recursionDirection & TO_CHILDREN)
+ for(int i=0,j=item->childCount();i<j;i++)
+ setCheckState(item->child(i), newState, TO_CHILDREN);
+
+ retval = item->setData(QVariant(static_cast<int>(newState)), 0,
Qt::CheckStateRole);
+ if(recursionDirection & TO_PARENT) {
+ setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
+ }
+ }
+ else /*newState == Qt::PartiallyChecked*/ {
+ bool checked = false;
+ bool unchecked = false;
+ Qt::CheckState childState;
+ for(int i=0,j=item->childCount();i<j&&(!checked||!unchecked);i++) {
+ childState = static_cast<Qt::CheckState>(item->child(i)->data(0,
Qt::CheckStateRole).value<int>());
+ if(childState == Qt::Checked)
+ checked = true;
+ else if(childState == Qt::Unchecked)
+ unchecked = true;
+ }
+ if(recursionDirection == (TO_PARENT | TO_CHILDREN)) {
+ if(checked && !unchecked)
+ newState = Qt::Unchecked;
+ else if(!checked && unchecked)
+ newState = Qt::Checked;
+ for(int i=0,j=item->childCount();i<j;i++)
+ setCheckState(item->child(i), newState, TO_CHILDREN);
+ retval = item->setData(QVariant(static_cast<int>(newState)), 0,
Qt::CheckStateRole);
+ }
+ else {
+ if(checked && !unchecked)
+ newState = Qt::Checked; //only checked children
+ else if(!checked && unchecked)
+ newState = Qt::Unchecked; //only unchecked children
+ retval = item->setData(QVariant(static_cast<int>(newState)), 0,
Qt::CheckStateRole);
+ }
+ if(recursionDirection & TO_PARENT) {
+ setCheckState(item->parent(), Qt::PartiallyChecked, TO_PARENT);
+ }
+ }
+ QModelIndex index(createIndex(item->row(),0,item));
+ emit dataChanged(index, index);
+ return retval;
+}


Reply all
Reply to author
Forward
0 new messages