summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/dingwidget.cpp28
-rw-r--r--noncore/apps/odict/dingwidget.h2
-rw-r--r--noncore/apps/odict/odict.cpp6
3 files changed, 13 insertions, 23 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp
index 5b5d731..cfef84d 100644
--- a/noncore/apps/odict/dingwidget.cpp
+++ b/noncore/apps/odict/dingwidget.cpp
@@ -31,23 +31,14 @@
31#include <stdlib.h> // for getenv 31#include <stdlib.h> // for getenv
32 32
33 33
34DingWidget::DingWidget( ) 34DingWidget::DingWidget( )
35{ 35{
36 methodname = QString::null; 36 methodname = QString::null;
37 trenner = "::";//QString::null; 37 trenner = QString::null;
38 lines = 0L; 38 lines = 0L;
39 loadValues();
40
41 //X qDebug( topbrowser );
42 //X qDebug( top );
43//X
44 //X topbrowser = "blahbalh";
45 //X
46 //X qDebug( topbrowser );
47 //X qDebug( top );
48} 39}
49 40
50void DingWidget::loadDict( QString name ) 41void DingWidget::loadDict( QString name )
51{ 42{
52 qDebug( "MUSS ich wirklich aufgerufen werder? schreit loadDict" ); 43 qDebug( "MUSS ich wirklich aufgerufen werder? schreit loadDict" );
53 qDebug( "Starte mit dem loadedDict(...)" ); 44 qDebug( "Starte mit dem loadedDict(...)" );
@@ -65,12 +56,13 @@ void DingWidget::loadDict( QString name )
65 { 56 {
66 lines.append( stream.readLine() ); 57 lines.append( stream.readLine() );
67 } 58 }
68 file.close(); 59 file.close();
69 } 60 }
70 qDebug( "loadedDict(...) ist beended" ); 61 qDebug( "loadedDict(...) ist beended" );
62 loadValues();
71} 63}
72 64
73QString DingWidget::loadedDict() 65QString DingWidget::loadedDict()
74{ 66{
75 qDebug( dictName ); 67 qDebug( dictName );
76 qDebug( "^ ^ ^ ^ ^ ^ ^ war der dictName" ); 68 qDebug( "^ ^ ^ ^ ^ ^ ^ war der dictName" );
@@ -105,38 +97,40 @@ BroswerContent DingWidget::setText( QString word )
105 return parseInfo(); 97 return parseInfo();
106} 98}
107 99
108void DingWidget::loadValues() 100void DingWidget::loadValues()
109{ 101{
110 Config cfg( "odict" ); 102 Config cfg( "odict" );
111 cfg.setGroup( "Method_"+methodname ); 103 cfg.setGroup( "Method_" + methodname );
112 //trenner = cfg.readEntry( "Seperator" ); 104 trenner = cfg.readEntry( "Seperator" );
113} 105}
114 106
115BroswerContent DingWidget::parseInfo() 107BroswerContent DingWidget::parseInfo()
116{ 108{
109 if ( isCompleteWord ) queryword = " " + queryword + " ";
117 QStringList search = lines.grep( queryword , isCaseSensitive ); 110 QStringList search = lines.grep( queryword , isCaseSensitive );
118 111
119 QString current; 112 QString current;
120 QString left; 113 QString left;
121 QString right; 114 QString right;
122 QString html_header = "<html><table>";
123 QString html_footer = "</table></html>";
124 QString html_table_left = "<tr><td width='50'>";
125 QString html_table_sep = "</td><td>";
126 QString html_table_right = "</td></tr>";
127 QRegExp reg_div( trenner ); 115 QRegExp reg_div( trenner );
128 QRegExp reg_word( queryword ); 116 QRegExp reg_word( queryword );
129 reg_word.setCaseSensitive( isCaseSensitive ); 117 reg_word.setCaseSensitive( isCaseSensitive );
130 QStringList toplist, bottomlist; 118 QStringList toplist, bottomlist;
131 QString substitute = "<strong>"+queryword+"</strong>"; 119 QString substitute = "<strong>"+queryword+"</strong>";
132 120
133 /* Dieser Block ist von Patrik. Ich versuche einen neuen 121 /* Dieser Block ist von Patrik. Ich versuche einen neuen
134 * Ansatz. Zum einen ist HTML scheiße an dieser Stelle und 122 * Ansatz. Zum einen ist HTML scheiße an dieser Stelle und
135 * zum andern funktioniert der Code nicht so wie er sollte. 123 * zum andern funktioniert der Code nicht so wie er sollte.
136 QString substitute = "<a href=''>"+queryword+"</a>"; 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>";
137 131
138 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) 132 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it )
139 { 133 {
140 current = *it; 134 current = *it;
141 left = current.left( current.find(reg_div) ); 135 left = current.left( current.find(reg_div) );
142 right = current.right( current.length() - current.find(reg_div) - 1 ); 136 right = current.right( current.length() - current.find(reg_div) - 1 );
diff --git a/noncore/apps/odict/dingwidget.h b/noncore/apps/odict/dingwidget.h
index ba37009..74f40c9 100644
--- a/noncore/apps/odict/dingwidget.h
+++ b/noncore/apps/odict/dingwidget.h
@@ -26,22 +26,22 @@ class DingWidget
26 void setCaseSensitive( bool ); 26 void setCaseSensitive( bool );
27 void setCompleteWord( bool ); 27 void setCompleteWord( bool );
28 void loadDict( QString ); 28 void loadDict( QString );
29 QString loadedDict(); 29 QString loadedDict();
30 void setQueryWord( QString ); 30 void setQueryWord( QString );
31 void setDict( QString ); 31 void setDict( QString );
32 void loadValues();
32 33
33 private: 34 private:
34 BroswerContent parseInfo(); 35 BroswerContent parseInfo();
35 36
36 BroswerContent s_strings; 37 BroswerContent s_strings;
37 bool isCompleteWord; 38 bool isCompleteWord;
38 bool isCaseSensitive; 39 bool isCaseSensitive;
39 40
40 QString dictName; 41 QString dictName;
41 42
42 QString search_word; 43 QString search_word;
43 void loadValues();
44 QString queryword; 44 QString queryword;
45 QString methodname; 45 QString methodname;
46 QString trenner; 46 QString trenner;
47}; 47};
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 42604ee..78c3f90 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -54,12 +54,13 @@ ODict::ODict() : QMainWindow()
54 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 54 ok_button = new QPushButton( tr( "&Ok" ), hbox );
55 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 55 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
56 browser_top = new QTextBrowser( vbox ); 56 browser_top = new QTextBrowser( vbox );
57 browser_bottom = new QTextBrowser( vbox ); 57 browser_bottom = new QTextBrowser( vbox );
58 58
59 ding = new DingWidget(); 59 ding = new DingWidget();
60 ding->loadValues();
60 61
61 loadConfig(); 62 loadConfig();
62 setCentralWidget( vbox ); 63 setCentralWidget( vbox );
63} 64}
64 65
65void ODict::loadConfig() 66void ODict::loadConfig()
@@ -107,25 +108,20 @@ void ODict::slotStartQuery()
107 //X } 108 //X }
108 //X if (!activated_name || activated_name.isEmpty()) 109 //X if (!activated_name || activated_name.isEmpty())
109 //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); 110 //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") );
110 //X else 111 //X else
111 //X { 112 //X {
112 113
113 if ( casesens ) qDebug( "casesens = TRUE" );
114 else qDebug( "casesens = FALSE" );
115
116 ding->setCaseSensitive( casesens ); 114 ding->setCaseSensitive( casesens );
117 ding->setCompleteWord( completewords ); 115 ding->setCompleteWord( completewords );
118 ding->setDict( activated_name ); 116 ding->setDict( activated_name );
119 117
120 if ( activated_name != ding->loadedDict() ) 118 if ( activated_name != ding->loadedDict() )
121 { 119 {
122 qDebug( "ComboBox geändert" );
123 ding->loadDict(activated_name); 120 ding->loadDict(activated_name);
124 } 121 }
125 else qDebug( "ComboBox war GLEICH" );
126 122
127 BroswerContent test = ding->setText( querystring ); 123 BroswerContent test = ding->setText( querystring );
128 124
129 browser_top->setText( test.top ); 125 browser_top->setText( test.top );
130 browser_bottom->setText( test.bottom ); 126 browser_bottom->setText( test.bottom );
131 127