author | cniehaus <cniehaus> | 2003-01-03 22:31:19 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-01-03 22:31:19 (UTC) |
commit | da1889933ccd03ef948fef7debda0b7e13f12add (patch) (unidiff) | |
tree | 98df5c800d091800f1264dcbd601b951b0522a96 | |
parent | 5c6c68a2297762fe69ac6d1bd62fd0e09afeccb3 (diff) | |
download | opie-da1889933ccd03ef948fef7debda0b7e13f12add.zip opie-da1889933ccd03ef948fef7debda0b7e13f12add.tar.gz opie-da1889933ccd03ef948fef7debda0b7e13f12add.tar.bz2 |
minifixes to avoid clashes with tille
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/odict/odict.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/odict/odict.h | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index 6e3179f..61ddbbf 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -11,78 +11,80 @@ | |||
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(QWidget *parent, QString word, QTextBrowser *browser_top, QTextBrowser *browser_bottom) : QWidget(parent) | 33 | DingWidget::DingWidget(QWidget *parent, QString word, QTextBrowser *browser_top, QTextBrowser *browser_bottom) : QWidget(parent) |
34 | { | 34 | { |
35 | queryword = word; | 35 | queryword = word; |
36 | QString opie_dir = getenv("OPIEDIR"); | 36 | QString opie_dir = getenv("OPIEDIR"); |
37 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); | 37 | QFile file( opie_dir+"/noncore/apps/odict/eng_ita.dic" ); |
38 | QStringList lines; | 38 | QStringList lines; |
39 | 39 | ||
40 | if( file.open( IO_ReadOnly ) ) | 40 | if( file.open( IO_ReadOnly ) ) |
41 | { | 41 | { |
42 | QTextStream stream( &file ); | 42 | QTextStream stream( &file ); |
43 | while ( !stream.eof() ) | 43 | while ( !stream.eof() ) |
44 | { | 44 | { |
45 | lines.append( stream.readLine() ); | 45 | lines.append( stream.readLine() ); |
46 | } | 46 | } |
47 | file.close(); | 47 | file.close(); |
48 | } | 48 | } |
49 | 49 | ||
50 | lines = lines.grep( queryword ); | 50 | lines = lines.grep( queryword ); |
51 | 51 | ||
52 | QString top, bottom; | 52 | QString top, bottom; |
53 | 53 | ||
54 | parseInfo( lines, top , bottom ); | 54 | parseInfo( lines, top , bottom ); |
55 | browser_top->setText( top ); | 55 | browser_top->setText( top ); |
56 | browser_bottom->setText( bottom ); | 56 | browser_bottom->setText( bottom ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void DingWidget::parseInfo( QStringList &lines, QString &top, QString &bottom ) | 59 | void DingWidget::parseInfo( QStringList &lines, QString &top, QString &bottom ) |
60 | { | 60 | { |
61 | 61 | ||
62 | QString current; | 62 | QString current; |
63 | QString left; | 63 | QString left; |
64 | QString right; | 64 | QString right; |
65 | QRegExp reg_div( "\\" ); | 65 | QRegExp reg_div( "\\" ); |
66 | QRegExp reg_word( queryword ); | 66 | QRegExp reg_word( queryword ); |
67 | //rot:QString substitute = "<font color='#FF0000'>"+queryword+"</font>"; | 67 | //rot:QString substitute = "<font color='#FF0000'>"+queryword+"</font>"; |
68 | QString substitute = "<a href=''>"+queryword+"</a>"; | 68 | QString substitute = "<a href=''>"+queryword+"</a>"; |
69 | QStringList toplist, bottomlist; | 69 | QStringList toplist, bottomlist; |
70 | for( QStringList::Iterator it = lines.begin() ; it != lines.end() ; ++it ) | 70 | for( QStringList::Iterator it = lines.begin() ; it != lines.end() ; ++it ) |
71 | { | 71 | { |
72 | current = *it; | 72 | current = *it; |
73 | left = current.left( current.find(reg_div) ); | 73 | left = current.left( current.find(reg_div) ); |
74 | right = current.right( current.length() - current.find(reg_div) - 1 ); | 74 | right = current.right( current.length() - current.find(reg_div) - 1 ); |
75 | if ( left.contains( reg_word ) ){ | 75 | if ( left.contains( reg_word ) ) |
76 | { | ||
76 | left.replace( queryword, substitute ); | 77 | left.replace( queryword, substitute ); |
77 | toplist.append( left + " -> " + right); | 78 | toplist.append( left + " -> " + right); |
78 | }else{ | 79 | } |
80 | else | ||
81 | { | ||
79 | right.replace( reg_word, substitute ); | 82 | right.replace( reg_word, substitute ); |
80 | bottomlist.append( right + " -> " + left ); | 83 | bottomlist.append( right + " -> " + left ); |
81 | } | 84 | } |
82 | // .replace( reg_word, substitute ); | ||
83 | } | 85 | } |
84 | 86 | ||
85 | //thats it, the lists are rendered. Lets put them in one string | 87 | //thats it, the lists are rendered. Lets put them in one string |
86 | bottom = bottomlist.join( "<br>\n" ); | 88 | bottom = bottomlist.join( "<br>\n" ); |
87 | top = toplist.join( "<br>\n" ); | 89 | top = toplist.join( "<br>\n" ); |
88 | } | 90 | } |
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 166f6b9..7de9169 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -1,128 +1,137 @@ | |||
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 | 36 | ||
36 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
37 | 38 | ||
38 | 39 | ||
39 | ODict::ODict() : QMainWindow() | 40 | ODict::ODict() : QMainWindow() |
40 | { | 41 | { |
41 | vbox = new QVBox( this ); | 42 | vbox = new QVBox( this ); |
42 | setCaption( tr( "OPIE-Dictionary" ) ); | 43 | setCaption( tr( "OPIE-Dictionary" ) ); |
43 | setupMenus(); | 44 | setupMenus(); |
44 | 45 | ||
45 | QHBox *hbox = new QHBox( vbox ); | 46 | QHBox *hbox = new QHBox( vbox ); |
46 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 47 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
47 | query_le = new QLineEdit( hbox ); | 48 | query_le = new QLineEdit( hbox ); |
49 | query_co = new QComboBox( hbox ); | ||
48 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 50 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
49 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 51 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
50 | browser_top = new QTextBrowser( vbox ); | 52 | browser_top = new QTextBrowser( vbox ); |
51 | browser_bottom = new QTextBrowser( vbox ); | 53 | browser_bottom = new QTextBrowser( vbox ); |
52 | 54 | ||
53 | loadConfig(); | 55 | loadConfig(); |
54 | setCentralWidget( vbox ); | 56 | setCentralWidget( vbox ); |
55 | } | 57 | } |
56 | 58 | ||
57 | void ODict::loadConfig() | 59 | void ODict::loadConfig() |
58 | { | 60 | { |
59 | Config cfg ( "odict" ); | 61 | Config cfg ( "odict" ); |
60 | cfg.setGroup( "generalsettings" ); | 62 | cfg.setGroup( "generalsettings" ); |
61 | errorTol = cfg.readEntry( "errtol" ).toInt(); | 63 | errorTol = cfg.readEntry( "errtol" ).toInt(); |
62 | casesens = cfg.readEntry( "casesens" ).toInt(); | 64 | casesens = cfg.readEntry( "casesens" ).toInt(); |
63 | regexp = cfg.readEntry( "regexp" ).toInt(); | 65 | regexp = cfg.readEntry( "regexp" ).toInt(); |
64 | completewords = cfg.readEntry( "completewords" ).toInt(); | 66 | completewords = cfg.readEntry( "completewords" ).toInt(); |
67 | |||
68 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | ||
69 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | ||
70 | { | ||
71 | cfg.setGroup( *it ); | ||
72 | query_co->insertItem( cfg.readEntry( "Name" ) ); | ||
73 | } | ||
65 | } | 74 | } |
66 | 75 | ||
67 | 76 | ||
68 | void ODict::saveConfig() | 77 | void ODict::saveConfig() |
69 | { | 78 | { |
70 | Config cfg ( "odict" ); | 79 | Config cfg ( "odict" ); |
71 | cfg.setGroup( "generalsettings" ); | 80 | cfg.setGroup( "generalsettings" ); |
72 | cfg.writeEntry( "errtol" , errorTol ); | 81 | cfg.writeEntry( "errtol" , errorTol ); |
73 | cfg.writeEntry( "casesens" , casesens ); | 82 | cfg.writeEntry( "casesens" , casesens ); |
74 | cfg.writeEntry( "regexp" , regexp ); | 83 | cfg.writeEntry( "regexp" , regexp ); |
75 | cfg.writeEntry( "completewords" , completewords ); | 84 | cfg.writeEntry( "completewords" , completewords ); |
76 | } | 85 | } |
77 | 86 | ||
78 | void ODict::slotDisplayAbout() | 87 | void ODict::slotDisplayAbout() |
79 | { | 88 | { |
80 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); | 89 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); |
81 | } | 90 | } |
82 | 91 | ||
83 | void ODict::slotStartQuery() | 92 | void ODict::slotStartQuery() |
84 | { | 93 | { |
85 | QString querystring = query_le->text(); | 94 | QString querystring = query_le->text(); |
86 | DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom); | 95 | DingWidget *ding = new DingWidget( vbox , querystring , browser_top, browser_bottom); |
87 | } | 96 | } |
88 | 97 | ||
89 | 98 | ||
90 | void ODict::slotSetErrorcount( int count ) | 99 | void ODict::slotSetErrorcount( int count ) |
91 | { | 100 | { |
92 | errorTol = count; | 101 | errorTol = count; |
93 | } | 102 | } |
94 | 103 | ||
95 | void ODict::slotSettings() | 104 | void ODict::slotSettings() |
96 | { | 105 | { |
97 | ConfigDlg dlg( this, "Config" , true); | 106 | ConfigDlg dlg( this, "Config" , true); |
98 | if ( dlg.exec() == QDialog::Accepted ) | 107 | if ( dlg.exec() == QDialog::Accepted ) |
99 | dlg.writeEntries(); | 108 | dlg.writeEntries(); |
100 | else qDebug( "abgebrochen" ); | 109 | else qDebug( "abgebrochen" ); |
101 | } | 110 | } |
102 | 111 | ||
103 | void ODict::slotSetParameter( int count ) | 112 | void ODict::slotSetParameter( int count ) |
104 | { | 113 | { |
105 | if ( count == 0 ) | 114 | if ( count == 0 ) |
106 | { | 115 | { |
107 | if ( casesens ) | 116 | if ( casesens ) |
108 | casesens = false; | 117 | casesens = false; |
109 | else | 118 | else |
110 | casesens = true; | 119 | casesens = true; |
111 | } | 120 | } |
112 | 121 | ||
113 | if ( count == 1 ) | 122 | if ( count == 1 ) |
114 | { | 123 | { |
115 | if ( completewords ) | 124 | if ( completewords ) |
116 | completewords = false; | 125 | completewords = false; |
117 | else | 126 | else |
118 | completewords = true; | 127 | completewords = true; |
119 | } | 128 | } |
120 | if ( count == 2 ) | 129 | if ( count == 2 ) |
121 | { | 130 | { |
122 | if ( regexp ) | 131 | if ( regexp ) |
123 | regexp = false; | 132 | regexp = false; |
124 | else | 133 | else |
125 | regexp = true; | 134 | regexp = true; |
126 | } | 135 | } |
127 | else qWarning( "ERROR" ); | 136 | else qWarning( "ERROR" ); |
128 | } | 137 | } |
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index ef0822d..7c1f32f 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h | |||
@@ -1,61 +1,63 @@ | |||
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 | 24 | ||
24 | class ODict : public QMainWindow | 25 | class ODict : public QMainWindow |
25 | { | 26 | { |
26 | Q_OBJECT | 27 | Q_OBJECT |
27 | 28 | ||
28 | public: | 29 | public: |
29 | ODict(); | 30 | ODict(); |
30 | QVBox *vbox; | 31 | QVBox *vbox; |
31 | QTextBrowser *browser_top, | 32 | QTextBrowser *browser_top, |
32 | *browser_bottom; | 33 | *browser_bottom; |
33 | 34 | ||
34 | private: | 35 | private: |
35 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; | 36 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; |
36 | QMenuBar *menu; | 37 | QMenuBar *menu; |
37 | QHBox *hbox; | 38 | QHBox *hbox; |
38 | QLineEdit *query_le; | 39 | QLineEdit *query_le; |
40 | QComboBox *query_co; | ||
39 | QPushButton *ok_button; | 41 | QPushButton *ok_button; |
40 | 42 | ||
41 | QVBoxLayout *vbox_layout; | 43 | QVBoxLayout *vbox_layout; |
42 | 44 | ||
43 | QAction *setting_a, *setting_b; | 45 | QAction *setting_a, *setting_b; |
44 | 46 | ||
45 | //DingWidget *ding; | 47 | //DingWidget *ding; |
46 | 48 | ||
47 | void setupMenus(); | 49 | void setupMenus(); |
48 | 50 | ||
49 | int errorTol; | 51 | int errorTol; |
50 | bool casesens, completewords, regexp; | 52 | bool casesens, completewords, regexp; |
51 | 53 | ||
52 | void loadConfig(); | 54 | void loadConfig(); |
53 | void saveConfig(); | 55 | void saveConfig(); |
54 | 56 | ||
55 | private slots: | 57 | private slots: |
56 | void slotDisplayAbout(); | 58 | void slotDisplayAbout(); |
57 | void slotStartQuery(); | 59 | void slotStartQuery(); |
58 | void slotSetErrorcount( int ); | 60 | void slotSetErrorcount( int ); |
59 | void slotSettings(); | 61 | void slotSettings(); |
60 | void slotSetParameter( int ); | 62 | void slotSetParameter( int ); |
61 | }; | 63 | }; |