-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 113 | ||||
-rw-r--r-- | noncore/apps/odict/dingwidget.h | 35 | ||||
-rw-r--r-- | noncore/apps/odict/odict.cpp | 55 | ||||
-rw-r--r-- | noncore/apps/odict/odict.h | 4 |
4 files changed, 161 insertions, 46 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index 2913836..7abad22 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -1,111 +1,184 @@ | |||
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 "dingwidget.h" | 17 | #include "dingwidget.h" |
18 | 18 | ||
19 | #include <qfile.h> | 19 | #include <qfile.h> |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qtextstream.h> | 27 | #include <qtextstream.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <stdlib.h> // for getenv | 31 | #include <stdlib.h> // for getenv |
32 | 32 | ||
33 | DingWidget::DingWidget(QString word, QTextBrowser *browser_top, QTextBrowser *browser_bottom, QString activated_name) | 33 | |
34 | DingWidget::DingWidget( ) | ||
34 | { | 35 | { |
35 | methodname = activated_name; | 36 | methodname = QString::null; |
36 | queryword = word; | 37 | trenner = "::";//QString::null; |
37 | trenner = QString::null; | ||
38 | lines = 0L; | 38 | lines = 0L; |
39 | loadValues(); | 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 | } | ||
49 | |||
50 | void DingWidget::loadDict( QString name ) | ||
51 | { | ||
52 | qDebug( "MUSS ich wirklich aufgerufen werder? schreit loadDict" ); | ||
53 | qDebug( "Starte mit dem loadedDict(...)" ); | ||
54 | dictName = name; | ||
55 | qDebug( "bin in loadedDict() und lade das Dict:" ); | ||
56 | qDebug( dictName ); | ||
40 | QString opie_dir = getenv("OPIEDIR"); | 57 | QString opie_dir = getenv("OPIEDIR"); |
41 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); | 58 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); |
59 | //FIXME:this should of course be not hardcoded ;) | ||
42 | 60 | ||
43 | if( file.open( IO_ReadOnly ) ) | 61 | if( file.open( IO_ReadOnly ) ) |
44 | { | 62 | { |
45 | QTextStream stream( &file ); | 63 | QTextStream stream( &file ); |
46 | while ( !stream.eof() ) | 64 | while ( !stream.eof() ) |
47 | { | 65 | { |
48 | lines.append( stream.readLine() ); | 66 | lines.append( stream.readLine() ); |
49 | } | 67 | } |
50 | file.close(); | 68 | file.close(); |
51 | } | 69 | } |
70 | qDebug( "loadedDict(...) ist beended" ); | ||
71 | } | ||
72 | |||
73 | QString DingWidget::loadedDict() | ||
74 | { | ||
75 | qDebug( dictName ); | ||
76 | qDebug( "^ ^ ^ ^ ^ ^ ^ war der dictName" ); | ||
77 | return dictName; | ||
78 | } | ||
52 | 79 | ||
53 | lines = lines.grep( queryword ); | 80 | void DingWidget::setCaseSensitive( bool caseS ) |
81 | { | ||
82 | isCaseSensitive = caseS; | ||
83 | } | ||
54 | 84 | ||
55 | topbrowser = browser_top; | 85 | void DingWidget::setDict( QString dict ) |
56 | bottombrowser = browser_bottom; | 86 | { |
87 | methodname = dict; | ||
57 | } | 88 | } |
58 | 89 | ||
59 | void DingWidget::setText() | 90 | void DingWidget::setCompleteWord( bool cword ) |
60 | { | 91 | { |
61 | QString top, bottom; | 92 | isCompleteWord = cword; |
62 | QStringList test = lines; | 93 | } |
63 | parseInfo( test, top , bottom ); | 94 | |
64 | 95 | void DingWidget::setQueryWord( QString qword ) | |
65 | topbrowser->setText( top ); | 96 | { |
66 | bottombrowser->setText( bottom ); | 97 | queryword = qword; |
98 | } | ||
99 | |||
100 | BroswerContent DingWidget::setText( QString word ) | ||
101 | { | ||
102 | queryword = word; | ||
103 | qDebug( queryword ); | ||
104 | qDebug( "^ ^ ^ ^ ^ ^ ^ war das gesuchte Word"); | ||
105 | return parseInfo(); | ||
67 | } | 106 | } |
68 | 107 | ||
69 | void DingWidget::loadValues() | 108 | void DingWidget::loadValues() |
70 | { | 109 | { |
71 | Config cfg( "odict" ); | 110 | Config cfg( "odict" ); |
72 | cfg.setGroup( "Method_"+methodname ); | 111 | cfg.setGroup( "Method_"+methodname ); |
73 | trenner = cfg.readEntry( "Seperator" ); | 112 | //trenner = cfg.readEntry( "Seperator" ); |
74 | } | 113 | } |
75 | 114 | ||
76 | void DingWidget::parseInfo( QStringList &lines, QString &top, QString &bottom ) | 115 | BroswerContent DingWidget::parseInfo() |
77 | { | 116 | { |
117 | QStringList search = lines.grep( queryword ); | ||
78 | 118 | ||
79 | QString current; | 119 | QString current; |
80 | QString left; | 120 | QString left; |
81 | QString right; | 121 | QString right; |
82 | QString html_header = "<html><table>"; | 122 | QString html_header = "<html><table>"; |
83 | QString html_footer = "</table></html>"; | 123 | QString html_footer = "</table></html>"; |
84 | QString html_table_left = "<tr><td width='50'>"; | 124 | QString html_table_left = "<tr><td width='50'>"; |
85 | QString html_table_sep = "</td><td>"; | 125 | QString html_table_sep = "</td><td>"; |
86 | QString html_table_right = "</td></tr>"; | 126 | QString html_table_right = "</td></tr>"; |
87 | QRegExp reg_div( trenner ); | 127 | QRegExp reg_div( trenner ); |
88 | QRegExp reg_word( queryword ); | 128 | QRegExp reg_word( queryword ); |
89 | QString substitute = "<a href=''>"+queryword+"</a>"; | ||
90 | QStringList toplist, bottomlist; | 129 | QStringList toplist, bottomlist; |
91 | for( QStringList::Iterator it = lines.begin() ; it != lines.end() ; ++it ) | 130 | QString substitute = "<strong>"+queryword+"</strong>"; |
131 | |||
132 | /* Dieser Block ist von Patrik. Ich versuche einen neuen | ||
133 | * Ansatz. Zum einen ist HTML scheiße an dieser Stelle und | ||
134 | * zum andern funktioniert der Code nicht so wie er sollte. | ||
135 | QString substitute = "<a href=''>"+queryword+"</a>"; | ||
136 | |||
137 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) | ||
92 | { | 138 | { |
93 | current = *it; | 139 | current = *it; |
94 | left = current.left( current.find(reg_div) ); | 140 | left = current.left( current.find(reg_div) ); |
95 | right = current.right( current.length() - current.find(reg_div) - 1 ); | 141 | right = current.right( current.length() - current.find(reg_div) - 1 ); |
96 | if ( left.contains( reg_word ) ) | 142 | if ( left.contains( reg_word ) ) |
97 | { | 143 | { |
98 | left.replace( queryword, substitute ); | 144 | left.replace( queryword, substitute ); |
99 | toplist.append( html_table_left + left + html_table_sep + right + html_table_right ); | 145 | toplist.append( html_table_left + left + html_table_sep + right + html_table_right ); |
100 | } | 146 | } |
101 | else | 147 | else |
102 | { | 148 | { |
103 | right.replace( reg_word, substitute ); | 149 | right.replace( reg_word, substitute ); |
104 | bottomlist.append( html_table_left + right + html_table_sep + left + html_table_right ); | 150 | bottomlist.append( html_table_left + right + html_table_sep + left + html_table_right ); |
105 | } | 151 | } |
106 | } | 152 | } |
107 | 153 | ||
108 | //thats it, the lists are rendered. Lets put them in one string | 154 | //thats it, the lists are rendered. Lets put them in one string |
109 | bottom = html_header + bottomlist.join( "<br>" ) + html_footer; | 155 | s_strings.bottom = html_header + bottomlist.join( "<br>" ) + html_footer; |
110 | top = html_header + toplist.join( "<br>" ) + html_footer; | 156 | s_strings.top = html_header + toplist.join( "<br>" ) + html_footer; |
157 | */ | ||
158 | |||
159 | for( QStringList::Iterator it = search.begin() ; it != search.end() ; ++it ) | ||
160 | { | ||
161 | current = *it; | ||
162 | left = current.left( current.find( trenner ) ); | ||
163 | |||
164 | right = current.right( current.length() - current.find(trenner) -2 ); | ||
165 | |||
166 | if ( left.contains( queryword ) ) | ||
167 | { | ||
168 | left.replace( queryword, substitute ); | ||
169 | left = left + "-->" + right; | ||
170 | toplist.append( left ); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | right.replace( queryword, substitute ); | ||
175 | left = right + "-->" + left; | ||
176 | bottomlist.append( right ); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | s_strings.bottom = bottomlist.join( "\n" ); | ||
181 | s_strings.top = toplist.join( "\n" ); | ||
182 | |||
183 | return s_strings; | ||
111 | } | 184 | } |
diff --git a/noncore/apps/odict/dingwidget.h b/noncore/apps/odict/dingwidget.h index c96039f..ba37009 100644 --- a/noncore/apps/odict/dingwidget.h +++ b/noncore/apps/odict/dingwidget.h | |||
@@ -1,34 +1,47 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | 9 | ||
10 | class QString; | ||
11 | class QTextBrowser; | ||
12 | class QStringList; | ||
13 | |||
14 | #include <qstringlist.h> | 10 | #include <qstringlist.h> |
15 | |||
16 | #include <qstring.h> | 11 | #include <qstring.h> |
17 | 12 | ||
13 | struct BroswerContent | ||
14 | { | ||
15 | QString top; | ||
16 | QString bottom; | ||
17 | }; | ||
18 | |||
18 | class DingWidget | 19 | class DingWidget |
19 | { | 20 | { |
20 | public: | 21 | public: |
21 | DingWidget(QString word = 0, QTextBrowser* = 0, QTextBrowser* =0, QString activated_name=0); | 22 | DingWidget(); |
22 | 23 | ||
23 | void setText(); | 24 | BroswerContent setText( QString ); |
24 | QStringList lines; | 25 | QStringList lines; |
26 | void setCaseSensitive( bool ); | ||
27 | void setCompleteWord( bool ); | ||
28 | void loadDict( QString ); | ||
29 | QString loadedDict(); | ||
30 | void setQueryWord( QString ); | ||
31 | void setDict( QString ); | ||
32 | |||
25 | private: | 33 | private: |
34 | BroswerContent parseInfo(); | ||
35 | |||
36 | BroswerContent s_strings; | ||
37 | bool isCompleteWord; | ||
38 | bool isCaseSensitive; | ||
39 | |||
40 | QString dictName; | ||
41 | |||
26 | QString search_word; | 42 | QString search_word; |
27 | void parseInfo( QStringList& , QString&, QString& ); | ||
28 | QString queryword; | ||
29 | void loadValues(); | 43 | void loadValues(); |
44 | QString queryword; | ||
30 | QString methodname; | 45 | QString methodname; |
31 | QString trenner; | 46 | QString trenner; |
32 | |||
33 | QTextBrowser *topbrowser, *bottombrowser; | ||
34 | }; | 47 | }; |
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 6f176f9..549c40a 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,194 +1,223 @@ | |||
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 | |||
43 | activated_name = QString::null; | 42 | activated_name = QString::null; |
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 | ||
48 | QHBox *hbox = new QHBox( vbox ); | 49 | QHBox *hbox = new QHBox( vbox ); |
49 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 50 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
50 | query_le = new QLineEdit( hbox ); | 51 | query_le = new QLineEdit( hbox ); |
51 | query_co = new QComboBox( hbox ); | 52 | query_co = new QComboBox( hbox ); |
52 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); | 53 | connect( query_co , SIGNAL( activated(int) ), this, SLOT( slotMethodChanged(int) ) ); |
53 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 54 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
54 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 55 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
55 | browser_top = new QTextBrowser( vbox ); | 56 | browser_top = new QTextBrowser( vbox ); |
56 | browser_bottom = new QTextBrowser( vbox ); | 57 | browser_bottom = new QTextBrowser( vbox ); |
57 | 58 | ||
59 | ding = new DingWidget(); | ||
60 | |||
58 | loadConfig(); | 61 | loadConfig(); |
59 | setCentralWidget( vbox ); | 62 | setCentralWidget( vbox ); |
60 | } | 63 | } |
61 | 64 | ||
62 | void ODict::loadConfig() | 65 | void ODict::loadConfig() |
63 | { | 66 | { |
64 | Config cfg ( "odict" ); | 67 | Config cfg ( "odict" ); |
65 | cfg.setGroup( "generalsettings" ); | 68 | cfg.setGroup( "generalsettings" ); |
66 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 69 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
67 | casesens = cfg.readEntry( "casesens" ).toInt(); | 70 | casesens = cfg.readEntry( "casesens" ).toInt(); |
68 | regexp = cfg.readEntry( "regexp" ).toInt(); | 71 | regexp = cfg.readEntry( "regexp" ).toInt(); |
69 | completewords = cfg.readEntry( "completewords" ).toInt(); | 72 | completewords = cfg.readEntry( "completewords" ).toInt(); |
70 | 73 | ||
71 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 74 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
72 | query_co->clear(); | 75 | query_co->clear(); |
73 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 76 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
74 | { | 77 | { |
75 | cfg.setGroup( *it ); | 78 | cfg.setGroup( *it ); |
76 | query_co->insertItem( cfg.readEntry( "Name" ) ); | 79 | query_co->insertItem( cfg.readEntry( "Name" ) ); |
77 | } | 80 | } |
81 | slotMethodChanged(1 ); //FIXME: this line should not contain a integer | ||
78 | } | 82 | } |
79 | 83 | ||
80 | 84 | ||
81 | void ODict::saveConfig() | 85 | void ODict::saveConfig() |
82 | { | 86 | { |
83 | Config cfg ( "odict" ); | 87 | Config cfg ( "odict" ); |
84 | cfg.setGroup( "generalsettings" ); | 88 | cfg.setGroup( "generalsettings" ); |
85 | cfg.writeEntry( "errtol" , errorTol ); | 89 | cfg.writeEntry( "errtol" , errorTol ); |
86 | cfg.writeEntry( "casesens" , casesens ); | 90 | cfg.writeEntry( "casesens" , casesens ); |
87 | cfg.writeEntry( "regexp" , regexp ); | 91 | cfg.writeEntry( "regexp" , regexp ); |
88 | cfg.writeEntry( "completewords" , completewords ); | 92 | cfg.writeEntry( "completewords" , completewords ); |
89 | } | 93 | } |
90 | 94 | ||
91 | void ODict::slotDisplayAbout() | 95 | void ODict::slotDisplayAbout() |
92 | { | 96 | { |
93 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030104" ) ); | 97 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030108" ) ); |
94 | } | 98 | } |
95 | 99 | ||
96 | void ODict::slotStartQuery() | 100 | void ODict::slotStartQuery() |
97 | { | 101 | { |
98 | QString querystring = query_le->text(); | 102 | QString querystring = query_le->text(); |
99 | qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); | 103 | //X qDebug("opening dict >%s< for >%s<", activated_name.latin1(),querystring.latin1()); |
100 | if (querystring.isEmpty()){ | 104 | //X if (querystring.isEmpty()){ |
101 | qWarning("empty querystring"); | 105 | //X qWarning("empty querystring"); |
102 | return; | 106 | //X return; |
103 | } | 107 | //X } |
104 | if (!activated_name || activated_name.isEmpty()) | 108 | //X if (!activated_name || activated_name.isEmpty()) |
105 | QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); | 109 | //X QMessageBox::warning(this,tr("No Dictionary"),tr("Please choose a dictonary") ); |
106 | else | 110 | //X else |
107 | DingWidget *ding = new DingWidget( querystring , browser_top, browser_bottom, activated_name ); | 111 | //X { |
108 | ding->setText(); | 112 | |
113 | ding->setCaseSensitive( casesens ); | ||
114 | ding->setCompleteWord( completewords ); | ||
115 | ding->setDict( activated_name ); | ||
116 | |||
117 | qDebug( " activated_name ist :" ); | ||
118 | qDebug( activated_name ); | ||
119 | |||
120 | qDebug( " loadedDict() ist :" ); | ||
121 | qDebug( ding->loadedDict() ); | ||
122 | if ( activated_name != ding->loadedDict() ) | ||
123 | { | ||
124 | qDebug( "ComboBox geändert" ); | ||
125 | ding->loadDict(activated_name); | ||
126 | } | ||
127 | else qDebug( "ComboBox war GLEICH" ); | ||
128 | |||
129 | BroswerContent test = ding->setText( querystring ); | ||
130 | |||
131 | browser_top->setText( test.top ); | ||
132 | browser_bottom->setText( test.bottom ); | ||
133 | |||
134 | qDebug( "Text sollte gesetzt sein..." ); | ||
135 | |||
136 | //X } | ||
137 | |||
109 | } | 138 | } |
110 | 139 | ||
111 | 140 | ||
112 | void ODict::slotSetErrorcount( int count ) | 141 | void ODict::slotSetErrorcount( int count ) |
113 | { | 142 | { |
114 | errorTol = count; | 143 | errorTol = count; |
115 | } | 144 | } |
116 | 145 | ||
117 | void ODict::slotSettings() | 146 | void ODict::slotSettings() |
118 | { | 147 | { |
119 | ConfigDlg dlg( this, "Config" , true); | 148 | ConfigDlg dlg( this, "Config" , true); |
120 | if ( dlg.exec() == QDialog::Accepted ) | 149 | if ( dlg.exec() == QDialog::Accepted ) |
121 | { | 150 | { |
122 | dlg.writeEntries(); | 151 | dlg.writeEntries(); |
123 | loadConfig(); | 152 | loadConfig(); |
124 | } | 153 | } |
125 | else qDebug( "abgebrochen" ); | 154 | else qDebug( "abgebrochen" ); |
126 | } | 155 | } |
127 | 156 | ||
128 | void ODict::slotSetParameter( int count ) | 157 | void ODict::slotSetParameter( int count ) |
129 | { | 158 | { |
130 | if ( count == 0 ) | 159 | if ( count == 0 ) |
131 | { | 160 | { |
132 | if ( casesens ) | 161 | if ( casesens ) |
133 | casesens = false; | 162 | casesens = false; |
134 | else | 163 | else |
135 | casesens = true; | 164 | casesens = true; |
136 | } | 165 | } |
137 | 166 | ||
138 | if ( count == 1 ) | 167 | if ( count == 1 ) |
139 | { | 168 | { |
140 | if ( completewords ) | 169 | if ( completewords ) |
141 | completewords = false; | 170 | completewords = false; |
142 | else | 171 | else |
143 | completewords = true; | 172 | completewords = true; |
144 | } | 173 | } |
145 | if ( count == 2 ) | 174 | if ( count == 2 ) |
146 | { | 175 | { |
147 | if ( regexp ) | 176 | if ( regexp ) |
148 | regexp = false; | 177 | regexp = false; |
149 | else | 178 | else |
150 | regexp = true; | 179 | regexp = true; |
151 | } | 180 | } |
152 | else qWarning( "ERROR" ); | 181 | else qWarning( "ERROR" ); |
153 | } | 182 | } |
154 | 183 | ||
155 | void ODict::slotMethodChanged( int methodnumber ) | 184 | void ODict::slotMethodChanged( int /*methodnumber*/ ) |
156 | { | 185 | { |
157 | activated_name = query_co->currentText(); | 186 | activated_name = query_co->currentText(); |
158 | } | 187 | } |
159 | 188 | ||
160 | void ODict::setupMenus() | 189 | void ODict::setupMenus() |
161 | { | 190 | { |
162 | menu = new QMenuBar( this ); | 191 | menu = new QMenuBar( this ); |
163 | 192 | ||
164 | settings = new QPopupMenu( menu ); | 193 | settings = new QPopupMenu( menu ); |
165 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 194 | setting_a = new QAction(tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
166 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 195 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
167 | setting_a->addTo( settings ); | 196 | setting_a->addTo( settings ); |
168 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); | 197 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "today/config" ), QString::null, 0, this, 0 ); |
169 | 198 | ||
170 | parameter = new QPopupMenu( menu ); | 199 | parameter = new QPopupMenu( menu ); |
171 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 200 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); |
172 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 201 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
173 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; | 202 | parameter->insertItem( tr( "Only &complete Words" ), 1 , 1) ; |
174 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); | 203 | parameter->insertItem( tr( "Allow ®. expressions" ), 2 ); |
175 | parameter->insertSeparator(); | 204 | parameter->insertSeparator(); |
176 | error_tol_menu = new QPopupMenu( menu ); | 205 | error_tol_menu = new QPopupMenu( menu ); |
177 | error_tol_menu->setCheckable( TRUE ); | 206 | error_tol_menu->setCheckable( TRUE ); |
178 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); | 207 | connect( error_tol_menu, SIGNAL( activated( int ) ), this, SLOT( slotSetErrorcount( int ) ) ); |
179 | 208 | ||
180 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); | 209 | error_tol_menu->insertItem( tr( "0 Errors" ), 0 ); |
181 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); | 210 | error_tol_menu->insertItem( tr( "1 Errors" ), 1 ); |
182 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); | 211 | error_tol_menu->insertItem( tr( "2 Errors" ), 2 ); |
183 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); | 212 | error_tol_menu->insertItem( tr( "3 Errors" ), 3 ); |
184 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); | 213 | error_tol_menu->insertItem( tr( "4 Errors" ), 4 ); |
185 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); | 214 | error_tol_menu->insertItem( tr( "Until Hit" ), 5 ); |
186 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); | 215 | parameter->insertItem( tr( "&Error tolerance" ), error_tol_menu ); |
187 | 216 | ||
188 | help = new QPopupMenu( menu ); | 217 | help = new QPopupMenu( menu ); |
189 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); | 218 | help->insertItem("&About",this,SLOT( slotDisplayAbout() )); |
190 | 219 | ||
191 | menu->insertItem( tr( "Settings" ) , settings ); | 220 | menu->insertItem( tr( "Settings" ) , settings ); |
192 | menu->insertItem( tr( "Parameter" ) , parameter ); | 221 | menu->insertItem( tr( "Parameter" ) , parameter ); |
193 | menu->insertItem( tr( "Help" ) , help ); | 222 | menu->insertItem( tr( "Help" ) , help ); |
194 | } | 223 | } |
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index 5096c5e..b20c165 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | 9 | ||
10 | #include <qmainwindow.h> | 10 | #include <qmainwindow.h> |
11 | 11 | ||
12 | class QVBox; | 12 | class QVBox; |
13 | class QPopupMenu; | 13 | class QPopupMenu; |
14 | class QMenuBar; | 14 | class QMenuBar; |
15 | class QHBox; | 15 | class QHBox; |
16 | class QPushButton; | 16 | class QPushButton; |
17 | class QLineEdit; | 17 | class QLineEdit; |
18 | class QAction; | 18 | class QAction; |
19 | class QVBoxLayout; | 19 | class QVBoxLayout; |
20 | class QActionGroup; | 20 | class QActionGroup; |
21 | class DingWidget; | 21 | class DingWidget; |
22 | class QTextBrowser; | 22 | class QTextBrowser; |
23 | class QComboBox; | 23 | class QComboBox; |
24 | class DingWidget; | ||
24 | 25 | ||
25 | class ODict : public QMainWindow | 26 | class ODict : public QMainWindow |
26 | { | 27 | { |
27 | Q_OBJECT | 28 | Q_OBJECT |
28 | 29 | ||
29 | public: | 30 | public: |
30 | ODict(); | 31 | ODict(); |
31 | QVBox *vbox; | 32 | QVBox *vbox; |
32 | QTextBrowser *browser_top, | 33 | QTextBrowser *browser_top, |
33 | *browser_bottom; | 34 | *browser_bottom; |
35 | DingWidget *ding; | ||
34 | 36 | ||
35 | private: | 37 | private: |
36 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; | 38 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; |
37 | QMenuBar *menu; | 39 | QMenuBar *menu; |
38 | QHBox *hbox; | 40 | QHBox *hbox; |
39 | QLineEdit *query_le; | 41 | QLineEdit *query_le; |
40 | QComboBox *query_co; | 42 | QComboBox *query_co; |
41 | QPushButton *ok_button; | 43 | QPushButton *ok_button; |
42 | 44 | ||
43 | QVBoxLayout *vbox_layout; | 45 | QVBoxLayout *vbox_layout; |
44 | 46 | ||
45 | QAction *setting_a, *setting_b; | 47 | QAction *setting_a, *setting_b; |
46 | |||
47 | DingWidget *ding; | ||
48 | 48 | ||
49 | void setupMenus(); | 49 | void setupMenus(); |
50 | 50 | ||
51 | int errorTol; | 51 | int errorTol; |
52 | bool casesens, completewords, regexp; | 52 | bool casesens, completewords, regexp; |
53 | 53 | ||
54 | void loadConfig(); | 54 | void loadConfig(); |
55 | void saveConfig(); | 55 | void saveConfig(); |
56 | 56 | ||
57 | QString activated_name; | 57 | QString activated_name; |
58 | 58 | ||
59 | private slots: | 59 | private slots: |
60 | void slotDisplayAbout(); | 60 | void slotDisplayAbout(); |
61 | void slotStartQuery(); | 61 | void slotStartQuery(); |
62 | void slotSetErrorcount( int ); | 62 | void slotSetErrorcount( int ); |
63 | void slotSettings(); | 63 | void slotSettings(); |
64 | void slotSetParameter( int ); | 64 | void slotSetParameter( int ); |
65 | void slotMethodChanged( int ); | 65 | void slotMethodChanged( int ); |
66 | }; | 66 | }; |