summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2015-01-08 22:56:31 +0100
committerhjk <hjk@theqtcompany.com>2015-01-09 13:49:00 +0100
commit82c2f51a295d72ded67637e776d74464d2680a87 (patch)
tree9af8f750603e646038045099dc0861c97574d628 /src
parent94b8a21fbf871774c05875d82d8bb8174ebf3e0b (diff)
downloadqt-creator-82c2f51a295d72ded67637e776d74464d2680a87.tar.gz
TreeModel: Make debug help code less intrusive
Has not been needed for a while. Change-Id: I141725d77343c4afa9907fde6af8e283f2744c88 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/treemodel.cpp40
-rw-r--r--src/libs/utils/treemodel.h2
2 files changed, 21 insertions, 21 deletions
diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp
index 32e7cdc8bc..c0521c1499 100644
--- a/src/libs/utils/treemodel.cpp
+++ b/src/libs/utils/treemodel.cpp
@@ -38,6 +38,19 @@
to use in a QTreeView.
*/
+#if 0
+#define CHECK_INDEX(index) \
+ do { \
+ if (index.isValid()) { \
+ QTC_CHECK(index.model() == this); \
+ } else { \
+ QTC_CHECK(index.model() == 0); \
+ } \
+ } while (false)
+#else
+#define CHECK_INDEX(index)
+#endif
+
namespace Utils {
//
@@ -171,7 +184,7 @@ TreeModel::~TreeModel()
QModelIndex TreeModel::parent(const QModelIndex &idx) const
{
- checkIndex(idx);
+ CHECK_INDEX(idx);
if (!idx.isValid())
return QModelIndex();
@@ -193,7 +206,7 @@ QModelIndex TreeModel::parent(const QModelIndex &idx) const
int TreeModel::rowCount(const QModelIndex &idx) const
{
- checkIndex(idx);
+ CHECK_INDEX(idx);
if (!idx.isValid())
return m_root->rowCount();
if (idx.column() > 0)
@@ -203,7 +216,7 @@ int TreeModel::rowCount(const QModelIndex &idx) const
int TreeModel::columnCount(const QModelIndex &idx) const
{
- checkIndex(idx);
+ CHECK_INDEX(idx);
if (!idx.isValid())
return m_root->columnCount();
if (idx.column() > 0)
@@ -245,7 +258,7 @@ void TreeModel::setRootItem(TreeItem *item)
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
{
- checkIndex(parent);
+ CHECK_INDEX(parent);
if (!hasIndex(row, column, parent))
return QModelIndex();
@@ -258,10 +271,8 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
TreeItem *TreeModel::itemFromIndex(const QModelIndex &idx) const
{
- checkIndex(idx);
- TreeItem *item = idx.isValid() ? static_cast<TreeItem*>(idx.internalPointer()) : m_root;
-// CHECK(checkItem(item));
- return item;
+ CHECK_INDEX(idx);
+ return idx.isValid() ? static_cast<TreeItem*>(idx.internalPointer()) : m_root;
}
QModelIndex TreeModel::indexFromItem(const TreeItem *item) const
@@ -318,29 +329,20 @@ void TreeModel::removeItem(TreeItem *item)
QModelIndex TreeModel::indexFromItemHelper(const TreeItem *needle,
TreeItem *parentItem, const QModelIndex &parentIndex) const
{
- checkIndex(parentIndex);
+ CHECK_INDEX(parentIndex);
if (needle == parentItem)
return parentIndex;
for (int i = parentItem->rowCount(); --i >= 0; ) {
TreeItem *childItem = parentItem->child(i);
QModelIndex childIndex = index(i, 0, parentIndex);
QModelIndex idx = indexFromItemHelper(needle, childItem, childIndex);
- checkIndex(idx);
+ CHECK_INDEX(idx);
if (idx.isValid())
return idx;
}
return QModelIndex();
}
-void TreeModel::checkIndex(const QModelIndex &index) const
-{
- if (index.isValid()) {
- QTC_CHECK(index.model() == this);
- } else {
- QTC_CHECK(index.model() == 0);
- }
-}
-
//
// TreeLevelItems
//
diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h
index 4742f8ddc8..5707dfb3d7 100644
--- a/src/libs/utils/treemodel.h
+++ b/src/libs/utils/treemodel.h
@@ -204,8 +204,6 @@ private:
QModelIndex indexFromItemHelper(const TreeItem *needle,
TreeItem *parentItem, const QModelIndex &parentIndex) const;
- void checkIndex(const QModelIndex &index) const;
-
TreeItem *m_root; // Owned.
};