author | cniehaus <cniehaus> | 2003-01-03 18:27:56 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-01-03 18:27:56 (UTC) |
commit | de71690306857498edcf1036123452c7321d1588 (patch) (unidiff) | |
tree | 86aa1bf0c375fbba7eca1173c904c726e31182e6 | |
parent | 7a97cd36cbc4c1a82043cdd44c82f931e2cdbb7f (diff) | |
download | opie-de71690306857498edcf1036123452c7321d1588.zip opie-de71690306857498edcf1036123452c7321d1588.tar.gz opie-de71690306857498edcf1036123452c7321d1588.tar.bz2 |
I won't get a nobelprize for this code but at least it works
-rw-r--r-- | noncore/apps/odict/dingwidget.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/odict/dingwidget.h | 14 | ||||
-rw-r--r-- | noncore/apps/odict/odict.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/odict/odict.h | 10 |
4 files changed, 62 insertions, 13 deletions
diff --git a/noncore/apps/odict/dingwidget.cpp b/noncore/apps/odict/dingwidget.cpp index ff83114..c54cf56 100644 --- a/noncore/apps/odict/dingwidget.cpp +++ b/noncore/apps/odict/dingwidget.cpp | |||
@@ -13,18 +13,50 @@ | |||
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 <qpe/config.h> | 20 | #include <qpe/config.h> |
20 | #include <qhbox.h> | 21 | #include <qhbox.h> |
21 | #include <qlabel.h> | 22 | #include <qlabel.h> |
22 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
23 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
24 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
25 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qtextstream.h> | ||
28 | #include <qstringlist.h> | ||
29 | #include <qregexp.h> | ||
30 | #include <qtextbrowser.h> | ||
26 | 31 | ||
27 | DingWidget::DingWidget() : QWidget() | 32 | DingWidget::DingWidget(QWidget *parent, QString word, QTextBrowser *browser) : QWidget(parent) |
28 | { | 33 | { |
34 | QFile file( "/home/carsten/opie/opie/noncore/apps/odict/eng_ita.dic" ); | ||
35 | QStringList lines; | ||
36 | |||
37 | if( file.open( IO_ReadOnly ) ) | ||
38 | { | ||
39 | QTextStream stream( &file ); | ||
40 | while ( !stream.eof() ) | ||
41 | { | ||
42 | lines.append( stream.readLine() ); | ||
43 | } | ||
44 | file.close(); | ||
45 | } | ||
46 | |||
47 | lines = lines.grep( word ); | ||
48 | |||
49 | //X for( QStringList::Iterator it = lines.begin() ; it != lines.end() ; ++it ) | ||
50 | //X { | ||
51 | //X qDebug( *it ); | ||
52 | //X } | ||
53 | browser->setText( parseInfo( lines ) ); | ||
29 | } | 54 | } |
30 | 55 | ||
56 | QString DingWidget::parseInfo( QStringList &lines ) | ||
57 | { | ||
58 | QString parsed = 0; | ||
59 | QStringList temp = lines; | ||
60 | parsed = temp.first(); | ||
61 | return parsed; | ||
62 | } | ||
diff --git a/noncore/apps/odict/dingwidget.h b/noncore/apps/odict/dingwidget.h index 68841d0..54e16ab 100644 --- a/noncore/apps/odict/dingwidget.h +++ b/noncore/apps/odict/dingwidget.h | |||
@@ -6,19 +6,21 @@ | |||
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | 9 | ||
10 | #include <qwidget.h> | 10 | #include <qwidget.h> |
11 | 11 | ||
12 | class QPopupMenu; | 12 | class QString; |
13 | class QMenuBar; | 13 | class QTextBrowser; |
14 | class QHBox; | 14 | class QString; |
15 | class QPushButton; | 15 | class QStringList; |
16 | class QLineEdit; | ||
17 | 16 | ||
18 | class DingWidget : public QWidget | 17 | class DingWidget : public QWidget |
19 | { | 18 | { |
20 | Q_OBJECT | 19 | Q_OBJECT |
21 | 20 | ||
22 | public: | 21 | public: |
23 | DingWidget(); | 22 | DingWidget(QWidget *parent = 0, QString word = 0, QTextBrowser* = 0); |
23 | |||
24 | private: | ||
25 | QString parseInfo( QStringList& ); | ||
24 | }; | 26 | }; |
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index 0412807..6c03ce3 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -13,43 +13,47 @@ | |||
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 | 20 | ||
20 | #include <opie/otabwidget.h> | 21 | #include <qlayout.h> |
21 | |||
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 <qlabel.h> | 28 | #include <qlabel.h> |
28 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
29 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
30 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
31 | #include <qstring.h> | 32 | #include <qstring.h> |
32 | #include <qaction.h> | 33 | #include <qaction.h> |
34 | #include <qtextbrowser.h> | ||
33 | 35 | ||
34 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
35 | 37 | ||
36 | 38 | ||
37 | ODict::ODict() : QMainWindow() | 39 | ODict::ODict() : QMainWindow() |
38 | { | 40 | { |
41 | vbox = new QVBox( this ); | ||
39 | setCaption( tr( "OPIE-Dictionary" ) ); | 42 | setCaption( tr( "OPIE-Dictionary" ) ); |
40 | setupMenus(); | 43 | setupMenus(); |
41 | 44 | ||
42 | QHBox *hbox = new QHBox( this ); | 45 | QHBox *hbox = new QHBox( vbox ); |
43 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); | 46 | QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); query_label->show(); |
44 | query_le = new QLineEdit( hbox ); | 47 | query_le = new QLineEdit( hbox ); |
45 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); | 48 | ok_button = new QPushButton( tr( "&Ok" ), hbox ); |
46 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); | 49 | connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); |
47 | 50 | browser = new QTextBrowser( vbox ); | |
48 | setCentralWidget( hbox ); | 51 | |
49 | loadConfig(); | 52 | loadConfig(); |
53 | setCentralWidget( vbox ); | ||
50 | } | 54 | } |
51 | 55 | ||
52 | void ODict::loadConfig() | 56 | void ODict::loadConfig() |
53 | { | 57 | { |
54 | Config cfg ( "odict" ); | 58 | Config cfg ( "odict" ); |
55 | cfg.setGroup( "generalsettings" ); | 59 | cfg.setGroup( "generalsettings" ); |
@@ -69,18 +73,19 @@ void ODict::saveConfig() | |||
69 | cfg.writeEntry( "regexp" , regexp ); | 73 | cfg.writeEntry( "regexp" , regexp ); |
70 | cfg.writeEntry( "completewords" , completewords ); | 74 | cfg.writeEntry( "completewords" , completewords ); |
71 | } | 75 | } |
72 | 76 | ||
73 | void ODict::slotDisplayAbout() | 77 | void ODict::slotDisplayAbout() |
74 | { | 78 | { |
75 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20021230" ) ); | 79 | QMessageBox::about( this, tr( "About ODict" ), tr( "OPIE-Dictionary ODict \n (c) 2002, 2003 Carsten Niehaus \n cniehaus@handhelds.org \n Version 20030103" ) ); |
76 | } | 80 | } |
77 | 81 | ||
78 | void ODict::slotStartQuery() | 82 | void ODict::slotStartQuery() |
79 | { | 83 | { |
80 | QString querystring = query_le->text(); | 84 | QString querystring = query_le->text(); |
85 | DingWidget *ding = new DingWidget( vbox , querystring , browser); | ||
81 | } | 86 | } |
82 | 87 | ||
83 | 88 | ||
84 | void ODict::slotSetErrorcount( int count ) | 89 | void ODict::slotSetErrorcount( int count ) |
85 | { | 90 | { |
86 | errorTol = count; | 91 | errorTol = count; |
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h index 014e488..d7e57e8 100644 --- a/noncore/apps/odict/odict.h +++ b/noncore/apps/odict/odict.h | |||
@@ -6,35 +6,45 @@ | |||
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 QPopupMenu; | 13 | class QPopupMenu; |
13 | class QMenuBar; | 14 | class QMenuBar; |
14 | class QHBox; | 15 | class QHBox; |
15 | class QPushButton; | 16 | class QPushButton; |
16 | class QLineEdit; | 17 | class QLineEdit; |
17 | class QAction; | 18 | class QAction; |
19 | class QVBoxLayout; | ||
18 | class QActionGroup; | 20 | class QActionGroup; |
21 | class DingWidget; | ||
22 | class QTextBrowser; | ||
19 | 23 | ||
20 | class ODict : public QMainWindow | 24 | class ODict : public QMainWindow |
21 | { | 25 | { |
22 | Q_OBJECT | 26 | Q_OBJECT |
23 | 27 | ||
24 | public: | 28 | public: |
25 | ODict(); | 29 | ODict(); |
30 | QVBox *vbox; | ||
31 | QTextBrowser *browser; | ||
26 | 32 | ||
27 | private: | 33 | private: |
28 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; | 34 | QPopupMenu *help, *settings, *parameter, *error_tol_menu; |
29 | QMenuBar *menu; | 35 | QMenuBar *menu; |
30 | QHBox *hbox; | 36 | QHBox *hbox; |
31 | QLineEdit *query_le; | 37 | QLineEdit *query_le; |
32 | QPushButton *ok_button; | 38 | QPushButton *ok_button; |
33 | 39 | ||
40 | QVBoxLayout *vbox_layout; | ||
41 | |||
34 | QAction *setting_a, *setting_b; | 42 | QAction *setting_a, *setting_b; |
43 | |||
44 | //DingWidget *ding; | ||
35 | 45 | ||
36 | void setupMenus(); | 46 | void setupMenus(); |
37 | 47 | ||
38 | int errorTol; | 48 | int errorTol; |
39 | bool casesens, completewords, regexp; | 49 | bool casesens, completewords, regexp; |
40 | 50 | ||