]>
cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemrange.h
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2013 by Frank Reininghaus <frank78ac@googlemail.com> *
5 * Based on the Itemviews NG project from Trolltech Labs: *
6 * http://qt.gitorious.org/qt-labs/itemviews-ng *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
22 ***************************************************************************/
31 KItemRange(int index
= 0, int count
= 0);
35 bool operator == (const KItemRange
& other
) const;
38 inline KItemRange::KItemRange(int index
, int count
) :
44 inline bool KItemRange::operator == (const KItemRange
& other
) const
46 return index
== other
.index
&& count
== other
.count
;
50 class KItemRangeList
: public QList
<KItemRange
>
53 KItemRangeList() : QList
<KItemRange
>() {}
54 KItemRangeList(const QList
<KItemRange
>& list
) : QList
<KItemRange
>(list
) {}
56 template<class Container
>
57 static KItemRangeList
fromSortedContainer(const Container
& container
);
59 KItemRangeList
& operator<<(const KItemRange
& range
)
66 template<class Container
>
67 KItemRangeList
KItemRangeList::fromSortedContainer(const Container
& container
)
69 typename
Container::const_iterator it
= container
.constBegin();
70 const typename
Container::const_iterator end
= container
.constEnd();
73 return KItemRangeList();
76 KItemRangeList result
;
84 if (*it
== index
+ count
) {
87 result
<< KItemRange(index
, count
);
94 result
<< KItemRange(index
, count
);