summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp
index fc9cffb..6335ea2 100644
--- a/noncore/apps/opie-reader/QTReader.cpp
+++ b/noncore/apps/opie-reader/QTReader.cpp
@@ -420,512 +420,513 @@ void QTReader::drawFonts( QPainter *p )
420// qDebug("df:<%u,%u>",sl,numlines); 420// qDebug("df:<%u,%u>",sl,numlines);
421 421
422 size_t newpos = locnarray[sl]; 422 size_t newpos = locnarray[sl];
423 CBuffer** nta = new CBuffer*[sl]; 423 CBuffer** nta = new CBuffer*[sl];
424 size_t* nla = new size_t[sl]; 424 size_t* nla = new size_t[sl];
425 for (int i = 0; i < sl; i++) 425 for (int i = 0; i < sl; i++)
426 { 426 {
427 nta[i] = textarray[i]; 427 nta[i] = textarray[i];
428 nla[i] = locnarray[i]; 428 nla[i] = locnarray[i];
429 } 429 }
430 for (int i = sl; i < numlines; i++) delete textarray[i]; 430 for (int i = sl; i < numlines; i++) delete textarray[i];
431 delete [] textarray; 431 delete [] textarray;
432 delete [] locnarray; 432 delete [] locnarray;
433 textarray = nta; 433 textarray = nta;
434 locnarray = nla; 434 locnarray = nla;
435 numlines = sl; 435 numlines = sl;
436 jumpto(mylastpos = newpos); 436 jumpto(mylastpos = newpos);
437// locate(pagepos); 437// locate(pagepos);
438 } 438 }
439 if (sl > numlines) 439 if (sl > numlines)
440 { 440 {
441// qDebug("df:<%u,%u>",sl,numlines); 441// qDebug("df:<%u,%u>",sl,numlines);
442 CBuffer** nta = new CBuffer*[sl]; 442 CBuffer** nta = new CBuffer*[sl];
443 size_t* nla = new size_t[sl]; 443 size_t* nla = new size_t[sl];
444 for (int i = 0; i < numlines; i++) 444 for (int i = 0; i < numlines; i++)
445 { 445 {
446 nta[i] = textarray[i]; 446 nta[i] = textarray[i];
447 nla[i] = locnarray[i]; 447 nla[i] = locnarray[i];
448 } 448 }
449 if (locate() != mylastpos) jumpto(mylastpos); 449 if (locate() != mylastpos) jumpto(mylastpos);
450 for (int i = numlines; i < sl; i++) 450 for (int i = numlines; i < sl; i++)
451 { 451 {
452 nta[i] = new CBuffer; 452 nta[i] = new CBuffer;
453 nla[i] = locate(); 453 nla[i] = locate();
454 getline(nta[i]); 454 getline(nta[i]);
455 } 455 }
456 mylastpos = locate(); 456 mylastpos = locate();
457 delete [] textarray; 457 delete [] textarray;
458 delete [] locnarray; 458 delete [] locnarray;
459 textarray = nta; 459 textarray = nta;
460 locnarray = nla; 460 locnarray = nla;
461 numlines = sl; 461 numlines = sl;
462 } 462 }
463 int ypos = (btight) ? 0 : m_ascent-m_linespacing; 463 int ypos = (btight) ? 0 : m_ascent-m_linespacing;
464 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; 464 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent;
465 for (int i = 0; i < numlines; i++) 465 for (int i = 0; i < numlines; i++)
466 { 466 {
467 drawText( *p, 0, ypos += m_linespacing, textarray[i]->data()); 467 drawText( *p, 0, ypos += m_linespacing, textarray[i]->data());
468 } 468 }
469 /* 469 /*
470 470
471 471
472 472
473 int nlines = height()/(fontmetric.ascent()+fontmetric.descent()); 473 int nlines = height()/(fontmetric.ascent()+fontmetric.descent());
474 tchar buffer[1024]; 474 tchar buffer[1024];
475 for (int i = 0; i < nlines; i++) 475 for (int i = 0; i < nlines; i++)
476 { 476 {
477 y += fontmetric.ascent(); 477 y += fontmetric.ascent();
478 sprintf(buffer, "%d:%d:%s[%d]:Lines %d:%s", i+1, m_textfont, fonts[m_textfont], m_fs, nlines, (const tchar*)m_string); 478 sprintf(buffer, "%d:%d:%s[%d]:Lines %d:%s", i+1, m_textfont, fonts[m_textfont], m_fs, nlines, (const tchar*)m_string);
479 drawText( *p, 0, y, buffer ); 479 drawText( *p, 0, y, buffer );
480 y += fontmetric.descent(); 480 y += fontmetric.descent();
481 } 481 }
482 */ 482 */
483 } 483 }
484 m_scrolldy = 0; 484 m_scrolldy = 0;
485} 485}
486 486
487QString QTReader::firstword() 487QString QTReader::firstword()
488{ 488{
489 if (m_bMonoSpaced) 489 if (m_bMonoSpaced)
490 { 490 {
491 return toQString(textarray[0]->data()); 491 return toQString(textarray[0]->data());
492 } 492 }
493 else 493 else
494 { 494 {
495 int start, end, len, j; 495 int start, end, len, j;
496 for (j = 0; j < numlines; j++) 496 for (j = 0; j < numlines; j++)
497 { 497 {
498 len = textarray[j]->length(); 498 len = textarray[j]->length();
499 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++); 499 for (start = 0; start < len && !isalpha((*textarray[j])[start]); start++);
500 if (start < len) break; 500 if (start < len) break;
501 } 501 }
502 if (j < numlines) 502 if (j < numlines)
503 { 503 {
504 QString ret = ""; 504 QString ret = "";
505 for (end = start; end < len && isalpha((*textarray[j])[end]); end++) 505 for (end = start; end < len && isalpha((*textarray[j])[end]); end++)
506 ret += (*textarray[j])[end]; 506 ret += (*textarray[j])[end];
507 if (ret.isEmpty()) ret = "Current position"; 507 if (ret.isEmpty()) ret = "Current position";
508 return ret; 508 return ret;
509 } 509 }
510 else 510 else
511 return "Current position"; 511 return "Current position";
512 } 512 }
513} 513}
514 514
515// 515//
516// Construct the QTReader with buttons. 516// Construct the QTReader with buttons.
517// 517//
518 518
519void QTReader::ChangeFont(int tgt) 519void QTReader::ChangeFont(int tgt)
520{ 520{
521 521
522 QValueList<int>::Iterator it; 522 QValueList<int>::Iterator it;
523 523
524// QValueList<int> sizes = QFontDatabase::pointSizes(m_fontname, (m_bBold) ? QFont::Bold : QFont::Normal); 524// QValueList<int> sizes = QFontDatabase::pointSizes(m_fontname, (m_bBold) ? QFont::Bold : QFont::Normal);
525 QFontDatabase fdb; 525 QFontDatabase fdb;
526/* 526/*
527 QStringList styles = fdb.styles(m_fontname); 527 QStringList styles = fdb.styles(m_fontname);
528 for ( QStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) 528 for ( QStringList::Iterator it = styles.begin(); it != styles.end(); ++it )
529 { 529 {
530 printf( "%s \n", (*it).latin1() ); 530 printf( "%s \n", (*it).latin1() );
531 } 531 }
532*/ 532*/
533 QValueList<int> sizes = fdb.pointSizes(m_fontname, (m_bBold) ? QString("Bold") : QString::null); 533 QValueList<int> sizes = fdb.pointSizes(m_fontname, (m_bBold) ? QString("Bold") : QString::null);
534 uint n = sizes.count(); 534 uint n = sizes.count();
535 if (fontsizes != NULL) delete [] fontsizes; 535 if (fontsizes != NULL) delete [] fontsizes;
536 fontsizes = new unsigned int[n+1]; 536 fontsizes = new unsigned int[n+1];
537 uint i = 0; 537 uint i = 0;
538 uint best = 0; 538 uint best = 0;
539 for (it = sizes.begin(); it != sizes.end(); it++) 539 for (it = sizes.begin(); it != sizes.end(); it++)
540 { 540 {
541 fontsizes[i] = (*it)/10; 541 fontsizes[i] = (*it)/10;
542 if (abs(tgt-fontsizes[i]) < abs(tgt-fontsizes[best])) 542 if (abs(tgt-fontsizes[i]) < abs(tgt-fontsizes[best]))
543 { 543 {
544 best = i; 544 best = i;
545 } 545 }
546 i++; 546 i++;
547 } 547 }
548 m_textsize = best; 548 m_textsize = best;
549 fontsizes[i] = 0; 549 fontsizes[i] = 0;
550 setfont(NULL); 550 setfont(NULL);
551 QFont font(m_fontname, fontsizes[m_textsize], (m_bBold) ? QFont::Bold : QFont::Normal ); 551 QFont font(m_fontname, fontsizes[m_textsize], (m_bBold) ? QFont::Bold : QFont::Normal );
552 if (m_fm == NULL) 552 if (m_fm == NULL)
553 { 553 {
554 m_fm = new QFontMetrics(font); 554 m_fm = new QFontMetrics(font);
555 buffdoc.setfm(m_fm); 555 buffdoc.setfm(m_fm);
556 } 556 }
557} 557}
558 558
559void QTReader::init() 559void QTReader::init()
560{ 560{
561 // setCaption( "Qt Draw Demo Application" ); 561 // setCaption( "Qt Draw Demo Application" );
562 562
563 setBackgroundColor( white ); 563 setBackgroundColor( white );
564// QPainter p(this); 564// QPainter p(this);
565// p.setBackgroundMode( Qt::OpaqueMode ); 565// p.setBackgroundMode( Qt::OpaqueMode );
566 buffdoc.setfilter(getfilter()); 566 buffdoc.setfilter(getfilter());
567 ChangeFont(m_textsize); 567 ChangeFont(m_textsize);
568 // setFocusPolicy(QWidget::StrongFocus); 568 // setFocusPolicy(QWidget::StrongFocus);
569 // resize( 240, 320 ); 569 // resize( 240, 320 );
570 //setFocus(); 570 //setFocus();
571 timer = new QTimer(this); 571 timer = new QTimer(this);
572 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll())); 572 connect(timer, SIGNAL(timeout()), this, SLOT(doscroll()));
573// QMessageBox::information(this, "init", m_lastfile, 1); 573// QMessageBox::information(this, "init", m_lastfile, 1);
574 m_lastwidth = width(); 574 m_lastwidth = width();
575 if (!m_lastfile.isEmpty()) 575 if (!m_lastfile.isEmpty())
576 { 576 {
577 m_string = DocLnk(m_lastfile).name(); 577 m_string = DocLnk(m_lastfile).name();
578 load_file(m_lastfile); 578 load_file(m_lastfile);
579 } 579 }
580} 580}
581 581
582// 582//
583// Clean up 583// Clean up
584// 584//
585QTReader::~QTReader() 585QTReader::~QTReader()
586{ 586{
587 if (fontsizes != NULL) delete [] fontsizes; 587 if (fontsizes != NULL) delete [] fontsizes;
588#ifndef QT_NO_PRINTER 588#ifndef QT_NO_PRINTER
589 // delete printer; 589 // delete printer;
590#endif 590#endif
591} 591}
592 592
593// 593//
594// Calls the drawing function as specified by the radio buttons. 594// Calls the drawing function as specified by the radio buttons.
595// 595//
596 596
597void QTReader::drawIt( QPainter *p ) 597void QTReader::drawIt( QPainter *p )
598{ 598{
599 drawFonts(p); 599 drawFonts(p);
600} 600}
601 601
602// 602//
603// Called when the print button is clicked. 603// Called when the print button is clicked.
604// 604//
605/* 605/*
606void QTReader::printIt() 606void QTReader::printIt()
607{ 607{
608#ifndef QT_NO_PRINTER 608#ifndef QT_NO_PRINTER
609 if ( printer->setup( this ) ) { 609 if ( printer->setup( this ) ) {
610 QPainter paint; 610 QPainter paint;
611 if ( !paint.begin( printer ) ) 611 if ( !paint.begin( printer ) )
612 return; 612 return;
613 drawIt( &paint ); 613 drawIt( &paint );
614 } 614 }
615#endif 615#endif
616} 616}
617*/ 617*/
618// 618//
619// Called when the widget needs to be updated. 619// Called when the widget needs to be updated.
620// 620//
621 621
622void QTReader::paintEvent( QPaintEvent * ) 622void QTReader::paintEvent( QPaintEvent * )
623{ 623{
624 QPainter paint( this ); 624 QPainter paint( this );
625 drawIt( &paint ); 625 drawIt( &paint );
626} 626}
627 627
628// 628//
629// Called when the widget has been resized. 629// Called when the widget has been resized.
630// Moves the button group to the upper right corner 630// Moves the button group to the upper right corner
631// of the widget. 631// of the widget.
632 632
633/* 633/*
634void QTReader::resizeEvent( QResizeEvent * ) 634void QTReader::resizeEvent( QResizeEvent * )
635{ 635{
636 // qDebug("resize:(%u,%u)", width(), height()); 636 // qDebug("resize:(%u,%u)", width(), height());
637 // bgroup->move( width()-bgroup->width(), 0 ); 637 // bgroup->move( width()-bgroup->width(), 0 );
638} 638}
639*/ 639*/
640 640
641// 641//
642// Create and display our widget. 642// Create and display our widget.
643// 643//
644/* 644/*
645int main( int argc, tchar **argv ) 645int main( int argc, tchar **argv )
646{ 646{
647 QApplication app( argc, argv ); 647 QApplication app( argc, argv );
648 QTReader draw; 648 QTReader draw;
649 app.setMainWidget( &draw ); 649 app.setMainWidget( &draw );
650 draw.setCaption("Qt Example - Drawdemo"); 650 draw.setCaption("Qt Example - Drawdemo");
651 draw.show(); 651 draw.show();
652 return app.exec(); 652 return app.exec();
653} 653}
654*/ 654*/
655 655
656 656
657bool QTReader::locate(unsigned long n) { 657bool QTReader::locate(unsigned long n) {
658 //printf("Locate\n"); 658 //printf("Locate\n");
659 buffdoc.locate(n); 659 buffdoc.locate(n);
660 // qDebug("&buffdoc.located"); 660 // qDebug("&buffdoc.located");
661 fillbuffer(); 661 fillbuffer();
662 // qDebug("&Buffer filled"); 662 // qDebug("&Buffer filled");
663 update(); 663 update();
664 // qDebug("&Located"); 664 // qDebug("&Located");
665 return true; 665 return true;
666} 666}
667 667
668unsigned int QTReader::screenlines() 668unsigned int QTReader::screenlines()
669{ 669{
670 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; 670 // int linespacing = (tight) ? m_ascent : m_ascent+m_descent;
671 // return (height()-m_descent)/(m_linespacing); 671 // return (height()-m_descent)/(m_linespacing);
672 return (height()-2)/(m_linespacing); 672 return (height()-2)/(m_linespacing);
673}; 673};
674 674
675bool QTReader::fillbuffer() { 675bool QTReader::fillbuffer() {
676 if (buffdoc.empty()) return false;
676 //printf("Fillbuffer\n"); 677 //printf("Fillbuffer\n");
677 m_scrolldy = 0; 678 m_scrolldy = 0;
678 int ch; 679 int ch;
679 bool ret = false; 680 bool ret = false;
680 int delta = screenlines(); 681 int delta = screenlines();
681 // qDebug("fillbuffer:%u-%u",delta,numlines); 682 // qDebug("fillbuffer:%u-%u",delta,numlines);
682 if (delta != numlines) 683 if (delta != numlines)
683 { 684 {
684 if (textarray != NULL) 685 if (textarray != NULL)
685 { 686 {
686 for (int i = 0; i < numlines; i++) delete textarray[i]; 687 for (int i = 0; i < numlines; i++) delete textarray[i];
687 delete [] textarray; 688 delete [] textarray;
688 delete [] locnarray; 689 delete [] locnarray;
689 } 690 }
690 numlines = delta; 691 numlines = delta;
691 textarray = new CBuffer*[numlines]; 692 textarray = new CBuffer*[numlines];
692 locnarray = new size_t[numlines]; 693 locnarray = new size_t[numlines];
693 for (int i = 0; i < numlines; i++) textarray[i] = new CBuffer; 694 for (int i = 0; i < numlines; i++) textarray[i] = new CBuffer;
694 } 695 }
695 // qDebug("fillbuffer:pagepos:%u",pagepos); 696 // qDebug("fillbuffer:pagepos:%u",pagepos);
696 unsigned int oldpagepos = pagepos; 697 unsigned int oldpagepos = pagepos;
697// if (textarray != NULL) 698// if (textarray != NULL)
698// pagepos = locnarray[0]; 699// pagepos = locnarray[0];
699// else 700// else
700 pagepos = locate(); 701 pagepos = locate();
701 for (int i = 0; i < delta; i++) 702 for (int i = 0; i < delta; i++)
702 { 703 {
703 locnarray[i] = locate(); 704 locnarray[i] = locate();
704 ch = getline(textarray[i]); 705 ch = getline(textarray[i]);
705 // if (ch == EOF) { 706 // if (ch == EOF) {
706 if (!ch) 707 if (!ch)
707 { 708 {
708 if (i == 0) 709 if (i == 0)
709 { 710 {
710 locate(oldpagepos); 711 locate(oldpagepos);
711 return false; 712 return false;
712 } 713 }
713 else 714 else
714 { 715 {
715 ret = true; 716 ret = true;
716 for (int j = i+1; j < delta; j++) 717 for (int j = i+1; j < delta; j++)
717 { 718 {
718 locnarray[j] = locnarray[j-1]; 719 locnarray[j] = locnarray[j-1];
719 (*(textarray[j]))[0] = '\0'; 720 (*(textarray[j]))[0] = '\0';
720 } 721 }
721 break; 722 break;
722 } 723 }
723 } 724 }
724 if (ch == '\012') ret = true; 725 if (ch == '\012') ret = true;
725 } 726 }
726 mylastpos = locate(); 727 mylastpos = locate();
727 // qDebug("fillbuffer:lastpos:%u",mylastpos); 728 // qDebug("fillbuffer:lastpos:%u",mylastpos);
728 return true; 729 return true;
729} 730}
730 731
731 732
732void QTReader::dopagedn() 733void QTReader::dopagedn()
733{ 734{
734 if (m_overlap == 0) 735 if (m_overlap == 0)
735 { 736 {
736 if (locate() != mylastpos) jumpto(mylastpos); 737 if (locate() != mylastpos) jumpto(mylastpos);
737 } 738 }
738 else 739 else
739 { 740 {
740 if (m_overlap >= screenlines()) m_overlap = screenlines()/2; 741 if (m_overlap >= screenlines()) m_overlap = screenlines()/2;
741 jumpto(locnarray[screenlines()-m_overlap]); 742 jumpto(locnarray[screenlines()-m_overlap]);
742 } 743 }
743 if (fillbuffer()) 744 if (fillbuffer())
744 { 745 {
745 update(); 746 update();
746 } 747 }
747} 748}
748 749
749void QTReader::dopageup() 750void QTReader::dopageup()
750{ 751{
751 CBuffer** buff = textarray; 752 CBuffer** buff = textarray;
752 unsigned int *loc = new unsigned int[numlines]; 753 unsigned int *loc = new unsigned int[numlines];
753 int cbptr = 0; 754 int cbptr = 0;
754 if (locate() != mylastpos) jumpto(mylastpos); 755 if (locate() != mylastpos) jumpto(mylastpos);
755 if (m_overlap >= screenlines()) m_overlap = screenlines()/2; 756 if (m_overlap >= screenlines()) m_overlap = screenlines()/2;
756 unsigned int target = locnarray[m_overlap]; 757 unsigned int target = locnarray[m_overlap];
757 if (buffdoc.hasrandomaccess()) 758 if (buffdoc.hasrandomaccess())
758 { 759 {
759 unsigned int delta = locate()-pagelocate(); 760 unsigned int delta = locate()-pagelocate();
760 if (delta < 64) delta = 64; 761 if (delta < 64) delta = 64;
761 if (delta % 2 != 0) delta++; 762 if (delta % 2 != 0) delta++;
762 if (target % 2 != 0) target++; 763 if (target % 2 != 0) target++;
763 do 764 do
764 { 765 {
765 delta <<= 1; 766 delta <<= 1;
766 if (delta >= target) 767 if (delta >= target)
767 { 768 {
768 delta = target; 769 delta = target;
769 jumpto(0); 770 jumpto(0);
770 for (int i = 0; i < numlines; i++) 771 for (int i = 0; i < numlines; i++)
771 { 772 {
772 loc[i] = locate(); 773 loc[i] = locate();
773 getline(buff[i]); 774 getline(buff[i]);
774 } 775 }
775 break; 776 break;
776 } 777 }
777 jumpto(target-delta); 778 jumpto(target-delta);
778 do 779 do
779 { 780 {
780 getline(buff[0]); 781 getline(buff[0]);
781#ifdef WS 782#ifdef WS
782 //printf("Trying:%s\n",buff[0]); 783 //printf("Trying:%s\n",buff[0]);
783#endif 784#endif
784 if (locate() > target) continue; 785 if (locate() > target) continue;
785 } 786 }
786 while (!buffdoc.iseol()); 787 while (!buffdoc.iseol());
787 for (int i = 0; i < numlines; i++) 788 for (int i = 0; i < numlines; i++)
788 { 789 {
789 loc[i] = locate(); 790 loc[i] = locate();
790 getline(buff[i]); 791 getline(buff[i]);
791#ifdef WS 792#ifdef WS
792 //printf("Filling:%s\n",buff[i]); 793 //printf("Filling:%s\n",buff[i]);
793#endif 794#endif
794 } 795 }
795 } 796 }
796 while (locate() >= target && delta < 4096); 797 while (locate() >= target && delta < 4096);
797#ifdef WS 798#ifdef WS
798 //printf("Delta:%u\n",delta); 799 //printf("Delta:%u\n",delta);
799#endif 800#endif
800 } 801 }
801 else 802 else
802 { 803 {
803 jumpto(0); 804 jumpto(0);
804 for (int i = 0; i < numlines; i++) 805 for (int i = 0; i < numlines; i++)
805 { 806 {
806 loc[i] = locate(); 807 loc[i] = locate();
807 getline(buff[i]); 808 getline(buff[i]);
808 } 809 }
809 } 810 }
810 cbptr = 0; 811 cbptr = 0;
811 while (locate() < target) 812 while (locate() < target)
812 { 813 {
813 loc[cbptr] = locate(); 814 loc[cbptr] = locate();
814 getline(buff[cbptr]); 815 getline(buff[cbptr]);
815#ifdef WS 816#ifdef WS
816 //printf("Adding:%s\n",buff[cbptr]->data()); 817 //printf("Adding:%s\n",buff[cbptr]->data());
817#endif 818#endif
818 cbptr = (cbptr+1) % numlines; 819 cbptr = (cbptr+1) % numlines;
819 } 820 }
820 pagepos = loc[cbptr]; 821 pagepos = loc[cbptr];
821 textarray = new CBuffer*[numlines]; 822 textarray = new CBuffer*[numlines];
822 for (int i = 0; i < numlines; i++) 823 for (int i = 0; i < numlines; i++)
823 { 824 {
824 int j = (cbptr+i)%numlines; 825 int j = (cbptr+i)%numlines;
825 textarray[i] = buff[j]; 826 textarray[i] = buff[j];
826 locnarray[i] = loc[j]; 827 locnarray[i] = loc[j];
827 } 828 }
828 delete [] buff; 829 delete [] buff;
829 delete [] loc; 830 delete [] loc;
830 mylastpos = locate(); 831 mylastpos = locate();
831 update(); 832 update();
832} 833}
833 834
834bool QTReader::load_file(const char *newfile, unsigned int _lcn) 835bool QTReader::load_file(const char *newfile, unsigned int _lcn)
835{ 836{
836// QMessageBox::information(this, "Name", name, 1); 837// QMessageBox::information(this, "Name", name, 1);
837// QMessageBox::information(this, "load_file", newfile, 1); 838// QMessageBox::information(this, "load_file", newfile, 1);
838 839
839 bool bRC = false; 840 bool bRC = false;
840 unsigned int lcn = _lcn; 841 unsigned int lcn = _lcn;
841 if (m_lastfile == newfile) 842 if (m_lastfile == newfile)
842 { 843 {
843 lcn = m_lastposn; 844 lcn = m_lastposn;
844 } 845 }
845 m_lastfile = newfile; 846 m_lastfile = newfile;
846 // QMessageBox::information(0, "Opening...", newfile); 847 // QMessageBox::information(0, "Opening...", newfile);
847 if (buffdoc.openfile(this,newfile) == 0) 848 if (buffdoc.openfile(this,newfile) == 0)
848 { 849 {
849 bRC = true; 850 bRC = true;
850 // qDebug("buffdoc.openfile done"); 851 // qDebug("buffdoc.openfile done");
851 locate(lcn); 852 locate(lcn);
852 // qDebug("buffdoc.locate done"); 853 // qDebug("buffdoc.locate done");
853 } 854 }
854 update(); 855 update();
855 // qDebug("Updated"); 856 // qDebug("Updated");
856 return bRC; 857 return bRC;
857} 858}
858 859
859void QTReader::lineDown() 860void QTReader::lineDown()
860{ 861{
861 pagepos = locnarray[1]; 862 pagepos = locnarray[1];
862 CBuffer* buff = textarray[0]; 863 CBuffer* buff = textarray[0];
863 for (int i = 1; i < numlines; i++) 864 for (int i = 1; i < numlines; i++)
864 { 865 {
865 textarray[i-1] = textarray[i]; 866 textarray[i-1] = textarray[i];
866 locnarray[i-1] = locnarray[i]; 867 locnarray[i-1] = locnarray[i];
867 } 868 }
868 locnarray[numlines-1] = locate(); 869 locnarray[numlines-1] = locate();
869 if (getline(buff)) 870 if (getline(buff))
870 { 871 {
871 textarray[numlines-1] = buff; 872 textarray[numlines-1] = buff;
872 mylastpos = locate(); 873 mylastpos = locate();
873 } 874 }
874 else 875 else
875 { 876 {
876 textarray[numlines-1] = buff; 877 textarray[numlines-1] = buff;
877 } 878 }
878 update(); 879 update();
879} 880}
880/* 881/*
881void QTReader::lineUp() 882void QTReader::lineUp()
882{ 883{
883 CBuffer** buff = textarray; 884 CBuffer** buff = textarray;
884 unsigned int *loc = new unsigned int[numlines]; 885 unsigned int *loc = new unsigned int[numlines];
885 int cbptr = 0; 886 int cbptr = 0;
886 if (locate() != mylastpos) jumpto(mylastpos); 887 if (locate() != mylastpos) jumpto(mylastpos);
887 unsigned int target = locnarray[numlines-1]; 888 unsigned int target = locnarray[numlines-1];
888 if (buffdoc.hasrandomaccess()) 889 if (buffdoc.hasrandomaccess())
889 { 890 {
890 unsigned int delta = locate()-pagelocate(); 891 unsigned int delta = locate()-pagelocate();
891 if (delta < 64) delta = 64; 892 if (delta < 64) delta = 64;
892 do 893 do
893 { 894 {
894 delta <<= 1; 895 delta <<= 1;
895 if (delta >= target) 896 if (delta >= target)
896 { 897 {
897 delta = target; 898 delta = target;
898 jumpto(0); 899 jumpto(0);
899 for (int i = 0; i < numlines; i++) 900 for (int i = 0; i < numlines; i++)
900 { 901 {
901 loc[i] = locate(); 902 loc[i] = locate();
902 getline(buff[i]); 903 getline(buff[i]);
903 } 904 }
904 break; 905 break;
905 } 906 }
906 jumpto(target-delta); 907 jumpto(target-delta);
907 do 908 do
908 { 909 {
909 buffdoc.getline(buff[0],width()); 910 buffdoc.getline(buff[0],width());
910#ifdef WS 911#ifdef WS
911 //printf("Trying:%s\n",buff[0]); 912 //printf("Trying:%s\n",buff[0]);
912#endif 913#endif
913 if (locate() > target) continue; 914 if (locate() > target) continue;
914 } 915 }
915 while (!buffdoc.iseol()); 916 while (!buffdoc.iseol());
916 for (int i = 0; i < numlines; i++) 917 for (int i = 0; i < numlines; i++)
917 { 918 {
918 loc[i] = locate(); 919 loc[i] = locate();
919 buffdoc.getline(buff[i],width()); 920 buffdoc.getline(buff[i],width());
920#ifdef WS 921#ifdef WS
921 //printf("Filling:%s\n",buff[i]); 922 //printf("Filling:%s\n",buff[i]);
922#endif 923#endif
923 } 924 }
924 } 925 }
925 while (locate() >= target && delta < 4096); 926 while (locate() >= target && delta < 4096);
926#ifdef WS 927#ifdef WS
927 //printf("Delta:%u\n",delta); 928 //printf("Delta:%u\n",delta);
928#endif 929#endif
929 } 930 }
930 else 931 else
931 { 932 {