Qt 4.8
Classes | Public Types | Public Functions | Public Variables | Private Types | Private Functions | Properties | List of all members
QSpanCollection Class Reference

#include <qtableview_p.h>

Classes

struct  Span
 

Public Types

typedef QLinkedList< Span * > SpanList
 

Public Functions

void addSpan (Span *span)
 
void clear ()
 
SpanspanAt (int x, int y) const
 
QList< Span * > spansInRect (int x, int y, int w, int h) const
 
void updateInsertedColumns (int start, int end)
 
void updateInsertedRows (int start, int end)
 
void updateRemovedColumns (int start, int end)
 
void updateRemovedRows (int start, int end)
 
void updateSpan (Span *span, int old_height)
 
 ~QSpanCollection ()
 

Public Variables

SpanList spans
 

Private Types

typedef QMap< int, SubIndexIndex
 
typedef QMap< int, Span * > SubIndex
 

Private Functions

bool cleanSpanSubIndex (SubIndex &subindex, int end, bool update=false)
 

Properties

Index index
 

Detailed Description

Warning
This function is not part of the public interface.

This is a list of span with a binary index to look up quickly a span at a certain index.

The index is a map of map. spans are mentaly divided into sub spans so that the start of any subspans doesn't overlap with any other subspans. There is no real representation of the subspans. The key of the first map is the row where the subspan starts, the value of the first map is a list (map) of all subspans that starts at the same row. It is indexed with its row

Definition at line 77 of file qtableview_p.h.

Typedefs

◆ Index

typedef QMap<int, SubIndex> QSpanCollection::Index
private

Definition at line 124 of file qtableview_p.h.

◆ SpanList

Definition at line 119 of file qtableview_p.h.

◆ SubIndex

typedef QMap<int, Span *> QSpanCollection::SubIndex
private

Definition at line 123 of file qtableview_p.h.

Constructors and Destructors

◆ ~QSpanCollection()

QSpanCollection::~QSpanCollection ( )
inline

Definition at line 99 of file qtableview_p.h.

100  {
101  qDeleteAll(spans);
102  }
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ addSpan()

void QSpanCollection::addSpan ( QSpanCollection::Span span)
Warning
This function is not part of the public interface. Add a span to the collection. the collection takes the ownership.

Definition at line 65 of file qtableview.cpp.

66 {
67  spans.append(span);
68  Index::iterator it_y = index.lowerBound(-span->top());
69  if (it_y == index.end() || it_y.key() != -span->top()) {
70  //there is no spans that starts with the row in the index, so create a sublist for it.
71  SubIndex sub_index;
72  if (it_y != index.end()) {
73  //the previouslist is the list of spans that sarts _before_ the row of the span.
74  // and which may intersect this row.
75  const SubIndex previousList = it_y.value();
76  foreach(Span *s, previousList) {
77  //If a subspans intersect the row, we need to split it into subspans
78  if(s->bottom() >= span->top())
79  sub_index.insert(-s->left(), s);
80  }
81  }
82  it_y = index.insert(-span->top(), sub_index);
83  //we will insert span to *it_y in the later loop
84  }
85 
86  //insert the span as supspan in all the lists that intesects the span
87  while(-it_y.key() <= span->bottom()) {
88  (*it_y).insert(-span->left(), span);
89  if(it_y == index.begin())
90  break;
91  --it_y;
92  }
93 }
void append(const T &)
Inserts value at the end of the list.
Definition: qlinkedlist.h:350
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QMap< int, Span * > SubIndex
Definition: qtableview_p.h:123
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
Definition: qmap.h:899

◆ cleanSpanSubIndex()

bool QSpanCollection::cleanSpanSubIndex ( QSpanCollection::SubIndex subindex,
int  y,
bool  update = false 
)
private
Warning
This function is not part of the public interface. Cleans a subindex from to be deleted spans. The update argument is used to move the spans inside the subindex, in case their anchor changed.
Returns
true if no span in this subindex starts at y, and should thus be deleted.

Definition at line 312 of file qtableview.cpp.

Referenced by updateRemovedColumns(), and updateRemovedRows().

313 {
314  if (subindex.isEmpty())
315  return true;
316 
317  bool should_be_deleted = true;
318  SubIndex::iterator it = subindex.end();
319  do {
320  --it;
321  int x = -it.key();
322  Span *span = it.value();
323  if (span->will_be_deleted) {
324  it = subindex.erase(it);
325  continue;
326  }
327  if (update && span->m_left != x) {
328  subindex.insert(-span->m_left, span);
329  it = subindex.erase(it);
330  }
331  if (should_be_deleted && span->m_top == y)
332  should_be_deleted = false;
333  } while (it != subindex.begin());
334 
335  return should_be_deleted;
336 }
#define it(className, varName)
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
Definition: qmap.h:203
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717

◆ clear()

void QSpanCollection::clear ( )
Warning
This function is not part of the public interface. remove and deletes all spans inside the collection

Definition at line 160 of file qtableview.cpp.

161 {
162  qDeleteAll(spans);
163  index.clear();
164  spans.clear();
165 }
void clear()
Removes all the items in the list.
Definition: qlinkedlist.h:311
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
void clear()
Removes all items from the map.
Definition: qmap.h:444

◆ spanAt()

QSpanCollection::Span * QSpanCollection::spanAt ( int  x,
int  y 
) const
Warning
This function is not part of the public interface.
Returns
a spans that spans over cell x,y (column,row) or 0 if there is none.

Definition at line 142 of file qtableview.cpp.

143 {
145  if (it_y == index.end())
146  return 0;
147  SubIndex::const_iterator it_x = (*it_y).lowerBound(-x);
148  if (it_x == (*it_y).end())
149  return 0;
150  Span *span = *it_x;
151  if (span->right() >= x && span->bottom() >= y)
152  return span;
153  return 0;
154 }
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
Definition: qmap.h:899
friend class const_iterator
Definition: qmap.h:369

◆ spansInRect()

QList< QSpanCollection::Span * > QSpanCollection::spansInRect ( int  x,
int  y,
int  w,
int  h 
) const
Warning
This function is not part of the public interface. return a list to all the spans that spans over cells in the given rectangle

Definition at line 170 of file qtableview.cpp.

171 {
172  QSet<Span *> list;
174  if(it_y == index.end())
175  --it_y;
176  while(-it_y.key() <= y + h) {
177  SubIndex::const_iterator it_x = (*it_y).lowerBound(-x);
178  if (it_x == (*it_y).end())
179  --it_x;
180  while(-it_x.key() <= x + w) {
181  Span *s = *it_x;
182  if (s->bottom() >= y && s->right() >= x)
183  list << s;
184  if (it_x == (*it_y).begin())
185  break;
186  --it_x;
187  }
188  if(it_y == index.begin())
189  break;
190  --it_y;
191  }
192  return list.toList();
193 }
QList< T > toList() const
Definition: qset.h:296
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
Definition: qmap.h:899
friend class const_iterator
Definition: qmap.h:369

◆ updateInsertedColumns()

void QSpanCollection::updateInsertedColumns ( int  start,
int  end 
)
Warning
This function is not part of the public interface. Updates the span collection after column insertion.

Definition at line 258 of file qtableview.cpp.

