-rw-r--r-- | noncore/apps/odict/odict.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index a404e89..cc3148a 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -24,49 +24,48 @@ | |||
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qaction.h> | 33 | #include <qaction.h> |
34 | #include <qtextbrowser.h> | 34 | #include <qtextbrowser.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | 36 | ||
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | 39 | ||
40 | ODict::ODict() : QMainWindow() | 40 | ODict::ODict() : QMainWindow() |
41 | { | 41 | { |
42 | activated_name = QString::null; | 42 | activated_name = QString::null; |
43 | 43 | ||
44 | vbox = new QVBox( this ); | 44 | vbox = new QVBox( this ); |
45 | setCaption( tr( "OPIE-Dictionary" ) ); | 45 | setCaption( tr( "OPIE-Dictionary" ) ); |
46 | setupMenus(); | 46 | setupMenus(); |
47 | 47 | ||
48 | |||
49 | QHBox *hbox = new QHBox( vbox ); | 48 | QHBox *hbox = new QHBox( vbox ); |
50 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
51 | query_le = new QLineEdit( hbox ); | 50 | query_le = new QLineEdit( hbox ); |
52 | query_co = new QComboBox( hbox ); | 51 | query_co = new QComboBox( hbox ); |
53 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); | 52 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); |
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 | browser_top = new QTextBrowser( vbox ); | 55 | browser_top = new QTextBrowser( vbox ); |
57 | browser_bottom = new QTextBrowser( vbox ); | 56 | browser_bottom = new QTextBrowser( vbox ); |
58 | 57 | ||
59 | ding = new DingWidget(); | 58 | ding = new DingWidget(); |
60 | ding->loadValues(); | 59 | ding->loadValues(); |
61 | 60 | ||
62 | loadConfig(); | 61 | loadConfig(); |
63 | setCentralWidget( vbox ); | 62 | setCentralWidget( vbox ); |
64 | } | 63 | } |
65 | 64 | ||
66 | void ODict::loadConfig() | 65 | void ODict::loadConfig() |
67 | { | 66 | { |
68 | Config cfg ( "odict" ); | 67 | Config cfg ( "odict" ); |
69 | cfg.setGroup( "generalsettings" ); | 68 | cfg.setGroup( "generalsettings" ); |
70 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 69 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
71 | casesens = cfg.readEntry( "casesens" ).toInt(); | 70 | casesens = cfg.readEntry( "casesens" ).toInt(); |
72 | regexp = cfg.readEntry( "regexp" ).toInt(); | 71 | regexp = cfg.readEntry( "regexp" ).toInt(); |
@@ -75,72 +74,59 @@ void ODict::loadConfig() | |||
75 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 74 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
76 | query_co->clear(); | 75 | query_co->clear(); |
77 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 76 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
78 | { | 77 | { |
79 | cfg.setGroup( *it ); | 78 | cfg.setGroup( *it ); |
80 | query_co->insertItem( cfg.readEntry( "Name" ) ); | 79 | query_co->insertItem( cfg.readEntry( "Name" ) ); |
81 | } | 80 | } |
82 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer | 81 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer |
83 | } | 82 | } |
84 | 83 | ||
85 | 84 | ||
86 | void ODict::saveConfig() | 85 | void ODict::saveConfig() |
87 | { | 86 | { |
88 | Config cfg ( "odict" ); | 87 | Config cfg ( "odict" ); |
89 | cfg.setGroup( "generalsettings" ); | 88 | cfg.setGroup( "generalsettings" ); |
90 | cfg.writeEntry( "errtol" , errorTol ); | 89 | cfg.writeEntry( "errtol" , errorTol ); |
91 | cfg.writeEntry( "casesens" , casesens ); | 90 | cfg.writeEntry( "casesens" , casesens ); |
92 | cfg.writeEntry( "regexp" , regexp ); | 91 | cfg.writeEntry( "regexp" , regexp ); |
93 | cfg.writeEntry( "completewords" , completewords ); | 92 | cfg.writeEntry( "completewords" , completewords ); |
94 | } | 93 | } |
95 | 94 | ||
96 | void ODict::slotStartQuery() | 95 | void ODict::slotStartQuery() |
97 | { | 96 | { |
98 | QString querystring = query_le->text(); | 97 | QString querystring = query_le->text(); |
99 | //X qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); | ||
100 | //X if (querystring.isEmpty()){ | ||
101 | //X qWarning("empty querystring"); | ||
102 | //X return; | ||
103 | //X } | ||
104 | //X if (!activated_name || activated_name.isEmpty()) | ||
105 | //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); | ||
106 | //X else | ||
107 | //X { | ||
108 | |||
109 | ding->setCaseSensitive( casesens ); | 98 | ding->setCaseSensitive( casesens ); |
110 | ding->setCompleteWord( completewords ); | 99 | ding->setCompleteWord( completewords ); |
111 | ding->setDict( activated_name ); | 100 | ding->setDict( activated_name ); |
112 | 101 | ||
113 | if ( activated_name != ding->loadedDict() ) | 102 | if ( activated_name != ding->loadedDict() ) |
114 | ding->loadDict(activated_name); | 103 | ding->loadDict(activated_name); |
115 | 104 | ||
116 | BroswerContent test = ding->setText( querystring ); | 105 | BroswerContent test = ding->setText( querystring ); |
117 | 106 | ||
118 | browser_top->setText( test.top ); | 107 | browser_top->setText( test.top ); |
119 | browser_bottom->setText( test.bottom ); | 108 | browser_bottom->setText( test.bottom ); |
120 | |||
121 | qDebug( "Text sollte gesetzt sein..." ); | ||
122 | //X } | ||
123 | } | 109 | } |
124 | 110 | ||
125 | 111 | ||
126 | void ODict::slotSetErrorcount( int count ) | 112 | void ODict::slotSetErrorcount( int count ) |
127 | { | 113 | { |
128 | errorTol = count; | 114 | errorTol = count; |
129 | } | 115 | } |
130 | 116 | ||
131 | void ODict::slotSettings() | 117 | void ODict::slotSettings() |
132 | { | 118 | { |
133 | ConfigDlg dlg( this, "Config" , true); | 119 | ConfigDlg dlg( this, "Config" , true); |
134 | if ( dlg.exec() == QDialog::Accepted ) | 120 | if ( dlg.exec() == QDialog::Accepted ) |
135 | { | 121 | { |
136 | dlg.writeEntries(); | 122 | dlg.writeEntries(); |
137 | loadConfig(); | 123 | loadConfig(); |
138 | } | 124 | } |
139 | else qDebug( "abgebrochen" ); | 125 | else qDebug( "abgebrochen" ); |
140 | } | 126 | } |
141 | 127 | ||
142 | void ODict::slotSetParameter( int count ) | 128 | void ODict::slotSetParameter( int count ) |
143 | { | 129 | { |
144 | if ( count == 0 ) | 130 | if ( count == 0 ) |
145 | { | 131 | { |
146 | if ( casesens ) | 132 | if ( casesens ) |
@@ -155,50 +141,50 @@ void ODict::slotSetParameter( int count ) | |||
155 | completewords = false; | 141 | completewords = false; |
156 | else | 142 | else |
157 | completewords = true; | 143 | completewords = true; |
158 | } | 144 | } |
159 | if ( count == 2 ) | 145 | if ( count == 2 ) |
160 | { | 146 | { |
161 | if ( regexp ) | 147 | if ( regexp ) |
162 | regexp = false; | 148 | regexp = false; |
163 | else | 149 | else |
164 | regexp = true; | 150 | regexp = true; |
165 | } | 151 | } |
166 | else qWarning( "ERROR" ); | 152 | else qWarning( "ERROR" ); |
167 | } | 153 | } |
168 | 154 | ||
169 | void ODict::slotMethodChanged( int /*methodnumber*/ ) | 155 | void ODict::slotMethodChanged( int /*methodnumber*/ ) |
170 | { | 156 | { |
171 | activated_name = query_co->currentText(); | 157 | activated_name = query_co->currentText(); |
172 | } | 158 | } |
173 | 159 | ||
174 | void ODict::setupMenus() | 160 | void ODict::setupMenus() |
175 | { | 161 | { |
176 | menu = new QMenuBar( this ); | 162 | menu = new QMenuBar( this ); |
177 | 163 | ||
178 | settings = new QPopupMenu( menu ); | 164 | settings = new QPopupMenu( menu ); |
179 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 165 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
180 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 166 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
181 | setting_a->addTo( settings ); | 167 | setting_a->addTo( settings ); |
182 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 168 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); |
183 | 169 | ||
184 | parameter = new QPopupMenu( menu ); | 170 | parameter = new QPopupMenu( menu ); |
185 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 171 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
186 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 172 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
187 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; | 173 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; |
188 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 174 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
189 | parameter->insertSeparator(); | 175 | parameter->insertSeparator(); |
190 | error_tol_menu = new QPopupMenu( menu ); | 176 | error_tol_menu = new QPopupMenu( menu ); |
191 | error_tol_menu->setCheckable( TRUE ); | 177 | error_tol_menu->setCheckable( TRUE ); |
192 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); | 178 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); |
193 | 179 | ||
194 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); | 180 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); |
195 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); | 181 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); |
196 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); | 182 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); |
197 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); | 183 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); |
198 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); | 184 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); |
199 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); | 185 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); |
200 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); | 186 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); |
201 | 187 | ||
202 | menu->insertItem( tr( "Settings" ) , settings ); | 188 | menu->insertItem( tr( "Settings" ) , settings ); |
203 | menu->insertItem( tr( "Parameter" ) , parameter ); | 189 | menu->insertItem( tr( "Parameter" ) , parameter ); |
204 | } | 190 | } |