LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
modeliterator.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QModelIndex>
12#include "modelsconfig.h"
13
14namespace LC::Util
15{
31 {
32 QAbstractItemModel * const Model_;
33 const QModelIndex Parent_;
34
35 int Row_;
36 int Col_;
37 public:
40 enum class Direction
41 {
47
53 };
54 private:
55 const Direction Dir_;
56 public:
65 ModelIterator (QAbstractItemModel *model, int row, int col = 0,
66 Direction dir = Direction::Rows, const QModelIndex& parent = {});
67
73 ModelIterator& operator++ ();
74
80 ModelIterator operator++ (int);
81
87 ModelIterator& operator-- ();
88
94 ModelIterator operator-- (int);
95
101 ModelIterator& operator+= (int count);
102
109 ModelIterator& operator-= (int count);
110
123 int operator- (const ModelIterator& other) const;
124
135 friend UTIL_MODELS_API bool operator== (const ModelIterator& left, const ModelIterator& right);
136
147 friend UTIL_MODELS_API bool operator!= (const ModelIterator& left, const ModelIterator& right);
148
154 QModelIndex operator* () const;
155
162 int GetRow () const;
163
170 int GetCol () const;
171 private:
172 int& GetIncrementable ();
173 int GetIncrementable () const;
174 };
175}
176
177namespace std
178{
179 template<>
180 struct iterator_traits<LC::Util::ModelIterator>
181 {
182 typedef QModelIndex value_type;
183 typedef int difference_type;
184
185 typedef random_access_iterator_tag iterator_category;
186 };
187}
Provides an iterator-based API to a Qt model.
ModelIterator(QAbstractItemModel *model, int row, int col=0, Direction dir=Direction::Rows, const QModelIndex &parent={})
Constructs an iterator.
Direction
The direction of traversal.
@ Rows
The model should be traversed by rows.
@ Cols
The model should be traversed by columns.
auto operator==(const T &left, const T &right)
Definition common.h:38
#define UTIL_MODELS_API
Definition constants.h:15
STL namespace.