]>
cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemrange.h
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2013 Frank Reininghaus <frank78ac@googlemail.com>
5 * Based on the Itemviews NG project from Trolltech Labs
7 * SPDX-License-Identifier: GPL-2.0-or-later
16 KItemRange(int index
= 0, int count
= 0);
20 bool operator==(const KItemRange
&other
) const;
23 inline KItemRange::KItemRange(int index
, int count
)
29 inline bool KItemRange::operator==(const KItemRange
&other
) const
31 return index
== other
.index
&& count
== other
.count
;
34 class KItemRangeList
: public QList
<KItemRange
>
41 explicit KItemRangeList(const QList
<KItemRange
> &list
)
42 : QList
<KItemRange
>(list
)
46 template<class Container
>
47 static KItemRangeList
fromSortedContainer(const Container
&container
);
49 KItemRangeList
&operator<<(const KItemRange
&range
)
56 template<class Container
>
57 KItemRangeList
KItemRangeList::fromSortedContainer(const Container
&container
)
59 typename
Container::const_iterator it
= container
.constBegin();
60 const typename
Container::const_iterator end
= container
.constEnd();
63 return KItemRangeList();
66 KItemRangeList result
;
71 // Remove duplicates, see https://bugs.kde.org/show_bug.cgi?id=335672
72 while (it
!= end
&& *it
== index
) {
77 if (*it
== index
+ count
) {
80 result
<< KItemRange(index
, count
);
86 // Remove duplicates, see https://bugs.kde.org/show_bug.cgi?id=335672
87 while (it
!= end
&& *it
== *(it
- 1)) {
92 result
<< KItemRange(index
, count
);