-rw-r--r-- | noncore/apps/odict/odict.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/odict/odict.pro | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 2857c65..e2d1d7b 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,181 +1,189 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
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> | 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 | 42 | ||
43 | activated_name = QString::null; | 43 | activated_name = QString::null; |
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 | QHBox *hbox = new QHBox( vbox ); | 48 | QHBox *hbox = new QHBox( vbox ); |
49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
50 | query_le = new QLineEdit( hbox ); | 50 | query_le = new QLineEdit( hbox ); |
51 | query_co = new QComboBox( hbox ); | 51 | query_co = new QComboBox( hbox ); |
52 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); | 52 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); |
53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
55 | browser_top = new QTextBrowser( vbox ); | 55 | browser_top = new QTextBrowser( vbox ); |
56 | browser_bottom = new QTextBrowser( vbox ); | 56 | browser_bottom = new QTextBrowser( vbox ); |
57 | 57 | ||
58 | loadConfig(); | 58 | loadConfig(); |
59 | setCentralWidget( vbox ); | 59 | setCentralWidget( vbox ); |
60 | } | 60 | } |
61 | 61 | ||
62 | void ODict::loadConfig() | 62 | void ODict::loadConfig() |
63 | { | 63 | { |
64 | Config cfg ( "odict" ); | 64 | Config cfg ( "odict" ); |
65 | cfg.setGroup( "generalsettings" ); | 65 | cfg.setGroup( "generalsettings" ); |
66 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 66 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
67 | casesens = cfg.readEntry( "casesens" ).toInt(); | 67 | casesens = cfg.readEntry( "casesens" ).toInt(); |
68 | regexp = cfg.readEntry( "regexp" ).toInt(); | 68 | regexp = cfg.readEntry( "regexp" ).toInt(); |
69 | completewords = cfg.readEntry( "completewords" ).toInt(); | 69 | completewords = cfg.readEntry( "completewords" ).toInt(); |
70 | 70 | ||
71 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 71 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
72 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 72 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
73 | { | 73 | { |
74 | cfg.setGroup( *it ); | 74 | cfg.setGroup( *it ); |
75 | query_co->insertItem( cfg.readEntry( "Name" ) ); | 75 | query_co->insertItem( cfg.readEntry( "Name" ) ); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void ODict::saveConfig() | 80 | void ODict::saveConfig() |
81 | { | 81 | { |
82 | Config cfg ( "odict" ); | 82 | Config cfg ( "odict" ); |
83 | cfg.setGroup( "generalsettings" ); | 83 | cfg.setGroup( "generalsettings" ); |
84 | cfg.writeEntry( "errtol" , errorTol ); | 84 | cfg.writeEntry( "errtol" , errorTol ); |
85 | cfg.writeEntry( "casesens" , casesens ); | 85 | cfg.writeEntry( "casesens" , casesens ); |
86 | cfg.writeEntry( "regexp" , regexp ); | 86 | cfg.writeEntry( "regexp" , regexp ); |
87 | cfg.writeEntry( "completewords" , completewords ); | 87 | cfg.writeEntry( "completewords" , completewords ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void ODict::slotDisplayAbout() | 90 | void ODict::slotDisplayAbout() |
91 | { | 91 | { |
92 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); | 92 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void ODict::slotStartQuery() | 95 | void ODict::slotStartQuery() |
96 | { | 96 | { |
97 | QString querystring = query_le->text(); | 97 | QString querystring = query_le->text(); |
98 | DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom, activated_name); | 98 | qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); |
99 | if (querystring.isEmpty()){ | ||
100 | qWarning("emphty querysting"); | ||
101 | return; | ||
102 | } | ||
103 | if (!activated_name || activated_name.isEmpty()) | ||
104 | QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); | ||
105 | else | ||
106 | DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom, activated_name); | ||
99 | } | 107 | } |
100 | 108 | ||
101 | 109 | ||
102 | void ODict::slotSetErrorcount( int count ) | 110 | void ODict::slotSetErrorcount( int count ) |
103 | { | 111 | { |
104 | errorTol = count; | 112 | errorTol = count; |
105 | } | 113 | } |
106 | 114 | ||
107 | void ODict::slotSettings() | 115 | void ODict::slotSettings() |
108 | { | 116 | { |
109 | ConfigDlg dlg( this, "Config" , true); | 117 | ConfigDlg dlg( this, "Config" , true); |
110 | if ( dlg.exec() == QDialog::Accepted ) | 118 | if ( dlg.exec() == QDialog::Accepted ) |
111 | dlg.writeEntries(); | 119 | dlg.writeEntries(); |
112 | else qDebug( "abgebrochen" ); | 120 | else qDebug( "abgebrochen" ); |
113 | } | 121 | } |
114 | 122 | ||
115 | void ODict::slotSetParameter( int count ) | 123 | void ODict::slotSetParameter( int count ) |
116 | { | 124 | { |
117 | if ( count == 0 ) | 125 | if ( count == 0 ) |
118 | { | 126 | { |
119 | if ( casesens ) | 127 | if ( casesens ) |
120 | casesens = false; | 128 | casesens = false; |
121 | else | 129 | else |
122 | casesens = true; | 130 | casesens = true; |
123 | } | 131 | } |
124 | 132 | ||
125 | if ( count == 1 ) | 133 | if ( count == 1 ) |
126 | { | 134 | { |
127 | if ( completewords ) | 135 | if ( completewords ) |
128 | completewords = false; | 136 | completewords = false; |
129 | else | 137 | else |
130 | completewords = true; | 138 | completewords = true; |
131 | } | 139 | } |
132 | if ( count == 2 ) | 140 | if ( count == 2 ) |
133 | { | 141 | { |
134 | if ( regexp ) | 142 | if ( regexp ) |
135 | regexp = false; | 143 | regexp = false; |
136 | else | 144 | else |
137 | regexp = true; | 145 | regexp = true; |
138 | } | 146 | } |
139 | else qWarning( "ERROR" ); | 147 | else qWarning( "ERROR" ); |
140 | } | 148 | } |
141 | 149 | ||
142 | void ODict::slotMethodChanged( int methodnumber ) | 150 | void ODict::slotMethodChanged( int methodnumber ) |
143 | { | 151 | { |
144 | activated_name = query_co->currentText(); | 152 | activated_name = query_co->currentText(); |
145 | } | 153 | } |
146 | 154 | ||
147 | void ODict::setupMenus() | 155 | void ODict::setupMenus() |
148 | { | 156 | { |
149 | menu = new QMenuBar( this ); | 157 | menu = new QMenuBar( this ); |
150 | 158 | ||
151 | settings = new QPopupMenu( menu ); | 159 | settings = new QPopupMenu( menu ); |
152 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 160 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
153 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 161 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
154 | setting_a->addTo( settings ); | 162 | setting_a->addTo( settings ); |
155 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 163 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
156 | 164 | ||
157 | parameter = new QPopupMenu( menu ); | 165 | parameter = new QPopupMenu( menu ); |
158 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 166 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
159 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 167 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
160 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; | 168 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; |
161 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 169 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
162 | parameter->insertSeparator(); | 170 | parameter->insertSeparator(); |
163 | error_tol_menu = new QPopupMenu( menu ); | 171 | error_tol_menu = new QPopupMenu( menu ); |
164 | error_tol_menu->setCheckable( TRUE ); | 172 | error_tol_menu->setCheckable( TRUE ); |
165 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); | 173 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); |
166 | 174 | ||
167 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); | 175 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); |
168 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); | 176 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); |
169 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); | 177 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); |
170 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); | 178 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); |
171 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); | 179 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); |
172 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); | 180 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); |
173 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); | 181 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); |
174 | 182 | ||
175 | help = new QPopupMenu( menu ); | 183 | help = new QPopupMenu( menu ); |
176 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); | 184 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); |
177 | 185 | ||
178 | menu->insertItem( tr( "Settings" ) , settings ); | 186 | menu->insertItem( tr( "Settings" ) , settings ); |
179 | menu->insertItem( tr( "Parameter" ) , parameter ); | 187 | menu->insertItem( tr( "Parameter" ) , parameter ); |
180 | menu->insertItem( tr( "Help" ) , help ); | 188 | menu->insertItem( tr( "Help" ) , help ); |
181 | } | 189 | } |
diff --git a/noncore/apps/odict/odict.pro b/noncore/apps/odict/odict.pro index e39fa95..23ef0e0 100644 --- a/noncore/apps/odict/odict.pro +++ b/noncore/apps/odict/odict.pro | |||
@@ -1,37 +1,38 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on debug |
3 | #CONFIG = qt warn_on release | ||
3 | HEADERS = odict.h \ | 4 | HEADERS = odict.h \ |
4 | searchmethoddlg.h \ | 5 | searchmethoddlg.h \ |
5 | configdlg.h \ | 6 | configdlg.h \ |
6 | dingwidget.h \ | 7 | dingwidget.h \ |
7 | dictwidget.h | 8 | dictwidget.h |
8 | 9 | ||
9 | SOURCES = main.cpp \ | 10 | SOURCES = main.cpp \ |
10 | odict.cpp \ | 11 | odict.cpp \ |
11 | searchmethoddlg.cpp \ | 12 | searchmethoddlg.cpp \ |
12 | configdlg.cpp \ | 13 | configdlg.cpp \ |
13 | dictwidget.cpp \ | 14 | dictwidget.cpp \ |
14 | dingwidget.cpp | 15 | dingwidget.cpp |
15 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lqpe -lstdc++ -lopie | 18 | LIBS += -lqpe -lstdc++ -lopie |
18 | TARGET = odict | 19 | TARGET = odict |
19 | DESTDIR = $(OPIEDIR)/bin | 20 | DESTDIR = $(OPIEDIR)/bin |
20 | 21 | ||
21 | TRANSLATIONS = ../../../i18n/de/odict.ts \ | 22 | TRANSLATIONS = ../../../i18n/de/odict.ts \ |
22 | ../../../i18n/xx/odict.ts \ | 23 | ../../../i18n/xx/odict.ts \ |
23 | ../../../i18n/en/odict.ts \ | 24 | ../../../i18n/en/odict.ts \ |
24 | ../../../i18n/es/odict.ts \ | 25 | ../../../i18n/es/odict.ts \ |
25 | ../../../i18n/fr/odict.ts \ | 26 | ../../../i18n/fr/odict.ts \ |
26 | ../../../i18n/hu/odict.ts \ | 27 | ../../../i18n/hu/odict.ts \ |
27 | ../../../i18n/ja/odict.ts \ | 28 | ../../../i18n/ja/odict.ts \ |
28 | ../../../i18n/ko/odict.ts \ | 29 | ../../../i18n/ko/odict.ts \ |
29 | ../../../i18n/no/odict.ts \ | 30 | ../../../i18n/no/odict.ts \ |
30 | ../../../i18n/pl/odict.ts \ | 31 | ../../../i18n/pl/odict.ts \ |
31 | ../../../i18n/pt/odict.ts \ | 32 | ../../../i18n/pt/odict.ts \ |
32 | ../../../i18n/pt_BR/odict.ts \ | 33 | ../../../i18n/pt_BR/odict.ts \ |
33 | ../../../i18n/sl/odict.ts \ | 34 | ../../../i18n/sl/odict.ts \ |
34 | ../../../i18n/zh_CN/odict.ts \ | 35 | ../../../i18n/zh_CN/odict.ts \ |
35 | ../../../i18n/zh_TW/odict.ts \ | 36 | ../../../i18n/zh_TW/odict.ts \ |
36 | ../../../i18n/it/odict.ts \ | 37 | ../../../i18n/it/odict.ts \ |
37 | ../../../i18n/da/odict.ts | 38 | ../../../i18n/da/odict.ts |