author | cniehaus <cniehaus> | 2003-05-02 09:16:28 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-05-02 09:16:28 (UTC) |
commit | e4d80a4839a97f2554e880a25ee32d0388371ef3 (patch) (unidiff) | |
tree | 281d697d5805aeb4a8ceff47b1cd634debe4c538 | |
parent | 49dfb55bd22f5027fcbcbc55648efd4bce6c8fd6 (diff) | |
download | opie-e4d80a4839a97f2554e880a25ee32d0388371ef3.zip opie-e4d80a4839a97f2554e880a25ee32d0388371ef3.tar.gz opie-e4d80a4839a97f2554e880a25ee32d0388371ef3.tar.bz2 |
linebreak works :)
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index f012333..4be6e71 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -1,149 +1,148 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | #include "dingwidget.h" | 17 | #include "dingwidget.h" |
18 | 18 | ||
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qtextstream.h> | 27 | #include <qtextstream.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <stdlib.h> // for getenv | 31 | #include <stdlib.h> // for getenv |
32 | 32 | ||
33 | DingWidget::DingWidget( ) | 33 | DingWidget::DingWidget( ) |
34 | { | 34 | { |
35 | methodname = QString::null; | 35 | methodname = QString::null; |
36 | trenner = QString::null; | 36 | trenner = QString::null; |
37 | lines = 0L; | 37 | lines = 0L; |
38 | } | 38 | } |
39 | 39 | ||
40 | void DingWidget::loadDict( QString name ) | 40 | void DingWidget::loadDict( QString name ) |
41 | { | 41 | { |
42 | qDebug( "MUSS ich wirklich aufgerufen werder? schreit loadDict" ); | 42 | qDebug( "MUSS ich wirklich aufgerufen werder? schreit loadDict" ); |
43 | qDebug( "Starte mit dem loadedDict(...)" ); | 43 | qDebug( "Starte mit dem loadedDict(...)" ); |
44 | dictName = name; | 44 | dictName = name; |
45 | qDebug( "bin in loadedDict() und lade das Dict:" ); | 45 | qDebug( "bin in loadedDict() und lade das Dict:" ); |
46 | qDebug( dictName ); | 46 | qDebug( dictName ); |
47 | QString opie_dir = getenv("OPIEDIR"); | 47 | QString opie_dir = getenv("OPIEDIR"); |
48 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); | 48 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); |
49 | //FIXME:this should of course be not hardcoded ;) | 49 | //FIXME:this should of course be not hardcoded ;) |
50 | 50 | ||
51 | if( file.open( IO_ReadOnly ) ) | 51 | if( file.open( IO_ReadOnly ) ) |
52 | { | 52 | { |
53 | QTextStream stream( &file ); | 53 | QTextStream stream( &file ); |
54 | while ( !stream.eof() ) | 54 | while ( !stream.eof() ) |
55 | { | 55 | { |
56 | lines.append( stream.readLine() ); | 56 | lines.append( stream.readLine() ); |
57 | } | 57 | } |
58 | file.close(); | 58 | file.close(); |
59 | } | 59 | } |
60 | qDebug( "loadedDict(...) ist beended" ); | 60 | qDebug( "loadedDict(...) ist beended" ); |
61 | loadValues(); | 61 | loadValues(); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString DingWidget::loadedDict() | 64 | QString DingWidget::loadedDict() |
65 | { | 65 | { |
66 | qDebug( dictName ); | 66 | qDebug( dictName ); |
67 | qDebug( "^ ^ ^ ^ ^ ^ ^ war der dictName" ); | 67 | qDebug( "^ ^ ^ ^ ^ ^ ^ war der dictName" ); |
68 | return dictName; | 68 | return dictName; |
69 | } | 69 | } |
70 | 70 | ||
71 | void DingWidget::setCaseSensitive( bool caseS ) | 71 | void DingWidget::setCaseSensitive( bool caseS ) |
72 | { | 72 | { |
73 | isCaseSensitive = caseS; | 73 | isCaseSensitive = caseS; |
74 | } | 74 | } |
75 | 75 | ||
76 | void DingWidget::setDict( QString dict ) | 76 | void DingWidget::setDict( QString dict ) |
77 | { | 77 | { |
78 | methodname = dict; | 78 | methodname = dict; |
79 | } | 79 | } |
80 | 80 | ||
81 | void DingWidget::setCompleteWord( bool cword ) | 81 | void DingWidget::setCompleteWord( bool cword ) |
82 | { | 82 | { |
83 | isCompleteWord = cword; | 83 | isCompleteWord = cword; |
84 | } | 84 | } |
85 | 85 | ||
86 | void DingWidget::setQueryWord( QString qword ) | 86 | void DingWidget::setQueryWord( QString qword ) |
87 | { | 87 | { |
88 | queryword = qword; | 88 | queryword = qword; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void DingWidget::loadValues() | 92 | void DingWidget::loadValues() |
93 | { | 93 | { |
94 | Config cfg( "odict" ); | 94 | Config cfg( "odict" ); |
95 | cfg.setGroup( "Method_" + methodname ); | 95 | cfg.setGroup( "Method_" + methodname ); |
96 | trenner = cfg.readEntry( "Seperator" ); | 96 | trenner = cfg.readEntry( "Seperator" ); |
97 | } | 97 | } |
98 | 98 | ||
99 | BroswerContent DingWidget::setText( QString word ) | 99 | BroswerContent DingWidget::setText( QString word ) |
100 | { | 100 | { |
101 | queryword = word; | 101 | queryword = word; |
102 | qDebug( queryword ); | 102 | qDebug( queryword ); |
103 | qDebug( "^ ^ ^ ^ ^ ^ ^ war das gesuchte Word"); | 103 | qDebug( "^ ^ ^ ^ ^ ^ ^ war das gesuchte Word"); |
104 | return parseInfo(); | 104 | return parseInfo(); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | BroswerContent DingWidget::parseInfo() | 108 | BroswerContent DingWidget::parseInfo() |
109 | { | 109 | { |
110 | if ( isCompleteWord ) | 110 | if ( isCompleteWord ) |
111 | queryword = " " + queryword + " "; | 111 | queryword = " " + queryword + " "; |
112 | QStringList search = lines.grep( queryword , isCaseSensitive ); | 112 | QStringList search = lines.grep( queryword , isCaseSensitive ); |
113 | 113 | ||
114 | QString current; | 114 | QString current; |
115 | QString left; | 115 | QString left; |
116 | QString right; | 116 | QString right; |
117 | QRegExp reg_div( trenner ); | 117 | QRegExp reg_div( trenner ); |
118 | QRegExp reg_word( queryword ); | 118 | QRegExp reg_word( queryword ); |
119 | reg_word.setCaseSensitive( isCaseSensitive ); | 119 | reg_word.setCaseSensitive( isCaseSensitive ); |
120 | QStringList toplist, bottomlist; | 120 | QStringList toplist, bottomlist; |
121 | //QString substitute = "<strong>"+queryword+"</strong>"; | 121 | QString substitute = "<strong>"+queryword+"</strong>"; |
122 | QString substitute = queryword; | ||
123 | 122 | ||
124 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) | 123 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) |
125 | { | 124 | { |
126 | current = *it; | 125 | current = *it; |
127 | left = current.left( current.find( trenner ) ); | 126 | left = current.left( current.find( trenner ) ); |
128 | 127 | ||
129 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); | 128 | right = current.right( current.length() - current.find(trenner) - trenner.length() ); |
130 | 129 | ||
131 | if ( left.contains( queryword , isCaseSensitive ) ) | 130 | if ( left.contains( queryword , isCaseSensitive ) ) |
132 | { | 131 | { |
133 | left.replace( queryword, substitute ); | 132 | left.replace( queryword, substitute ); |
134 | left = left + " --> " + right; | 133 | left = left + " --> " + right; |
135 | toplist.append( left ); | 134 | toplist.append( left ); |
136 | } | 135 | } |
137 | else | 136 | else |
138 | { | 137 | { |
139 | right.replace( queryword, substitute ); | 138 | right.replace( queryword, substitute ); |
140 | right = right + " --> " + left; | 139 | right = right + " --> " + left; |
141 | bottomlist.append( right ); | 140 | bottomlist.append( right ); |
142 | } | 141 | } |
143 | } | 142 | } |
144 | 143 | ||
145 | s_strings.top = toplist.join( "\n" ); | 144 | s_strings.top = toplist.join( "<br>" ); |
146 | s_strings.bottom = bottomlist.join( "\n" ); | 145 | s_strings.bottom = bottomlist.join( "<br>" ); |
147 | 146 | ||
148 | return s_strings; | 147 | return s_strings; |
149 | } | 148 | } |