src/hbwidgets/itemviews/hbtreemodeliterator_p_p.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    37 HbTreeModelIteratorPrivate::~HbTreeModelIteratorPrivate()
    37 HbTreeModelIteratorPrivate::~HbTreeModelIteratorPrivate()
    38 {
    38 {
    39 }
    39 }
    40 
    40 
    41 /*
    41 /*
    42     Return first index belonging to specified parent
    42     Return first visible index belonging to specified parent.
    43     If parent is colapsed QModelIndex is returned
    43     If parent is collapsed QModelIndex is returned.
    44 */
    44 */
    45 QModelIndex HbTreeModelIteratorPrivate::first(const QModelIndex &parent) const
    45 QModelIndex HbTreeModelIteratorPrivate::first(const QModelIndex &parent) const
    46 {
    46 {
    47     if (mModel) {
    47     if (mModel) {
    48         if (!parent.isValid()
    48         if (!parent.isValid()
    52     }
    52     }
    53     return QModelIndex();
    53     return QModelIndex();
    54 }
    54 }
    55 
    55 
    56 /*
    56 /*
    57     Return last index belonging to specified parent - last child in whole parent branch
    57     Return last visible index belonging to specified parent - last child in whole parent branch.
       
    58     If parent is collapsed QModelIndex is returned.
    58 */
    59 */
    59 QModelIndex HbTreeModelIteratorPrivate::last(const QModelIndex &parent) const
    60 QModelIndex HbTreeModelIteratorPrivate::last(const QModelIndex &parent) const
    60 {
    61 {
    61     // last(mRootIndex) when mRootIndex is not expanded return invalid index
    62     // last(mRootIndex) when mRootIndex is not expanded return invalid index
    62     if (mModel) {
    63     if (mModel) {
   110         result++;
   111         result++;
   111         if (!startIndex.isValid()) { //end reached, not found
   112         if (!startIndex.isValid()) { //end reached, not found
   112             return -1;
   113             return -1;
   113         }
   114         }
   114     }
   115     }
   115     mCachedPosition.count = result;
   116 
   116     mCachedPosition.index = index;
   117     if (mUseCache) {
       
   118         mCachedPosition.count = result;
       
   119         mCachedPosition.index = index;
       
   120     }
   117     return result;
   121     return result;
   118 }
   122 }
   119 
   123 
   120 int HbTreeModelIteratorPrivate::searchBackward(const QModelIndex &index) const
   124 int HbTreeModelIteratorPrivate::searchBackward(const QModelIndex &index) const
   121 {
   125 {
   128         if (startIndex == mRootIndex
   132         if (startIndex == mRootIndex
   129             || !startIndex.isValid()) { //start reached, not found
   133             || !startIndex.isValid()) { //start reached, not found
   130             return -1;
   134             return -1;
   131         }
   135         }
   132     }
   136     }
   133     mCachedPosition.count = result;
   137 
   134     mCachedPosition.index = index;
   138     if (mUseCache) {
       
   139         mCachedPosition.count = result;
       
   140         mCachedPosition.index = index;
       
   141     }
   135     return result;
   142     return result;
   136 }
   143 }
   137 
   144 
   138 QModelIndexList HbTreeModelIteratorPrivate::createParentChainList(const QModelIndex &index) const
   145 QModelIndexList HbTreeModelIteratorPrivate::createParentChainList(const QModelIndex &index) const
   139 {
   146 {