summaryrefslogtreecommitdiff
path: root/noncore/apps/odict
authorcniehaus <cniehaus>2003-04-30 19:28:50 (UTC)
committer cniehaus <cniehaus>2003-04-30 19:28:50 (UTC)
commitb48845bf24f1361a349c86a48a7b54e49df94533 (patch) (unidiff)
tree38e6e2e027c6ed0c2d1bd94aa78e27b8434daea7 /noncore/apps/odict
parente6428d30a5dc90ed3ec6ca7e1cb3f92c81437cc0 (diff)
downloadopie-b48845bf24f1361a349c86a48a7b54e49df94533.zip
opie-b48845bf24f1361a349c86a48a7b54e49df94533.tar.gz
opie-b48845bf24f1361a349c86a48a7b54e49df94533.tar.bz2
I hope I will code more in the next days
Diffstat (limited to 'noncore/apps/odict') (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
@@ -30,7 +30,6 @@
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;
@@ -89,6 +88,14 @@ void DingWidget::setQueryWord( QString qword )
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;
@@ -97,16 +104,11 @@ BroswerContent DingWidget::setText( QString 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;
@@ -118,62 +120,29 @@ BroswerContent DingWidget::parseInfo()
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
@@ -201,10 +201,6 @@ void ODict::setupMenus()
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}