summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/dingwidget.cpp9
-rw-r--r--noncore/apps/odict/dingwidget.h3
-rw-r--r--noncore/apps/odict/odict.cpp6
3 files changed, 8 insertions, 10 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp
index 55a716d..c804385 100644
--- a/noncore/apps/odict/dingwidget.cpp
+++ b/noncore/apps/odict/dingwidget.cpp
@@ -29,31 +29,33 @@ DingWidget::DingWidget( )
29 trenner = QString::null; 29 trenner = QString::null;
30 lines = 0L; 30 lines = 0L;
31} 31}
32 32
33void DingWidget::loadDict( QString name ) 33void DingWidget::loadDict( QString name )
34{ 34{
35 lines.clear(); //as we will load a new list we have to 35 lines.clear(); //as we will load a new list we have to
36 //remove the old one 36 //remove the old one
37 qDebug( "DingWidget::loadDict( ... )" );
38 37
39 Config cfg( "odict" ); 38 Config cfg( "odict" );
40 cfg.setGroup( "Method_" + name ); 39 cfg.setGroup( "Method_" + name );
41 QFile file( cfg.readEntry( "file" ) ); 40 QFile file( cfg.readEntry( "file" ) );
42 41
43 if( file.open( IO_ReadOnly ) ) 42 if( file.open( IO_ReadOnly ) )
44 { 43 {
45 QTextStream stream( &file ); 44 QTextStream stream( &file );
46 while ( !stream.eof() ) 45 while ( !stream.eof() )
47 { 46 {
48 lines.append( stream.readLine() ); 47 lines.append( stream.readLine() );
49 } 48 }
50 file.close(); 49 file.close();
51 } 50 }
51
52 setDict( name );
53
52 loadValues(); 54 loadValues();
53} 55}
54 56
55QString DingWidget::loadedDict() const 57QString DingWidget::loadedDict() const
56{ 58{
57 return dictName; 59 return dictName;
58} 60}
59 61
@@ -74,16 +76,17 @@ void DingWidget::setQueryWord( QString qword )
74 76
75 77
76void DingWidget::loadValues() 78void DingWidget::loadValues()
77{ 79{
78 if ( !methodname ) return; 80 if ( !methodname ) return;
79 Config cfg( "odict" ); 81 Config cfg( "odict" );
80 cfg.setGroup( "Method_" + methodname ); 82 cfg.setGroup( "Method_" + methodname );
81 trenner = cfg.readEntry( "Seperator" ); 83 trenner = cfg.readEntry( "Seperator" );
84
82 lang1_name = cfg.readEntry( "Lang1" ); 85 lang1_name = cfg.readEntry( "Lang1" );
83 lang2_name = cfg.readEntry( "Lang2" ); 86 lang2_name = cfg.readEntry( "Lang2" );
84} 87}
85 88
86BroswerContent DingWidget::setText( QString word ) 89BroswerContent DingWidget::setText( QString word )
87{ 90{
88 queryword = word; 91 queryword = word;
89 return parseInfo(); 92 return parseInfo();
@@ -102,26 +105,26 @@ BroswerContent DingWidget::parseInfo()
102 reg_word.setCaseSensitive( isCaseSensitive ); 105 reg_word.setCaseSensitive( isCaseSensitive );
103 QStringList toplist, bottomlist; 106 QStringList toplist, bottomlist;
104 QString substitute = "<strong>"+queryword+"</strong>"; 107 QString substitute = "<strong>"+queryword+"</strong>";
105 108
106 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) 109 for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it )
107 { 110 {
108 current = *it; 111 current = *it;
109 left = current.left( current.find( trenner ) ); 112 left = current.left( current.find( trenner ) );
110 113
111 right = current.right( current.length() - current.find(trenner) - trenner.length() ); 114 right = current.right( current.length() - current.find(trenner) - trenner.length() );
112 115
113 if ( left.contains( queryword , isCaseSensitive ) ) 116 if ( left.contains( queryword , isCaseSensitive ) )
114 { 117 {
115 left.replace( queryword, substitute ); 118 left.replace( queryword, substitute );
116 left = left + " --> " + right; 119 left = left + " --> " + right;
117 toplist.append( left ); 120 toplist.append( left );
118 } 121 }
119 else 122 else if( right.contains( queryword , isCaseSensitive ) )
120 { 123 {
121 right.replace( queryword, substitute ); 124 right.replace( queryword, substitute );
122 right = right + " --> " + left; 125 right = right + " --> " + left;
123 bottomlist.append( right ); 126 bottomlist.append( right );
124 } 127 }
125 } 128 }
126 129
127 s_strings.top = toplist.join( "<br>" ); 130 s_strings.top = toplist.join( "<br>" );
diff --git a/noncore/apps/odict/dingwidget.h b/noncore/apps/odict/dingwidget.h
index dbb55e2..9163a43 100644
--- a/noncore/apps/odict/dingwidget.h
+++ b/noncore/apps/odict/dingwidget.h
@@ -19,32 +19,31 @@ struct BroswerContent
19class DingWidget 19class DingWidget
20{ 20{
21 public: 21 public:
22 DingWidget(); 22 DingWidget();
23 23
24 BroswerContent setText( QString ); 24 BroswerContent setText( QString );
25 QStringList lines; 25 QStringList lines;
26 void setCaseSensitive( bool ); 26 void setCaseSensitive( bool );
27 void setCompleteWord( bool );
28 void loadDict( QString ); 27 void loadDict( QString );
29 QString loadedDict() const; 28 QString loadedDict() const;
30 void setQueryWord( QString ); 29 void setQueryWord( QString );
31 void setDict( QString ); 30 void setDict( QString );
32 void loadValues(); 31 void loadValues();
33 32
34 QString lang1_name, 33 QString lang1_name,
35 lang2_name; 34 lang2_name;
36 35
37 bool isCaseSensitive; 36 bool isCaseSensitive;
37
38 private: 38 private:
39 BroswerContent parseInfo(); 39 BroswerContent parseInfo();
40 40
41 BroswerContent s_strings; 41 BroswerContent s_strings;
42 bool isCompleteWord;
43 42
44 QString dictName; 43 QString dictName;
45 44
46 QString search_word; 45 QString search_word;
47 QString queryword; 46 QString queryword;
48 QString methodname; 47 QString methodname;
49 QString trenner; 48 QString trenner;
50}; 49};
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index c1de6ac..2028701 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -56,17 +56,16 @@ ODict::ODict() : QMainWindow()
56 top_name = new QLabel( vbox ); 56 top_name = new QLabel( vbox );
57 top_name->setAlignment( AlignHCenter ); 57 top_name->setAlignment( AlignHCenter );
58 browser_top = new QTextBrowser( vbox ); 58 browser_top = new QTextBrowser( vbox );
59 bottom_name = new QLabel( vbox ); 59 bottom_name = new QLabel( vbox );
60 bottom_name->setAlignment( AlignHCenter ); 60 bottom_name->setAlignment( AlignHCenter );
61 browser_bottom = new QTextBrowser( vbox ); 61 browser_bottom = new QTextBrowser( vbox );
62 62
63 ding = new DingWidget(); 63 ding = new DingWidget();
64 ding->loadValues();
65 64
66 loadConfig(); 65 loadConfig();
67 setCentralWidget( vbox ); 66 setCentralWidget( vbox );
68} 67}
69 68
70void ODict::loadConfig() 69void ODict::loadConfig()
71{ 70{
72 /* 71 /*
@@ -103,16 +102,17 @@ void ODict::loadConfig()
103 i++; 102 i++;
104 } 103 }
105 /* 104 /*
106 * now set the two names of the dictionary and the correct QComboBox-Entry 105 * now set the two names of the dictionary and the correct QComboBox-Entry
107 */ 106 */
108 107
109 lookupLanguageNames( lastname ); 108 lookupLanguageNames( lastname );
110 ding->loadDict( lastname ); 109 ding->loadDict( lastname );
110 ding->loadValues();
111 111
112 query_co->setCurrentItem( e ); 112 query_co->setCurrentItem( e );
113 top_name->setText( top_name_content ); 113 top_name->setText( top_name_content );
114 bottom_name->setText( bottom_name_content ); 114 bottom_name->setText( bottom_name_content );
115} 115}
116 116
117void ODict::lookupLanguageNames( QString dictname ) 117void ODict::lookupLanguageNames( QString dictname )
118{ 118{
@@ -194,20 +194,16 @@ void ODict::slotSetParameter( int count )
194 } 194 }
195 saveConfig(); 195 saveConfig();
196} 196}
197 197
198void ODict::slotMethodChanged( const QString& methodnumber ) 198void ODict::slotMethodChanged( const QString& methodnumber )
199{ 199{
200 activated_name = methodnumber; 200 activated_name = methodnumber;
201 201
202 qDebug( "activated_name in slotMethodChanged() ist:" );
203 qDebug( activated_name );
204 qDebug( ding->loadedDict() );
205
206 if ( activated_name != ding->loadedDict() ) 202 if ( activated_name != ding->loadedDict() )
207 { 203 {
208 ding->loadDict(activated_name); 204 ding->loadDict(activated_name);
209 205
210 lookupLanguageNames( activated_name ); 206 lookupLanguageNames( activated_name );
211 top_name->setText( top_name_content ); 207 top_name->setText( top_name_content );
212 bottom_name->setText( bottom_name_content ); 208 bottom_name->setText( bottom_name_content );
213 } 209 }