summaryrefslogtreecommitdiff
authorpohly <pohly>2005-05-08 16:13:24 (UTC)
committer pohly <pohly>2005-05-08 16:13:24 (UTC)
commitea889d21f3b5bf846ff20a6fad9a756108a28ad7 (patch) (unidiff)
tree3d0462ccf147fb95886657d8bb610caa168e01ea
parent2ccb0ad8b77eb3c62914f5df5b1bba3becb83617 (diff)
downloadopie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.zip
opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.gz
opie-ea889d21f3b5bf846ff20a6fad9a756108a28ad7.tar.bz2
code change by tim: ask the user to confirm the remapping of the ESC key
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp
index 6753698..8ef0674 100644
--- a/noncore/apps/opie-reader/QTReaderApp.cpp
+++ b/noncore/apps/opie-reader/QTReaderApp.cpp
@@ -2649,1025 +2649,1030 @@ void QTReaderApp::editFind()
2649 searchEdit->setFocus(); 2649 searchEdit->setFocus();
2650#ifdef __ISEARCH 2650#ifdef __ISEARCH
2651 searchStack->push(new searchrecord("",reader->pagelocate())); 2651 searchStack->push(new searchrecord("",reader->pagelocate()));
2652#endif 2652#endif
2653} 2653}
2654 2654
2655void QTReaderApp::findNext() 2655void QTReaderApp::findNext()
2656{ 2656{
2657// // qDebug("findNext called\n"); 2657// // qDebug("findNext called\n");
2658#ifdef __ISEARCH 2658#ifdef __ISEARCH
2659 QString arg = searchEdit->text(); 2659 QString arg = searchEdit->text();
2660#else 2660#else
2661 QRegExp arg = searchEdit->text(); 2661 QRegExp arg = searchEdit->text();
2662#endif 2662#endif
2663 CDrawBuffer test(&(reader->m_fontControl)); 2663 CDrawBuffer test(&(reader->m_fontControl));
2664 size_t start = reader->pagelocate(); 2664 size_t start = reader->pagelocate();
2665 reader->jumpto(start); 2665 reader->jumpto(start);
2666 reader->getline(&test); 2666 reader->getline(&test);
2667 dosearch(start, test, arg); 2667 dosearch(start, test, arg);
2668} 2668}
2669 2669
2670void QTReaderApp::findClose() 2670void QTReaderApp::findClose()
2671{ 2671{
2672 searchVisible = FALSE; 2672 searchVisible = FALSE;
2673 searchEdit->setText(""); 2673 searchEdit->setText("");
2674#ifdef USEQPE 2674#ifdef USEQPE
2675 Global::hideInputMethod(); 2675 Global::hideInputMethod();
2676#endif 2676#endif
2677 searchBar->hide(); 2677 searchBar->hide();
2678#ifdef __ISEARCH 2678#ifdef __ISEARCH
2679// searchStack = new QStack<searchrecord>; 2679// searchStack = new QStack<searchrecord>;
2680 while (!searchStack->isEmpty()) 2680 while (!searchStack->isEmpty())
2681 { 2681 {
2682 delete searchStack->pop(); 2682 delete searchStack->pop();
2683 } 2683 }
2684 delete searchStack; 2684 delete searchStack;
2685#endif 2685#endif
2686 reader->setFocus(); 2686 reader->setFocus();
2687} 2687}
2688 2688
2689void QTReaderApp::regClose() 2689void QTReaderApp::regClose()
2690{ 2690{
2691 regVisible = FALSE; 2691 regVisible = FALSE;
2692 regEdit->setText(""); 2692 regEdit->setText("");
2693 regBar->hide(); 2693 regBar->hide();
2694#ifdef USEQPE 2694#ifdef USEQPE
2695 Global::hideInputMethod(); 2695 Global::hideInputMethod();
2696#endif 2696#endif
2697 reader->setFocus(); 2697 reader->setFocus();
2698} 2698}
2699 2699
2700#ifdef __ISEARCH 2700#ifdef __ISEARCH
2701bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) 2701bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg)
2702#else 2702#else
2703bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) 2703bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg)
2704#endif 2704#endif
2705{ 2705{
2706 bool ret = true; 2706 bool ret = true;
2707 unsigned long fs, ts; 2707 unsigned long fs, ts;
2708 reader->sizes(fs,ts); 2708 reader->sizes(fs,ts);
2709 size_t pos = reader->locate(); 2709 size_t pos = reader->locate();
2710 pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); 2710 pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height());
2711 pbar->show(); 2711 pbar->show();
2712 pbar->raise(); 2712 pbar->raise();
2713 pbar->reset(); 2713 pbar->reset();
2714 int offset; 2714 int offset;
2715 int lastpc = (100*pos)/ts; 2715 int lastpc = (100*pos)/ts;
2716 pbar->setProgress(lastpc); 2716 pbar->setProgress(lastpc);
2717// qApp->processEvents(); 2717// qApp->processEvents();
2718 if (reader->buffdoc.getpara(test) >= 0) 2718 if (reader->buffdoc.getpara(test) >= 0)
2719 { 2719 {
2720 reader->setFocus(); 2720 reader->setFocus();
2721#ifdef __ISEARCH 2721#ifdef __ISEARCH
2722 while (strstr(test.data(),(const tchar*)arg) == NULL) 2722 while (strstr(test.data(),(const tchar*)arg) == NULL)
2723#else 2723#else
2724#ifdef _UNICODE 2724#ifdef _UNICODE
2725 while ((offset = arg.match(toQString(test.data()))) == -1) 2725 while ((offset = arg.match(toQString(test.data()))) == -1)
2726#else 2726#else
2727 while (arg.match(test.data()) == -1) 2727 while (arg.match(test.data()) == -1)
2728#endif 2728#endif
2729#endif 2729#endif
2730 { 2730 {
2731 pos = reader->locate(); 2731 pos = reader->locate();
2732 int pc = (100*pos)/ts; 2732 int pc = (100*pos)/ts;
2733 if (pc != lastpc) 2733 if (pc != lastpc)
2734 { 2734 {
2735 pbar->setProgress(pc); 2735 pbar->setProgress(pc);
2736 qApp->processEvents(); 2736 qApp->processEvents();
2737 reader->setFocus(); 2737 reader->setFocus();
2738 lastpc = pc; 2738 lastpc = pc;
2739 } 2739 }
2740 2740
2741 if (reader->buffdoc.getpara(test) < 0) 2741 if (reader->buffdoc.getpara(test) < 0)
2742 { 2742 {
2743 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 2743 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2744 pos = searchStart; 2744 pos = searchStart;
2745 else 2745 else
2746 pos = start; 2746 pos = start;
2747 findClose(); 2747 findClose();
2748 pbar->hide(); 2748 pbar->hide();
2749 reader->locate(pos); 2749 reader->locate(pos);
2750 return false; 2750 return false;
2751 } 2751 }
2752 } 2752 }
2753// qDebug("Found it at %u:%u", pos, offset); 2753// qDebug("Found it at %u:%u", pos, offset);
2754 pbar->hide(); 2754 pbar->hide();
2755// qDebug("Hid"); 2755// qDebug("Hid");
2756 reader->locate(pos+offset); 2756 reader->locate(pos+offset);
2757// qDebug("Loacted"); 2757// qDebug("Loacted");
2758// qDebug("page up"); 2758// qDebug("page up");
2759 ret = true; 2759 ret = true;
2760 } 2760 }
2761 else 2761 else
2762 { 2762 {
2763 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) 2763 if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2)
2764 pos = searchStart; 2764 pos = searchStart;
2765 else 2765 else
2766 pos = start; 2766 pos = start;
2767 ret = false; 2767 ret = false;
2768 findClose(); 2768 findClose();
2769 } 2769 }
2770 return ret; 2770 return ret;
2771} 2771}
2772 2772
2773#ifdef __ISEARCH 2773#ifdef __ISEARCH
2774void QTReaderApp::search(const QString & arg) 2774void QTReaderApp::search(const QString & arg)
2775{ 2775{
2776 searchrecord* ss = searchStack->top(); 2776 searchrecord* ss = searchStack->top();
2777 CBuffer test; 2777 CBuffer test;
2778 size_t start = reader->pagelocate(); 2778 size_t start = reader->pagelocate();
2779 bool haspopped = false; 2779 bool haspopped = false;
2780 while (arg.left(ss->s.length()) != ss->s) 2780 while (arg.left(ss->s.length()) != ss->s)
2781 { 2781 {
2782 haspopped = true; 2782 haspopped = true;
2783 start = ss->pos; 2783 start = ss->pos;
2784// reader->locate(start); 2784// reader->locate(start);
2785 searchStack->pop(); 2785 searchStack->pop();
2786 delete ss; 2786 delete ss;
2787 } 2787 }
2788 if (haspopped) reader->locate(start); 2788 if (haspopped) reader->locate(start);
2789/* 2789/*
2790 if (arg.length() < ss->len) 2790 if (arg.length() < ss->len)
2791 { 2791 {
2792 start = ss->pos; 2792 start = ss->pos;
2793 reader->locate(start); 2793 reader->locate(start);
2794 searchStack->pop(); 2794 searchStack->pop();
2795 delete ss; 2795 delete ss;
2796 } 2796 }
2797*/ 2797*/
2798 else 2798 else
2799 { 2799 {
2800 start = reader->pagelocate(); 2800 start = reader->pagelocate();
2801 reader->jumpto(start); 2801 reader->jumpto(start);
2802 searchStack->push(new searchrecord(arg,start)); 2802 searchStack->push(new searchrecord(arg,start));
2803 } 2803 }
2804 dosearch(start, test, arg); 2804 dosearch(start, test, arg);
2805} 2805}
2806#else 2806#else
2807void QTReaderApp::search() 2807void QTReaderApp::search()
2808{ 2808{
2809 findNext(); 2809 findNext();
2810} 2810}
2811#endif 2811#endif
2812 2812
2813void QTReaderApp::openFile( const QString &f, unsigned int loc ) 2813void QTReaderApp::openFile( const QString &f, unsigned int loc )
2814{ 2814{
2815// qDebug("File:%s", (const char*)f); 2815// qDebug("File:%s", (const char*)f);
2816// openFile(DocLnk(f)); 2816// openFile(DocLnk(f));
2817//} 2817//}
2818// 2818//
2819//void QTReaderApp::openFile( const DocLnk &f ) 2819//void QTReaderApp::openFile( const DocLnk &f )
2820//{ 2820//{
2821 clear(); 2821 clear();
2822 QFileInfo fm(f); 2822 QFileInfo fm(f);
2823 if ( fm.exists() ) 2823 if ( fm.exists() )
2824 { 2824 {
2825// QMessageBox::information(0, "Progress", "Calling fileNew()"); 2825// QMessageBox::information(0, "Progress", "Calling fileNew()");
2826#ifdef USEQPE 2826#ifdef USEQPE
2827 if (fm.extension( FALSE ) == "desktop") 2827 if (fm.extension( FALSE ) == "desktop")
2828 { 2828 {
2829 DocLnk d(f); 2829 DocLnk d(f);
2830 QFileInfo fnew(d.file()); 2830 QFileInfo fnew(d.file());
2831 fm = fnew; 2831 fm = fnew;
2832 if (!fm.exists()) return; 2832 if (!fm.exists()) return;
2833 } 2833 }
2834#endif 2834#endif
2835 clear(); 2835 clear();
2836 reader->setText(fm.baseName(), fm.absFilePath(), loc); 2836 reader->setText(fm.baseName(), fm.absFilePath(), loc);
2837 m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); 2837 m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false);
2838 qDebug("Showing tools"); 2838 qDebug("Showing tools");
2839 showEditTools(); 2839 showEditTools();
2840 qDebug("Shown tools"); 2840 qDebug("Shown tools");
2841 readbkmks(); 2841 readbkmks();
2842 qDebug("read markss"); 2842 qDebug("read markss");
2843 m_savedpos = 0xffffffff; 2843 m_savedpos = 0xffffffff;
2844 } 2844 }
2845 else 2845 else
2846 { 2846 {
2847 QString msg = f; 2847 QString msg = f;
2848 msg += "\nFile does not exist"; 2848 msg += "\nFile does not exist";
2849 QMessageBox::information(this, PROGNAME, msg); 2849 QMessageBox::information(this, PROGNAME, msg);
2850 reader->m_lastfile = QString::null; 2850 reader->m_lastfile = QString::null;
2851 } 2851 }
2852 2852
2853} 2853}
2854/* 2854/*
2855void QTReaderApp::resizeEvent(QResizeEvent* e) 2855void QTReaderApp::resizeEvent(QResizeEvent* e)
2856{ 2856{
2857 if (m_fullscreen) 2857 if (m_fullscreen)
2858 { 2858 {
2859 showNormal(); 2859 showNormal();
2860 showFullScreen(); 2860 showFullScreen();
2861 } 2861 }
2862} 2862}
2863*/ 2863*/
2864void QTReaderApp::handlekey(QKeyEvent* e) 2864void QTReaderApp::handlekey(QKeyEvent* e)
2865{ 2865{
2866// qDebug("Keypress event"); 2866// qDebug("Keypress event");
2867 timeb now; 2867 timeb now;
2868 ftime(&now); 2868 ftime(&now);
2869 unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; 2869 unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm;
2870 if (etime < m_debounce) 2870 if (etime < m_debounce)
2871 { 2871 {
2872 return; 2872 return;
2873 } 2873 }
2874 switch(e->key()) 2874 switch(e->key())
2875 { 2875 {
2876 case Key_Escape: 2876 case Key_Escape:
2877 qDebug("escape event"); 2877 qDebug("escape event");
2878 if (m_disableesckey) 2878 if (m_disableesckey)
2879 { 2879 {
2880 m_disableesckey = false; 2880 m_disableesckey = false;
2881 } 2881 }
2882 else 2882 else
2883 { 2883 {
2884 m_bcloseDisabled = true; 2884 m_bcloseDisabled = true;
2885 if (m_fullscreen) 2885 if (m_fullscreen)
2886 { 2886 {
2887 m_actFullscreen->setOn(false); 2887 m_actFullscreen->setOn(false);
2888 e->accept(); 2888 e->accept();
2889 } 2889 }
2890 else 2890 else
2891 { 2891 {
2892 // qDebug("escape action"); 2892 // qDebug("escape action");
2893 doAction(e); 2893 doAction(e);
2894 } 2894 }
2895 } 2895 }
2896 break; 2896 break;
2897 /* 2897 /*
2898 case Key_Left: 2898 case Key_Left:
2899 { 2899 {
2900 if (reader->m_autoScroll) 2900 if (reader->m_autoScroll)
2901 { 2901 {
2902 reader->reduceScroll(); 2902 reader->reduceScroll();
2903 } 2903 }
2904 else 2904 else
2905 { 2905 {
2906 doAction(e); 2906 doAction(e);
2907 } 2907 }
2908 } 2908 }
2909 break; 2909 break;
2910 case Key_Right: 2910 case Key_Right:
2911 { 2911 {
2912 if (reader->m_autoScroll) 2912 if (reader->m_autoScroll)
2913 { 2913 {
2914 reader->increaseScroll(); 2914 reader->increaseScroll();
2915 } 2915 }
2916 else 2916 else
2917 { 2917 {
2918 doAction(e); 2918 doAction(e);
2919 } 2919 }
2920 } 2920 }
2921 break; 2921 break;
2922 case Key_Up: 2922 case Key_Up:
2923 { 2923 {
2924 if (reader->m_autoScroll) 2924 if (reader->m_autoScroll)
2925 { 2925 {
2926 reader->increaseScroll(); 2926 reader->increaseScroll();
2927 } 2927 }
2928 else 2928 else
2929 { 2929 {
2930 doAction(e); 2930 doAction(e);
2931 } 2931 }
2932 } 2932 }
2933 break; 2933 break;
2934 case Key_Down: 2934 case Key_Down:
2935 { 2935 {
2936 if (reader->m_autoScroll) 2936 if (reader->m_autoScroll)
2937 { 2937 {
2938 reader->reduceScroll(); 2938 reader->reduceScroll();
2939 } 2939 }
2940 else 2940 else
2941 { 2941 {
2942 doAction(e); 2942 doAction(e);
2943 } 2943 }
2944 } 2944 }
2945 break; 2945 break;
2946 */ 2946 */
2947 default: 2947 default:
2948 { 2948 {
2949 doAction(e); 2949 doAction(e);
2950 } 2950 }
2951 2951
2952/* 2952/*
2953 QString msg("Key press was:"); 2953 QString msg("Key press was:");
2954 QString key; 2954 QString key;
2955 msg += key.setNum(e->key()); 2955 msg += key.setNum(e->key());
2956 QMessageBox::information(this, PROGNAME, msg); 2956 QMessageBox::information(this, PROGNAME, msg);
2957*/ 2957*/
2958 } 2958 }
2959 ftime(&m_lastkeytime); 2959 ftime(&m_lastkeytime);
2960} 2960}
2961 2961
2962#if defined(USEQPE) && defined(USENEWFULLSCREEN) 2962#if defined(USEQPE) && defined(USENEWFULLSCREEN)
2963void QTReaderApp::focusInEvent(QFocusEvent *) 2963void QTReaderApp::focusInEvent(QFocusEvent *)
2964{ 2964{
2965 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) 2965 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
2966 { 2966 {
2967 m_usenewfullscreen = false; 2967 m_usenewfullscreen = false;
2968 reader->bDoUpdates = false; 2968 reader->bDoUpdates = false;
2969 showEditTools(); 2969 showEditTools();
2970 reader->bDoUpdates = true; 2970 reader->bDoUpdates = true;
2971 reader->update(); 2971 reader->update();
2972 m_usenewfullscreen = true; 2972 m_usenewfullscreen = true;
2973 } 2973 }
2974} 2974}
2975 2975
2976void QTReaderApp::resizeEvent(QResizeEvent *) 2976void QTReaderApp::resizeEvent(QResizeEvent *)
2977{ 2977{
2978 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) 2978 if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader))
2979 { 2979 {
2980 m_usenewfullscreen = false; 2980 m_usenewfullscreen = false;
2981 reader->bDoUpdates = false; 2981 reader->bDoUpdates = false;
2982 showEditTools(); 2982 showEditTools();
2983 reader->bDoUpdates = true; 2983 reader->bDoUpdates = true;
2984 reader->update(); 2984 reader->update();
2985 m_usenewfullscreen = true; 2985 m_usenewfullscreen = true;
2986 } 2986 }
2987} 2987}
2988#endif 2988#endif
2989 2989
2990void QTReaderApp::showEditTools() 2990void QTReaderApp::showEditTools()
2991{ 2991{
2992// if ( !doc ) 2992// if ( !doc )
2993 //close(); 2993 //close();
2994 if (m_fullscreen) 2994 if (m_fullscreen)
2995 { 2995 {
2996#if defined(USEQPE) 2996#if defined(USEQPE)
2997 if (menubar != NULL) menubar->hide(); 2997 if (menubar != NULL) menubar->hide();
2998#endif 2998#endif
2999 if (fileBar != NULL) fileBar->hide(); 2999 if (fileBar != NULL) fileBar->hide();
3000 if (viewBar != NULL) viewBar->hide(); 3000 if (viewBar != NULL) viewBar->hide();
3001 if (navBar != NULL) navBar->hide(); 3001 if (navBar != NULL) navBar->hide();
3002 if (markBar != NULL) markBar->hide(); 3002 if (markBar != NULL) markBar->hide();
3003 if (m_prog != NULL) 3003 if (m_prog != NULL)
3004 { 3004 {
3005 // qDebug("Hiding status"); 3005 // qDebug("Hiding status");
3006 m_prog->hide(); 3006 m_prog->hide();
3007 } 3007 }
3008 searchBar->hide(); 3008 searchBar->hide();
3009 regBar->hide(); 3009 regBar->hide();
3010#ifdef USEQPE 3010#ifdef USEQPE
3011 Global::hideInputMethod(); 3011 Global::hideInputMethod();
3012#endif 3012#endif
3013 if (m_scrollbar != NULL) m_scrollbar->hide(); 3013 if (m_scrollbar != NULL) m_scrollbar->hide();
3014 m_fontBar->hide(); 3014 m_fontBar->hide();
3015 //showNormal(); 3015 //showNormal();
3016 showFullScreen(); 3016 showFullScreen();
3017 } 3017 }
3018 else 3018 else
3019 { 3019 {
3020 //qDebug("him"); 3020 //qDebug("him");
3021#ifdef USEQPE 3021#ifdef USEQPE
3022 Global::hideInputMethod(); 3022 Global::hideInputMethod();
3023#endif 3023#endif
3024 //qDebug("eb"); 3024 //qDebug("eb");
3025 if (m_scrollbar != NULL) 3025 if (m_scrollbar != NULL)
3026 { 3026 {
3027 if (m_scrollishidden) 3027 if (m_scrollishidden)
3028 { 3028 {
3029 m_scrollbar->hide(); 3029 m_scrollbar->hide();
3030 } 3030 }
3031 else 3031 else
3032 { 3032 {
3033 m_scrollbar->show(); 3033 m_scrollbar->show();
3034 } 3034 }
3035 } 3035 }
3036 if (!m_hidebars) 3036 if (!m_hidebars)
3037 { 3037 {
3038#if defined(USEQPE) 3038#if defined(USEQPE)
3039 menubar->show(); 3039 menubar->show();
3040#endif 3040#endif
3041 if (fileBar != NULL) fileBar->show(); 3041 if (fileBar != NULL) fileBar->show();
3042 if (viewBar != NULL) viewBar->show(); 3042 if (viewBar != NULL) viewBar->show();
3043 if (navBar != NULL) navBar->show(); 3043 if (navBar != NULL) navBar->show();
3044 if (markBar != NULL) markBar->show(); 3044 if (markBar != NULL) markBar->show();
3045 if (m_prog != NULL && !m_statusishidden) 3045 if (m_prog != NULL && !m_statusishidden)
3046 { 3046 {
3047 // qDebug("Showing status"); 3047 // qDebug("Showing status");
3048 m_prog->show(); 3048 m_prog->show();
3049 // qDebug("Shown status"); 3049 // qDebug("Shown status");
3050 } 3050 }
3051 // qDebug("Showing mb"); 3051 // qDebug("Showing mb");
3052 mb->show(); 3052 mb->show();
3053 } 3053 }
3054 if ( searchVisible ) 3054 if ( searchVisible )
3055 { 3055 {
3056#ifdef USEQPE 3056#ifdef USEQPE
3057 Global::showInputMethod(); 3057 Global::showInputMethod();
3058#endif 3058#endif
3059 searchBar->show(); 3059 searchBar->show();
3060 } 3060 }
3061 if ( regVisible ) 3061 if ( regVisible )
3062 { 3062 {
3063#ifdef USEQPE 3063#ifdef USEQPE
3064 Global::showInputMethod(); 3064 Global::showInputMethod();
3065#endif 3065#endif
3066 regBar->show(); 3066 regBar->show();
3067 } 3067 }
3068 if (m_fontVisible) m_fontBar->show(); 3068 if (m_fontVisible) m_fontBar->show();
3069 //qDebug("sn"); 3069 //qDebug("sn");
3070 showNormal(); 3070 showNormal();
3071 //qDebug("sm"); 3071 //qDebug("sm");
3072#if defined(USEQPE) && !defined(SIMPAD) 3072#if defined(USEQPE) && !defined(SIMPAD)
3073 showMaximized(); 3073 showMaximized();
3074#endif 3074#endif
3075 //setCentralWidget(reader); 3075 //setCentralWidget(reader);
3076 } 3076 }
3077 3077
3078 // qDebug("uc"); 3078 // qDebug("uc");
3079 updateCaption(); 3079 updateCaption();
3080 // qDebug("rw"); 3080 // qDebug("rw");
3081 editorStack->raiseWidget( reader ); 3081 editorStack->raiseWidget( reader );
3082 // qDebug("sf"); 3082 // qDebug("sf");
3083 reader->setFocus(); 3083 reader->setFocus();
3084 // qDebug("ref"); 3084 // qDebug("ref");
3085 //reader->refresh(true); 3085 //reader->refresh(true);
3086 // qDebug("done"); 3086 // qDebug("done");
3087} 3087}
3088/* 3088/*
3089void QTReaderApp::save() 3089void QTReaderApp::save()
3090{ 3090{
3091 if ( !doc ) 3091 if ( !doc )
3092 return; 3092 return;
3093 if ( !editor->edited() ) 3093 if ( !editor->edited() )
3094 return; 3094 return;
3095 3095
3096 QString rt = editor->text(); 3096 QString rt = editor->text();
3097 QString pt = rt; 3097 QString pt = rt;
3098 3098
3099 if ( doc->name().isEmpty() ) { 3099 if ( doc->name().isEmpty() ) {
3100 unsigned ispace = pt.find( ' ' ); 3100 unsigned ispace = pt.find( ' ' );
3101 unsigned ienter = pt.find( '\n' ); 3101 unsigned ienter = pt.find( '\n' );
3102 int i = (ispace < ienter) ? ispace : ienter; 3102 int i = (ispace < ienter) ? ispace : ienter;
3103 QString docname; 3103 QString docname;
3104 if ( i == -1 ) { 3104 if ( i == -1 ) {
3105 if ( pt.isEmpty() ) 3105 if ( pt.isEmpty() )
3106 docname = "Empty Text"; 3106 docname = "Empty Text";
3107 else 3107 else
3108 docname = pt; 3108 docname = pt;
3109 } else { 3109 } else {
3110 docname = pt.left( i ); 3110 docname = pt.left( i );
3111 } 3111 }
3112 doc->setName(docname); 3112 doc->setName(docname);
3113 } 3113 }
3114 FileManager fm; 3114 FileManager fm;
3115 fm.saveFile( *doc, rt ); 3115 fm.saveFile( *doc, rt );
3116} 3116}
3117*/ 3117*/
3118 3118
3119void QTReaderApp::clear() 3119void QTReaderApp::clear()
3120{ 3120{
3121// if (doc != 0) 3121// if (doc != 0)
3122// { 3122// {
3123// QMessageBox::information(this, PROGNAME, "Deleting doc", 1); 3123// QMessageBox::information(this, PROGNAME, "Deleting doc", 1);
3124 //delete doc; 3124 //delete doc;
3125// QMessageBox::information(this, PROGNAME, "Deleted doc", 1); 3125// QMessageBox::information(this, PROGNAME, "Deleted doc", 1);
3126 //doc = 0; 3126 //doc = 0;
3127 // } 3127 // }
3128 reader->clear(); 3128 reader->clear();
3129} 3129}
3130 3130
3131void QTReaderApp::updateCaption() 3131void QTReaderApp::updateCaption()
3132{ 3132{
3133// if ( !doc ) 3133// if ( !doc )
3134 //setCaption( tr("QTReader") ); 3134 //setCaption( tr("QTReader") );
3135// else { 3135// else {
3136 //QString s = doc->name(); 3136 //QString s = doc->name();
3137 //if ( s.isEmpty() ) 3137 //if ( s.isEmpty() )
3138 // s = tr( "Unnamed" ); 3138 // s = tr( "Unnamed" );
3139 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); 3139 setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) );
3140// } 3140// }
3141} 3141}
3142 3142
3143void QTReaderApp::setDocument(const QString& fileref) 3143void QTReaderApp::setDocument(const QString& fileref)
3144{ 3144{
3145//QMessageBox::information(0, "setDocument", fileref); 3145//QMessageBox::information(0, "setDocument", fileref);
3146 openFile(fileref); 3146 openFile(fileref);
3147// showEditTools(); 3147// showEditTools();
3148} 3148}
3149 3149
3150void QTReaderApp::closeEvent( QCloseEvent *e ) 3150void QTReaderApp::closeEvent( QCloseEvent *e )
3151{ 3151{
3152// qDebug("Close event"); 3152// qDebug("Close event");
3153 if (m_fullscreen) 3153 if (m_fullscreen)
3154 { 3154 {
3155 m_fullscreen = false; 3155 m_fullscreen = false;
3156 showEditTools(); 3156 showEditTools();
3157 e->ignore(); 3157 e->ignore();
3158 } 3158 }
3159 else if (editorStack->visibleWidget() == m_buttonprefs) 3159 else if (editorStack->visibleWidget() == m_buttonprefs)
3160 { 3160 {
3161 m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); 3161 int ret = QMessageBox::warning(this, PROGNAME,
3162tr("Do you wish to map this key?\n\nIf you proceed you will map\nthe escape key and you will\nneed to press the close box\ntwice to exit this program\n\nContinue?"), tr("Yes"), tr("No"), QString::null, 0, 1);
3163 if (ret == 0)
3164 {
3165 m_buttonprefs->mapkey(Qt::NoButton, Key_Escape);
3166 }
3162 e->ignore(); 3167 e->ignore();
3163 } 3168 }
3164 else if (m_dontSave) 3169 else if (m_dontSave)
3165 { 3170 {
3166 e->accept(); 3171 e->accept();
3167 } 3172 }
3168 else 3173 else
3169 { 3174 {
3170 if (editorStack->visibleWidget() == reader) 3175 if (editorStack->visibleWidget() == reader)
3171 { 3176 {
3172 if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) 3177 if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled)
3173 { 3178 {
3174 //qDebug("Close disabled"); 3179 //qDebug("Close disabled");
3175 m_bcloseDisabled = false; 3180 m_bcloseDisabled = false;
3176 e->ignore(); 3181 e->ignore();
3177 } 3182 }
3178 else 3183 else
3179 { 3184 {
3180 if (m_fontVisible) 3185 if (m_fontVisible)
3181 { 3186 {
3182 m_fontBar->hide(); 3187 m_fontBar->hide();
3183 m_fontVisible = false; 3188 m_fontVisible = false;
3184 e->ignore(); 3189 e->ignore();
3185 return; 3190 return;
3186 } 3191 }
3187 if (regVisible) 3192 if (regVisible)
3188 { 3193 {
3189 regBar->hide(); 3194 regBar->hide();
3190#ifdef USEQPE 3195#ifdef USEQPE
3191 Global::hideInputMethod(); 3196 Global::hideInputMethod();
3192#endif 3197#endif
3193 regVisible = false; 3198 regVisible = false;
3194 e->ignore(); 3199 e->ignore();
3195 return; 3200 return;
3196 } 3201 }
3197 if (searchVisible) 3202 if (searchVisible)
3198 { 3203 {
3199 searchBar->hide(); 3204 searchBar->hide();
3200#ifdef USEQPE 3205#ifdef USEQPE
3201 Global::hideInputMethod(); 3206 Global::hideInputMethod();
3202#endif 3207#endif
3203 searchVisible = false; 3208 searchVisible = false;
3204 e->ignore(); 3209 e->ignore();
3205 return; 3210 return;
3206 } 3211 }
3207 if (m_fBkmksChanged && pBkmklist != NULL) 3212 if (m_fBkmksChanged && pBkmklist != NULL)
3208 { 3213 {
3209 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) 3214 if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0)
3210 savebkmks(); 3215 savebkmks();
3211 delete pBkmklist; 3216 delete pBkmklist;
3212 reader->pBkmklist = pBkmklist = NULL; 3217 reader->pBkmklist = pBkmklist = NULL;
3213 m_fBkmksChanged = false; 3218 m_fBkmksChanged = false;
3214 } 3219 }
3215 updatefileinfo(); 3220 updatefileinfo();
3216 saveprefs(); 3221 saveprefs();
3217 e->accept(); 3222 e->accept();
3218 } 3223 }
3219 } 3224 }
3220 else 3225 else
3221 { 3226 {
3222 showEditTools(); 3227 showEditTools();
3223 m_disableesckey = true; 3228 m_disableesckey = true;
3224 } 3229 }
3225 } 3230 }
3226} 3231}
3227 3232
3228void QTReaderApp::do_gotomark() 3233void QTReaderApp::do_gotomark()
3229{ 3234{
3230 m_nBkmkAction = cGotoBkmk; 3235 m_nBkmkAction = cGotoBkmk;
3231 if (!listbkmk(pBkmklist)) 3236 if (!listbkmk(pBkmklist))
3232 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 3237 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
3233} 3238}
3234 3239
3235void QTReaderApp::do_delmark() 3240void QTReaderApp::do_delmark()
3236{ 3241{
3237 m_nBkmkAction = cDelBkmk; 3242 m_nBkmkAction = cDelBkmk;
3238 if (!listbkmk(pBkmklist)) 3243 if (!listbkmk(pBkmklist))
3239 QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); 3244 QMessageBox::information(this, PROGNAME, "No bookmarks in memory");
3240} 3245}
3241 3246
3242bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) 3247bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel)
3243{ 3248{
3244 bkmkselector->clear(); 3249 bkmkselector->clear();
3245 if (_lab.isEmpty()) 3250 if (_lab.isEmpty())
3246 bkmkselector->setText("Cancel"); 3251 bkmkselector->setText("Cancel");
3247 else 3252 else
3248 bkmkselector->setText(_lab); 3253 bkmkselector->setText(_lab);
3249 int cnt = 0; 3254 int cnt = 0;
3250 int slt = -1; 3255 int slt = -1;
3251 if (plist != NULL) 3256 if (plist != NULL)
3252 { 3257 {
3253 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) 3258 for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++)
3254 { 3259 {
3255 if (presel) 3260 if (presel)
3256 { 3261 {
3257 Bkmk* p = i.pContent(); 3262 Bkmk* p = i.pContent();
3258 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) 3263 if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile)
3259 { 3264 {
3260 slt = cnt; 3265 slt = cnt;
3261 } 3266 }
3262 } 3267 }
3263#ifdef _UNICODE 3268#ifdef _UNICODE
3264 // qDebug("Item:%s", (const char*)toQString(i->name())); 3269 // qDebug("Item:%s", (const char*)toQString(i->name()));
3265 bkmkselector->insertItem(toQString(i->name()), cnt++); 3270 bkmkselector->insertItem(toQString(i->name()), cnt++);
3266#else 3271#else
3267 bkmkselector->insertItem(i->name(), cnt++); 3272 bkmkselector->insertItem(i->name(), cnt++);
3268#endif 3273#endif
3269 3274
3270 } 3275 }
3271 } 3276 }
3272 if (cnt > 0) 3277 if (cnt > 0)
3273 { 3278 {
3274 hidetoolbars(); 3279 hidetoolbars();
3275 editorStack->raiseWidget( bkmkselector ); 3280 editorStack->raiseWidget( bkmkselector );
3276 if (slt != -1) bkmkselector->setCurrentItem(slt); 3281 if (slt != -1) bkmkselector->setCurrentItem(slt);
3277 return true; 3282 return true;
3278 } 3283 }
3279 else 3284 else
3280 return false; 3285 return false;
3281} 3286}
3282 3287
3283void QTReaderApp::do_autogen() 3288void QTReaderApp::do_autogen()
3284{ 3289{
3285 m_nRegAction = cAutoGen; 3290 m_nRegAction = cAutoGen;
3286 regEdit->setText(m_autogenstr); 3291 regEdit->setText(m_autogenstr);
3287 do_regedit(); 3292 do_regedit();
3288} 3293}
3289 3294
3290void QTReaderApp::do_regedit() 3295void QTReaderApp::do_regedit()
3291{ 3296{
3292// fileBar->hide(); 3297// fileBar->hide();
3293 reader->bDoUpdates = false; 3298 reader->bDoUpdates = false;
3294// qDebug("Showing regbar"); 3299// qDebug("Showing regbar");
3295 regBar->show(); 3300 regBar->show();
3296// qDebug("Showing kbd"); 3301// qDebug("Showing kbd");
3297#ifdef USEQPE 3302#ifdef USEQPE
3298 Global::showInputMethod(); 3303 Global::showInputMethod();
3299#endif 3304#endif
3300 regVisible = true; 3305 regVisible = true;
3301 regEdit->setFocus(); 3306 regEdit->setFocus();
3302// qApp->processEvents(); 3307// qApp->processEvents();
3303 reader->bDoUpdates = true; 3308 reader->bDoUpdates = true;
3304 reader->update(); 3309 reader->update();
3305} 3310}
3306 3311
3307bool QTReaderApp::openfrombkmk(Bkmk* bk) 3312bool QTReaderApp::openfrombkmk(Bkmk* bk)
3308{ 3313{
3309 QString fn = toQString( 3314 QString fn = toQString(
3310 CFiledata(bk->anno()).name() 3315 CFiledata(bk->anno()).name()
3311 ); 3316 );
3312 //qDebug("fileinfo"); 3317 //qDebug("fileinfo");
3313 if (!fn.isEmpty() && QFileInfo(fn).isFile()) 3318 if (!fn.isEmpty() && QFileInfo(fn).isFile())
3314 { 3319 {
3315 //qDebug("Opening"); 3320 //qDebug("Opening");
3316 struct stat fnstat; 3321 struct stat fnstat;
3317 stat((const char *)fn, &fnstat); 3322 stat((const char *)fn, &fnstat);
3318 3323
3319 if (CFiledata(bk->anno()).date() 3324 if (CFiledata(bk->anno()).date()
3320 != fnstat.st_mtime) 3325 != fnstat.st_mtime)
3321 { 3326 {
3322 CFiledata fd(bk->anno()); 3327 CFiledata fd(bk->anno());
3323 fd.setdate(fnstat.st_mtime); 3328 fd.setdate(fnstat.st_mtime);
3324 bk->value(0); 3329 bk->value(0);
3325 reader->m_lastposn = 0; 3330 reader->m_lastposn = 0;
3326 openFile(fn); 3331 openFile(fn);
3327 } 3332 }
3328 else 3333 else
3329 { 3334 {
3330 unsigned short svlen = bk->filedatalen(); 3335 unsigned short svlen = bk->filedatalen();
3331 unsigned char* svdata = bk->filedata(); 3336 unsigned char* svdata = bk->filedata();
3332 openFile(fn, bk->value()); 3337 openFile(fn, bk->value());
3333 reader->putSaveData(svdata, svlen); 3338 reader->putSaveData(svdata, svlen);
3334 // setstate(svdata, svlen); 3339 // setstate(svdata, svlen);
3335 if (svlen != 0) 3340 if (svlen != 0)
3336 { 3341 {
3337 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); 3342 QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?");
3338 } 3343 }
3339 // qDebug("updating"); 3344 // qDebug("updating");
3340 // showEditTools(); 3345 // showEditTools();
3341 } 3346 }
3342 return true; 3347 return true;
3343 } 3348 }
3344 else 3349 else
3345 { 3350 {
3346 return false; 3351 return false;
3347 } 3352 }
3348} 3353}
3349 3354
3350void QTReaderApp::gotobkmk(int ind) 3355void QTReaderApp::gotobkmk(int ind)
3351{ 3356{
3352 qDebug("gbkmk"); 3357 qDebug("gbkmk");
3353 showEditTools(); 3358 showEditTools();
3354 switch (m_nBkmkAction) 3359 switch (m_nBkmkAction)
3355 { 3360 {
3356 case cOpenFile: 3361 case cOpenFile:
3357 { 3362 {
3358 // qApp->processEvents(); 3363 // qApp->processEvents();
3359 if (!openfrombkmk((*pOpenlist)[ind])) 3364 if (!openfrombkmk((*pOpenlist)[ind]))
3360 { 3365 {
3361 pOpenlist->erase(ind); 3366 pOpenlist->erase(ind);
3362 QMessageBox::information(this, PROGNAME, "Can't find file"); 3367 QMessageBox::information(this, PROGNAME, "Can't find file");
3363 } 3368 }
3364 } 3369 }
3365 break; 3370 break;
3366 case cGotoBkmk: 3371 case cGotoBkmk:
3367 reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); 3372 reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate());
3368 reader->locate((*pBkmklist)[ind]->value()); 3373 reader->locate((*pBkmklist)[ind]->value());
3369 break; 3374 break;
3370 case cDelBkmk: 3375 case cDelBkmk:
3371 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); 3376 //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name());
3372 pBkmklist->erase(ind); 3377 pBkmklist->erase(ind);
3373 m_fBkmksChanged = true; 3378 m_fBkmksChanged = true;
3374 reader->refresh(true); 3379 reader->refresh(true);
3375 // pBkmklist->sort(); 3380 // pBkmklist->sort();
3376 break; 3381 break;
3377 case cRmBkmkFile: 3382 case cRmBkmkFile:
3378 { 3383 {
3379#ifndef USEQPE 3384#ifndef USEQPE
3380 QDir d = QDir::home(); // "/" 3385 QDir d = QDir::home(); // "/"
3381 d.cd(APPDIR); 3386 d.cd(APPDIR);
3382 d.remove(bkmkselector->text(ind)); 3387 d.remove(bkmkselector->text(ind));
3383#else /* USEQPE */ 3388#else /* USEQPE */
3384 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); 3389 unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind)));
3385#endif /* USEQPE */ 3390#endif /* USEQPE */
3386 } 3391 }
3387 break; 3392 break;
3388 case cLdConfig: 3393 case cLdConfig:
3389 readconfig(APPDIR "/configs", bkmkselector->text(ind), false); 3394 readconfig(APPDIR "/configs", bkmkselector->text(ind), false);
3390 break; 3395 break;
3391 case cLdTheme: 3396 case cLdTheme:
3392 m_themename = bkmkselector->text(ind); 3397 m_themename = bkmkselector->text(ind);
3393 readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); 3398 readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false);
3394 setBackgroundBitmap(); 3399 setBackgroundBitmap();
3395 break; 3400 break;
3396 case cRmConfig: 3401 case cRmConfig:
3397 { 3402 {
3398#ifndef USEQPE 3403#ifndef USEQPE
3399 QDir d = QDir::home(); // "/" 3404 QDir d = QDir::home(); // "/"
3400 d.cd(APPDIR "/configs"); 3405 d.cd(APPDIR "/configs");
3401 d.remove(bkmkselector->text(ind)); 3406 d.remove(bkmkselector->text(ind));
3402#else /* USEQPE */ 3407#else /* USEQPE */
3403 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); 3408 unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind)));
3404#endif /* USEQPE */ 3409#endif /* USEQPE */
3405 } 3410 }
3406 break; 3411 break;
3407 case cExportLinks: 3412 case cExportLinks:
3408 { 3413 {
3409#ifndef USEQPE 3414#ifndef USEQPE
3410 QDir d = QDir::home(); // "/" 3415 QDir d = QDir::home(); // "/"
3411 d.cd(APPDIR "/urls"); 3416 d.cd(APPDIR "/urls");
3412 QFileInfo fi(d, bkmkselector->text(ind)); 3417 QFileInfo fi(d, bkmkselector->text(ind));
3413 if (fi.exists()) 3418 if (fi.exists())
3414 { 3419 {
3415 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); 3420 QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) );
3416 if (!outfile.isEmpty()) 3421 if (!outfile.isEmpty())
3417 { 3422 {
3418 FILE* fout = fopen((const char *)outfile, "w"); 3423 FILE* fout = fopen((const char *)outfile, "w");
3419 if (fout != NULL) 3424 if (fout != NULL)
3420 { 3425 {
3421 FILE* fin = fopen((const char *)fi.absFilePath(), "r"); 3426 FILE* fin = fopen((const char *)fi.absFilePath(), "r");
3422 if (fin != NULL) 3427 if (fin != NULL)
3423 { 3428 {
3424 fprintf(fout, "<html><body>\n"); 3429 fprintf(fout, "<html><body>\n");
3425 int ch = 0; 3430 int ch = 0;
3426 while ((ch = fgetc(fin)) != EOF) 3431 while ((ch = fgetc(fin)) != EOF)
3427 { 3432 {
3428 fputc(ch, fout); 3433 fputc(ch, fout);
3429 } 3434 }
3430 fclose(fin); 3435 fclose(fin);
3431 fprintf(fout, "</html></body>\n"); 3436 fprintf(fout, "</html></body>\n");
3432 d.remove(bkmkselector->text(ind)); 3437 d.remove(bkmkselector->text(ind));
3433 } 3438 }
3434 fclose(fout); 3439 fclose(fout);
3435 } 3440 }
3436 else 3441 else
3437 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3442 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3438 } 3443 }
3439 } 3444 }
3440#else /* USEQPE */ 3445#else /* USEQPE */
3441 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 3446 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
3442 if (fin != NULL) 3447 if (fin != NULL)
3443 { 3448 {
3444 bool allok = false; 3449 bool allok = false;
3445#if defined(OPIE) && defined(OPIEFILEDIALOG) 3450#if defined(OPIE) && defined(OPIEFILEDIALOG)
3446 QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); 3451 QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader");
3447 if (!outfile.isEmpty()) 3452 if (!outfile.isEmpty())
3448 { 3453 {
3449 FILE* fout = fopen((const char *)outfile, "w"); 3454 FILE* fout = fopen((const char *)outfile, "w");
3450 if (fout != NULL) 3455 if (fout != NULL)
3451 { 3456 {
3452 fprintf(fout, "<html><body>\n"); 3457 fprintf(fout, "<html><body>\n");
3453 int ch = 0; 3458 int ch = 0;
3454 while ((ch = fgetc(fin)) != EOF) 3459 while ((ch = fgetc(fin)) != EOF)
3455 { 3460 {
3456 fputc(ch, fout); 3461 fputc(ch, fout);
3457 } 3462 }
3458 fprintf(fout, "</html></body>\n"); 3463 fprintf(fout, "</html></body>\n");
3459 fclose(fout); 3464 fclose(fout);
3460 allok = true; 3465 allok = true;
3461 } 3466 }
3462 else 3467 else
3463 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3468 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3464 } 3469 }
3465 fclose(fin); 3470 fclose(fin);
3466 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); 3471 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
3467#else 3472#else
3468 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); 3473 fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null);
3469 if (fb->exec()) 3474 if (fb->exec())
3470 { 3475 {
3471 QString outfile = fb->getCurrentFile(); 3476 QString outfile = fb->getCurrentFile();
3472 FILE* fout = fopen((const char *)outfile, "w"); 3477 FILE* fout = fopen((const char *)outfile, "w");
3473 if (fout != NULL) 3478 if (fout != NULL)
3474 { 3479 {
3475 fprintf(fout, "<html><body>\n"); 3480 fprintf(fout, "<html><body>\n");
3476 int ch = 0; 3481 int ch = 0;
3477 while ((ch = fgetc(fin)) != EOF) 3482 while ((ch = fgetc(fin)) != EOF)
3478 { 3483 {
3479 fputc(ch, fout); 3484 fputc(ch, fout);
3480 } 3485 }
3481 fprintf(fout, "</html></body>\n"); 3486 fprintf(fout, "</html></body>\n");
3482 fclose(fout); 3487 fclose(fout);
3483 allok = true; 3488 allok = true;
3484 } 3489 }
3485 else 3490 else
3486 QMessageBox::information(this, PROGNAME, "Couldn't open output"); 3491 QMessageBox::information(this, PROGNAME, "Couldn't open output");
3487 } 3492 }
3488 delete fb; 3493 delete fb;
3489 fclose(fin); 3494 fclose(fin);
3490 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); 3495 if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)));
3491#endif 3496#endif
3492 } 3497 }
3493 else 3498 else
3494 { 3499 {
3495 QMessageBox::information(this, PROGNAME, "Couldn't open input"); 3500 QMessageBox::information(this, PROGNAME, "Couldn't open input");
3496 } 3501 }
3497 3502
3498/* 3503/*
3499 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); 3504 CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE );
3500 int ret = f->exec(); 3505 int ret = f->exec();
3501 qDebug("Return:%d", ret); 3506 qDebug("Return:%d", ret);
3502 DocLnk* doc = f->getDoc(); 3507 DocLnk* doc = f->getDoc();
3503 if (doc != NULL) 3508 if (doc != NULL)
3504 { 3509 {
3505 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); 3510 FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r");
3506 QString rt; 3511 QString rt;
3507 rt = "<html><body>\n"; 3512 rt = "<html><body>\n";
3508 int ch = 0; 3513 int ch = 0;
3509 while ((ch = fgetc(fin)) != EOF) 3514 while ((ch = fgetc(fin)) != EOF)
3510 { 3515 {
3511 rt += (char)ch; 3516 rt += (char)ch;
3512 } 3517 }
3513 fclose(fin); 3518 fclose(fin);
3514 rt += "</html></body>\n"; 3519 rt += "</html></body>\n";
3515 if ( doc->name().isEmpty() ) 3520 if ( doc->name().isEmpty() )
3516 { 3521 {
3517 doc->setName(bkmkselector->text(ind)); 3522 doc->setName(bkmkselector->text(ind));
3518 } 3523 }
3519 FileManager fm; 3524 FileManager fm;
3520 fm.saveFile( *doc, rt ); 3525 fm.saveFile( *doc, rt );
3521 qDebug("YES"); 3526 qDebug("YES");
3522 } 3527 }
3523 else 3528 else
3524 { 3529 {
3525 qDebug("NO"); 3530 qDebug("NO");
3526 } 3531 }
3527 delete f; 3532 delete f;
3528*/ 3533*/
3529 3534
3530#endif /* USEQPE */ 3535#endif /* USEQPE */
3531 } 3536 }
3532 break; 3537 break;
3533 } 3538 }
3534} 3539}
3535 3540
3536void QTReaderApp::cancelbkmk() 3541void QTReaderApp::cancelbkmk()
3537{ 3542{
3538 if (m_nBkmkAction == cOpenFile) 3543 if (m_nBkmkAction == cOpenFile)
3539 { 3544 {
3540 QString fn = usefilebrowser(); 3545 QString fn = usefilebrowser();
3541 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); 3546 if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn);
3542 } 3547 }
3543 showEditTools(); 3548 showEditTools();
3544} 3549}
3545 3550
3546void QTReaderApp::reparastring() 3551void QTReaderApp::reparastring()
3547{ 3552{
3548 m_nRegAction = cRepara; 3553 m_nRegAction = cRepara;
3549 regEdit->setText(reader->m_reparastring); 3554 regEdit->setText(reader->m_reparastring);
3550 do_regedit(); 3555 do_regedit();
3551} 3556}
3552 3557
3553void QTReaderApp::do_reparastring(const QString& _lcn) 3558void QTReaderApp::do_reparastring(const QString& _lcn)
3554{ 3559{
3555 reader->m_reparastring = _lcn; 3560 reader->m_reparastring = _lcn;
3556 if (reader->brepara) 3561 if (reader->brepara)
3557 { 3562 {
3558 reader->bDoUpdates = true; 3563 reader->bDoUpdates = true;
3559 reader->setfilter(reader->getfilter()); 3564 reader->setfilter(reader->getfilter());
3560 } 3565 }
3561} 3566}
3562 3567
3563void QTReaderApp::jump() 3568void QTReaderApp::jump()
3564{ 3569{
3565 m_nRegAction = cJump; 3570 m_nRegAction = cJump;
3566 char lcn[20]; 3571 char lcn[20];
3567 sprintf(lcn, "%lu", reader->pagelocate()); 3572 sprintf(lcn, "%lu", reader->pagelocate());
3568 regEdit->setText(lcn); 3573 regEdit->setText(lcn);
3569 do_regedit(); 3574 do_regedit();
3570} 3575}
3571 3576
3572void QTReaderApp::do_jump(const QString& _lcn) 3577void QTReaderApp::do_jump(const QString& _lcn)
3573{ 3578{
3574 bool ok; 3579 bool ok;
3575 QString lcn = _lcn.stripWhiteSpace(); 3580 QString lcn = _lcn.stripWhiteSpace();
3576 unsigned long ulcn = lcn.toULong(&ok); 3581 unsigned long ulcn = lcn.toULong(&ok);
3577 if (!ok) 3582 if (!ok)
3578 { 3583 {
3579 double pc = 0.0; 3584 double pc = 0.0;
3580#ifdef _WINDOWS 3585#ifdef _WINDOWS
3581 if (lcn.at(lcn.length()-1) == '%') 3586 if (lcn.at(lcn.length()-1) == '%')
3582#else 3587#else
3583 if (lcn[lcn.length()-1] == '%') 3588 if (lcn[lcn.length()-1] == '%')
3584#endif 3589#endif
3585 { 3590 {
3586 lcn = lcn.left(lcn.length()-1); 3591 lcn = lcn.left(lcn.length()-1);
3587 pc = lcn.toDouble(&ok); 3592 pc = lcn.toDouble(&ok);
3588 } 3593 }
3589 else 3594 else
3590 { 3595 {
3591 pc = lcn.toDouble(&ok); 3596 pc = lcn.toDouble(&ok);
3592 } 3597 }
3593 if (ok && 0 <= pc && pc <= 100) 3598 if (ok && 0 <= pc && pc <= 100)
3594 { 3599 {
3595 ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); 3600 ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection();
3596 } 3601 }
3597 else 3602 else
3598 { 3603 {
3599 ok = false; 3604 ok = false;
3600 } 3605 }
3601 } 3606 }
3602 if (ok) 3607 if (ok)
3603 reader->locate(ulcn); 3608 reader->locate(ulcn);
3604 else 3609 else
3605 QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); 3610 QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage");
3606} 3611}
3607 3612
3608void QTReaderApp::do_regaction() 3613void QTReaderApp::do_regaction()
3609{ 3614{
3610 reader->bDoUpdates = false; 3615 reader->bDoUpdates = false;
3611 regBar->hide(); 3616 regBar->hide();
3612#ifdef USEQPE 3617#ifdef USEQPE
3613 Global::hideInputMethod(); 3618 Global::hideInputMethod();
3614#endif 3619#endif
3615 regVisible = false; 3620 regVisible = false;
3616 switch(m_nRegAction) 3621 switch(m_nRegAction)
3617 { 3622 {
3618 case cAutoGen: 3623 case cAutoGen:
3619 do_autogen(regEdit->text()); 3624 do_autogen(regEdit->text());
3620 break; 3625 break;
3621 case cAddBkmk: 3626 case cAddBkmk:
3622 do_addbkmk(regEdit->text()); 3627 do_addbkmk(regEdit->text());
3623 break; 3628 break;
3624 case cRepara: 3629 case cRepara:
3625 do_reparastring(regEdit->text()); 3630 do_reparastring(regEdit->text());
3626 break; 3631 break;
3627 case cJump: 3632 case cJump:
3628 do_jump(regEdit->text()); 3633 do_jump(regEdit->text());
3629 break; 3634 break;
3630/* 3635/*
3631 case cMonoSpace: 3636 case cMonoSpace:
3632 do_mono(regEdit->text()); 3637 do_mono(regEdit->text());
3633 break; 3638 break;
3634*/ 3639*/
3635 case cSetTarget: 3640 case cSetTarget:
3636 do_settarget(regEdit->text()); 3641 do_settarget(regEdit->text());
3637 break; 3642 break;
3638#ifdef _SCROLLPIPE 3643#ifdef _SCROLLPIPE
3639 case cSetPipeTarget: 3644 case cSetPipeTarget:
3640 do_setpipetarget(regEdit->text()); 3645 do_setpipetarget(regEdit->text());
3641 break; 3646 break;
3642#endif 3647#endif
3643 case cSetConfigName: 3648 case cSetConfigName:
3644 // qDebug("Saving config"); 3649 // qDebug("Saving config");
3645 do_saveconfig(regEdit->text(), false); 3650 do_saveconfig(regEdit->text(), false);
3646 break; 3651 break;
3647 } 3652 }
3648// reader->restore(); 3653// reader->restore();
3649// fileBar->show(); 3654// fileBar->show();
3650 reader->setFocus(); 3655 reader->setFocus();
3651// qApp->processEvents(); 3656// qApp->processEvents();
3652 reader->bDoUpdates = true; 3657 reader->bDoUpdates = true;
3653 reader->update(); 3658 reader->update();
3654} 3659}
3655 3660
3656void QTReaderApp::do_settarget(const QString& _txt) 3661void QTReaderApp::do_settarget(const QString& _txt)
3657{ 3662{
3658 int ind = _txt.find('/'); 3663 int ind = _txt.find('/');
3659 if (ind == -1) 3664 if (ind == -1)
3660 { 3665 {
3661 m_targetapp = ""; 3666 m_targetapp = "";
3662 m_targetmsg = ""; 3667 m_targetmsg = "";
3663 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); 3668 QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename");
3664 } 3669 }
3665 else 3670 else
3666 { 3671 {
3667 m_targetapp = _txt.left(ind); 3672 m_targetapp = _txt.left(ind);
3668 m_targetmsg = _txt.right(_txt.length()-ind-1); 3673 m_targetmsg = _txt.right(_txt.length()-ind-1);
3669 } 3674 }
3670} 3675}
3671 3676
3672void QTReaderApp::chooseencoding() 3677void QTReaderApp::chooseencoding()
3673{ 3678{