• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • gui
coordrangelist.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Gui library, made within the KDE community.
3 
4  Copyright 2003 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "coordrangelist.h"
24 
25 
26 namespace Okteta
27 {
28 
29 CoordRangeList::CoordRangeList()
30 {
31 }
32 
33 
34 void CoordRangeList::addCoordRange( const CoordRange& coordRange )
35 {
36  if( ! coordRange.isValid() )
37  return;
38 
39  // we try to insert it by ascending indizes
40  // if sections are overlapping we combine them
41  Iterator it = begin();
42  Iterator endIt = end();
43  for( ; it != endIt; ++it )
44  {
45  // TODO: add bufferwidth to rangelist so consecutive ranges can be joined, cmp sectionlist
46  // is next CoordRange behind the new CoordRange?
47  if( coordRange.endsBefore(*it) )
48  {
49  // put the new before it
50  insert( it, coordRange );
51  return;
52  }
53 
54  // does the next CoordRange overlap?
55  if( (*it).overlaps(coordRange) )
56  {
57  CoordRange mergedCoordRange( coordRange );
58  // Start of the combined sections is the smaller one
59  mergedCoordRange.extendStartTo( (*it).start() );
60  // next we search all the overlapping sections and keep the highest end index
61  Coord endCoord( (*it).end() );
62  iterator it2 = it;
63  for( ++it2; it2 != endIt; ++it2 )
64  {
65  if( coordRange.endsBefore((*it2).start()) )
66  break;
67  endCoord = (*it2).end();
68  }
69  // the higher end is the end of the combined CoordRange
70  mergedCoordRange.extendEndTo( endCoord );
71  // remove all overlapping sections
72  it = erase( it, it2 );
73  // and instead insert the combined one
74  insert( it, mergedCoordRange );
75  return;
76  }
77  }
78 
79  // all others are before the new?
80  if( it == endIt )
81  // add it at the end
82  append( coordRange );
83 }
84 
85 
86 CoordRangeList::~CoordRangeList()
87 {
88 }
89 
90 }
Okteta::CoordRange
describes a range in the buffercoord
Definition: coordrange.h:51
Okteta::CoordRangeList::~CoordRangeList
~CoordRangeList()
Definition: coordrangelist.cpp:86
KDE::Range::extendEndTo
void extendEndTo(T Limit)
extends the end to Limit.
Definition: range.h:76
Okteta::Coord
a class which represents a coord in a 2-dim.
Definition: coord.h:47
Okteta::CoordRangeList::addCoordRange
void addCoordRange(const CoordRange &coordRange)
Definition: coordrangelist.cpp:34
coordrangelist.h
KDE::Range::extendStartTo
void extendStartTo(T Limit)
extends the start to Limit.
Definition: range.h:74
KDE::Range::endsBefore
bool endsBefore(T Value) const
returns true if range is before index.
Definition: range.h:103
Okteta::CoordRangeList::CoordRangeList
CoordRangeList()
Definition: coordrangelist.cpp:29
KDE::Range::isValid
bool isValid() const
returns true if the range covers at least one index
Definition: range.h:122
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal