Logo Search packages:      
Sourcecode: kdeutils version File versions

void KHexEdit::repaintChanged (  )  [protected]

repaints all the parts that are signed as changed

Definition at line 1872 of file khexedit.cpp.

References BufferLayout, BufferRanges, KHE::KRange< T >::end(), hasChanged(), KHE::KBufferRanges::isModified(), KHE::KColumn::isVisible(), KHE::KBufferLayout::noOfBytesPerLine(), KHE::KColumn::overlaps(), KHE::KBufferColumn::preparePainting(), KHE::KBufferRanges::resetChangedRanges(), KHE::KRange< T >::start(), KHE::KColumnsView::totalHeight(), KHE::KColumnsView::totalWidth(), and KHE::KColumnsView::visibleLines().

Referenced by doKeyboardAction(), insert(), moveCursor(), removeSelectedData(), KHE::KBytesEdit::repaintRange(), selectAll(), selectWord(), and setCursorPosition().

{
  if( !isUpdatesEnabled() || !viewport()->isUpdatesEnabled() || !BufferRanges->isModified() )
    return;

  // TODO: we do this only to let the scrollview handle new or removed lines. overlaps with repaintRange
  resizeContents( totalWidth(), totalHeight() );

  KPixelX cx = contentsX();
  KPixelY cy = contentsY();
  KPixelX cw = visibleWidth();
  KPixelY ch = visibleHeight();

  // calculate affected lines/indizes
  KSection VisibleLines = visibleLines( KPixelYs(cy,ch,false) );
  KSection FullPositions( 0, BufferLayout->noOfBytesPerLine()-1 );
  KCoordRange VisibleRange( FullPositions, VisibleLines );
//   std::cout << "repaintChanged->"<<FirstIndex<<":"<<FirstLine<<","<<LastIndex<<":"<<LastLine<<std::endl;

  // collect affected buffer columns
  QPtrList<KBufferColumn> RepaintColumns;

  KBufferColumn *C = ValueColumn;
  while( true )
  {
    if( C->isVisible() && C->overlaps(cx,cx+cw-1) )
    {
      RepaintColumns.append( C );
      C->preparePainting( cx, cw );
    }

    if( C == CharColumn )
      break;
    C = CharColumn;
  }

  if( RepaintColumns.count() > 0 )
  {
    KCoordRange ChangedRange;
    // as there might be multiple selections on this line redo until no more is changed
    while( hasChanged(VisibleRange,&ChangedRange) )
    {
//       std::cout << "  changed->"<<FirstChangedIndex<<","<<LastChangedIndex<<std::endl;

      // only one line?
      if( ChangedRange.start().line() == ChangedRange.end().line() )
        for( KBufferColumn *C=RepaintColumns.first(); C; C=RepaintColumns.next() )
          paintLine( C, ChangedRange.start().line(),
                     KSection(ChangedRange.start().pos(),ChangedRange.end().pos()) );
      //
      else
      {
        // first line
        for( KBufferColumn *C=RepaintColumns.first(); C; C=RepaintColumns.next() )
          paintLine( C, ChangedRange.start().line(),
                     KSection(ChangedRange.start().pos(),FullPositions.end()) );

        // at least one full line?
        for( int l = ChangedRange.start().line()+1; l < ChangedRange.end().line(); ++l )
          for( KBufferColumn *C=RepaintColumns.first(); C; C=RepaintColumns.next() )
            paintLine( C, l, FullPositions );

        // last line
        for( KBufferColumn *C=RepaintColumns.first(); C; C=RepaintColumns.next() )
          paintLine( C, ChangedRange.end().line(),
                     KSection(FullPositions.start(),ChangedRange.end().pos()) );
      }

      // continue the search at the overnext index
      VisibleRange.setStart( ChangedRange.end()+2 );
      if( !VisibleRange.isValid() )
        break;
    }
  }


  // Paint possible removed bytes at the end of the last line
  // Paint new/removed trailing lines
//   drawContents( P, cx, cy, cw, ch );
  // Paint empty rects
//  paintEmptyArea( P, cx, cy, cw, ch );
//   BufferLayout->noOfLines()

  BufferRanges->resetChangedRanges();
}


Generated by  Doxygen 1.6.0   Back to index