author | cniehaus <cniehaus> | 2003-05-10 20:18:16 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-05-10 20:18:16 (UTC) |
commit | 1bff948326aa752c3f4aceac4083717f8c2066e8 (patch) (unidiff) | |
tree | a4b4eb9dd70f363f960a5be7ae94c6e52951dcfc /noncore/apps/odict/odict.cpp | |
parent | b7d34545193f39c146ab56b1127863279a3121ce (diff) | |
download | opie-1bff948326aa752c3f4aceac4083717f8c2066e8.zip opie-1bff948326aa752c3f4aceac4083717f8c2066e8.tar.gz opie-1bff948326aa752c3f4aceac4083717f8c2066e8.tar.bz2 |
bugfixes, bugfixes...
Diffstat (limited to 'noncore/apps/odict/odict.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/odict/odict.cpp | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 0745f53..c1de6ac 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -13,38 +13,37 @@ | |||
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 "odict.h" | 17 | #include "odict.h" |
18 | #include "configdlg.h" | 18 | #include "configdlg.h" |
19 | #include "dingwidget.h" | 19 | #include "dingwidget.h" |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | #include <qpe/config.h> | ||
26 | #include <qhbox.h> | 25 | #include <qhbox.h> |
27 | #include <qvbox.h> | 26 | #include <qvbox.h> |
28 | #include <qlabel.h> | 27 | #include <qlabel.h> |
29 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
30 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
31 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
32 | #include <qstring.h> | 31 | #include <qstring.h> |
33 | #include <qaction.h> | 32 | #include <qaction.h> |
34 | #include <qtextbrowser.h> | 33 | #include <qtextbrowser.h> |
35 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
36 | 35 | ||
37 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
38 | 37 | #include <qpe/config.h> | |
39 | 38 | ||
40 | ODict::ODict() : QMainWindow() | 39 | ODict::ODict() : QMainWindow() |
41 | { | 40 | { |
42 | activated_name = QString::null; | 41 | activated_name = QString::null; |
43 | 42 | ||
44 | vbox = new QVBox( this ); | 43 | vbox = new QVBox( this ); |
45 | setCaption( tr( "OPIE-Dictionary" ) ); | 44 | setCaption( tr( "OPIE-Dictionary" ) ); |
46 | setupMenus(); | 45 | setupMenus(); |
47 | 46 | ||
48 | QHBox *hbox = new QHBox( vbox ); | 47 | QHBox *hbox = new QHBox( vbox ); |
49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); | 48 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); |
50 | query_label->show(); | 49 | query_label->show(); |
@@ -54,41 +53,40 @@ ODict::ODict() : QMainWindow() | |||
54 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
55 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
56 | 55 | ||
57 | top_name = new QLabel( vbox ); | 56 | top_name = new QLabel( vbox ); |
58 | top_name->setAlignment( AlignHCenter ); | 57 | top_name->setAlignment( AlignHCenter ); |
59 | browser_top = new QTextBrowser( vbox ); | 58 | browser_top = new QTextBrowser( vbox ); |
60 | bottom_name = new QLabel( vbox ); | 59 | bottom_name = new QLabel( vbox ); |
61 | bottom_name->setAlignment( AlignHCenter ); | 60 | bottom_name->setAlignment( AlignHCenter ); |
62 | browser_bottom = new QTextBrowser( vbox ); | 61 | browser_bottom = new QTextBrowser( vbox ); |
63 | 62 | ||
64 | ding = new DingWidget(); | 63 | ding = new DingWidget(); |
65 | ding->loadValues(); | 64 | ding->loadValues(); |
66 | 65 | ||
67 | loadConfig(); | 66 | loadConfig(); |
68 | setCentralWidget( vbox ); | 67 | setCentralWidget( vbox ); |
69 | } | 68 | } |
70 | 69 | ||
71 | void ODict::loadConfig() | 70 | void ODict::loadConfig() |
72 | { | 71 | { |
73 | /* | 72 | /* |
74 | * the name of the last used dictionary | 73 | * the name of the last used dictionary |
75 | */ | 74 | */ |
76 | QString lastname; | 75 | QString lastname; |
77 | 76 | ||
78 | Config cfg ( "odict" ); | 77 | Config cfg ( "odict" ); |
79 | cfg.setGroup( "generalsettings" ); | 78 | cfg.setGroup( "generalsettings" ); |
80 | casesens = cfg.readEntry( "casesens" ).toInt(); | 79 | casesens = cfg.readEntry( "casesens" ).toInt(); |
81 | regexp = cfg.readEntry( "regexp" ).toInt(); | 80 | regexp = cfg.readEntry( "regexp" ).toInt(); |
82 | completewords = cfg.readEntry( "completewords" ).toInt(); | ||
83 | 81 | ||
84 | QString lastDict = cfg.readEntry( "lastdict" ); | 82 | QString lastDict = cfg.readEntry( "lastdict" ); |
85 | int i = 0, e = 0; | 83 | int i = 0, e = 0; |
86 | 84 | ||
87 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 85 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
88 | query_co->clear(); | 86 | query_co->clear(); |
89 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 87 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
90 | { | 88 | { |
91 | QString name; | 89 | QString name; |
92 | cfg.setGroup( *it ); | 90 | cfg.setGroup( *it ); |
93 | name = cfg.readEntry( "Name" ); | 91 | name = cfg.readEntry( "Name" ); |
94 | query_co->insertItem( name ); | 92 | query_co->insertItem( name ); |
@@ -100,160 +98,137 @@ void ODict::loadConfig() | |||
100 | if ( lastDict == name ) | 98 | if ( lastDict == name ) |
101 | { | 99 | { |
102 | e = i; | 100 | e = i; |
103 | lastname = name; | 101 | lastname = name; |
104 | } | 102 | } |
105 | i++; | 103 | i++; |
106 | } | 104 | } |
107 | /* | 105 | /* |
108 | * now set the two names of the dictionary and the correct QComboBox-Entry | 106 | * now set the two names of the dictionary and the correct QComboBox-Entry |
109 | */ | 107 | */ |
110 | 108 | ||
111 | lookupLanguageNames( lastname ); | 109 | lookupLanguageNames( lastname ); |
110 | ding->loadDict( lastname ); | ||
112 | 111 | ||
113 | query_co->setCurrentItem( e ); | 112 | query_co->setCurrentItem( e ); |
114 | top_name->setText( top_name_content ); | 113 | top_name->setText( top_name_content ); |
115 | bottom_name->setText( bottom_name_content ); | 114 | bottom_name->setText( bottom_name_content ); |
116 | } | 115 | } |
117 | 116 | ||
118 | void ODict::lookupLanguageNames( QString dictname ) | 117 | void ODict::lookupLanguageNames( QString dictname ) |
119 | { | 118 | { |
120 | Config cfg ( "odict" ); | 119 | Config cfg ( "odict" ); |
121 | cfg.setGroup( "Method_"+dictname ); | 120 | cfg.setGroup( "Method_"+dictname ); |
122 | top_name_content = cfg.readEntry( "Lang1" ); | 121 | top_name_content = cfg.readEntry( "Lang1" ); |
123 | bottom_name_content = cfg.readEntry( "Lang2" ); | 122 | bottom_name_content = cfg.readEntry( "Lang2" ); |
124 | } | 123 | } |
125 | 124 | ||
126 | void ODict::saveConfig() | 125 | void ODict::saveConfig() |
127 | { | 126 | { |
128 | Config cfg ( "odict" ); | 127 | Config cfg ( "odict" ); |
129 | cfg.setGroup( "generalsettings" ); | 128 | cfg.setGroup( "generalsettings" ); |
130 | cfg.writeEntry( "casesens" , casesens ); | 129 | cfg.writeEntry( "casesens" , casesens ); |
131 | cfg.writeEntry( "regexp" , regexp ); | 130 | cfg.writeEntry( "regexp" , regexp ); |
132 | cfg.writeEntry( "completewords" , completewords ); | ||
133 | cfg.writeEntry( "lastdict" , query_co->currentText() ); | 131 | cfg.writeEntry( "lastdict" , query_co->currentText() ); |
134 | } | 132 | } |
135 | 133 | ||
136 | void ODict::slotStartQuery() | 134 | void ODict::slotStartQuery() |
137 | { | 135 | { |
138 | qDebug( "bin in slotStartQuery()" ); | ||
139 | |||
140 | QString querystring = query_le->text(); | 136 | QString querystring = query_le->text(); |
141 | if ( !querystring.isEmpty() ) | 137 | if ( !querystring.isEmpty() ) |
142 | { | 138 | { |
143 | /* | 139 | /* |
144 | * if the user has not yet defined a dictionary | 140 | * if the user has not yet defined a dictionary |
145 | */ | 141 | */ |
146 | if ( !query_co->currentText() ) | 142 | if ( !query_co->currentText() ) |
147 | { | 143 | { |
148 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), | 144 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), |
149 | tr( "No dictionary defined" ), | 145 | tr( "No dictionary defined" ), |
150 | tr( "&Define one" ), | 146 | tr( "&Define one" ), |
151 | tr( "&Cancel" ), | 147 | tr( "&Cancel" ), |
152 | 0, // Define a dict choosen | 148 | 0, // Define a dict |
153 | 1 ) ) // Cancel choosen | 149 | 1 ) ) // Cancel choosen |
154 | { | 150 | { |
155 | case 0: | 151 | case 0: |
156 | slotSettings(); | 152 | slotSettings(); |
157 | break; | 153 | break; |
158 | case 1: // stop here | 154 | case 1: // stop here |
159 | return; | 155 | return; |
160 | } | 156 | } |
161 | } | 157 | } |
162 | 158 | ||
163 | /* | 159 | /* |
164 | * ok, the user has defined a dict | 160 | * ok, the user has defined a dict |
165 | */ | 161 | */ |
166 | ding->setCaseSensitive( casesens ); | 162 | ding->setCaseSensitive( casesens ); |
167 | ding->setCompleteWord( completewords ); | ||
168 | |||
169 | qDebug( "activated_name ist:" ); | ||
170 | qDebug( activated_name ); | ||
171 | |||
172 | ding->setDict( activated_name ); | ||
173 | |||
174 | //X if ( activated_name != ding->loadedDict() ) | ||
175 | ding->loadDict(activated_name); | ||
176 | 163 | ||
177 | BroswerContent test = ding->setText( querystring ); | 164 | BroswerContent test = ding->setText( querystring ); |
178 | 165 | ||
179 | qDebug( querystring ); | ||
180 | if ( ding->isCaseSensitive ) | ||
181 | qDebug( "ist CS"); | ||
182 | else qDebug( "kein CS" ); | ||
183 | |||
184 | browser_top->setText( test.top ); | 166 | browser_top->setText( test.top ); |
185 | browser_bottom->setText( test.bottom ); | 167 | browser_bottom->setText( test.bottom ); |
186 | } | 168 | } |
187 | } | 169 | } |
188 | 170 | ||
189 | void ODict::slotSettings() | 171 | void ODict::slotSettings() |
190 | { | 172 | { |
191 | ConfigDlg dlg( this, "Config" , true); | 173 | ConfigDlg dlg( this, "Config" , true); |
192 | if ( dlg.exec() == QDialog::Accepted ) | 174 | if ( dlg.exec() == QDialog::Accepted ) |
193 | saveConfig(); | 175 | saveConfig(); |
194 | } | 176 | } |
195 | 177 | ||
196 | void ODict::slotSetParameter( int count ) | 178 | void ODict::slotSetParameter( int count ) |
197 | { | 179 | { |
198 | if ( count == 0 ) | 180 | if ( count == 0 ) |
199 | { | 181 | { |
200 | if ( casesens ) | 182 | if ( casesens ) |
201 | casesens = false; | 183 | casesens = false; |
202 | else | 184 | else |
203 | casesens = true; | 185 | casesens = true; |
204 | } | 186 | } |
205 | 187 | ||
206 | if ( count == 1 ) | 188 | if ( count == 1 ) |
207 | { | 189 | { |
208 | if ( completewords ) | ||
209 | completewords = false; | ||
210 | else | ||
211 | completewords = true; | ||
212 | } | ||
213 | if ( count == 2 ) | ||
214 | { | ||
215 | if ( regexp ) | 190 | if ( regexp ) |
216 | regexp = false; | 191 | regexp = false; |
217 | else | 192 | else |
218 | regexp = true; | 193 | regexp = true; |
219 | } | 194 | } |
220 | saveConfig(); | 195 | saveConfig(); |
221 | } | 196 | } |
222 | 197 | ||
223 | void ODict::slotMethodChanged( const QString& methodnumber ) | 198 | void ODict::slotMethodChanged( const QString& methodnumber ) |
224 | { | 199 | { |
225 | activated_name = methodnumber; | 200 | activated_name = methodnumber; |
226 | 201 | ||
227 | qDebug( "activated_name in slotMethodChanged() ist:" ); | 202 | qDebug( "activated_name in slotMethodChanged() ist:" ); |
228 | qDebug( activated_name ); | 203 | qDebug( activated_name ); |
204 | qDebug( ding->loadedDict() ); | ||
229 | 205 | ||
230 | //X if ( activated_name != ding->loadedDict() ) | 206 | if ( activated_name != ding->loadedDict() ) |
231 | { | 207 | { |
232 | ding->loadDict(activated_name); | 208 | ding->loadDict(activated_name); |
233 | 209 | ||
234 | lookupLanguageNames( activated_name ); | 210 | lookupLanguageNames( activated_name ); |
235 | top_name->setText( top_name_content ); | 211 | top_name->setText( top_name_content ); |
236 | bottom_name->setText( bottom_name_content ); | 212 | bottom_name->setText( bottom_name_content ); |
237 | } | 213 | } |
238 | } | 214 | } |
239 | 215 | ||
240 | void ODict::setupMenus() | 216 | void ODict::setupMenus() |
241 | { | 217 | { |
242 | menu = new QMenuBar( this ); | 218 | menu = new QMenuBar( this ); |
243 | 219 | ||
244 | settings = new QPopupMenu( menu ); | 220 | settings = new QPopupMenu( menu ); |
245 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 221 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
246 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 222 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
247 | setting_a->addTo( settings ); | 223 | setting_a->addTo( settings ); |
248 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); | 224 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); |
249 | 225 | ||
250 | parameter = new QPopupMenu( menu ); | 226 | parameter = new QPopupMenu( menu ); |
251 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 227 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
252 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 228 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
253 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; | ||
254 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 229 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
255 | parameter->insertSeparator(); | 230 | parameter->insertSeparator(); |
256 | 231 | ||
257 | menu->insertItem( tr( "Settings" ) , settings ); | 232 | menu->insertItem( tr( "Settings" ) , settings ); |
258 | menu->insertItem( tr( "Parameter" ) , parameter ); | 233 | menu->insertItem( tr( "Parameter" ) , parameter ); |
259 | } | 234 | } |