-rw-r--r-- | noncore/apps/opie-reader/CFilter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 6d94d70..ab98829 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -572,193 +572,194 @@ void HighlightFilter::refresh(unsigned long pos) | |||
572 | blue = i->blue(); | 572 | blue = i->blue(); |
573 | lastpos = (*i).value(); | 573 | lastpos = (*i).value(); |
574 | nextpos = (*i).value2(); | 574 | nextpos = (*i).value2(); |
575 | break; | 575 | break; |
576 | } | 576 | } |
577 | if ((*i).value() > pos) | 577 | if ((*i).value() > pos) |
578 | { | 578 | { |
579 | nextpos = (*i).value(); | 579 | nextpos = (*i).value(); |
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | lastpos = (*i).value(); | 582 | lastpos = (*i).value(); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
588 | { | 588 | { |
589 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) | 590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) |
591 | { | 591 | { |
592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); | 592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); |
593 | refresh(pos); | 593 | refresh(pos); |
594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); | 594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); |
595 | } | 595 | } |
596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
597 | if (r == 255 && g == 255 && b == 255) | 597 | if (r == 255 && g == 255 && b == 255) |
598 | { | 598 | { |
599 | sty.setBackground(red, green, blue); | 599 | sty.setBackground(red, green, blue); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
604 | { | 604 | { |
605 | if (uselast) | 605 | if (uselast) |
606 | { | 606 | { |
607 | ch = lastchar; | 607 | ch = lastchar; |
608 | sty = laststy; | 608 | sty = laststy; |
609 | uselast = false; | 609 | uselast = false; |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | else | 612 | else |
613 | { | 613 | { |
614 | parent->getch(ch, sty, pos); | 614 | parent->getch(ch, sty, pos); |
615 | } | 615 | } |
616 | switch (ch) | 616 | switch (ch) |
617 | { | 617 | { |
618 | case 'f': | 618 | case 'f': |
619 | { | 619 | { |
620 | tchar savedchar = 'f'; | 620 | tchar savedchar = 'f'; |
621 | parent->getch(ch, sty, pos); | 621 | parent->getch(ch, sty, pos); |
622 | switch (ch) | 622 | switch (ch) |
623 | { | 623 | { |
624 | case 'i': | 624 | case 'i': |
625 | ch = (251 << 8) + 1; | 625 | ch = (251 << 8) + 1; |
626 | break; | 626 | break; |
627 | case 'l': | 627 | case 'l': |
628 | ch = (251 << 8) + 2; | 628 | ch = (251 << 8) + 2; |
629 | break; | 629 | break; |
630 | default: | 630 | default: |
631 | lastchar = ch; | 631 | lastchar = ch; |
632 | uselast = true; | 632 | uselast = true; |
633 | laststy = sty; | 633 | laststy = sty; |
634 | ch = savedchar; | 634 | ch = savedchar; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | break; | 637 | break; |
638 | default: | 638 | default: |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | class ErrorFilter : public CFilter | 643 | class ErrorFilter : public CFilter |
644 | { | 644 | { |
645 | QString error; | 645 | QString error; |
646 | int currentpos; | 646 | int currentpos; |
647 | public: | 647 | public: |
648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} | 648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} |
649 | ~ErrorFilter() {} | 649 | ~ErrorFilter() {} |
650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
651 | { | 651 | { |
652 | if (currentpos == error.length()) | 652 | if (currentpos == error.length()) |
653 | { | 653 | { |
654 | ch = UEOF; | 654 | ch = UEOF; |
655 | currentpos = 0; | 655 | currentpos = 0; |
656 | } | 656 | } |
657 | else | 657 | else |
658 | { | 658 | { |
659 | ch = error[currentpos++].unicode(); | 659 | ch = error[currentpos++].unicode(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | QString about() { return parent->about(); } | 662 | QString about() { return parent->about(); } |
663 | }; | 663 | }; |
664 | 664 | ||
665 | #ifndef __STATIC | 665 | #ifndef __STATIC |
666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) | 666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) |
667 | { | 667 | { |
668 | QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); | 668 | QString filterpath(QTReaderUtil::getPluginPath("filters")); |
669 | filterpath += "/lib"; | ||
669 | filterpath += nm; | 670 | filterpath += nm; |
670 | filterpath += ".so"; | 671 | filterpath += ".so"; |
671 | if (QFile::exists(filterpath)) | 672 | if (QFile::exists(filterpath)) |
672 | { | 673 | { |
673 | qDebug("Filter:%s", (const char*)filterpath); | 674 | qDebug("Filter:%s", (const char*)filterpath); |
674 | handle = dlopen(filterpath, RTLD_LAZY); | 675 | handle = dlopen(filterpath, RTLD_LAZY); |
675 | if (handle == 0) | 676 | if (handle == 0) |
676 | { | 677 | { |
677 | qDebug("Can't find filter:%s", dlerror()); | 678 | qDebug("Can't find filter:%s", dlerror()); |
678 | // status = -10; | 679 | // status = -10; |
679 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | 680 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); |
680 | return; | 681 | return; |
681 | } | 682 | } |
682 | CFilter* (*newfilter)(const QString&); | 683 | CFilter* (*newfilter)(const QString&); |
683 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | 684 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); |
684 | if (newfilter == NULL) | 685 | if (newfilter == NULL) |
685 | { | 686 | { |
686 | qDebug("Can't find newfilter"); | 687 | qDebug("Can't find newfilter"); |
687 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); | 688 | filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); |
688 | return; | 689 | return; |
689 | } | 690 | } |
690 | filt = (*newfilter)(optional); | 691 | filt = (*newfilter)(optional); |
691 | } | 692 | } |
692 | else | 693 | else |
693 | { | 694 | { |
694 | qDebug("No filter path"); | 695 | qDebug("No filter path"); |
695 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); | 696 | filt = new ErrorFilter(QString("No filter plugins installed:")+nm); |
696 | } | 697 | } |
697 | if (filt == NULL) | 698 | if (filt == NULL) |
698 | { | 699 | { |
699 | qDebug("Can't do newfilter"); | 700 | qDebug("Can't do newfilter"); |
700 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); | 701 | filt = new ErrorFilter(QString("Filter creation failed:")+nm); |
701 | return; | 702 | return; |
702 | } | 703 | } |
703 | } | 704 | } |
704 | #endif | 705 | #endif |
705 | 706 | ||
706 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 707 | void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
707 | { | 708 | { |
708 | parent->getch(ch, sty, pos); | 709 | parent->getch(ch, sty, pos); |
709 | int r,g,b; | 710 | int r,g,b; |
710 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); | 711 | r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); |
711 | sty.setColour(r,g,b); | 712 | sty.setColour(r,g,b); |
712 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); | 713 | r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); |
713 | sty.setBackground(r,g,b); | 714 | sty.setBackground(r,g,b); |
714 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); | 715 | r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); |
715 | sty.setPaper(r,g,b); | 716 | sty.setPaper(r,g,b); |
716 | } | 717 | } |
717 | /* | 718 | /* |
718 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 719 | void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
719 | { | 720 | { |
720 | parent->getch(ch, sty, pos); | 721 | parent->getch(ch, sty, pos); |
721 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); | 722 | QColor fg(sty.Red(), sty.Green(), sty.Blue()); |
722 | int h,s,v; | 723 | int h,s,v; |
723 | fg.hsv(&h,&s,&v); | 724 | fg.hsv(&h,&s,&v); |
724 | fg.setHsv(h,s,255-v); | 725 | fg.setHsv(h,s,255-v); |
725 | int r,g,b; | 726 | int r,g,b; |
726 | fg.rgb(&r,&g,&b); | 727 | fg.rgb(&r,&g,&b); |
727 | sty.setColour(r,g,b); | 728 | sty.setColour(r,g,b); |
728 | 729 | ||
729 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); | 730 | fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); |
730 | fg.hsv(&h,&s,&v); | 731 | fg.hsv(&h,&s,&v); |
731 | fg.setHsv(h,s,255-v); | 732 | fg.setHsv(h,s,255-v); |
732 | fg.rgb(&r,&g,&b); | 733 | fg.rgb(&r,&g,&b); |
733 | sty.setBackground(r,g,b); | 734 | sty.setBackground(r,g,b); |
734 | } | 735 | } |
735 | */ | 736 | */ |
736 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 737 | void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
737 | { | 738 | { |
738 | parent->getch(ch, sty, pos); | 739 | parent->getch(ch, sty, pos); |
739 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); | 740 | int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); |
740 | if (r == 255 && g == 255 && b == 255) | 741 | if (r == 255 && g == 255 && b == 255) |
741 | { | 742 | { |
742 | sty.setPaper(m_r,m_g,m_b); | 743 | sty.setPaper(m_r,m_g,m_b); |
743 | } | 744 | } |
744 | else | 745 | else |
745 | { | 746 | { |
746 | qDebug("We have background [%x%x%x]", r, g, b); | 747 | qDebug("We have background [%x%x%x]", r, g, b); |
747 | } | 748 | } |
748 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 749 | r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
749 | if (r == 255 && g == 255 && b == 255) | 750 | if (r == 255 && g == 255 && b == 255) |
750 | { | 751 | { |
751 | sty.setBackground(m_r,m_g,m_b); | 752 | sty.setBackground(m_r,m_g,m_b); |
752 | } | 753 | } |
753 | else | 754 | else |
754 | { | 755 | { |
755 | qDebug("We have background [%x%x%x]", r, g, b); | 756 | qDebug("We have background [%x%x%x]", r, g, b); |
756 | } | 757 | } |
757 | } | 758 | } |
758 | 759 | ||
759 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 760 | void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
760 | { | 761 | { |
761 | parent->getch(ch, sty, pos); | 762 | parent->getch(ch, sty, pos); |
762 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); | 763 | int r = sty.Red(), g = sty.Green(), b = sty.Blue(); |
763 | if (r == 0 && g == 0 && b == 0) | 764 | if (r == 0 && g == 0 && b == 0) |
764 | { | 765 | { |