src/hbwidgets/itemviews/hbtreemodeliterator_p.cpp
changeset 5 627c4a0fd0e7
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    39 {
    39 {
    40 }
    40 }
    41 
    41 
    42 /*!
    42 /*!
    43     \reimp
    43     \reimp
    44 
    44     Returns count of visible indexes under \a parent.
    45     Children of collapsed parents are not taken into account.
    45     Children of collapsed parents are not taken into account.
    46 */
    46 */
    47 int HbTreeModelIterator::indexCount(const QModelIndex &parent) const
    47 int HbTreeModelIterator::indexCount(const QModelIndex &parent) const
    48 {
    48 {
    49     Q_D(const HbTreeModelIterator);
    49     Q_D(const HbTreeModelIterator);
    71     return itemsCount;
    71     return itemsCount;
    72 }
    72 }
    73 
    73 
    74 /*!
    74 /*!
    75     \reimp
    75     \reimp
    76     Position depends on item state - expanded/colapsed
    76     Returns ordinal of index starting from root. Ordinal for first index under root is 0.
       
    77     Indexes in collapsed parents are taken into account.
    77 */
    78 */
    78 int HbTreeModelIterator::indexPosition(const QModelIndex &index) const
    79 int HbTreeModelIterator::indexPosition(const QModelIndex &index) const
    79 {
    80 {
    80     Q_D(const HbTreeModelIterator);
    81     Q_D(const HbTreeModelIterator);
    81     int result = -1;
    82     int result = -1;
    92     return result;
    93     return result;
    93 }
    94 }
    94 
    95 
    95 /*!
    96 /*!
    96     \reimp
    97     \reimp
    97     Index is calculated from position and it depends on item state - expanded/colapsed
    98     Returnes index of item, which is visible at pos ordinal under parent. 
       
    99     Indexes in collapsed parents are not taken into account.
    98     Very slow - need to interate throught whole model in worst case!
   100     Very slow - need to interate throught whole model in worst case!
    99 */
   101 */
   100 QModelIndex HbTreeModelIterator::index(int pos, const QModelIndex &parent) const
   102 QModelIndex HbTreeModelIterator::index(int pos, const QModelIndex &parent) const
   101 {
   103 {
   102     Q_D(const HbTreeModelIterator);
   104     Q_D(const HbTreeModelIterator);
   173 }
   175 }
   174 
   176 
   175 /*!
   177 /*!
   176     \reimp
   178     \reimp
   177 
   179 
   178     Next index for valid index is determined in following way:
   180     Next visible index for valid index is determined in following way:
   179     - If index is in collapsed branch QModelIndex is returned
   181     - If index is in collapsed branch QModelIndex is returned. 
   180     - If index has children and it is expanded then first child is returned
   182     - If index has children and it is expanded then first child is returned
   181     - Otherwise if index has next sibling then that is returned
   183     - Otherwise if index has next sibling then that is returned
   182     - Otherwise next valid sibling for parent is returned
   184     - Otherwise next valid sibling for parent is returned
   183     - Otherwise QModelIndex is returned
   185     - Otherwise QModelIndex is returned
       
   186     If index was invalid then first valid index is returned.
   184 
   187 
   185     \a index must belong to mRootIndex branch, otherwise result is not determined.
   188     \a index must belong to mRootIndex branch, otherwise result is not determined.
   186 
   189 
   187     To get first index use nextIndex(QModelIndex()).
   190     To get first index use nextIndex(QModelIndex()).
   188 */
   191 */
   229 }
   232 }
   230 
   233 
   231 /*!
   234 /*!
   232     \reimp
   235     \reimp
   233 
   236 
   234     Previous index for valid index is determined in following way:
   237     Previous visible index for valid index is determined in following way:
   235     - If index is in collapsed branch QModelIndex is returned
   238     - If index is in collapsed branch QModelIndex is returned
   236     - If index has previous sibling last child from it is returned
   239     - If index has previous sibling last child from it is returned
   237     - Otherwise previous sibling is returned
   240     - Otherwise previous sibling is returned
   238     - Otherwise parent index is returned
   241     - Otherwise parent index is returned
   239     - Otherwise QModelIndex is returned
   242     - Otherwise QModelIndex is returned