summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2003-04-30 19:28:50 (UTC)
committer cniehaus <cniehaus>2003-04-30 19:28:50 (UTC)
commitb48845bf24f1361a349c86a48a7b54e49df94533 (patch) (unidiff)
tree38e6e2e027c6ed0c2d1bd94aa78e27b8434daea7
parente6428d30a5dc90ed3ec6ca7e1cb3f92c81437cc0 (diff)
downloadopie-b48845bf24f1361a349c86a48a7b54e49df94533.zip
opie-b48845bf24f1361a349c86a48a7b54e49df94533.tar.gz
opie-b48845bf24f1361a349c86a48a7b54e49df94533.tar.bz2
I hope I will code more in the next days
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/dingwidget.cpp59
-rw-r--r--noncore/apps/odict/odict.cpp4
2 files changed, 14 insertions, 49 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp
index cfef84d..16164ed 100644
--- a/noncore/apps/odict/dingwidget.cpp
+++ b/noncore/apps/odict/dingwidget.cpp
@@ -27,13 +27,12 @@
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
34DingWidget::DingWidget( ) 33DingWidget::DingWidget( )
35{ 34{
36 methodname = QString::null; 35 methodname = QString::null;
37 trenner = QString::null; 36 trenner = QString::null;
38 lines = 0L; 37 lines = 0L;
39} 38}
@@ -86,94 +85,64 @@ void DingWidget::setCompleteWord( bool cword )
86 85
87void DingWidget::setQueryWord( QString qword ) 86void DingWidget::setQueryWord( QString qword )
88{ 87{
89 queryword = qword; 88 queryword = qword;
90} 89}
91 90
91
92void DingWidget::loadValues()
93{
94 Config cfg( "odict" );
95 cfg.setGroup( "Method_" + methodname );
96 trenner = cfg.readEntry( "Seperator" );
97}
98
92BroswerContent DingWidget::setText( QString word ) 99BroswerContent DingWidget::setText( QString word )
93{ 100{
94 queryword = word; 101 queryword = word;
95 qDebug( queryword ); 102 qDebug( queryword );
96 qDebug( "^ ^ ^ ^ ^ ^ ^ war das gesuchte Word"); 103 qDebug( "^ ^ ^ ^ ^ ^ ^ war das gesuchte Word");
97 return parseInfo(); 104 return parseInfo();
98} 105}
99 106
100void DingWidget::loadValues()
101{
102 Config cfg( "odict" );
103 cfg.setGroup( "Method_" + methodname );
104 trenner = cfg.readEntry( "Seperator" );
105}
106 107
107BroswerContent DingWidget::parseInfo() 108BroswerContent DingWidget::parseInfo()
108{ 109{
109 if ( isCompleteWord ) queryword = " " + queryword + " "; 110 if ( isCompleteWord )
111 queryword = " " + queryword + " ";
110 QStringList search = lines.grep( queryword , isCaseSensitive ); 112 QStringList search = lines.grep( queryword , isCaseSensitive );
111 113
112 QString current; 114 QString current;
113 QString left; 115 QString left;
114 QString right; 116 QString right;
115 QRegExp reg_div( trenner ); 117 QRegExp reg_div( trenner );
116 QRegExp reg_word( queryword ); 118 QRegExp reg_word( queryword );
117 reg_word.setCaseSensitive( isCaseSensitive ); 119 reg_word.setCaseSensitive( isCaseSensitive );
118 QStringList toplist, bottomlist; 120 QStringList toplist, bottomlist;
119 QString substitute = "<strong>"+queryword+"</strong>"; 121 QString substitute = "<strong>"+queryword+"</strong>";
120 122
121 /* Dieser Block ist von Patrik. Ich versuche einen neuen
122 * Ansatz. Zum einen ist HTML scheiße an dieser Stelle und
123 * zum andern funktioniert der Code nicht so wie er sollte.
124 QString substitute = "<a href=''>"+queryword+"</a>";
125
126 QString html_header = "<html><table>";
127 QString html_footer = "</table></html>";
128 QString html_table_left = "<tr><td width='50'>";
129 QString html_table_sep = "</td><td>";
130 QString html_table_right = "</td></tr>";
131
132 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it )
133 {
134 current = *it;
135 left = current.left( current.find(reg_div) );
136 right = current.right( current.length() - current.find(reg_div) - 1 );
137 if ( left.contains( reg_word ) )
138 {
139 left.replace( queryword, substitute );
140 toplist.append( html_table_left + left + html_table_sep + right + html_table_right );
141 }
142 else
143 {
144 right.replace( reg_word, substitute );
145 bottomlist.append( html_table_left + right + html_table_sep + left + html_table_right );
146 }
147 }
148
149 //thats it, the lists are rendered. Lets put them in one string
150 s_strings.bottom = html_header + bottomlist.join( "<br>" ) + html_footer;
151 s_strings.top = html_header + toplist.join( "<br>" ) + html_footer;
152 */
153
154 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) 123 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it )
155 { 124 {
156 current = *it; 125 current = *it;
157 left = current.left( current.find( trenner ) ); 126 left = current.left( current.find( trenner ) );
158 127
159 right = current.right( current.length() - current.find(trenner) -2 ); 128 right = current.right( current.length() - current.find(trenner) - trenner.length() );
160 129
161 if ( left.contains( queryword , isCaseSensitive ) ) 130 if ( left.contains( queryword , isCaseSensitive ) )
162 { 131 {
163 left.replace( queryword, substitute ); 132 left.replace( queryword, substitute );
164 left = left + "-->" + right; 133 left = left + " -- " + right;
165 toplist.append( left ); 134 toplist.append( left );
166 } 135 }
167 else 136 else
168 { 137 {
169 right.replace( queryword, substitute ); 138 right.replace( queryword, substitute );
170 left = right + "-->" + left; 139 left = right + " -- " + left;
171 bottomlist.append( right ); 140 bottomlist.append( right );
172 } 141 }
173 } 142 }
174 143
175 s_strings.bottom = bottomlist.join( "\n" );
176 s_strings.top = toplist.join( "\n" ); 144 s_strings.top = toplist.join( "\n" );
145 s_strings.bottom = bottomlist.join( "\n" );
177 146
178 return s_strings; 147 return s_strings;
179} 148}
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index c4114f7..58cff5f 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -198,13 +198,9 @@ void ODict::setupMenus()
198 error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); 198 error_tol_menu->insertItem( tr( "2 Errors" ), 2 );
199 error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); 199 error_tol_menu->insertItem( tr( "3 Errors" ), 3 );
200 error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); 200 error_tol_menu->insertItem( tr( "4 Errors" ), 4 );
201 error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); 201 error_tol_menu->insertItem( tr( "Until Hit" ), 5 );
202 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); 202 parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu );
203 203
204 help = new QPopupMenu( menu );
205 help->insertItem("&About",this,SLOT( slotDisplayAbout() ));
206
207 menu->insertItem( tr( "Settings" ) , settings ); 204 menu->insertItem( tr( "Settings" ) , settings );
208 menu->insertItem( tr( "Parameter" ) , parameter ); 205 menu->insertItem( tr( "Parameter" ) , parameter );
209 menu->insertItem( tr( "Help" ) , help );
210} 206}