259 {
260 #ifdef DEBUG_SPAN_UPDATE
261  qDebug() << Q_FUNC_INFO;
262  qDebug() << start << end;
263  qDebug() << index;
264 #endif
265  if (spans.isEmpty())
266  return;
267 
268  int delta = end - start + 1;
269 #ifdef DEBUG_SPAN_UPDATE
270  qDebug("Before");
271 #endif
272  for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {
273  Span *span = *it;
274 #ifdef DEBUG_SPAN_UPDATE
275  qDebug() << span << *span;
276 #endif
277  if (span->m_right < start)
278  continue;
279  if (span->m_left >= start)
280  span->m_left += delta;
281  span->m_right += delta;
282  }
283 
284 #ifdef DEBUG_SPAN_UPDATE
285  qDebug("After");
286  foreach (QSpanCollection::Span *span, spans)
287  qDebug() << span << *span;
288 #endif
289 
290  for (Index::iterator it_y = index.begin(); it_y != index.end(); ++it_y) {
291  SubIndex &subindex = it_y.value();
292  for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {
293  int x = -it.key();
294  if (x < start) {
295  ++it;
296  continue;
297  }
298  subindex.insert(-x - delta, it.value());
299  it = subindex.erase(it);
300  }
301  }
302 #ifdef DEBUG_SPAN_UPDATE
303  qDebug() << index;
304 #endif
305 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class iterator
Definition: qlinkedlist.h:149
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlinkedlist.h:103
Q_CORE_EXPORT void qDebug(const char *,...)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlinkedlist.h:185
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
QMap< int, Span * > SubIndex
Definition: qtableview_p.h:123
static const KeyPair *const end
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ updateInsertedRows()

void QSpanCollection::updateInsertedRows ( int  start,
int  end 
)
Warning
This function is not part of the public interface. Updates the span collection after row insertion.

Definition at line 208 of file qtableview.cpp.

209 {
210 #ifdef DEBUG_SPAN_UPDATE
211  qDebug() << Q_FUNC_INFO;
212  qDebug() << start << end;
213  qDebug() << index;
214 #endif
215  if (spans.isEmpty())
216  return;
217 
218  int delta = end - start + 1;
219 #ifdef DEBUG_SPAN_UPDATE
220  qDebug("Before");
221 #endif
222  for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {
223  Span *span = *it;
224 #ifdef DEBUG_SPAN_UPDATE
225  qDebug() << span << *span;
226 #endif
227  if (span->m_bottom < start)
228  continue;
229  if (span->m_top >= start)
230  span->m_top += delta;
231  span->m_bottom += delta;
232  }
233 
234 #ifdef DEBUG_SPAN_UPDATE
235  qDebug("After");
236  foreach (QSpanCollection::Span *span, spans)
237  qDebug() << span << *span;
238 #endif
239 
240  for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {
241  int y = -it_y.key();
242  if (y < start) {
243  ++it_y;
244  continue;
245  }
246 
247  index.insert(-y - delta, it_y.value());
248  it_y = index.erase(it_y);
249  }
250 #ifdef DEBUG_SPAN_UPDATE
251  qDebug() << index;
252 #endif
253 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class iterator
Definition: qlinkedlist.h:149
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlinkedlist.h:103
Q_CORE_EXPORT void qDebug(const char *,...)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlinkedlist.h:185
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717
static const KeyPair *const end
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ updateRemovedColumns()

void QSpanCollection::updateRemovedColumns ( int  start,
int  end 
)
Warning
This function is not part of the public interface. Updates the span collection after column removal.

Definition at line 470 of file qtableview.cpp.

471 {
472 #ifdef DEBUG_SPAN_UPDATE
473  qDebug() << Q_FUNC_INFO;
474  qDebug() << start << end;
475  qDebug() << index;
476 #endif
477  if (spans.isEmpty())
478  return;
479 
480  SpanList toBeDeleted;
481  int delta = end - start + 1;
482 #ifdef DEBUG_SPAN_UPDATE
483  qDebug("Before");
484 #endif
485  for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {
486  Span *span = *it;
487 #ifdef DEBUG_SPAN_UPDATE
488  qDebug() << span << *span;
489 #endif
490  if (span->m_right < start) {
491  ++it;
492  continue;
493  }
494  if (span->m_left < start) {
495  if (span->m_right <= end)
496  span->m_right = start - 1;
497  else
498  span->m_right -= delta;
499  } else {
500  if (span->m_right > end) {
501  if (span->m_left <= end)
502  span->m_left = start;
503  else
504  span->m_left -= delta;
505  span->m_right -= delta;
506  } else {
507  span->will_be_deleted = true;
508  }
509  }
510  if (span->m_top == span->m_bottom && span->m_left == span->m_right)
511  span->will_be_deleted = true;
512  if (span->will_be_deleted) {
513  toBeDeleted.append(span);
514  it = spans.erase(it);
515  } else {
516  ++it;
517  }
518  }
519 
520 #ifdef DEBUG_SPAN_UPDATE
521  qDebug("After");
522  foreach (QSpanCollection::Span *span, spans)
523  qDebug() << span << *span;
524 #endif
525  if (spans.isEmpty()) {
526  qDeleteAll(toBeDeleted);
527  index.clear();
528  return;
529  }
530 
531  for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {
532  int y = -it_y.key();
533  if (cleanSpanSubIndex(it_y.value(), y, true))
534  it_y = index.erase(it_y);
535  else
536  ++it_y;
537  }
538 
539 #ifdef DEBUG_SPAN_UPDATE
540  qDebug() << index;
541  qDebug("Deleted");
542  foreach (QSpanCollection::Span *span, toBeDeleted)
543  qDebug() << span << *span;
544 #endif
545  qDeleteAll(toBeDeleted);
546 }
iterator erase(iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next it...
Definition: qlinkedlist.h:470
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class iterator
Definition: qlinkedlist.h:149
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlinkedlist.h:103
Q_CORE_EXPORT void qDebug(const char *,...)
bool cleanSpanSubIndex(SubIndex &subindex, int end, bool update=false)
Definition: qtableview.cpp:312
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlinkedlist.h:185
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
QLinkedList< Span * > SpanList
Definition: qtableview_p.h:119
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717
static const KeyPair *const end
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
void clear()
Removes all items from the map.
Definition: qmap.h:444
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ updateRemovedRows()

void QSpanCollection::updateRemovedRows ( int  start,
int  end 
)
Warning
This function is not part of the public interface. Updates the span collection after row removal.

Definition at line 341 of file qtableview.cpp.

342 {
343 #ifdef DEBUG_SPAN_UPDATE
344  qDebug() << Q_FUNC_INFO;
345  qDebug() << start << end;
346  qDebug() << index;
347 #endif
348  if (spans.isEmpty())
349  return;
350 
351  SpanList spansToBeDeleted;
352  int delta = end - start + 1;
353 #ifdef DEBUG_SPAN_UPDATE
354  qDebug("Before");
355 #endif
356  for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {
357  Span *span = *it;
358 #ifdef DEBUG_SPAN_UPDATE
359  qDebug() << span << *span;
360 #endif
361  if (span->m_bottom < start) {
362  ++it;
363  continue;
364  }
365  if (span->m_top < start) {
366  if (span->m_bottom <= end)
367  span->m_bottom = start - 1;
368  else
369  span->m_bottom -= delta;
370  } else {
371  if (span->m_bottom > end) {
372  if (span->m_top <= end)
373  span->m_top = start;
374  else
375  span->m_top -= delta;
376  span->m_bottom -= delta;
377  } else {
378  span->will_be_deleted = true;
379  }
380  }
381  if (span->m_top == span->m_bottom && span->m_left == span->m_right)
382  span->will_be_deleted = true;
383  if (span->will_be_deleted) {
384  spansToBeDeleted.append(span);
385  it = spans.erase(it);
386  } else {
387  ++it;
388  }
389  }
390 
391 #ifdef DEBUG_SPAN_UPDATE
392  qDebug("After");
393  foreach (QSpanCollection::Span *span, spans)
394  qDebug() << span << *span;
395 #endif
396  if (spans.isEmpty()) {
397  qDeleteAll(spansToBeDeleted);
398  index.clear();
399  return;
400  }
401 
402  Index::iterator it_y = index.end();
403  do {
404  --it_y;
405  int y = -it_y.key();
406  SubIndex &subindex = it_y.value();
407  if (y < start) {
408  if (cleanSpanSubIndex(subindex, y))
409  it_y = index.erase(it_y);
410  } else if (y >= start && y <= end) {
411  bool span_at_start = false;
412  SubIndex spansToBeMoved;
413  for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ++it) {
414  Span *span = it.value();
415  if (span->will_be_deleted)
416  continue;
417  if (!span_at_start && span->m_top == start)
418  span_at_start = true;
419  spansToBeMoved.insert(it.key(), span);
420  }
421 
422  if (y == start && span_at_start)
423  subindex.clear();
424  else
425  it_y = index.erase(it_y);
426 
427  if (span_at_start) {
428  Index::iterator it_start;
429  if (y == start)
430  it_start = it_y;
431  else {
432  it_start = index.find(-start);
433  if (it_start == index.end())
434  it_start = index.insert(-start, SubIndex());
435  }
436  SubIndex &start_subindex = it_start.value();
437  for (SubIndex::iterator it = spansToBeMoved.begin(); it != spansToBeMoved.end(); ++it)
438  start_subindex.insert(it.key(), it.value());
439  }
440  } else {
441  if (y == end + 1) {
442  Index::iterator it_top = index.find(-y + delta);
443  if (it_top == index.end())
444  it_top = index.insert(-y + delta, SubIndex());
445  for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {
446  Span *span = it.value();
447  if (!span->will_be_deleted)
448  it_top.value().insert(it.key(), span);
449  ++it;
450  }
451  } else {
452  index.insert(-y + delta, subindex);
453  }
454  it_y = index.erase(it_y);
455  }
456  } while (it_y != index.begin());
457 
458 #ifdef DEBUG_SPAN_UPDATE
459  qDebug() << index;
460  qDebug("Deleted");
461  foreach (QSpanCollection::Span *span, spansToBeDeleted)
462  qDebug() << span << *span;
463 #endif
464  qDeleteAll(spansToBeDeleted);
465 }
iterator erase(iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next it...
Definition: qlinkedlist.h:470
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlinkedlist.h:182
friend class iterator
Definition: qlinkedlist.h:149
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlinkedlist.h:103
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
Q_CORE_EXPORT void qDebug(const char *,...)
bool cleanSpanSubIndex(SubIndex &subindex, int end, bool update=false)
Definition: qtableview.cpp:312
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlinkedlist.h:185
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
QLinkedList< Span * > SpanList
Definition: qtableview_p.h:119
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QMap< int, Span * > SubIndex
Definition: qtableview_p.h:123
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717
static const KeyPair *const end
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
void clear()
Removes all items from the map.
Definition: qmap.h:444
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ updateSpan()

void QSpanCollection::updateSpan ( QSpanCollection::Span span,
int  old_height 
)
Warning
This function is not part of the public interface. Has to be called after the height and width of a span is changed.

old_height is the height before the change

if the size of the span is now 0x0 the span will be deleted.

Definition at line 103 of file qtableview.cpp.

104 {
105  if (old_height < span->height()) {
106  //add the span as subspan in all the lists that intersect the new covered columns
107  Index::iterator it_y = index.lowerBound(-(span->top() + old_height - 1));
108  Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
109  while (-it_y.key() <= span->bottom()) {
110  (*it_y).insert(-span->left(), span);
111  if(it_y == index.begin())
112  break;
113  --it_y;
114  }
115  } else if (old_height > span->height()) {
116  //remove the span from all the subspans lists that intersect the columns not covered anymore
117  Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); //qMax useful if height is 0
118  Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
119  while (-it_y.key() <= span->top() + old_height -1) {
120  if (-it_y.key() > span->bottom()) {
121  int removed = (*it_y).remove(-span->left());
122  Q_ASSERT(removed == 1); Q_UNUSED(removed);
123  if (it_y->isEmpty()) {
124  it_y = index.erase(it_y);
125  }
126  }
127  if(it_y == index.begin())
128  break;
129  --it_y;
130  }
131  }
132 
133  if (span->width() == 0 && span->height() == 0) {
134  spans.removeOne(span);
135  delete span;
136  }
137 }
bool removeOne(const T &t)
Removes the first occurrences of value in the list.
Definition: qlinkedlist.h:397
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
friend class iterator
Definition: qmap.h:299
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717
iterator lowerBound(const Key &key)
Returns an iterator pointing to the first item with key key in the map.
Definition: qmap.h:899
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Properties

◆ index

Index QSpanCollection::index
private

◆ spans

SpanList QSpanCollection::spans

The documentation for this class was generated from the following files: